Exemplo n.º 1
0
    def test_has_old_override_no_new_override(self):
        """Test that overrides are properly migrated.

        Test that if the old app version has an override and the
        new app version does not, the old override is migrated to the
        new version.
        """
        dbutils.create_test_helm_overrides(
            app_id=self.old_db_app.id,
            name=app_constants.HELM_CHART_LEGACY_INGRESS_NGINX,
            namespace=app_constants.HELM_NS_NGINX_INGRESS_CONTROLLER,
            user_overrides=json.dumps(self.old_overrides))

        dbutils.create_test_helm_overrides(
            app_id=self.new_db_app.id,
            name=app_constants.HELM_CHART_INGRESS_NGINX,
            namespace=app_constants.HELM_NS_NGINX_INGRESS_CONTROLLER,
            user_overrides=None)

        lifecycleOperator = NginxICOperator()
        lifecycleOperator.app_lifecycle_actions(None, None, self.app_op,
                                                self.new_app, self.hook_info)

        overrides = self.dbapi.helm_override_get(
            app_id=self.new_app.id,
            name=app_constants.HELM_CHART_INGRESS_NGINX,
            namespace=app_constants.HELM_NS_NGINX_INGRESS_CONTROLLER)

        self.assertEqual(self.old_overrides,
                         json.loads(overrides['user_overrides']))
Exemplo n.º 2
0
    def test_has_old_override_new_override(self):
        """Test that no overrides are migrated.

        Test that the migration does not occur when a override
        is present in the new version
        """

        dbutils.create_test_helm_overrides(
            app_id=self.old_db_app.id,
            name=app_constants.HELM_CHART_LEGACY_INGRESS_NGINX,
            namespace=app_constants.HELM_NS_NGINX_INGRESS_CONTROLLER,
            user_overrides=json.dumps(self.old_overrides))

        dbutils.create_test_helm_overrides(
            app_id=self.new_db_app.id,
            name=app_constants.HELM_CHART_INGRESS_NGINX,
            namespace=app_constants.HELM_NS_NGINX_INGRESS_CONTROLLER,
            user_overrides=json.dumps(self.new_overrides))

        lifecycleOperator = NginxICOperator()
        lifecycleOperator.app_lifecycle_actions(None, None, self.app_op,
                                                self.new_app, self.hook_info)

        overrides = self.dbapi.helm_override_get(
            app_id=self.new_app.id,
            name=app_constants.HELM_CHART_INGRESS_NGINX,
            namespace=app_constants.HELM_NS_NGINX_INGRESS_CONTROLLER)

        self.assertEqual(self.new_overrides,
                         json.loads(overrides['user_overrides']))
Exemplo n.º 3
0
    def test_has_no_old_app(self):
        """Test that no overrides are migrated.

        Test if new application is successfully applied with
        overrides when no previous version is present
        """

        self.dbapi.kube_app_destroy(
            name=self.old_db_app.name,
            version=self.old_db_app.app_version,
            inactive=True,
        )

        dbutils.create_test_helm_overrides(
            app_id=self.new_db_app.id,
            name=app_constants.HELM_CHART_INGRESS_NGINX,
            namespace=app_constants.HELM_NS_NGINX_INGRESS_CONTROLLER,
            user_overrides=json.dumps(self.new_overrides))

        lifecycleOperator = NginxICOperator()
        lifecycleOperator.app_lifecycle_actions(None, None, self.app_op,
                                                self.new_app, self.hook_info)

        overrides = self.dbapi.helm_override_get(
            app_id=self.new_app.id,
            name=app_constants.HELM_CHART_INGRESS_NGINX,
            namespace=app_constants.HELM_NS_NGINX_INGRESS_CONTROLLER)

        self.assertEqual(self.new_overrides,
                         json.loads(overrides['user_overrides']))
Exemplo n.º 4
0
    def test_has_no_old_override_no_new_override(self):
        """Test that no overrides are migrated.

        Test that if the old app version does not trigger migration
        when no override is present
        """
        old_overrides = None

        dbutils.create_test_helm_overrides(
            app_id=self.old_db_app.id,
            name=app_constants.HELM_CHART_LEGACY_INGRESS_NGINX,
            namespace=app_constants.HELM_NS_NGINX_INGRESS_CONTROLLER)

        dbutils.create_test_helm_overrides(
            app_id=self.new_db_app.id,
            name=app_constants.HELM_CHART_INGRESS_NGINX,
            namespace=app_constants.HELM_NS_NGINX_INGRESS_CONTROLLER,
            user_overrides=None)

        lifecycleOperator = NginxICOperator()
        lifecycleOperator.app_lifecycle_actions(None, None, self.app_op,
                                                self.new_app, self.hook_info)

        overrides = self.dbapi.helm_override_get(
            app_id=self.new_app.id,
            name=app_constants.HELM_CHART_INGRESS_NGINX,
            namespace=app_constants.HELM_NS_NGINX_INGRESS_CONTROLLER)

        self.assertEqual(old_overrides, overrides['user_overrides'])
 def _create_db_overrides(self, appid, chart_name, chart_namespace,
                          system_override_attr, user_override, obj_id=None):
     return dbutils.create_test_helm_overrides(id=obj_id,
                                   app_id=appid,
                                   name=chart_name,
                                   namespace=chart_namespace,
                                   system_overrides=system_override_attr,
                                   user_overrides=user_override)