CLOUDSTACK-8258: test_iso.py - Removed assertion on Iso name when random characters are appended to test data before creating Iso
Signed-off-by: SrikanteswaraRao Talluri <tall...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/97345821 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/97345821 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/97345821 Branch: refs/heads/hotfix/scp-exception Commit: 973458219734ead34253b1bf8f2b0bd29dd1b152 Parents: a95ce81 Author: Gaurav Aradhye <gaurav.arad...@clogeny.com> Authored: Mon Feb 16 03:29:46 2015 -0800 Committer: SrikanteswaraRao Talluri <tall...@apache.org> Committed: Tue Feb 17 18:19:52 2015 +0530 ---------------------------------------------------------------------- test/integration/smoke/test_iso.py | 520 +++++++++++++++++--------------- 1 file changed, 283 insertions(+), 237 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/97345821/test/integration/smoke/test_iso.py ---------------------------------------------------------------------- diff --git a/test/integration/smoke/test_iso.py b/test/integration/smoke/test_iso.py index 4bd66b5..443b6a6 100644 --- a/test/integration/smoke/test_iso.py +++ b/test/integration/smoke/test_iso.py @@ -5,9 +5,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -16,24 +16,27 @@ # under the License. """ BVT tests for Templates ISO """ -#Import Local Modules -import marvin -from marvin.cloudstackTestCase import * -from marvin.cloudstackAPI import * -from marvin.lib.utils import * -from marvin.lib.base import * -from marvin.lib.common import * +# Import Local Modules +from marvin.cloudstackTestCase import cloudstackTestCase, unittest +from marvin.cloudstackAPI import listZones, updateIso, extractIso, updateIsoPermissions, copyIso, deleteIso +from marvin.lib.utils import cleanup_resources, random_gen +from marvin.lib.base import Account, Iso +from marvin.lib.common import (get_domain, + get_zone, + list_isos, + list_os_types) from nose.plugins.attrib import attr import urllib -from random import random -#Import System modules +# Import System modules import time _multiprocess_shared_ = True + class TestCreateIso(cloudstackTestCase): -#TODO: SIMENH: check the existence of registered of ISO in secondary deploy a VM with registered ISO. can be added \ -# as another test + # TODO: SIMENH: check the existence of registered of ISO in secondary deploy a VM with registered ISO. can be added \ + # as another test + def setUp(self): self.services = self.testClient.getParsedTestDataConfig() self.apiclient = self.testClient.getApiClient() @@ -44,17 +47,17 @@ class TestCreateIso(cloudstackTestCase): self.services['mode'] = self.zone.networktype self.services["domainid"] = self.domain.id self.services["iso2"]["zoneid"] = self.zone.id - + self.account = Account.create( - self.apiclient, - self.services["account"], - domainid=self.domain.id - ) + self.apiclient, + self.services["account"], + domainid=self.domain.id + ) # Finding the OsTypeId from Ostype ostypes = list_os_types( - self.apiclient, - description=self.services["ostype"] - ) + self.apiclient, + description=self.services["ostype"] + ) if not isinstance(ostypes, list): raise unittest.SkipTest("OSTypeId for given description not found") @@ -67,7 +70,7 @@ class TestCreateIso(cloudstackTestCase): def tearDown(self): try: - #Clean up, terminate the created ISOs + # Clean up, terminate the created ISOs cleanup_resources(self.apiclient, self.cleanup) except Exception as e: @@ -75,7 +78,14 @@ class TestCreateIso(cloudstackTestCase): return - @attr(tags = ["advanced", "basic", "eip", "sg", "advancedns"], required_hardware="false") + @attr( + tags=[ + "advanced", + "basic", + "eip", + "sg", + "advancedns"], + required_hardware="false") def test_01_create_iso(self): """Test create public & private ISO """ @@ -87,51 +97,46 @@ class TestCreateIso(cloudstackTestCase): # 3. listIsos API should show the newly added ISO iso = Iso.create( - self.apiclient, - self.services["iso2"], - account=self.account.name, - domainid=self.account.domainid - ) + self.apiclient, + self.services["iso2"], + account=self.account.name, + domainid=self.account.domainid + ) self.debug("ISO created with ID: %s" % iso.id) - + try: iso.download(self.apiclient) except Exception as e: - self.fail("Exception while downloading ISO %s: %s"\ + self.fail("Exception while downloading ISO %s: %s" % (iso.id, e)) list_iso_response = list_isos( - self.apiclient, - id=iso.id - ) + self.apiclient, + id=iso.id + ) self.assertEqual( - isinstance(list_iso_response, list), - True, - "Check list response returns a valid list" - ) + isinstance(list_iso_response, list), + True, + "Check list response returns a valid list" + ) self.assertNotEqual( - len(list_iso_response), - 0, - "Check template available in List ISOs" - ) + len(list_iso_response), + 0, + "Check template available in List ISOs" + ) iso_response = list_iso_response[0] - - self.assertEqual( - iso_response.displaytext, - self.services["iso2"]["displaytext"], - "Check display text of newly created ISO" - ) + self.assertEqual( - iso_response.name, - self.services["iso2"]["name"], - "Check name of newly created ISO" - ) + iso_response.displaytext, + self.services["iso2"]["displaytext"], + "Check display text of newly created ISO" + ) self.assertEqual( - iso_response.zoneid, - self.services["iso2"]["zoneid"], - "Check zone ID of newly created ISO" - ) + iso_response.zoneid, + self.services["iso2"]["zoneid"], + "Check zone ID of newly created ISO" + ) return @@ -146,28 +151,28 @@ class TestISO(cloudstackTestCase): # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) - + cls.services["domainid"] = cls.domain.id cls.services["iso1"]["zoneid"] = cls.zone.id cls.services["iso2"]["zoneid"] = cls.zone.id cls.services["sourcezoneid"] = cls.zone.id - #populate second zone id for iso copy + # populate second zone id for iso copy cmd = listZones.listZonesCmd() cls.zones = cls.apiclient.listZones(cmd) if not isinstance(cls.zones, list): raise Exception("Failed to find zones.") - #Create an account, ISOs etc. + # Create an account, ISOs etc. cls.account = Account.create( - cls.apiclient, - cls.services["account"], - domainid=cls.domain.id - ) + cls.apiclient, + cls.services["account"], + domainid=cls.domain.id + ) # Finding the OsTypeId from Ostype ostypes = list_os_types( - cls.apiclient, - description=cls.services["ostype"] - ) + cls.apiclient, + description=cls.services["ostype"] + ) if not isinstance(ostypes, list): raise unittest.SkipTest("OSTypeId for given description not found") @@ -176,37 +181,39 @@ class TestISO(cloudstackTestCase): cls.services["ostypeid"] = ostypes[0].id cls.iso_1 = Iso.create( - cls.apiclient, - cls.services["iso1"], - account=cls.account.name, - domainid=cls.account.domainid - ) + cls.apiclient, + cls.services["iso1"], + account=cls.account.name, + domainid=cls.account.domainid + ) try: cls.iso_1.download(cls.apiclient) except Exception as e: - raise Exception("Exception while downloading ISO %s: %s"\ - % (cls.iso_1.id, e)) - + raise Exception("Exception while downloading ISO %s: %s" + % (cls.iso_1.id, e)) + cls.iso_2 = Iso.create( - cls.apiclient, - cls.services["iso2"], - account=cls.account.name, - domainid=cls.account.domainid - ) + cls.apiclient, + cls.services["iso2"], + account=cls.account.name, + domainid=cls.account.domainid + ) try: cls.iso_2.download(cls.apiclient) except Exception as e: - raise Exception("Exception while downloading ISO %s: %s"\ - % (cls.iso_2.id, e)) - + raise Exception("Exception while downloading ISO %s: %s" + % (cls.iso_2.id, e)) + cls._cleanup = [cls.account] return @classmethod def tearDownClass(cls): try: - cls.apiclient = super(TestISO, cls).getClsTestClient().getApiClient() - #Clean up, terminate the created templates + cls.apiclient = super( + TestISO, + cls).getClsTestClient().getApiClient() + # Clean up, terminate the created templates cleanup_resources(cls.apiclient, cls._cleanup) except Exception as e: @@ -221,7 +228,7 @@ class TestISO(cloudstackTestCase): def tearDown(self): try: - #Clean up, terminate the created ISOs, VMs + # Clean up, terminate the created ISOs, VMs cleanup_resources(self.apiclient, self.cleanup) except Exception as e: @@ -229,22 +236,29 @@ class TestISO(cloudstackTestCase): return + def get_iso_details(self, isoname): - def get_iso_details(self,isoname): - - #ListIsos to list default ISOS (VM and xen tools) + # ListIsos to list default ISOS (VM and xen tools) list_default_iso_response = list_isos( - self.apiclient, - name=isoname, - isready="true" - ) + self.apiclient, + name=isoname, + isready="true" + ) self.assertEqual( - list_default_iso_response, - None, - "Check if ISO exists in ListIsos" - ) - - @attr(tags = ["advanced", "basic", "eip", "sg", "advancedns", "smoke"], required_hardware="false") + list_default_iso_response, + None, + "Check if ISO exists in ListIsos" + ) + + @attr( + tags=[ + "advanced", + "basic", + "eip", + "sg", + "advancedns", + "smoke"], + required_hardware="false") def test_02_edit_iso(self): """Test Edit ISO """ @@ -253,14 +267,14 @@ class TestISO(cloudstackTestCase): # 1. UI should show the edited values for ISO # 2. database (vm_template table) should have updated values - #Generate random values for updating ISO name and Display text + # Generate random values for updating ISO name and Display text new_displayText = random_gen() new_name = random_gen() self.debug("Updating ISO permissions for ISO: %s" % self.iso_1.id) - + cmd = updateIso.updateIsoCmd() - #Assign new values to attributes + # Assign new values to attributes cmd.id = self.iso_1.id cmd.displaytext = new_displayText cmd.name = new_name @@ -269,47 +283,49 @@ class TestISO(cloudstackTestCase): self.apiclient.updateIso(cmd) - #Check whether attributes are updated in ISO using listIsos + # Check whether attributes are updated in ISO using listIsos list_iso_response = list_isos( - self.apiclient, - id=self.iso_1.id - ) + self.apiclient, + id=self.iso_1.id + ) self.assertEqual( - isinstance(list_iso_response, list), - True, - "Check list response returns a valid list" - ) + isinstance(list_iso_response, list), + True, + "Check list response returns a valid list" + ) self.assertNotEqual( - len(list_iso_response), - 0, - "Check template available in List ISOs" - ) + len(list_iso_response), + 0, + "Check template available in List ISOs" + ) iso_response = list_iso_response[0] self.assertEqual( - iso_response.displaytext, - new_displayText, - "Check display text of updated ISO" - ) - self.assertEqual( - iso_response.name, - new_name, - "Check name of updated ISO" - ) + iso_response.displaytext, + new_displayText, + "Check display text of updated ISO" + ) self.assertEqual( - iso_response.bootable, - self.services["bootable"], - "Check if image is bootable of updated ISO" - ) + iso_response.bootable, + self.services["bootable"], + "Check if image is bootable of updated ISO" + ) self.assertEqual( - iso_response.ostypeid, - self.services["ostypeid"], - "Check OSTypeID of updated ISO" - ) + iso_response.ostypeid, + self.services["ostypeid"], + "Check OSTypeID of updated ISO" + ) return - @attr(tags = ["advanced", "basic", "eip", "sg", "advancedns"], required_hardware="false") + @attr( + tags=[ + "advanced", + "basic", + "eip", + "sg", + "advancedns"], + required_hardware="false") def test_03_delete_iso(self): """Test delete ISO """ @@ -324,20 +340,27 @@ class TestISO(cloudstackTestCase): # Sleep to ensure that ISO state is reflected in other calls time.sleep(self.services["sleep"]) - #ListIsos to verify deleted ISO is properly deleted + # ListIsos to verify deleted ISO is properly deleted list_iso_response = list_isos( - self.apiclient, - id=self.iso_1.id - ) + self.apiclient, + id=self.iso_1.id + ) self.assertEqual( - list_iso_response, - None, - "Check if ISO exists in ListIsos" - ) + list_iso_response, + None, + "Check if ISO exists in ListIsos" + ) return - @attr(tags = ["advanced", "basic", "eip", "sg", "advancedns"], required_hardware="true") + @attr( + tags=[ + "advanced", + "basic", + "eip", + "sg", + "advancedns"], + required_hardware="true") def test_04_extract_Iso(self): "Test for extract ISO" @@ -348,7 +371,7 @@ class TestISO(cloudstackTestCase): # 3 .ListIsos should not display the system templates self.debug("Extracting ISO with ID: %s" % self.iso_2.id) - + cmd = extractIso.extractIsoCmd() cmd.id = self.iso_2.id cmd.mode = self.services["iso2"]["mode"] @@ -356,39 +379,47 @@ class TestISO(cloudstackTestCase): list_extract_response = self.apiclient.extractIso(cmd) try: - #Format URL to ASCII to retrieve response code + # Format URL to ASCII to retrieve response code formatted_url = urllib.unquote_plus(list_extract_response.url) url_response = urllib.urlopen(formatted_url) response_code = url_response.getcode() except Exception: self.fail( - "Extract ISO Failed with invalid URL %s (ISO id: %s)" \ + "Extract ISO Failed with invalid URL %s (ISO id: %s)" % (formatted_url, self.iso_2.id) ) self.assertEqual( - list_extract_response.id, - self.iso_2.id, - "Check ID of the downloaded ISO" - ) + list_extract_response.id, + self.iso_2.id, + "Check ID of the downloaded ISO" + ) self.assertEqual( - list_extract_response.extractMode, - self.services["iso2"]["mode"], - "Check mode of extraction" - ) + list_extract_response.extractMode, + self.services["iso2"]["mode"], + "Check mode of extraction" + ) self.assertEqual( - list_extract_response.zoneid, - self.services["iso2"]["zoneid"], - "Check zone ID of extraction" - ) + list_extract_response.zoneid, + self.services["iso2"]["zoneid"], + "Check zone ID of extraction" + ) self.assertEqual( - response_code, - 200, - "Check for a valid response of download URL" - ) + response_code, + 200, + "Check for a valid response of download URL" + ) return - @attr(tags = ["advanced", "basic", "eip", "sg", "advancedns", "smoke", "selfservice"]) + @attr( + tags=[ + "advanced", + "basic", + "eip", + "sg", + "advancedns", + "smoke", + "selfservice"]) def test_05_iso_permissions(self): """Update & Test for ISO permissions""" @@ -398,100 +429,112 @@ class TestISO(cloudstackTestCase): # table in database self.debug("Updating permissions for ISO: %s" % self.iso_2.id) - + cmd = updateIsoPermissions.updateIsoPermissionsCmd() cmd.id = self.iso_2.id - #Update ISO permissions + # Update ISO permissions cmd.isfeatured = self.services["isfeatured"] cmd.ispublic = self.services["ispublic"] cmd.isextractable = self.services["isextractable"] self.apiclient.updateIsoPermissions(cmd) - #Verify ListIsos have updated permissions for the ISO for normal user + # Verify ListIsos have updated permissions for the ISO for normal user list_iso_response = list_isos( - self.apiclient, - id=self.iso_2.id, - account=self.account.name, - domainid=self.account.domainid - ) + self.apiclient, + id=self.iso_2.id, + account=self.account.name, + domainid=self.account.domainid + ) self.assertEqual( - isinstance(list_iso_response, list), - True, - "Check list response returns a valid list" - ) - + isinstance(list_iso_response, list), + True, + "Check list response returns a valid list" + ) + iso_response = list_iso_response[0] self.assertEqual( - iso_response.id, - self.iso_2.id, - "Check ISO ID" - ) + iso_response.id, + self.iso_2.id, + "Check ISO ID" + ) self.assertEqual( - iso_response.ispublic, - self.services["ispublic"], - "Check ispublic permission of ISO" - ) + iso_response.ispublic, + self.services["ispublic"], + "Check ispublic permission of ISO" + ) self.assertEqual( - iso_response.isfeatured, - self.services["isfeatured"], - "Check isfeatured permission of ISO" - ) + iso_response.isfeatured, + self.services["isfeatured"], + "Check isfeatured permission of ISO" + ) return - @attr(tags = ["advanced", "basic", "eip", "sg", "advancedns", "smoke", "multizone", "provisioning"]) + @attr( + tags=[ + "advanced", + "basic", + "eip", + "sg", + "advancedns", + "smoke", + "multizone", + "provisioning"]) def test_06_copy_iso(self): """Test for copy ISO from one zone to another""" - #Validate the following - #1. copy ISO should be successful and secondary storage + # Validate the following + # 1. copy ISO should be successful and secondary storage # should contain new copied ISO. if len(self.zones) <= 1: - self.skipTest("Not enough zones available to perform copy template") + self.skipTest( + "Not enough zones available to perform copy template") - self.services["destzoneid"] = filter(lambda z: z.id != self.zone.id, self.zones)[0].id + self.services["destzoneid"] = filter( + lambda z: z.id != self.zone.id, + self.zones)[0].id self.debug("Copy ISO from %s to %s" % ( - self.zone.id, - self.services["destzoneid"] - )) - + self.zone.id, + self.services["destzoneid"] + )) + cmd = copyIso.copyIsoCmd() cmd.id = self.iso_2.id cmd.destzoneid = self.services["destzoneid"] cmd.sourcezoneid = self.zone.id self.apiclient.copyIso(cmd) - #Verify ISO is copied to another zone using ListIsos + # Verify ISO is copied to another zone using ListIsos list_iso_response = list_isos( - self.apiclient, - id=self.iso_2.id, - zoneid=self.services["destzoneid"] - ) + 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" - ) + 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" - ) + len(list_iso_response), + 0, + "Check template extracted in List ISO" + ) iso_response = list_iso_response[0] - + self.assertEqual( - iso_response.id, - self.iso_2.id, - "Check ID of the downloaded ISO" - ) + iso_response.id, + self.iso_2.id, + "Check ID of the downloaded ISO" + ) self.assertEqual( - iso_response.zoneid, - self.services["destzoneid"], - "Check zone ID of the copied ISO" - ) + iso_response.zoneid, + self.services["destzoneid"], + "Check zone ID of the copied ISO" + ) self.debug("Cleanup copied ISO: %s" % iso_response.id) # Cleanup- Delete the copied ISO @@ -499,29 +542,29 @@ class TestISO(cloudstackTestCase): while True: time.sleep(self.services["sleep"]) list_iso_response = list_isos( - self.apiclient, - id=self.iso_2.id, - zoneid=self.services["destzoneid"] - ) + 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" - ) + 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" - ) + len(list_iso_response), + 0, + "Check template extracted in List ISO" + ) iso_response = list_iso_response[0] - if iso_response.isready == True: + if iso_response.isready: break if timeout == 0: raise Exception( - "Failed to download copied iso(ID: %s)" % iso_response.id) + "Failed to download copied iso(ID: %s)" % iso_response.id) timeout = timeout - 1 cmd = deleteIso.deleteIsoCmd() @@ -530,8 +573,14 @@ class TestISO(cloudstackTestCase): self.apiclient.deleteIso(cmd) return - - @attr(tags = ["advanced", "basic", "eip", "sg", "advancedns"], required_hardware="false") + @attr( + tags=[ + "advanced", + "basic", + "eip", + "sg", + "advancedns"], + required_hardware="false") def test_07_list_default_iso(self): """Test delete ISO """ @@ -539,10 +588,7 @@ class TestISO(cloudstackTestCase): # Validate the following: # list ISO should list default ISOS (VM and xen tools) - - #ListIsos to list default ISOS (VM and xen tools) - list_xs__iso_response = self.get_iso_details("xs-tools.iso") - list_xs__iso_response = self.get_iso_details("vmware-tools.iso") - - + # ListIsos to list default ISOS (VM and xen tools) + self.get_iso_details("xs-tools.iso") + self.get_iso_details("vmware-tools.iso") return