Example #1
0
 def test_get_appname(self):
     test_app_name = 'test-app-1'
     dbutils.create_test_app(name=test_app_name,
                             status=constants.APP_APPLY_SUCCESS)
     test_app_1 = obj_app.get_by_name(self.context, 'test-app-1')
     app_name = self.app_operator.get_appname(test_app_1)
     self.assertEqual(test_app_name, app_name)
 def test_reapply(self):
     dbutils.create_test_app(name='test-app-1', active=True)
     constants.APP_PENDING_REAPPLY_FLAG = self.temp_dir.path + "/.app_reapply"
     self.app_operator.set_reapply('test-app-1')
     result = self.app_operator.needs_reapply('test-app-1')
     self.assertEqual(result, True)
     self.app_operator.clear_reapply('test-app-1')
     result = self.app_operator.needs_reapply('test-app-1')
     self.assertEqual(result, False)
 def test_is_app_active(self):
     dbutils.create_test_app(name='test-app-1', active=True)
     test_app_1 = obj_app.get_by_name(self.context, 'test-app-1')
     self.app_operator.activate(test_app_1)
     is_active = self.app_operator.is_app_active(test_app_1)
     self.assertEqual(is_active, True)
     self.app_operator.deactivate(test_app_1)
     is_active = self.app_operator.is_app_active(test_app_1)
     self.assertEqual(is_active, False)
 def _create_db_app(self, obj_id=None):
     return dbutils.create_test_app(id=obj_id, name='platform-integ-apps',
                             app_version='1.0-8',
                             manifest_name='platform-integration-manifest',
                             manifest_file='manifest.yaml',
                             status='applied',
                             active=True)
Example #5
0
    def setUp(self):
        super(HelmOperatorTestSuiteMixin, self).setUp()
        self.app = dbutils.create_test_app(name=self.app_name)
        # If a ceph keyring entry is missing, a subprocess will be invoked
        # so a fake keyring password is being supplied here.
        keyring.set_password('glance', 'admin_keyring', 'FakePassword1*')

        # Armada routines that write to disk can be mocked away
        save_overrides = mock.patch.object(ArmadaManifestOperator,
                                           'save_overrides')
        self.mock_save_overrides = save_overrides.start()
        self.addCleanup(save_overrides.stop)

        save_delete_manifest = mock.patch.object(ArmadaManifestOperator,
                                                 'save_delete_manifest')
        save_delete_manifest.start()
        self.addCleanup(save_delete_manifest.stop)

        save_summary = mock.patch.object(ArmadaManifestOperator,
                                         'save_summary')
        save_summary.start()
        self.addCleanup(save_summary.stop)

        # _write_file is called per helm chart
        write_file = mock.patch.object(ArmadaManifestOperator, '_write_file')
        write_file.start()
        self.addCleanup(write_file.stop)
    def test_deactivate(self):
        # Create kubernetes apps
        dbutils.create_test_app(name='test-app-1', active=True)
        test_app_1 = obj_app.get_by_name(self.context, 'test-app-1')
        self.assertEqual(test_app_1.active, True)
        res = self.app_operator.deactivate(test_app_1)
        # check was_active
        self.assertEqual(res, True)
        # check current active
        self.assertEqual(test_app_1.active, False)

        dbutils.create_test_app(name='test-app-2', active=False)
        test_app_2 = obj_app.get_by_name(self.context, 'test-app-2')
        self.assertEqual(test_app_2.active, False)
        res = self.app_operator.deactivate(test_app_2)
        # check was_active
        self.assertEqual(res, False)
        # check current active
        self.assertEqual(test_app_2.active, False)
 def setUp(self):
     super(StxAppLabelsTest, self).setUp()
     dbutils.create_test_app(name="stx-monitor",
                             status="uploaded",
                             progress="completed")
     self.controller = dbutils.create_test_ihost(
         id='1',
         uuid=None,
         forisystemid=self.system.id,
         hostname='controller-0',
         personality=constants.CONTROLLER,
         subfunctions=constants.CONTROLLER,
         invprovision=constants.PROVISIONED,
         administrative=constants.ADMIN_UNLOCKED,
         operational=constants.OPERATIONAL_ENABLED)
     self.controller1 = dbutils.create_test_ihost(
         id='2',
         uuid=None,
         forisystemid=self.system.id,
         hostname='controller-1',
         personality=constants.CONTROLLER,
         subfunctions=constants.CONTROLLER,
         mgmt_mac='01:02:03:04:05:C1',
         mgmt_ip='192.168.24.13',
         invprovision=constants.PROVISIONED,
         administrative=constants.ADMIN_UNLOCKED,
         operational=constants.OPERATIONAL_ENABLED)
     self.worker = dbutils.create_test_ihost(
         id='3',
         uuid=None,
         forisystemid=self.system.id,
         hostname='worker-0',
         personality=constants.WORKER,
         subfunctions=constants.WORKER,
         mgmt_mac='01:02:03:04:05:C5',
         mgmt_ip='192.168.24.14',
         invprovision=constants.PROVISIONED,
         administrative=constants.ADMIN_UNLOCKED,
         operational=constants.OPERATIONAL_ENABLED)
