Merge "New method to calculate replicas for armada apps"

This commit is contained in:
Zuul 2021-04-05 13:46:23 +00:00 committed by Gerrit Code Review
commit 190b55704d
2 changed files with 46 additions and 0 deletions

View File

@ -240,6 +240,20 @@ class BaseHelm(object):
constants.AVAILABILITY_DEGRADED],
vim_progress_status=constants.VIM_SERVICES_ENABLED)
def _num_replicas_for_platform_app(self):
"""
Returns the number of replicas that should be used by
platform managed applications. This method will return
the number of provisioned controllers, with a minimum of 1.
It takes care of the case where one controller is provisioned
and the other is installed but not provisioned. When the second
controller is provisioned, the unlock will check if the
overrides are different and reapply platform managed
applications appropriately
"""
return max(1, self._num_provisioned_controllers())
def _get_address_by_name(self, name, networktype):
"""
Retrieve an address entry by name and scoped by network type

View File

@ -0,0 +1,32 @@
# Copyright (c) 2021 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import mock
from sysinv.helm.base import BaseHelm
from sysinv.helm.helm import HelmOperator
from sysinv.tests import base as test_base
class TestHelmBase(test_base.TestCase):
def test_num_replicas_for_platform_app_0_controllers(self):
self.check_num_replicas_for_platform_app(num_provisioned_controllers=0, expected_replicas=1)
def test_num_replicas_for_platform_app_1_controllers(self):
self.check_num_replicas_for_platform_app(num_provisioned_controllers=1, expected_replicas=1)
def test_num_replicas_for_platform_app_2_controllers(self):
self.check_num_replicas_for_platform_app(num_provisioned_controllers=2, expected_replicas=2)
def check_num_replicas_for_platform_app(self, num_provisioned_controllers, expected_replicas):
mock_operator = mock.MagicMock(spec=HelmOperator)
mock_operator.dbapi = mock.MagicMock()
mock_operator.dbapi.count_hosts_matching_criteria.return_value = num_provisioned_controllers
base = BaseHelm(mock_operator)
actual_replicas = base._num_replicas_for_platform_app()
self.assertEqual(actual_replicas, expected_replicas)