From b94040627889675411f33c9910bb9806ea8ae0df Mon Sep 17 00:00:00 2001 From: Maysa Macedo Date: Wed, 3 Jul 2019 14:06:08 +0000 Subject: [PATCH] Ensure CRD validation is only checked if enabled CRD validation support was not added in previous releases. We should ensure all tests related to it are only triggered when crd validation is enabled in the tempest config. Change-Id: I92f22827d4456e9a13b9a5b45d96babf4bf93451 --- kuryr_tempest_plugin/config.py | 2 ++ kuryr_tempest_plugin/tests/scenario/test_namespace.py | 6 ++++++ .../tests/scenario/test_network_policy.py | 9 +++++++++ 3 files changed, 17 insertions(+) diff --git a/kuryr_tempest_plugin/config.py b/kuryr_tempest_plugin/config.py index bba3063d..5fbb4ad4 100644 --- a/kuryr_tempest_plugin/config.py +++ b/kuryr_tempest_plugin/config.py @@ -71,4 +71,6 @@ kuryr_k8s_opts = [ "have a multi-worker setup"), cfg.BoolOpt("cloud_provider", default=False, help="Whether or not a " "cloud provider is set"), + cfg.BoolOpt("validate_crd", default=False, help="Whether or not kuryr " + "CRDs should be validated"), ] diff --git a/kuryr_tempest_plugin/tests/scenario/test_namespace.py b/kuryr_tempest_plugin/tests/scenario/test_namespace.py index a6c0bc7b..35682c72 100644 --- a/kuryr_tempest_plugin/tests/scenario/test_namespace.py +++ b/kuryr_tempest_plugin/tests/scenario/test_namespace.py @@ -282,6 +282,9 @@ class TestNamespaceScenario(base.BaseKuryrScenarioTest): @decorators.idempotent_id('90b7cb81-f80e-4ff3-9892-9e5fdcd08289') def test_create_kuryrnet_crd_without_net_id(self): + if not CONF.kuryr_kubernetes.validate_crd: + raise self.skipException('CRD validation must be enabled to run ' + 'this test.') kuryrnet = dict(self._get_kuryrnet_obj()) del kuryrnet['spec']['netId'] error_msg = 'spec.netId in body is required' @@ -289,6 +292,9 @@ class TestNamespaceScenario(base.BaseKuryrScenarioTest): @decorators.idempotent_id('94641749-9fdf-4fb2-a46d-064f75eac113') def test_create_kuryrnet_crd_with_populated_as_string(self): + if not CONF.kuryr_kubernetes.validate_crd: + raise self.skipException('CRD validation must be enabled to run ' + 'this test.') kuryrnet = dict(self._get_kuryrnet_obj()) kuryrnet['spec']['populated'] = 'False' error_msg = 'spec.populated in body must be of type boolean' diff --git a/kuryr_tempest_plugin/tests/scenario/test_network_policy.py b/kuryr_tempest_plugin/tests/scenario/test_network_policy.py index 0fc600de..4805a467 100644 --- a/kuryr_tempest_plugin/tests/scenario/test_network_policy.py +++ b/kuryr_tempest_plugin/tests/scenario/test_network_policy.py @@ -234,6 +234,9 @@ class TestNetworkPolicyScenario(base.BaseKuryrScenarioTest): @decorators.idempotent_id('09a24a0f-322a-40ea-bb89-5b2246c8725d') def test_create_knp_crd_without_ingress_rules(self): + if not CONF.kuryr_kubernetes.validate_crd: + raise self.skipException('CRD validation must be enabled to run ' + 'this test.') np_name = 'test' knp_obj = dict(self._get_knp_obj(np_name)) del knp_obj['spec']['ingressSgRules'] @@ -242,6 +245,9 @@ class TestNetworkPolicyScenario(base.BaseKuryrScenarioTest): @decorators.idempotent_id('f036d26e-f603-4d00-ad92-b409b5a3ee6c') def test_create_knp_crd_without_sg_rule_id(self): + if not CONF.kuryr_kubernetes.validate_crd: + raise self.skipException('CRD validation must be enabled to run ' + 'this test.') np_name = 'test' sg_rule = dict(self._get_sg_rule()) del sg_rule['id'] @@ -251,6 +257,9 @@ class TestNetworkPolicyScenario(base.BaseKuryrScenarioTest): @decorators.idempotent_id('47f0e412-3e13-40b2-93e5-503790df870b') def test_create_knp_crd_with_networkpolicy_spec_wrong_type(self): + if not CONF.kuryr_kubernetes.validate_crd: + raise self.skipException('CRD validation must be enabled to run ' + 'this test.') np_name = 'test' knp_obj = dict(self._get_knp_obj(np_name)) knp_obj['spec']['networkpolicy_spec'] = []