Example #8
0
    def setUp(self):
        super(NginxICTestCase, self).setUp()

        self.dbapi = db_api.get_instance()
        self.app_op = mock.MagicMock()
        self.new_app = mock.MagicMock()

        self.new_app.id = 2
        self.new_app.name = constants.HELM_APP_NGINX_IC

        self.old_db_app = dbutils.create_test_app(
            id=1, name=constants.HELM_APP_NGINX_IC, app_version='1.0-0')
        # creating an inactive app does not work, need to update the status later
        self.dbapi.kube_app_update(self.old_db_app.id,
                                   {'status': constants.APP_INACTIVE_STATE})

        self.new_db_app = dbutils.create_test_app(
            id=self.new_app.id,
            status=constants.APP_APPLY_IN_PROGRESS,
            name=constants.HELM_APP_NGINX_IC,
            app_version='1.1-1')

        self.hook_info = lifecycle_hook.LifecycleHookInfo()
        self.hook_info.init(constants.APP_LIFECYCLE_MODE_AUTO,
                            constants.APP_LIFECYCLE_TYPE_RESOURCE,
                            constants.APP_LIFECYCLE_TIMING_PRE,
                            constants.APP_APPLY_OP)

        self.old_overrides = {
            'udp': {
                '161': 'kube-system/snmpd-service:161'
            },
            'tcp': {
                '162': 'kube-system/snmpd-service:162'
            }
        }

        self.new_overrides = {'host': 'dummy-service.host.wrs.com'}
Example #9
0
    def test_create_installed_app_not_compatible(self):
        # Test creation of upgrade when the installed application isn't
        # compatible with the new kubernetes version

        # Create application
        dbutils.create_test_app(name='stx-openstack',
                                app_version='1.0-19',
                                manifest_name='openstack-armada-manifest',
                                manifest_file='stx-openstack.yaml',
                                status='applied',
                                active=True)

        create_dict = dbutils.post_get_test_kube_upgrade(to_version='v1.43.2')
        result = self.post_json('/kube_upgrade',
                                create_dict,
                                headers={'User-Agent': 'sysinv-test'},
                                expect_errors=True)

        # Verify the failure
        self.assertEqual(result.content_type, 'application/json')
        self.assertEqual(http_client.BAD_REQUEST, result.status_int)
        self.assertIn("incompatible with the new Kubernetes version v1.43.2",
                      result.json['error_message'])
