From 774fc6bae0209edb366adbddd16aa2f205d389cb Mon Sep 17 00:00:00 2001 From: Maysa Macedo Date: Mon, 11 Oct 2021 10:06:35 +0000 Subject: [PATCH] Fix Namespace handling With the handling of Namespaces now being dependent on Pods creation, tempests tests need to get updated to account for that. Change-Id: Id0879f128ca8c057ea6ec540fec0e76d656e7b13 --- kuryr_tempest_plugin/config.py | 3 +++ kuryr_tempest_plugin/tests/scenario/base.py | 2 ++ kuryr_tempest_plugin/tests/scenario/base_network_policy.py | 3 +++ kuryr_tempest_plugin/tests/scenario/test_namespace.py | 5 +++-- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/kuryr_tempest_plugin/config.py b/kuryr_tempest_plugin/config.py index d392d18c..fd190fdf 100644 --- a/kuryr_tempest_plugin/config.py +++ b/kuryr_tempest_plugin/config.py @@ -104,5 +104,8 @@ kuryr_k8s_opts = [ " number LB members"), cfg.BoolOpt("enable_reconciliation", default=False, help="Whether or not reconciliation is enabled"), + cfg.BoolOpt("trigger_namespace_upon_pod", default=False, + help="Whether or not Namespace should be handled upon Pod " + "creation"), ] diff --git a/kuryr_tempest_plugin/tests/scenario/base.py b/kuryr_tempest_plugin/tests/scenario/base.py index 802e2dbe..e589d1c8 100644 --- a/kuryr_tempest_plugin/tests/scenario/base.py +++ b/kuryr_tempest_plugin/tests/scenario/base.py @@ -827,6 +827,8 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest): def create_namespace(cls, name=None, labels=None, wait_for_crd=True, timeout_period=consts.NS_TIMEOUT): + if CONF.kuryr_kubernetes.trigger_namespace_upon_pod: + wait_for_crd = False if not name: name = data_utils.rand_name(prefix='kuryr-namespace') namespace = cls.k8s_client.V1Namespace() diff --git a/kuryr_tempest_plugin/tests/scenario/base_network_policy.py b/kuryr_tempest_plugin/tests/scenario/base_network_policy.py index 848e027b..d9b2434d 100644 --- a/kuryr_tempest_plugin/tests/scenario/base_network_policy.py +++ b/kuryr_tempest_plugin/tests/scenario/base_network_policy.py @@ -148,6 +148,9 @@ class TestNetworkPolicyScenario(base.BaseKuryrScenarioTest, def test_ipblock_network_policy_allow_except(self): namespace_name, namespace = self.create_namespace() self.addCleanup(self.delete_namespace, namespace_name) + pod_name, pod = self.create_pod(namespace=namespace_name) + self.addCleanup(self.delete_pod, pod_name, pod, + namespace=namespace_name) if CONF.kuryr_kubernetes.kuryrnetworks: cidr = self.get_kuryr_network_crds( diff --git a/kuryr_tempest_plugin/tests/scenario/test_namespace.py b/kuryr_tempest_plugin/tests/scenario/test_namespace.py index 181c64fe..689278f4 100644 --- a/kuryr_tempest_plugin/tests/scenario/test_namespace.py +++ b/kuryr_tempest_plugin/tests/scenario/test_namespace.py @@ -55,6 +55,9 @@ class TestNamespaceScenario(base.BaseKuryrScenarioTest): self.assertIn(namespace_name, existing_namespaces) + pod_name, pod = self.create_pod(labels={"app": 'pod-label'}, + namespace=namespace_name) + subnet_name = 'ns/' + namespace_name + '-subnet' kuryr_net_crd_name = 'ns-' + namespace_name @@ -82,8 +85,6 @@ class TestNamespaceScenario(base.BaseKuryrScenarioTest): self.assertIn(kuryr_net_crd['spec']['netId'], net_id) # Check namespace pod connectivity - pod_name, pod = self.create_pod(labels={"app": 'pod-label'}, - namespace=namespace_name) self.create_setup_for_service_test(namespace=namespace_name, cleanup=False) self.check_service_internal_connectivity(namespace=namespace_name,