diff --git a/test/integration/component/test_templates.py b/test/integration/component/test_templates.py index e6b2dd6c476..e9be63d66b8 100644 --- a/test/integration/component/test_templates.py +++ b/test/integration/component/test_templates.py @@ -283,6 +283,13 @@ class TestTemplates(cloudstackTestCase): # Get Zone, templates etc cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) + #populate second zone id for iso copy + cmd = listZones.listZonesCmd() + zones = cls.api_client.listZones(cmd) + if not isinstance(zones, list): + raise Exception("Failed to find zones.") + if len(zones) >= 2: + cls.services["destzoneid"] = zones[1].id template = get_template( cls.api_client, @@ -467,6 +474,36 @@ class TestTemplates(cloudstackTestCase): ) # Cleanup- Delete the copied template + timeout = self.services["timeout"] + while True: + time.sleep(self.services["sleep"]) + list_template_response = list_templates( + self.apiclient, + templatefilter=\ + self.services["templatefilter"], + id=self.template_2.id, + zoneid=self.services["destzoneid"] + ) + self.assertEqual( + isinstance(list_template_response, list), + True, + "Check list response returns a valid list" + ) + self.assertNotEqual( + len(list_template_response), + 0, + "Check template extracted in List Templates" + ) + + template_response = list_template_response[0] + if template_response.isready == True: + break + + if timeout == 0: + raise Exception( + "Failed to download copied template(ID: %s)" % template_response.id) + + timeout = timeout - 1 cmd = deleteTemplate.deleteTemplateCmd() cmd.id = self.template.id cmd.zoneid = self.services["destzoneid"] diff --git a/test/integration/smoke/test_iso.py b/test/integration/smoke/test_iso.py index 2c14ed9704a..fc726721c9b 100644 --- a/test/integration/smoke/test_iso.py +++ b/test/integration/smoke/test_iso.py @@ -70,8 +70,6 @@ class Services: "mode": 'HTTP_DOWNLOAD', # Used in Extract template, value must be HTTP_DOWNLOAD }, - "destzoneid": 5, - # Copy ISO from one zone to another (Destination Zone) "isfeatured": True, "ispublic": True, "isextractable": True, @@ -203,6 +201,13 @@ class TestISO(cloudstackTestCase): cls.services["iso_1"]["zoneid"] = cls.zone.id cls.services["iso_2"]["zoneid"] = cls.zone.id cls.services["sourcezoneid"] = cls.zone.id + #populate second zone id for iso copy + cmd = listZones.listZonesCmd() + zones = cls.api_client.listZones(cmd) + if not isinstance(zones, list): + raise Exception("Failed to find zones.") + if len(zones) >= 2: + cls.services["destzoneid"] = zones[1].id #Create an account, ISOs etc. cls.account = Account.create( @@ -524,6 +529,35 @@ class TestISO(cloudstackTestCase): self.debug("Cleanup copied ISO: %s" % iso_response.id) # Cleanup- Delete the copied ISO + timeout = self.services["timeout"] + while True: + time.sleep(self.services["sleep"]) + list_iso_response = list_isos( + self.apiclient, + id=self.iso_2.id, + zoneid=self.services["destzoneid"] + ) + self.assertEqual( + isinstance(list_iso_response, list), + True, + "Check list response returns a valid list" + ) + + self.assertNotEqual( + len(list_iso_response), + 0, + "Check template extracted in List ISO" + ) + + iso_response = list_iso_response[0] + if iso_response.isready == True: + break + + if timeout == 0: + raise Exception( + "Failed to download copied iso(ID: %s)" % iso_response.id) + + timeout = timeout - 1 cmd = deleteIso.deleteIsoCmd() cmd.id = iso_response.id cmd.zoneid = self.services["destzoneid"] diff --git a/test/integration/smoke/test_templates.py b/test/integration/smoke/test_templates.py index 26d59f70057..d450a5d8122 100644 --- a/test/integration/smoke/test_templates.py +++ b/test/integration/smoke/test_templates.py @@ -87,8 +87,6 @@ class Services: "mode": "HTTP_DOWNLOAD", }, "templatefilter": 'self', - "destzoneid": 5, - # For Copy template (Destination zone) "isfeatured": True, "ispublic": True, "isextractable": False, @@ -295,6 +293,14 @@ class TestTemplates(cloudstackTestCase): # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) + #populate second zone id for iso copy + cmd = listZones.listZonesCmd() + zones = cls.api_client.listZones(cmd) + if not isinstance(zones, list): + raise Exception("Failed to find zones.") + if len(zones) >= 2: + cls.services["destzoneid"] = zones[1].id + cls.disk_offering = DiskOffering.create( cls.api_client, cls.services["disk_offering"] @@ -700,6 +706,36 @@ class TestTemplates(cloudstackTestCase): ) # Cleanup- Delete the copied template + timeout = self.services["timeout"] + while True: + time.sleep(self.services["sleep"]) + list_template_response = list_templates( + self.apiclient, + templatefilter=\ + self.services["templatefilter"], + id=self.template_2.id, + zoneid=self.services["destzoneid"] + ) + self.assertEqual( + isinstance(list_template_response, list), + True, + "Check list response returns a valid list" + ) + self.assertNotEqual( + len(list_template_response), + 0, + "Check template extracted in List Templates" + ) + + template_response = list_template_response[0] + if template_response.isready == True: + break + + if timeout == 0: + raise Exception( + "Failed to download copied template(ID: %s)" % template_response.id) + + timeout = timeout - 1 cmd = deleteTemplate.deleteTemplateCmd() cmd.id = template_response.id cmd.zoneid = self.services["destzoneid"]