Browse Source

Merge "Test recreate namespace and pod"

master
Zuul 1 week ago
parent
commit
55c980d4e4

+ 3
- 2
kuryr_tempest_plugin/tests/scenario/base.py View File

@@ -546,7 +546,7 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest):
546 546
                                         namespace=namespace)
547 547
 
548 548
     @classmethod
549
-    def create_namespace(cls, name=None):
549
+    def create_namespace(cls, name=None, wait_for_crd_annotation=True):
550 550
         if not name:
551 551
             name = data_utils.rand_name(prefix='kuryr-namespace')
552 552
         kuryr_crd_annotation = K8S_ANNOTATION_PREFIX + "-net-crd"
@@ -561,7 +561,8 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest):
561 561
             time.sleep(1)
562 562
             ns = cls.k8s_client.CoreV1Api().read_namespace_status(name)
563 563
             if (ns.metadata.annotations and
564
-                    ns.metadata.annotations.get(kuryr_crd_annotation)):
564
+                (not wait_for_crd_annotation or
565
+                    ns.metadata.annotations.get(kuryr_crd_annotation))):
565 566
                 break
566 567
 
567 568
         return name, namespace_obj

+ 34
- 0
kuryr_tempest_plugin/tests/scenario/test_namespace.py View File

@@ -19,6 +19,7 @@ import time
19 19
 
20 20
 from oslo_log import log as logging
21 21
 from tempest import config
22
+from tempest.lib.common.utils import data_utils
22 23
 from tempest.lib import decorators
23 24
 
24 25
 from kuryr_tempest_plugin.tests.scenario import base
@@ -339,3 +340,36 @@ class TestNamespaceScenario(base.BaseKuryrScenarioTest):
339 340
                             group, version, plural,
340 341
                             crd_manifest['metadata']['name'], body)
341 342
             raise Exception('{} for Kuryr Net CRD'.format(error_msg))
343
+
344
+    @decorators.idempotent_id('9e3ddb2d-d765-4ac5-8ab0-6a404adddd49')
345
+    def test_recreate_pod_in_namespace(self):
346
+        ns_name = data_utils.rand_name(prefix='kuryr-ns')
347
+
348
+        ns_name, ns = self.create_namespace(
349
+            name=ns_name, wait_for_crd_annotation=False)
350
+        self.addCleanup(self.delete_namespace, ns_name)
351
+        pod_name, pod = self.create_pod(
352
+            namespace=ns_name, wait_for_status=False)
353
+
354
+        self.delete_namespace(ns_name)
355
+        # wait for namespace to be deleted
356
+        retries = 120
357
+        while True:
358
+            try:
359
+                self.k8s_client.CoreV1Api().read_namespace(ns_name)
360
+                retries -= 1
361
+                self.assertNotEqual(0, retries,
362
+                                    "Timed out waiting for namespace %s to"
363
+                                    " be deleted" % ns_name)
364
+                time.sleep(1)
365
+            except kubernetes.client.rest.ApiException as e:
366
+                if e.status == 404:
367
+                    break
368
+
369
+        ns_name, ns = self.create_namespace(
370
+            name=ns_name, wait_for_crd_annotation=False)
371
+        pod_name, pod = self.create_pod(
372
+            namespace=ns_name, wait_for_status=False)
373
+
374
+        self.wait_for_pod_status(pod_name, namespace=ns_name,
375
+                                 pod_status='Running', retries=60)

Loading…
Cancel
Save