From 7305063fb4f508f4b97d7000c5e25068aa681a60 Mon Sep 17 00:00:00 2001 From: Girish Shilamkar Date: Tue, 28 Jan 2014 11:12:24 +0530 Subject: [PATCH] CLOUDSTACK-5925: get_*() functionality changed in marvin, changed BVT too. --- .../integration/smoke/test_affinity_groups.py | 36 +++++---- test/integration/smoke/test_deploy_vm.py | 8 +- .../smoke/test_deploy_vm_with_userdata.py | 13 +++- ...ploy_vms_with_varied_deploymentplanners.py | 15 ++-- test/integration/smoke/test_disk_offerings.py | 16 ++-- .../smoke/test_guest_vlan_range.py | 11 +-- test/integration/smoke/test_hosts.py | 7 +- test/integration/smoke/test_internal_lb.py | 13 +++- test/integration/smoke/test_iso.py | 35 ++++----- test/integration/smoke/test_loadbalance.py | 32 ++++---- .../smoke/test_multipleips_per_nic.py | 10 ++- test/integration/smoke/test_network.py | 74 +++++++++--------- test/integration/smoke/test_network_acl.py | 12 ++- test/integration/smoke/test_nic.py | 12 ++- .../smoke/test_non_contigiousvlan.py | 1 + .../smoke/test_portable_publicip.py | 43 +++++------ .../integration/smoke/test_primary_storage.py | 5 +- .../integration/smoke/test_public_ip_range.py | 13 ++-- test/integration/smoke/test_regions.py | 17 +++-- .../smoke/test_reset_vm_on_reboot.py | 26 ++++--- .../integration/smoke/test_resource_detail.py | 23 +++--- test/integration/smoke/test_routers.py | 26 ++++--- test/integration/smoke/test_scale_vm.py | 28 ++++--- .../smoke/test_secondary_storage.py | 4 +- .../smoke/test_service_offerings.py | 34 +++++---- test/integration/smoke/test_snapshots.py | 24 +++--- test/integration/smoke/test_ssvm.py | 3 +- test/integration/smoke/test_templates.py | 75 ++++++++++--------- test/integration/smoke/test_vm_life_cycle.py | 49 ++++++------ test/integration/smoke/test_vm_snapshots.py | 20 +++-- test/integration/smoke/test_volumes.py | 63 +++++++++------- test/integration/smoke/test_vpc_vpn.py | 23 ++++-- tools/marvin/marvin/integration/lib/common.py | 12 +-- 33 files changed, 446 insertions(+), 337 deletions(-) diff --git a/test/integration/smoke/test_affinity_groups.py b/test/integration/smoke/test_affinity_groups.py index 346a4a4f797..5c0ff7d7387 100644 --- a/test/integration/smoke/test_affinity_groups.py +++ b/test/integration/smoke/test_affinity_groups.py @@ -16,6 +16,7 @@ # specific language governing permissions and limitations # under the License. +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * from marvin.integration.lib.utils import * @@ -32,25 +33,30 @@ class TestDeployVmWithAffinityGroup(cloudstackTestCase): @classmethod def setUpClass(cls): - cls.test_client = super(TestDeployVmWithAffinityGroup, cls).getClsTestClient() - zone_name = cls.test_client.getZoneForTests() - cls.api_client = cls.test_client.getApiClient() - cls.services = cls.test_client.getConfigParser().parsedDict + cls.testClient = super(TestDeployVmWithAffinityGroup, cls).getClsTestClient() + zone_name = cls.testClient.getZoneForTests() + cls.domain = get_domain(cls.apiclient) + cls.apiclient = cls.testClient.getApiClient() + cls.services = cls.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - cls.domain = get_domain(cls.api_client, cls.services) - cls.zone = get_zone(cls.api_client, cls.services) + cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) + cls.template = get_template( - cls.api_client, + cls.apiclient, cls.zone.id, cls.services["ostype"] ) + + if cls.template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["template"] = cls.template.id cls.services["zoneid"] = cls.zone.id cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], domainid=cls.domain.id ) @@ -58,11 +64,11 @@ class TestDeployVmWithAffinityGroup(cloudstackTestCase): cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( - cls.api_client, + cls.apiclient, cls.services["service_offerings"] ) - cls.ag = AffinityGroup.create(cls.api_client, cls.services["virtual_machine"]["affinity"], + cls.ag = AffinityGroup.create(cls.apiclient, cls.services["virtual_machine"]["affinity"], account=cls.services["account"], domainid=cls.domain.id) cls._cleanup = [ @@ -82,7 +88,7 @@ class TestDeployVmWithAffinityGroup(cloudstackTestCase): """ #deploy VM1 in affinity group created in setUp vm1 = VirtualMachine.create( - self.api_client, + self.apiclient, self.services["virtual_machine"], templateid=self.template.id, accountid=self.account.name, @@ -92,7 +98,7 @@ class TestDeployVmWithAffinityGroup(cloudstackTestCase): ) list_vm1 = list_virtual_machines( - self.api_client, + self.apiclient, id=vm1.id ) self.assertEqual( @@ -115,7 +121,7 @@ class TestDeployVmWithAffinityGroup(cloudstackTestCase): #deploy VM2 in affinity group created in setUp vm2 = VirtualMachine.create( - self.api_client, + self.apiclient, self.services["virtual_machine"], templateid=self.template.id, accountid=self.account.name, @@ -124,7 +130,7 @@ class TestDeployVmWithAffinityGroup(cloudstackTestCase): affinitygroupnames=[self.ag.name] ) list_vm2 = list_virtual_machines( - self.api_client, + self.apiclient, id=vm2.id ) self.assertEqual( @@ -153,6 +159,6 @@ class TestDeployVmWithAffinityGroup(cloudstackTestCase): def tearDownClass(cls): try: #Clean up, terminate the created templates - cleanup_resources(cls.api_client, cls._cleanup) + cleanup_resources(cls.apiclient, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) diff --git a/test/integration/smoke/test_deploy_vm.py b/test/integration/smoke/test_deploy_vm.py index a09be359bad..e572c4dc346 100644 --- a/test/integration/smoke/test_deploy_vm.py +++ b/test/integration/smoke/test_deploy_vm.py @@ -16,6 +16,7 @@ # under the License. #Test from the Marvin - Testing in Python wiki +from marvin.cloudstackTestClient import getZoneForTests #All tests inherit from cloudstackTestCase from marvin.cloudstackTestCase import cloudstackTestCase @@ -40,14 +41,17 @@ class TestDeployVM(cloudstackTestCase): def setUp(self): self.apiclient = self.testClient.getApiClient() - self.testdata = self.testClient.getConfigParser().parsedDict + self.testdata = self.testClient.getParsedTestDataConfig() # Get Zone, Domain and Default Built-in template - self.domain = get_domain(self.apiclient, self.testdata) + self.domain = get_domain(self.apiclient) self.zone = get_zone(self.apiclient, self.testdata) self.testdata["mode"] = self.zone.networktype self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"]) + if self.template == FAILED: + self.fail("get_template() failed to return template with description %s" % self.testdata["ostype"]) + #create a user account self.account = Account.create( self.apiclient, diff --git a/test/integration/smoke/test_deploy_vm_with_userdata.py b/test/integration/smoke/test_deploy_vm_with_userdata.py index 7bb72b3aed6..d90db13c8d1 100644 --- a/test/integration/smoke/test_deploy_vm_with_userdata.py +++ b/test/integration/smoke/test_deploy_vm_with_userdata.py @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import cloudstackTestCase from marvin.integration.lib.base import (ServiceOffering, VirtualMachine, @@ -32,11 +33,11 @@ class TestDeployVmWithUserData(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestDeployVmWithUserData, cls).getClsTestClient() - cls.apiClient = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestDeployVmWithUserData, cls).getClsTestClient() + cls.apiClient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() - cls.zone = get_zone(cls.apiClient, cls.services) + cls.zone = get_zone(cls.apiClient, cls.getZoneForTests()) if cls.zone.localstorageenabled: #For devcloud since localstroage is enabled cls.services["service_offerings"]["storagetype"] = "local" @@ -51,6 +52,10 @@ class TestDeployVmWithUserData(cloudstackTestCase): cls.zone.id, cls.services["ostype"] ) + + if cls.template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + cls.debug("Successfully created account: %s, id: \ %s" % (cls.account.name,\ cls.account.id)) diff --git a/test/integration/smoke/test_deploy_vms_with_varied_deploymentplanners.py b/test/integration/smoke/test_deploy_vms_with_varied_deploymentplanners.py index 565228a352f..d1f6d3d5e5b 100644 --- a/test/integration/smoke/test_deploy_vms_with_varied_deploymentplanners.py +++ b/test/integration/smoke/test_deploy_vms_with_varied_deploymentplanners.py @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import cloudstackTestCase from marvin.integration.lib.base import Account, VirtualMachine, ServiceOffering, Host, Cluster from marvin.integration.lib.common import get_zone, get_domain, get_template @@ -28,18 +29,22 @@ class TestDeployVmWithVariedPlanners(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestDeployVmWithVariedPlanners, cls).getClsTestClient() - cls.apiclient = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestDeployVmWithVariedPlanners, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - cls.domain = get_domain(cls.apiclient, cls.services) - cls.zone = get_zone(cls.apiclient, cls.services) + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) cls.template = get_template( cls.apiclient, cls.zone.id, cls.services["ostype"] ) + + if cls.template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["template"] = cls.template.id cls.services["zoneid"] = cls.zone.id diff --git a/test/integration/smoke/test_disk_offerings.py b/test/integration/smoke/test_disk_offerings.py index b104ca88bed..d2d3b4dc131 100644 --- a/test/integration/smoke/test_disk_offerings.py +++ b/test/integration/smoke/test_disk_offerings.py @@ -30,7 +30,7 @@ _multiprocess_shared_ = True class TestCreateDiskOffering(cloudstackTestCase): def setUp(self): - self.services = self.testClient.getConfigParser().parsedDict + self.services = self.testClient.getParsedTestDataConfig() self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() self.cleanup = [] @@ -109,16 +109,16 @@ class TestDiskOfferings(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestDiskOfferings, cls).getClsTestClient() - self.api_client = self.cloudstackTestClient.getApiClient() - self.services = self.cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestDiskOfferings, cls).getClsTestClient() + self.apiclient = self.testClient.getApiClient() + self.services = self.testClient.getParsedTestDataConfig() cls.disk_offering_1 = DiskOffering.create( - cls.api_client, + cls.apiclient, cls.services["disk_offering"] ) cls.disk_offering_2 = DiskOffering.create( - cls.api_client, + cls.apiclient, cls.services["disk_offering"] ) cls._cleanup = [cls.disk_offering_1] @@ -127,8 +127,8 @@ class TestDiskOfferings(cloudstackTestCase): @classmethod def tearDownClass(cls): try: - cls.api_client = super(TestDiskOfferings, cls).getClsTestClient().getApiClient() - cleanup_resources(cls.api_client, cls._cleanup) + cls.apiclient = super(TestDiskOfferings, cls).getClsTestClient().getApiClient() + cleanup_resources(cls.apiclient, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return diff --git a/test/integration/smoke/test_guest_vlan_range.py b/test/integration/smoke/test_guest_vlan_range.py index 4e2de50fb75..e76f3d501d2 100644 --- a/test/integration/smoke/test_guest_vlan_range.py +++ b/test/integration/smoke/test_guest_vlan_range.py @@ -17,6 +17,7 @@ """ P1 tests for Dedicating Guest Vlan Ranges """ #Import Local Modules +from marvin.cloudstackTestClient import getZoneForTests import marvin from nose.plugins.attrib import attr from marvin.cloudstackTestCase import * @@ -30,13 +31,13 @@ class TestDedicateGuestVlanRange(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestDedicateGuestVlanRange, cls).getClsTestClient() - cls.apiclient = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestDedicateGuestVlanRange, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain - cls.domain = get_domain(cls.apiclient, cls.services) - cls.zone = get_zone(cls.apiclient, cls.services) + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) # Create Account cls.account = Account.create( diff --git a/test/integration/smoke/test_hosts.py b/test/integration/smoke/test_hosts.py index 4c58b9bf77e..7525bdadc25 100644 --- a/test/integration/smoke/test_hosts.py +++ b/test/integration/smoke/test_hosts.py @@ -18,6 +18,7 @@ """ #Import Local Modules import marvin +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * from marvin.integration.lib.utils import * @@ -36,9 +37,9 @@ class TestHosts(cloudstackTestCase): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() - self.services = self.testClient.getConfigParser().parsedDict - self.zone = get_zone(self.apiclient, self.services) - self.pod = get_pod(self.apiclient, self.zone.id, self.services) + self.services = self.testClient.getParsedTestDataConfig() + self.zone = get_zone(self.apiclient, self.getZoneForTests()) + self.pod = get_pod(apilcient=self.apiclient, self.zone.id) self.cleanup = [] return diff --git a/test/integration/smoke/test_internal_lb.py b/test/integration/smoke/test_internal_lb.py index d997ae0292f..e53e4edcd38 100644 --- a/test/integration/smoke/test_internal_lb.py +++ b/test/integration/smoke/test_internal_lb.py @@ -17,6 +17,7 @@ """ Tests for configuring Internal Load Balancing Rules. """ #Import Local Modules +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * from marvin.integration.lib.utils import * @@ -30,11 +31,11 @@ class TestInternalLb(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestInternalLb, cls).getClsTestClient() - cls.apiclient = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestInternalLb, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() - cls.zone = get_zone(cls.apiclient, cls.services) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) cls.domain = get_domain(cls.apiclient) cls.service_offering = ServiceOffering.create( cls.apiclient, @@ -46,6 +47,10 @@ class TestInternalLb(cloudstackTestCase): cls.zone.id, cls.services["ostype"] ) + + if cls.template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + cls.debug("Successfully created account: %s, id: \ %s" % (cls.account.name,\ cls.account.id)) diff --git a/test/integration/smoke/test_iso.py b/test/integration/smoke/test_iso.py index 50042ba53c8..376a17c31d6 100644 --- a/test/integration/smoke/test_iso.py +++ b/test/integration/smoke/test_iso.py @@ -18,6 +18,7 @@ """ #Import Local Modules import marvin +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * from marvin.integration.lib.utils import * @@ -34,12 +35,12 @@ _multiprocess_shared_ = True class TestCreateIso(cloudstackTestCase): def setUp(self): - self.services = self.testClient.getConfigParser().parsedDict + self.services = self.testClient.getParsedTestDataConfig() self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() # Get Zone, Domain and templates - self.domain = get_domain(self.apiclient, self.services) - self.zone = get_zone(self.apiclient, self.services) + self.domain = get_domain(self.apiclient) + self.zone = get_zone(self.apiclient, self.getZoneForTests()) self.services['mode'] = self.zone.networktype self.services["domainid"] = self.domain.id self.services["iso_2"]["zoneid"] = self.zone.id @@ -138,13 +139,13 @@ class TestISO(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestISO, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestISO, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - cls.domain = get_domain(cls.api_client, cls.services) - cls.zone = get_zone(cls.api_client, cls.services) + cls.domain = get_domain(cls.apiclient, cls.getZoneForTests()) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) cls.services["domainid"] = cls.domain.id cls.services["iso_1"]["zoneid"] = cls.zone.id @@ -152,20 +153,20 @@ class TestISO(cloudstackTestCase): cls.services["sourcezoneid"] = cls.zone.id #populate second zone id for iso copy cmd = listZones.listZonesCmd() - cls.zones = cls.api_client.listZones(cmd) + cls.zones = cls.apiclient.listZones(cmd) if not isinstance(cls.zones, list): raise Exception("Failed to find zones.") #Create an account, ISOs etc. cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], domainid=cls.domain.id ) cls.services["account"] = cls.account.name # Finding the OsTypeId from Ostype ostypes = list_os_types( - cls.api_client, + cls.apiclient, description=cls.services["ostype"] ) if not isinstance(ostypes, list): @@ -176,25 +177,25 @@ class TestISO(cloudstackTestCase): cls.services["ostypeid"] = ostypes[0].id cls.iso_1 = Iso.create( - cls.api_client, + cls.apiclient, cls.services["iso_1"], account=cls.account.name, domainid=cls.account.domainid ) try: - cls.iso_1.download(cls.api_client) + cls.iso_1.download(cls.apiclient) except Exception as e: raise Exception("Exception while downloading ISO %s: %s"\ % (cls.iso_1.id, e)) cls.iso_2 = Iso.create( - cls.api_client, + cls.apiclient, cls.services["iso_2"], account=cls.account.name, domainid=cls.account.domainid ) try: - cls.iso_2.download(cls.api_client) + cls.iso_2.download(cls.apiclient) except Exception as e: raise Exception("Exception while downloading ISO %s: %s"\ % (cls.iso_2.id, e)) @@ -205,9 +206,9 @@ class TestISO(cloudstackTestCase): @classmethod def tearDownClass(cls): try: - cls.api_client = super(TestISO, cls).getClsTestClient().getApiClient() + cls.apiclient = super(TestISO, cls).getClsTestClient().getApiClient() #Clean up, terminate the created templates - cleanup_resources(cls.api_client, cls._cleanup) + cleanup_resources(cls.apiclient, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) diff --git a/test/integration/smoke/test_loadbalance.py b/test/integration/smoke/test_loadbalance.py index db8f46ea137..355dcc591b6 100644 --- a/test/integration/smoke/test_loadbalance.py +++ b/test/integration/smoke/test_loadbalance.py @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * from marvin.sshClient import SshClient @@ -32,33 +33,36 @@ class TestLoadBalance(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestLoadBalance, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestLoadBalance, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - cls.domain = get_domain(cls.api_client, cls.services) - cls.zone = get_zone(cls.api_client, cls.services) + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) template = get_template( - cls.api_client, + cls.apiclient, cls.zone.id, cls.services["ostype"] ) + if cls.template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + cls.services["server"]["zoneid"] = cls.zone.id #Create an account, network, VM and IP addresses cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], admin=True, domainid=cls.domain.id ) cls.service_offering = ServiceOffering.create( - cls.api_client, + cls.apiclient, cls.services["service_offerings"] ) cls.vm_1 = VirtualMachine.create( - cls.api_client, + cls.apiclient, cls.services["server"], templateid=template.id, accountid=cls.account.name, @@ -66,7 +70,7 @@ class TestLoadBalance(cloudstackTestCase): serviceofferingid=cls.service_offering.id ) cls.vm_2 = VirtualMachine.create( - cls.api_client, + cls.apiclient, cls.services["server"], templateid=template.id, accountid=cls.account.name, @@ -74,7 +78,7 @@ class TestLoadBalance(cloudstackTestCase): serviceofferingid=cls.service_offering.id ) cls.vm_3 = VirtualMachine.create( - cls.api_client, + cls.apiclient, cls.services["server"], templateid=template.id, accountid=cls.account.name, @@ -82,7 +86,7 @@ class TestLoadBalance(cloudstackTestCase): serviceofferingid=cls.service_offering.id ) cls.non_src_nat_ip = PublicIPAddress.create( - cls.api_client, + cls.apiclient, cls.account.name, cls.zone.id, cls.account.domainid, @@ -90,7 +94,7 @@ class TestLoadBalance(cloudstackTestCase): ) # Open up firewall port for SSH cls.fw_rule = FireWallRule.create( - cls.api_client, + cls.apiclient, ipaddressid=cls.non_src_nat_ip.ipaddress.id, protocol=cls.services["lbrule"]["protocol"], cidrlist=['0.0.0.0/0'], @@ -113,7 +117,7 @@ class TestLoadBalance(cloudstackTestCase): @classmethod def tearDownClass(cls): - cleanup_resources(cls.api_client, cls._cleanup) + cleanup_resources(cls.apiclient, cls._cleanup) return def try_ssh(self, ip_addr, hostnames): diff --git a/test/integration/smoke/test_multipleips_per_nic.py b/test/integration/smoke/test_multipleips_per_nic.py index 9e04b531ede..ad00dba0e64 100644 --- a/test/integration/smoke/test_multipleips_per_nic.py +++ b/test/integration/smoke/test_multipleips_per_nic.py @@ -31,6 +31,7 @@ from marvin.integration.lib.utils import cleanup_resources #common - commonly used methods for all tests are listed here from marvin.integration.lib.common import get_zone, get_domain, get_template +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackAPI.addIpToNic import addIpToNicCmd from marvin.cloudstackAPI.removeIpFromNic import removeIpFromNicCmd from marvin.cloudstackAPI.listNics import listNicsCmd @@ -43,15 +44,18 @@ class TestDeployVM(cloudstackTestCase): """ def setUp(self): - self.testdata = self.testClient.getConfigParser().parsedDict + self.testdata = self.testClient.getParsedTestDataConfig() self.apiclient = self.testClient.getApiClient() # Get Zone, Domain and Default Built-in template - self.domain = get_domain(self.apiclient, self.testdata) - self.zone = get_zone(self.apiclient, self.testdata) + self.domain = get_domain(self.apiclient)) + self.zone = get_zone(self.apiclient, self.getZoneForTests()) self.testdata["mode"] = self.zone.networktype self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"]) + if self.template == FAILED: + self.fail("get_template() failed to return template with description %s" % self.testdata["ostype"]) + #create a user account self.account = Account.create( self.apiclient, diff --git a/test/integration/smoke/test_network.py b/test/integration/smoke/test_network.py index f0cdcfd93b4..04a2bd36373 100644 --- a/test/integration/smoke/test_network.py +++ b/test/integration/smoke/test_network.py @@ -18,6 +18,7 @@ """ #Import Local Modules import marvin +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackException import cloudstackAPIException from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * @@ -40,45 +41,45 @@ class TestPublicIP(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestPublicIP, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestPublicIP, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - cls.domain = get_domain(cls.api_client, cls.services) - cls.zone = get_zone(cls.api_client, cls.services) + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) cls.services['mode'] = cls.zone.networktype # Create Accounts & networks cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], admin=True, domainid=cls.domain.id ) cls.user = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], domainid=cls.domain.id ) cls.services["network"]["zoneid"] = cls.zone.id cls.network_offering = NetworkOffering.create( - cls.api_client, + cls.apiclient, cls.services["network_offering"], ) # Enable Network offering - cls.network_offering.update(cls.api_client, state='Enabled') + cls.network_offering.update(cls.apiclient, state='Enabled') cls.services["network"]["networkoffering"] = cls.network_offering.id cls.account_network = Network.create( - cls.api_client, + cls.apiclient, cls.services["network"], cls.account.name, cls.account.domainid ) cls.user_network = Network.create( - cls.api_client, + cls.apiclient, cls.services["network"], cls.user.name, cls.user.domainid @@ -86,13 +87,13 @@ class TestPublicIP(cloudstackTestCase): # Create Source NAT IP addresses account_src_nat_ip = PublicIPAddress.create( - cls.api_client, + cls.apiclient, cls.account.name, cls.zone.id, cls.account.domainid ) user_src_nat_ip = PublicIPAddress.create( - cls.api_client, + cls.apiclient, cls.user.name, cls.zone.id, cls.user.domainid @@ -110,7 +111,7 @@ class TestPublicIP(cloudstackTestCase): def tearDownClass(cls): try: #Cleanup resources used - cleanup_resources(cls.api_client, cls._cleanup) + cleanup_resources(cls.apiclient, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return @@ -221,32 +222,35 @@ class TestPortForwarding(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestPortForwarding, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestPortForwarding, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - cls.domain = get_domain(cls.api_client, cls.services) - cls.zone = get_zone(cls.api_client, cls.services) + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) template = get_template( - cls.api_client, + cls.apiclient, cls.zone.id, cls.services["ostype"] ) + if template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + #Create an account, network, VM and IP addresses cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], admin=True, domainid=cls.domain.id ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( - cls.api_client, + cls.apiclient, cls.services["service_offerings"] ) cls.virtual_machine = VirtualMachine.create( - cls.api_client, + cls.apiclient, cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.name, @@ -267,8 +271,8 @@ class TestPortForwarding(cloudstackTestCase): @classmethod def tearDownClass(cls): try: - cls.api_client = super(TestPortForwarding, cls).getClsTestClient().getApiClient() - cleanup_resources(cls.api_client, cls._cleanup) + cls.apiclient = super(TestPortForwarding, cls).getClsTestClient().getApiClient() + cleanup_resources(cls.apiclient, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) @@ -525,16 +529,18 @@ class TestRebootRouter(cloudstackTestCase): def setUp(self): self.apiclient = self.testClient.getApiClient() - self.services = self.testClient.cloudstackTestClient.getConfigParser().parsedDict + self.services = self.testClient.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - self.domain = get_domain(self.apiclient, self.services) - self.zone = get_zone(self.apiclient, self.services) + self.domain = get_domain(self.apiclient) + self.zone = get_zone(self.apiclient, self.getZoneForTests()) template = get_template( self.apiclient, self.zone.id, self.services["ostype"] ) + if template == FAILED: + self.fail("get_template() failed to return template with description %s" % self.services["ostype"]) self.services["virtual_machine"]["zoneid"] = self.zone.id #Create an account, network, VM and IP addresses @@ -691,11 +697,11 @@ class TestReleaseIP(cloudstackTestCase): def setUp(self): self.apiclient = self.testClient.getApiClient() - self.services = self.testClient.getConfigParser().parsedDict + self.services = self.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - self.domain = get_domain(self.apiclient, self.services) - self.zone = get_zone(self.apiclient, self.services) + self.domain = get_domain(self.apiclient) + self.zone = get_zone(self.apiclient, self.getZoneForTests()) template = get_template( self.apiclient, self.zone.id, @@ -828,11 +834,11 @@ class TestDeleteAccount(cloudstackTestCase): def setUp(self): self.apiclient = self.testClient.getApiClient() - self.services = self.testClient.getConfigParser().parsedDict + self.services = self.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - self.domain = get_domain(self.apiclient, self.services) - self.zone = get_zone(self.apiclient, self.services) + self.domain = get_domain(self.apiclient) + self.zone = get_zone(self.apiclient, self.getZoneForTests()) template = get_template( self.apiclient, self.zone.id, diff --git a/test/integration/smoke/test_network_acl.py b/test/integration/smoke/test_network_acl.py index 9e8df15e068..ce6d78b60ff 100644 --- a/test/integration/smoke/test_network_acl.py +++ b/test/integration/smoke/test_network_acl.py @@ -28,11 +28,11 @@ class TestNetworkACL(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestNetworkACL, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestNetworkACL, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() - cls.zone = get_zone(cls.apiclient, cls.services) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) cls.domain = get_domain(cls.apiclient) cls.service_offering = ServiceOffering.create( cls.apiclient, @@ -44,6 +44,10 @@ class TestNetworkACL(cloudstackTestCase): cls.zone.id, cls.services["ostype"] ) + + if cls.template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + cls.debug("Successfully created account: %s, id: \ %s" % (cls.account.name,\ cls.account.id)) diff --git a/test/integration/smoke/test_nic.py b/test/integration/smoke/test_nic.py index 0f87de1a8ef..668e91f0384 100644 --- a/test/integration/smoke/test_nic.py +++ b/test/integration/smoke/test_nic.py @@ -16,6 +16,7 @@ # under the License. """ NIC tests for VM """ import marvin +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * from marvin.sshClient import SshClient @@ -44,11 +45,11 @@ class TestNic(cloudstackTestCase): try: self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() - self.services = self.testClient.getConfigParser().parsedDict + self.services = self.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - domain = get_domain(self.apiclient, self.services) - zone = get_zone(self.apiclient, self.services) + domain = get_domain(self.apiclient) + zone = get_zone(self.apiclient, self.getZoneForTests()) self.services['mode'] = zone.networktype if zone.networktype != 'Advanced': @@ -64,7 +65,10 @@ class TestNic(cloudstackTestCase): zone.id, self.services["ostype"] ) - # Set Zones and disk offerings + if self.template == FAILED: + self.fail("get_template() failed to return template with description %s" % self.services["ostype"]) + + # Set Zones and disk offerings self.services["small"]["zoneid"] = zone.id self.services["small"]["template"] = template.id diff --git a/test/integration/smoke/test_non_contigiousvlan.py b/test/integration/smoke/test_non_contigiousvlan.py index f1736ae4476..efa4825e39f 100644 --- a/test/integration/smoke/test_non_contigiousvlan.py +++ b/test/integration/smoke/test_non_contigiousvlan.py @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. +from marvin.cloudstackTestClient import getZoneForTests from marvin import cloudstackTestCase from marvin.cloudstackAPI import * from marvin.cloudstackTestCase import cloudstackTestCase diff --git a/test/integration/smoke/test_portable_publicip.py b/test/integration/smoke/test_portable_publicip.py index 7eda7da62c1..d75ae09aeb4 100644 --- a/test/integration/smoke/test_portable_publicip.py +++ b/test/integration/smoke/test_portable_publicip.py @@ -16,6 +16,7 @@ # specific language governing permissions and limitations # under the License. +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * from marvin.integration.lib.utils import * @@ -33,17 +34,17 @@ class TestPortablePublicIPRange(cloudstackTestCase): """ @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestPortablePublicIPRange, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestPortablePublicIPRange, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain - cls.domain = get_domain(cls.api_client, cls.services) - cls.zone = get_zone(cls.api_client, cls.services) + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) # Create Account cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], domainid=cls.domain.id ) @@ -56,7 +57,7 @@ class TestPortablePublicIPRange(cloudstackTestCase): def tearDownClass(cls): try: # Cleanup resources used - cleanup_resources(cls.api_client, cls._cleanup) + cleanup_resources(cls.apiclient, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return @@ -81,7 +82,7 @@ class TestPortablePublicIPRange(cloudstackTestCase): """ self.debug("attempting to create a portable Public IP range") self.portable_ip_range = PortablePublicIpRange.create( - self.api_client, + self.apiclient, self.services ) self.debug("attempting to verify portable Public IP range is created") @@ -101,31 +102,31 @@ class TestPortablePublicIPAcquire(cloudstackTestCase): """ @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestPortablePublicIPAcquire, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestPortablePublicIPAcquire, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain - cls.domain = get_domain(cls.api_client, cls.services) - cls.zone = get_zone(cls.api_client, cls.services) + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) # Create Account cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], domainid=cls.domain.id ) cls.services["network"]["zoneid"] = cls.zone.id cls.network_offering = NetworkOffering.create( - cls.api_client, + cls.apiclient, cls.services["network_offering"], ) # Enable Network offering - cls.network_offering.update(cls.api_client, state='Enabled') + cls.network_offering.update(cls.apiclient, state='Enabled') cls.services["network"]["networkoffering"] = cls.network_offering.id cls.account_network = Network.create( - cls.api_client, + cls.apiclient, cls.services["network"], cls.account.name, cls.account.domainid @@ -142,7 +143,7 @@ class TestPortablePublicIPAcquire(cloudstackTestCase): def tearDownClass(cls): try: # Cleanup resources used - cleanup_resources(cls.api_client, cls._cleanup) + cleanup_resources(cls.apiclient, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return @@ -167,13 +168,13 @@ class TestPortablePublicIPAcquire(cloudstackTestCase): """ self.debug("attempting to create a portable Public IP range") self.portable_ip_range = PortablePublicIpRange.create( - self.api_client, + self.apiclient, self.services ) - ip_address = PublicIPAddress.create(self.api_client, self.account.name, + ip_address = PublicIPAddress.create(self.apiclient, self.account.name, self.zone.id, self.account.domainid, isportable=True) - ip_address.delete(self.api_client) + ip_address.delete(self.apiclient) self.portable_ip_range.delete(self.apiclient) return diff --git a/test/integration/smoke/test_primary_storage.py b/test/integration/smoke/test_primary_storage.py index a142a272268..e06d90e24a5 100644 --- a/test/integration/smoke/test_primary_storage.py +++ b/test/integration/smoke/test_primary_storage.py @@ -18,6 +18,7 @@ """ #Import Local Modules import marvin +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * from marvin.integration.lib.utils import * @@ -34,10 +35,10 @@ class TestPrimaryStorageServices(cloudstackTestCase): def setUp(self): self.apiclient = self.testClient.getApiClient() - self.services = self.testClient.getConfigParser().parsedDict + self.services = self.testClient.getParsedTestDataConfig() self.cleanup = [] # Get Zone and pod - self.zone = get_zone(self.apiclient, self.services) + self.zone = get_zone(self.apiclient, self.getZoneForTests()) self.pod = get_pod(self.apiclient, self.zone.id) return diff --git a/test/integration/smoke/test_public_ip_range.py b/test/integration/smoke/test_public_ip_range.py index f2cb2df7df4..5e51de339d5 100644 --- a/test/integration/smoke/test_public_ip_range.py +++ b/test/integration/smoke/test_public_ip_range.py @@ -17,6 +17,7 @@ """ P1 tests for Dedicating Public IP addresses """ #Import Local Modules +from marvin.cloudstackTestClient import getZoneForTests import marvin from nose.plugins.attrib import attr from marvin.cloudstackTestCase import * @@ -30,15 +31,15 @@ class TestDedicatePublicIPRange(cloudstackTestCase): @classmethod def setUpClass(cls): - cls.api_client = super(TestDedicatePublicIPRange, cls).getClsTestClient().getApiClient() + cls.apiclient = super(TestDedicatePublicIPRange, cls).getClsTestClient().getApiClient() cls.services = Services().services # Get Zone, Domain - cls.domain = get_domain(cls.api_client, cls.services) - cls.zone = get_zone(cls.api_client, cls.services) + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) # Create Account cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], domainid=cls.domain.id ) @@ -51,7 +52,7 @@ class TestDedicatePublicIPRange(cloudstackTestCase): def tearDownClass(cls): try: # Cleanup resources used - cleanup_resources(cls.api_client, cls._cleanup) + cleanup_resources(cls.apiclient, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return @@ -86,7 +87,7 @@ class TestDedicatePublicIPRange(cloudstackTestCase): self.debug("Creating Public IP range") self.public_ip_range = PublicIpRange.create( - self.api_client, + self.apiclient, self.services ) list_public_ip_range_response = PublicIpRange.list( diff --git a/test/integration/smoke/test_regions.py b/test/integration/smoke/test_regions.py index 288c3e6fe5b..fec96f08f86 100644 --- a/test/integration/smoke/test_regions.py +++ b/test/integration/smoke/test_regions.py @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * from marvin.integration.lib.utils import * @@ -28,22 +29,22 @@ class TestRegions(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestRegions, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestRegions, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() - cls.domain = get_domain(cls.api_client, cls.services) + cls.domain = get_domain(cls.apiclient) cls.cleanup = [] @attr(tags=["simulator", "basic", "advanced"]) def test_createRegion(self): """ Test for create region """ - region = Region.create(self.api_client, + region = Region.create(self.apiclient, self.services["region"] ) - list_region = Region.list(self.api_client, + list_region = Region.list(self.apiclient, id=self.services["region"]["regionid"] ) @@ -77,8 +78,8 @@ class TestRegions(cloudstackTestCase): def tearDownClass(cls): try: #Clean up - cleanup_resources(cls.api_client, cls.cleanup) - list_region = Region.list(cls.api_client, id=cls.services["region"]["regionid"]) + cleanup_resources(cls.apiclient, cls.cleanup) + list_region = Region.list(cls.apiclient, id=cls.services["region"]["regionid"]) assert list_region is None, "Region deletion fails" except Exception as e: raise Exception("Warning: Region cleanup/delete fails with : %s" % e) diff --git a/test/integration/smoke/test_reset_vm_on_reboot.py b/test/integration/smoke/test_reset_vm_on_reboot.py index 61e51785ec2..f5ba0b82924 100644 --- a/test/integration/smoke/test_reset_vm_on_reboot.py +++ b/test/integration/smoke/test_reset_vm_on_reboot.py @@ -18,6 +18,7 @@ """ #Import Local Modules import marvin +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * from marvin.integration.lib.utils import * @@ -30,40 +31,43 @@ _multiprocess_shared_ = True class TestResetVmOnReboot(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestResetVmOnReboot, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestResetVmOnReboot, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - domain = get_domain(cls.api_client, cls.services) - zone = get_zone(cls.api_client, cls.services) + domain = get_domain(cls.apiclient) + zone = get_zone(cls.apiclient, cls.getZoneForTests()) cls.services['mode'] = zone.networktype template = get_template( - cls.api_client, + cls.apiclient, zone.id, cls.services["ostype"] ) + if template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + # Set Zones and disk offerings ?? cls.services["small"]["zoneid"] = zone.id cls.services["small"]["template"] = template.id # Create account, service offerings, vm. cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], domainid=domain.id ) cls.small_offering = ServiceOffering.create( - cls.api_client, + cls.apiclient, cls.services["service_offerings"]["small"], isvolatile="true" ) #create a virtual machine cls.virtual_machine = VirtualMachine.create( - cls.api_client, + cls.apiclient, cls.services["small"], accountid=cls.account.name, domainid=cls.account.domainid, @@ -77,8 +81,8 @@ class TestResetVmOnReboot(cloudstackTestCase): @classmethod def tearDownClass(cls): - cls.api_client = super(TestResetVmOnReboot, cls).getClsTestClient().getApiClient() - cleanup_resources(cls.api_client, cls._cleanup) + cls.apiclient = super(TestResetVmOnReboot, cls).getClsTestClient().getApiClient() + cleanup_resources(cls.apiclient, cls._cleanup) return def setUp(self): diff --git a/test/integration/smoke/test_resource_detail.py b/test/integration/smoke/test_resource_detail.py index 054ee429270..1ec571e723d 100644 --- a/test/integration/smoke/test_resource_detail.py +++ b/test/integration/smoke/test_resource_detail.py @@ -18,6 +18,7 @@ """ #Import Local Modules import marvin +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * from marvin.sshClient import SshClient @@ -34,33 +35,33 @@ class TestResourceDetail(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestResourceDetail, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestResourceDetail, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - domain = get_domain(cls.api_client, cls.services) - zone = get_zone(cls.api_client, cls.services) + domain = get_domain(cls.apiclient) + zone = get_zone(cls.apiclient, cls.getZoneForTests()) cls.services['mode'] = zone.networktype # Set Zones and disk offerings ?? # Create account, service offerings, vm. cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], domainid=domain.id ) cls.disk_offering = DiskOffering.create( - cls.api_client, + cls.apiclient, cls.services["disk_offering"] ) #create a volume cls.volume = Volume.create( - cls.api_client, + cls.apiclient, { "diskname" : "ndm"}, zoneid=zone.id, account=cls.account.name, @@ -75,8 +76,8 @@ class TestResourceDetail(cloudstackTestCase): @classmethod def tearDownClass(cls): - cls.api_client = super(TestResourceDetail, cls).getClsTestClient().getApiClient() - cleanup_resources(cls.api_client, cls._cleanup) + cls.apiclient = super(TestResourceDetail, cls).getClsTestClient().getApiClient() + cleanup_resources(cls.apiclient, cls._cleanup) return def setUp(self): @@ -108,7 +109,7 @@ class TestResourceDetail(cloudstackTestCase): listResourceDetailCmd = listResourceDetails.listResourceDetailsCmd() listResourceDetailCmd.resourceid = self.volume.id listResourceDetailCmd.resourcetype = "Volume" - listResourceDetailResponse = self.api_client.listResourceDetails(listResourceDetailCmd) + listResourceDetailResponse = self.apiclient.listResourceDetails(listResourceDetailCmd) self.assertEqual(listResourceDetailResponse, None, "Check if the list API \ returns an empty response") diff --git a/test/integration/smoke/test_routers.py b/test/integration/smoke/test_routers.py index 3f1ea92924b..d200bf61d61 100644 --- a/test/integration/smoke/test_routers.py +++ b/test/integration/smoke/test_routers.py @@ -18,6 +18,7 @@ """ #Import Local Modules import marvin +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * from marvin.sshClient import SshClient @@ -36,33 +37,36 @@ class TestRouterServices(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestRouterServices, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestRouterServices, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - cls.domain = get_domain(cls.api_client, cls.services) - cls.zone = get_zone(cls.api_client, cls.services) + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) cls.services['mode'] = cls.zone.networktype template = get_template( - cls.api_client, + cls.apiclient, cls.zone.id, cls.services["ostype"] ) + if template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + cls.services["virtual_machine"]["zoneid"] = cls.zone.id #Create an account, network, VM and IP addresses cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], domainid=cls.domain.id ) cls.service_offering = ServiceOffering.create( - cls.api_client, + cls.apiclient, cls.services["service_offerings"] ) cls.vm_1 = VirtualMachine.create( - cls.api_client, + cls.apiclient, cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.name, @@ -78,12 +82,12 @@ class TestRouterServices(cloudstackTestCase): @classmethod def tearDownClass(cls): try: - cls.api_client = super( + cls.apiclient = super( TestRouterServices, cls ).getClsTestClient().getApiClient() #Clean up, terminate the created templates - cleanup_resources(cls.api_client, cls.cleanup) + cleanup_resources(cls.apiclient, cls.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) diff --git a/test/integration/smoke/test_scale_vm.py b/test/integration/smoke/test_scale_vm.py index d7138bff867..cc1c83cbd1f 100644 --- a/test/integration/smoke/test_scale_vm.py +++ b/test/integration/smoke/test_scale_vm.py @@ -18,6 +18,7 @@ """ #Import Local Modules import marvin +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * from marvin.integration.lib.utils import * @@ -30,44 +31,47 @@ _multiprocess_shared_ = True class TestScaleVm(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestScaleVm, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestScaleVm, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - domain = get_domain(cls.api_client, cls.services) - zone = get_zone(cls.api_client, cls.services) + domain = get_domain(cls.apiclient) + zone = get_zone(cls.apiclient, cls.getZoneForTests()) cls.services['mode'] = zone.networktype template = get_template( - cls.api_client, + cls.apiclient, zone.id, cls.services["ostype"] ) + if template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + # Set Zones and disk offerings ?? cls.services["small"]["zoneid"] = zone.id cls.services["small"]["template"] = template.id # Create account, service offerings, vm. cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], domainid=domain.id ) cls.small_offering = ServiceOffering.create( - cls.api_client, + cls.apiclient, cls.services["service_offerings"]["small"] ) cls.big_offering = ServiceOffering.create( - cls.api_client, + cls.apiclient, cls.services["service_offerings"]["big"] ) #create a virtual machine cls.virtual_machine = VirtualMachine.create( - cls.api_client, + cls.apiclient, cls.services["small"], accountid=cls.account.name, domainid=cls.account.domainid, @@ -81,8 +85,8 @@ class TestScaleVm(cloudstackTestCase): @classmethod def tearDownClass(cls): - cls.api_client = super(TestScaleVm, cls).getClsTestClient().getApiClient() - cleanup_resources(cls.api_client, cls._cleanup) + cls.apiclient = super(TestScaleVm, cls).getClsTestClient().getApiClient() + cleanup_resources(cls.apiclient, cls._cleanup) return def setUp(self): diff --git a/test/integration/smoke/test_secondary_storage.py b/test/integration/smoke/test_secondary_storage.py index ff9692f9c87..423f858a7e7 100644 --- a/test/integration/smoke/test_secondary_storage.py +++ b/test/integration/smoke/test_secondary_storage.py @@ -33,7 +33,7 @@ class TestSecStorageServices(cloudstackTestCase): @classmethod def setUpClass(cls): - cls.api_client = super(TestSecStorageServices, cls).getClsTestClient().getApiClient() + cls.apiclient = super(TestSecStorageServices, cls).getClsTestClient().getApiClient() cls._cleanup = [] return @@ -41,7 +41,7 @@ class TestSecStorageServices(cloudstackTestCase): def tearDownClass(cls): try: #Cleanup resources used - cleanup_resources(cls.api_client, cls._cleanup) + cleanup_resources(cls.apiclient, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return diff --git a/test/integration/smoke/test_service_offerings.py b/test/integration/smoke/test_service_offerings.py index 095bbfd2399..be14d156ff3 100644 --- a/test/integration/smoke/test_service_offerings.py +++ b/test/integration/smoke/test_service_offerings.py @@ -17,6 +17,7 @@ """ BVT tests for Service offerings""" #Import Local Modules +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import cloudstackTestCase from marvin.cloudstackAPI import changeServiceForVirtualMachine,updateServiceOffering from marvin.integration.lib.utils import (isAlmostEqual, @@ -41,7 +42,7 @@ class TestCreateServiceOffering(cloudstackTestCase): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() self.cleanup = [] - self.services = self.testClient.getConfigParser().parsedDict + self.services = self.testClient.getParsedTestDataConfig() def tearDown(self): try: @@ -132,27 +133,30 @@ class TestServiceOfferings(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestServiceOfferings, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestServiceOfferings, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() - domain = get_domain(cls.api_client, cls.services) - cls.zone = get_zone(cls.api_client, cls.services) + domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.service_offering_1 = ServiceOffering.create( - cls.api_client, + cls.apiclient, cls.services["service_offerings"] ) cls.service_offering_2 = ServiceOffering.create( - cls.api_client, + cls.apiclient, cls.services["service_offerings"] ) template = get_template( - cls.api_client, + cls.apiclient, cls.zone.id, cls.services["ostype"] ) + if template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + # Set Zones and disk offerings cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = template.id @@ -162,22 +166,22 @@ class TestServiceOfferings(cloudstackTestCase): # Create VMs, NAT Rules etc cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], domainid=domain.id ) cls.small_offering = ServiceOffering.create( - cls.api_client, + cls.apiclient, cls.services["service_offerings"]["small"] ) cls.medium_offering = ServiceOffering.create( - cls.api_client, + cls.apiclient, cls.services["service_offerings"]["medium"] ) cls.medium_virtual_machine = VirtualMachine.create( - cls.api_client, + cls.apiclient, cls.services["medium"], accountid=cls.account.name, domainid=cls.account.domainid, @@ -194,9 +198,9 @@ class TestServiceOfferings(cloudstackTestCase): @classmethod def tearDownClass(cls): try: - cls.api_client = super(TestServiceOfferings, cls).getClsTestClient().getApiClient() + cls.apiclient = super(TestServiceOfferings, cls).getClsTestClient().getApiClient() #Clean up, terminate the created templates - cleanup_resources(cls.api_client, cls._cleanup) + cleanup_resources(cls.apiclient, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) diff --git a/test/integration/smoke/test_snapshots.py b/test/integration/smoke/test_snapshots.py index 1d711dbfada..f4dbc83524e 100644 --- a/test/integration/smoke/test_snapshots.py +++ b/test/integration/smoke/test_snapshots.py @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. +from marvin.cloudstackTestClient import getZoneForTests from nose.plugins.attrib import attr from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * @@ -26,20 +27,23 @@ class TestSnapshotRootDisk(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestSnapshotRootDisk, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestSnapshotRootDisk, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - cls.domain = get_domain(cls.api_client, cls.services) - cls.zone = get_zone(cls.api_client, cls.services) + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) cls.services['mode'] = cls.zone.networktype template = get_template( - cls.api_client, + cls.apiclient, cls.zone.id, cls.services["ostype"] ) + if template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + cls.services["domainid"] = cls.domain.id cls.services["server_without_disk"]["zoneid"] = cls.zone.id cls.services["templates"]["ostypeid"] = template.ostypeid @@ -47,7 +51,7 @@ class TestSnapshotRootDisk(cloudstackTestCase): # Create VMs, NAT Rules etc cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], domainid=cls.domain.id ) @@ -55,12 +59,12 @@ class TestSnapshotRootDisk(cloudstackTestCase): cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( - cls.api_client, + cls.apiclient, cls.services["service_offerings"] ) cls.virtual_machine = cls.virtual_machine_with_disk = \ VirtualMachine.create( - cls.api_client, + cls.apiclient, cls.services["server_without_disk"], templateid=template.id, accountid=cls.account.name, @@ -78,7 +82,7 @@ class TestSnapshotRootDisk(cloudstackTestCase): def tearDownClass(cls): try: #Cleanup resources used - cleanup_resources(cls.api_client, cls._cleanup) + cleanup_resources(cls.apiclient, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return diff --git a/test/integration/smoke/test_ssvm.py b/test/integration/smoke/test_ssvm.py index c056746e145..b94e7092b01 100644 --- a/test/integration/smoke/test_ssvm.py +++ b/test/integration/smoke/test_ssvm.py @@ -19,6 +19,7 @@ #Import Local Modules import marvin from marvin.cloudstackTestCase import * +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackAPI import * from marvin.sshClient import SshClient from marvin.integration.lib.utils import * @@ -38,7 +39,7 @@ class TestSSVMs(cloudstackTestCase): self.apiclient = self.testClient.getApiClient() self.cleanup = [] self.services = Services().services - self.zone = get_zone(self.apiclient, self.services) + self.zone = get_zone(self.apiclient, self.getZoneForTests()) return def tearDown(self): diff --git a/test/integration/smoke/test_templates.py b/test/integration/smoke/test_templates.py index 65b4f35fc67..b9e32a1fe14 100644 --- a/test/integration/smoke/test_templates.py +++ b/test/integration/smoke/test_templates.py @@ -18,6 +18,7 @@ """ #Import Local Modules import marvin +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * from marvin.sshClient import SshClient @@ -53,23 +54,26 @@ class TestCreateTemplate(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestCreateTemplate, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestCreateTemplate, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - cls.domain = get_domain(cls.api_client, cls.services) - cls.zone = get_zone(cls.api_client, cls.services) + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.disk_offering = DiskOffering.create( - cls.api_client, + cls.apiclient, cls.services["disk_offering"] ) template = get_template( - cls.api_client, + cls.apiclient, cls.zone.id, cls.services["ostype"] ) + if template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + cls.services["template"]["ostypeid"] = template.ostypeid cls.services["template_2"]["ostypeid"] = template.ostypeid cls.services["ostypeid"] = template.ostypeid @@ -80,19 +84,19 @@ class TestCreateTemplate(cloudstackTestCase): cls.services["sourcezoneid"] = cls.zone.id cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], domainid=cls.domain.id ) cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( - cls.api_client, + cls.apiclient, cls.services["service_offerings"] ) #create virtual machine cls.virtual_machine = VirtualMachine.create( - cls.api_client, + cls.apiclient, cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.name, @@ -102,7 +106,7 @@ class TestCreateTemplate(cloudstackTestCase): ) #Stop virtual machine - cls.virtual_machine.stop(cls.api_client) + cls.virtual_machine.stop(cls.apiclient) # Poll listVM to ensure VM is stopped properly timeout = cls.services["timeout"] @@ -111,7 +115,7 @@ class TestCreateTemplate(cloudstackTestCase): # Ensure that VM is in stopped state list_vm_response = list_virtual_machines( - cls.api_client, + cls.apiclient, id=cls.virtual_machine.id ) @@ -129,7 +133,7 @@ class TestCreateTemplate(cloudstackTestCase): timeout = timeout - 1 list_volume = list_volumes( - cls.api_client, + cls.apiclient, virtualmachineid=cls.virtual_machine.id, type='ROOT', listall=True @@ -146,9 +150,9 @@ class TestCreateTemplate(cloudstackTestCase): @classmethod def tearDownClass(cls): try: - cls.api_client = super(TestCreateTemplate, cls).getClsTestClient().getApiClient() + cls.apiclient = super(TestCreateTemplate, cls).getClsTestClient().getApiClient() #Cleanup resources used - cleanup_resources(cls.api_client, cls._cleanup) + cleanup_resources(cls.apiclient, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) @@ -222,29 +226,32 @@ class TestTemplates(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestTemplates, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestTemplates, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - cls.domain = get_domain(cls.api_client, cls.services) - cls.zone = get_zone(cls.api_client, cls.services) + cls.domain = get_domain(cls.apiclient, cls.getZoneForTests()) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) cls.services['mode'] = cls.zone.networktype #populate second zone id for iso copy cmd = listZones.listZonesCmd() - cls.zones = cls.api_client.listZones(cmd) + cls.zones = cls.apiclient.listZones(cmd) if not isinstance(cls.zones, list): raise Exception("Failed to find zones.") cls.disk_offering = DiskOffering.create( - cls.api_client, + cls.apiclient, cls.services["disk_offering"] ) template = get_template( - cls.api_client, + cls.apiclient, cls.zone.id, cls.services["ostype"] ) + if template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["volume"]["diskoffering"] = cls.disk_offering.id cls.services["volume"]["zoneid"] = cls.zone.id @@ -256,14 +263,14 @@ class TestTemplates(cloudstackTestCase): cls.services["ostypeid"] = template.ostypeid cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], admin=True, domainid=cls.domain.id ) cls.user = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], domainid=cls.domain.id ) @@ -271,12 +278,12 @@ class TestTemplates(cloudstackTestCase): cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( - cls.api_client, + cls.apiclient, cls.services["service_offerings"] ) #create virtual machine cls.virtual_machine = VirtualMachine.create( - cls.api_client, + cls.apiclient, cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.name, @@ -285,7 +292,7 @@ class TestTemplates(cloudstackTestCase): mode=cls.services["mode"] ) #Stop virtual machine - cls.virtual_machine.stop(cls.api_client) + cls.virtual_machine.stop(cls.apiclient) # Poll listVM to ensure VM is stopped properly timeout = cls.services["timeout"] @@ -294,7 +301,7 @@ class TestTemplates(cloudstackTestCase): # Ensure that VM is in stopped state list_vm_response = list_virtual_machines( - cls.api_client, + cls.apiclient, id=cls.virtual_machine.id ) @@ -312,7 +319,7 @@ class TestTemplates(cloudstackTestCase): timeout = timeout - 1 list_volume = list_volumes( - cls.api_client, + cls.apiclient, virtualmachineid=cls.virtual_machine.id, type='ROOT', listall=True @@ -326,14 +333,14 @@ class TestTemplates(cloudstackTestCase): #Create templates for Edit, Delete & update permissions testcases cls.template_1 = Template.create( - cls.api_client, + cls.apiclient, cls.services["template"], cls.volume.id, account=cls.account.name, domainid=cls.account.domainid ) cls.template_2 = Template.create( - cls.api_client, + cls.apiclient, cls.services["template_2"], cls.volume.id, account=cls.account.name, @@ -349,9 +356,9 @@ class TestTemplates(cloudstackTestCase): @classmethod def tearDownClass(cls): try: - cls.api_client = super(TestTemplates, cls).getClsTestClient().getApiClient() + cls.apiclient = super(TestTemplates, cls).getClsTestClient().getApiClient() #Cleanup created resources such as templates and VMs - cleanup_resources(cls.api_client, cls._cleanup) + cleanup_resources(cls.apiclient, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) diff --git a/test/integration/smoke/test_vm_life_cycle.py b/test/integration/smoke/test_vm_life_cycle.py index 9afcba528e6..049467254b5 100644 --- a/test/integration/smoke/test_vm_life_cycle.py +++ b/test/integration/smoke/test_vm_life_cycle.py @@ -18,6 +18,7 @@ """ #Import Local Modules import marvin +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * from marvin.integration.lib.utils import * @@ -33,13 +34,13 @@ class TestDeployVM(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestDeployVM, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestDeployVM, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - domain = get_domain(cls.apiclient, cls.services) - cls.zone = get_zone(cls.apiclient, cls.services) + domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) cls.services['mode'] = cls.zone.networktype #If local storage is enabled, alter the offerings to use localstorage @@ -54,6 +55,9 @@ class TestDeployVM(cloudstackTestCase): cls.zone.id, cls.services["ostype"] ) + if template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + # Set Zones and disk offerings cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = template.id @@ -191,13 +195,13 @@ class TestVMLifeCycle(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestVMLifeCycle, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestVMLifeCycle, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - domain = get_domain(cls.api_client, cls.services) - cls.zone = get_zone(cls.api_client, cls.services) + domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) cls.services['mode'] = cls.zone.networktype #if local storage is enabled, alter the offerings to use localstorage @@ -208,10 +212,13 @@ class TestVMLifeCycle(cloudstackTestCase): cls.services["service_offerings"]["medium"]["storagetype"] = 'local' template = get_template( - cls.api_client, + cls.apiclient, cls.zone.id, cls.services["ostype"] ) + if template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + # Set Zones and disk offerings cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = template.id @@ -222,23 +229,23 @@ class TestVMLifeCycle(cloudstackTestCase): # Create VMs, NAT Rules etc cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], domainid=domain.id ) cls.small_offering = ServiceOffering.create( - cls.api_client, + cls.apiclient, cls.services["service_offerings"]["small"] ) cls.medium_offering = ServiceOffering.create( - cls.api_client, + cls.apiclient, cls.services["service_offerings"]["medium"] ) #create small and large virtual machines cls.small_virtual_machine = VirtualMachine.create( - cls.api_client, + cls.apiclient, cls.services["small"], accountid=cls.account.name, domainid=cls.account.domainid, @@ -246,7 +253,7 @@ class TestVMLifeCycle(cloudstackTestCase): mode=cls.services["mode"] ) cls.medium_virtual_machine = VirtualMachine.create( - cls.api_client, + cls.apiclient, cls.services["medium"], accountid=cls.account.name, domainid=cls.account.domainid, @@ -254,7 +261,7 @@ class TestVMLifeCycle(cloudstackTestCase): mode=cls.services["mode"] ) cls.virtual_machine = VirtualMachine.create( - cls.api_client, + cls.apiclient, cls.services["small"], accountid=cls.account.name, domainid=cls.account.domainid, @@ -269,8 +276,8 @@ class TestVMLifeCycle(cloudstackTestCase): @classmethod def tearDownClass(cls): - cls.api_client = super(TestVMLifeCycle, cls).getClsTestClient().getApiClient() - cleanup_resources(cls.api_client, cls._cleanup) + cls.apiclient = super(TestVMLifeCycle, cls).getClsTestClient().getApiClient() + cleanup_resources(cls.apiclient, cls._cleanup) return def setUp(self): @@ -510,7 +517,7 @@ class TestVMLifeCycle(cloudstackTestCase): #deploy VM on target host self.vm_to_migrate = VirtualMachine.create( - self.api_client, + self.apiclient, self.services["small"], accountid=self.account.name, domainid=self.account.domainid, @@ -523,7 +530,7 @@ class TestVMLifeCycle(cloudstackTestCase): migrate_host.id )) - self.vm_to_migrate.migrate(self.api_client, migrate_host.id) + self.vm_to_migrate.migrate(self.apiclient, migrate_host.id) list_vm_response = list_virtual_machines( self.apiclient, diff --git a/test/integration/smoke/test_vm_snapshots.py b/test/integration/smoke/test_vm_snapshots.py index 7fc0b8fae5a..617274c163b 100644 --- a/test/integration/smoke/test_vm_snapshots.py +++ b/test/integration/smoke/test_vm_snapshots.py @@ -17,6 +17,7 @@ # Import Local Modules import marvin +from marvin.cloudstackTestClient import getZoneForTests from nose.plugins.attrib import attr from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * @@ -28,17 +29,20 @@ class TestVmSnapshot(cloudstackTestCase): @classmethod def setUpClass(cls): - cls.api_client = super(TestVmSnapshot, cls).getClsTestClient().getApiClient() + cls.apiclient = super(TestVmSnapshot, cls).getClsTestClient().getApiClient() cls.services = Services().services # Get Zone, Domain and templates - cls.domain = get_domain(cls.api_client, cls.services) - cls.zone = get_zone(cls.api_client, cls.services) + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) template = get_template( - cls.api_client, + cls.apiclient, cls.zone.id, cls.services["ostype"] ) + if cls.template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + cls.services["domainid"] = cls.domain.id cls.services["server"]["zoneid"] = cls.zone.id cls.services["templates"]["ostypeid"] = template.ostypeid @@ -46,7 +50,7 @@ class TestVmSnapshot(cloudstackTestCase): # Create VMs, NAT Rules etc cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], domainid=cls.domain.id ) @@ -54,11 +58,11 @@ class TestVmSnapshot(cloudstackTestCase): cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( - cls.api_client, + cls.apiclient, cls.services["service_offerings"] ) cls.virtual_machine = VirtualMachine.create( - cls.api_client, + cls.apiclient, cls.services["server"], templateid=template.id, accountid=cls.account.name, @@ -79,7 +83,7 @@ class TestVmSnapshot(cloudstackTestCase): def tearDownClass(cls): try: # Cleanup resources used - cleanup_resources(cls.api_client, cls._cleanup) + cleanup_resources(cls.apiclient, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return diff --git a/test/integration/smoke/test_volumes.py b/test/integration/smoke/test_volumes.py index 7dee14ce474..860d9899f4f 100644 --- a/test/integration/smoke/test_volumes.py +++ b/test/integration/smoke/test_volumes.py @@ -18,6 +18,7 @@ """ #Import Local Modules import marvin +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import * from marvin.cloudstackException import * from marvin.cloudstackAPI import * @@ -38,28 +39,31 @@ class TestCreateVolume(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestCreateVolume, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestCreateVolume, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - cls.domain = get_domain(cls.api_client, cls.services) - cls.zone = get_zone(cls.api_client, cls.services) + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.disk_offering = DiskOffering.create( - cls.api_client, + cls.apiclient, cls.services["disk_offering"] ) cls.custom_disk_offering = DiskOffering.create( - cls.api_client, + cls.apiclient, cls.services["disk_offering"], custom=True ) template = get_template( - cls.api_client, + cls.apiclient, cls.zone.id, cls.services["ostype"] ) + if template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + cls.services["domainid"] = cls.domain.id cls.services["zoneid"] = cls.zone.id cls.services["template"] = template.id @@ -67,18 +71,18 @@ class TestCreateVolume(cloudstackTestCase): # Create VMs, NAT Rules etc cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], domainid=cls.domain.id ) cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( - cls.api_client, + cls.apiclient, cls.services["service_offerings"] ) cls.virtual_machine = VirtualMachine.create( - cls.api_client, + cls.apiclient, cls.services, accountid=cls.account.name, domainid=cls.account.domainid, @@ -218,8 +222,8 @@ class TestCreateVolume(cloudstackTestCase): @classmethod def tearDownClass(cls): try: - cls.api_client = super(TestCreateVolume, cls).getClsTestClient().getApiClient() - cleanup_resources(cls.api_client, cls._cleanup) + cls.apiclient = super(TestCreateVolume, cls).getClsTestClient().getApiClient() + cleanup_resources(cls.apiclient, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) @@ -228,33 +232,36 @@ class TestVolumes(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestVolumes, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestVolumes, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - cls.domain = get_domain(cls.api_client, cls.services) - cls.zone = get_zone(cls.api_client, cls.services) + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.disk_offering = DiskOffering.create( - cls.api_client, + cls.apiclient, cls.services["disk_offering"] ) cls.resized_disk_offering = DiskOffering.create( - cls.api_client, + cls.apiclient, cls.services["resized_disk_offering"] ) cls.custom_resized_disk_offering = DiskOffering.create( - cls.api_client, + cls.apiclient, cls.services["resized_disk_offering"], custom=True ) template = get_template( - cls.api_client, + cls.apiclient, cls.zone.id, cls.services["ostype"] ) + if template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + cls.services["domainid"] = cls.domain.id cls.services["zoneid"] = cls.zone.id cls.services["template"] = template.id @@ -264,18 +271,18 @@ class TestVolumes(cloudstackTestCase): # Create VMs, VMs etc cls.account = Account.create( - cls.api_client, + cls.apiclient, cls.services["account"], domainid=cls.domain.id ) cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( - cls.api_client, + cls.apiclient, cls.services["service_offerings"] ) cls.virtual_machine = VirtualMachine.create( - cls.api_client, + cls.apiclient, cls.services, accountid=cls.account.name, domainid=cls.account.domainid, @@ -284,7 +291,7 @@ class TestVolumes(cloudstackTestCase): ) cls.volume = Volume.create( - cls.api_client, + cls.apiclient, cls.services, account=cls.account.name, domainid=cls.account.domainid @@ -301,7 +308,7 @@ class TestVolumes(cloudstackTestCase): @classmethod def tearDownClass(cls): try: - cleanup_resources(cls.api_client, cls._cleanup) + cleanup_resources(cls.apiclient, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) @@ -649,7 +656,7 @@ class TestVolumes(cloudstackTestCase): self.debug("Delete Volume ID: %s" % self.volume.id) self.volume_1 = Volume.create( - self.api_client, + self.apiclient, self.services, account=self.account.name, domainid=self.account.domainid diff --git a/test/integration/smoke/test_vpc_vpn.py b/test/integration/smoke/test_vpc_vpn.py index d8e66d6104a..a117c6e6d66 100644 --- a/test/integration/smoke/test_vpc_vpn.py +++ b/test/integration/smoke/test_vpc_vpn.py @@ -17,6 +17,7 @@ """ Tests for VPN in VPC """ #Import Local Modules +from marvin.cloudstackTestClient import getZoneForTests from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * from marvin.integration.lib.utils import * @@ -30,11 +31,11 @@ class TestVpcRemoteAccessVpn(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestVpcRemoteAccessVpn, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestVpcRemoteAccessVpn, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() - cls.zone = get_zone(cls.apiclient, cls.services) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) cls.domain = get_domain(cls.apiclient) cls.service_offering = ServiceOffering.create( cls.apiclient, @@ -46,6 +47,9 @@ class TestVpcRemoteAccessVpn(cloudstackTestCase): cls.zone.id, cls.services["ostype"] ) + if cls.template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + cls.cleanup = [cls.account] @attr(tags=["advanced"]) @@ -134,11 +138,11 @@ class TestVpcSite2SiteVpn(cloudstackTestCase): @classmethod def setUpClass(cls): - cloudstackTestClient = super(TestVpcSite2SiteVpn, cls).getClsTestClient() - cls.api_client = cloudstackTestClient.getApiClient() - cls.services = cloudstackTestClient.getConfigParser().parsedDict + testClient = super(TestVpcSite2SiteVpn, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.services = testClient.getParsedTestDataConfig() - cls.zone = get_zone(cls.apiclient, cls.services) + cls.zone = get_zone(cls.apiclient, cls.getZoneForTests()) cls.domain = get_domain(cls.apiclient) cls.service_offering = ServiceOffering.create( cls.apiclient, @@ -150,6 +154,9 @@ class TestVpcSite2SiteVpn(cloudstackTestCase): cls.zone.id, cls.services["ostype"] ) + if cls.template == FAILED: + cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"]) + cls.cleanup = [cls.account] @attr(tags=["advanced"]) diff --git a/tools/marvin/marvin/integration/lib/common.py b/tools/marvin/marvin/integration/lib/common.py index c16339b22ae..e8cdfc11a88 100644 --- a/tools/marvin/marvin/integration/lib/common.py +++ b/tools/marvin/marvin/integration/lib/common.py @@ -214,13 +214,13 @@ def get_zone(apiclient, zone_name=None, zone_id=None): -def get_pod(apiclient, pod_id=None, pod_name=None, zone_id=None): +def get_pod(apiclient, zone_id=None, pod_id=None, pod_name=None): ''' @name : get_pod @Desc : Returns the Pod Information for a given zone id or Zone Name - @Input : pod_name : Name of the Pod + @Input : zone_id: Id of the Zone + pod_name : Name of the Pod pod_id : Id of the Pod - zone_id: Id of the Zone @Output : 1. Pod Information for the pod 2. FAILED In case the cmd failed ''' @@ -239,9 +239,9 @@ def get_pod(apiclient, pod_id=None, pod_name=None, zone_id=None): return cmd_out -def get_template(apiclient, template_id=None, template_name=None, account=None, template_type='BUILTIN' - domain_id=None, zone_id=None, project_id=None, - hypervisor=None, ostype_desc=None, template_filter="featured"): +def get_template(apiclient, zone_id=None, ostype_desc=None, template_filter="featured", template_type='BUILTIN', + template_id=None, template_name=None, account=None, domain_id=None, project_id=None, + hypervisor=None): ''' @Name : get_template @Desc : Retrieves the template Information based upon inputs provided