Example #10
0
    def test_create_system_unhealthy_from_bad_apps(self):
        """ Test kube upgrade create fails when invalid kube app found"""

        # The app is not fully setup, health query should fail
        dbutils.create_test_app(name='broken-app',
                                status=constants.APP_APPLY_IN_PROGRESS)

        # Test creation of upgrade when system health check fails from bad app
        create_dict = dbutils.post_get_test_kube_upgrade(to_version='v1.43.2')
        create_dict['force'] = True
        result = self.post_json('/kube_upgrade',
                                create_dict,
                                headers={'User-Agent': 'sysinv-test'},
                                expect_errors=True)

        # Verify that the upgrade has the expected attributes
        self.assertEqual(result.content_type, 'application/json')
        self.assertEqual(http_client.BAD_REQUEST, result.status_int)
        # The error should contain the following:
        #   System is not in a valid state for kubernetes upgrade.
        #   Run system health-query-kube-upgrade for more details.
        self.assertIn("Run system health-query-kube-upgrade for more details.",
                      result.json['error_message'])
Example #11
0
    def test_get_system_health_kube_upgrade_k8s_app_invalid_state(self):
        # Create controller-0
        config_uuid = str(uuid.uuid4())
        self._create_test_host(personality=constants.CONTROLLER,
                               unit=0,
                               config_status=None,
                               config_applied=config_uuid,
                               config_target=config_uuid,
                               invprovision=constants.PROVISIONED,
                               administrative=constants.ADMIN_UNLOCKED,
                               operational=constants.OPERATIONAL_ENABLED,
                               availability=constants.AVAILABILITY_ONLINE)

        # Create controller-1
        self._create_test_host(personality=constants.CONTROLLER,
                               unit=1,
                               config_status=None,
                               config_applied=config_uuid,
                               config_target=config_uuid,
                               invprovision=constants.PROVISIONED,
                               administrative=constants.ADMIN_UNLOCKED,
                               operational=constants.OPERATIONAL_ENABLED,
                               availability=constants.AVAILABILITY_ONLINE)

        # Create kubernetes apps
        dbutils.create_test_app(name='test-app-1',
                                status=constants.APP_APPLY_SUCCESS)
        dbutils.create_test_app(name='test-app-2',
                                status=constants.APP_APPLY_IN_PROGRESS)
        dbutils.create_test_app(name='test-app-3',
                                status=constants.APP_UPLOAD_SUCCESS)

        # Set up the mocked results
        self.mock_patch_query_hosts_result = self.patch_current_result
        self.kube_get_nodes_result = self.multi_node_result
        self.kube_get_control_plane_pod_ready_status_result = \
            self.cp_pod_ready_status_result

        # Check system health
        health_ok, output = self.health.get_system_health_kube_upgrade(
            self.context)
        assert health_ok is False, "output: %s" % output
        assert "applications are in a valid state: [Fail]" in output, \
            "output: %s" % output
        assert "applications not in a valid state: test-app-2" in output, \
            "output: %s" % output
Example #12
0
 def setUp(self):
     super(NovaApiProxyTestCase, self).setUp()
     self.app = dbutils.create_test_app(name=self.app_name)
 def setUp(self):
     super(OidcClientTestCase, self).setUp()
     self.app = dbutils.create_test_app(name=self.app_name)
     self.dbapi = dbapi.get_instance()
 def setUp(self):
     super(PTPNotificationTestCase, self).setUp()
     self.app = dbutils.create_test_app(name='ptp-notification')
     self.dbapi = dbapi.get_instance()
Example #15
0
 def setUp(self):
     super(CertManagerTestCase, self).setUp()
     self.app = dbutils.create_test_app(name='cert-manager')
     self.dbapi = dbapi.get_instance()
Example #16
0
 def setUp(self):
     super(DexTestCase, self).setUp()
     self.app = dbutils.create_test_app(name='oidc-auth-apps')
     self.dbapi = dbapi.get_instance()
 def setUp(self):
     super(SnmpTestCase, self).setUp()
     self.app = dbutils.create_test_app(name='snmp')
     self.dbapi = dbapi.get_instance()
Example #18
0
 def setUp(self):
     super(CinderConversionTestCase, self).setUp()
     self.app = dbutils.create_test_app(name=self.app_name)