diff --git a/tools/testClient/testcase/BVT-tests/test_hosts.py b/tools/testClient/testcase/BVT-tests/test_hosts.py index fdf0f435a12..4c81b87e27f 100644 --- a/tools/testClient/testcase/BVT-tests/test_hosts.py +++ b/tools/testClient/testcase/BVT-tests/test_hosts.py @@ -41,7 +41,7 @@ class Services: "clustertype": 'ExternalManaged', # CloudManaged or ExternalManaged" "username": 'administrator', - "password": 'password', + "password": 'fr3sca', "url": 'http://192.168.100.17/CloudStack-Clogeny-Pune/Pune-1', # Format:http://vCenter Host/Datacenter/Cluster "clustername": 'VMWare Cluster', @@ -57,7 +57,7 @@ class Services: # CloudManaged or ExternalManaged" "url": 'http://192.168.100.210', "username": "root", - "password": "password", + "password": "fr3sca", }, "kvm": { "hypervisor": 'KVM', @@ -66,7 +66,7 @@ class Services: # CloudManaged or ExternalManaged" "url": 'http://192.168.100.212', "username": "root", - "password": "password", + "password": "fr3sca", }, "vmware": { "hypervisor": 'VMware', @@ -75,7 +75,7 @@ class Services: # CloudManaged or ExternalManaged" "url": 'http://192.168.100.203', "username": "administrator", - "password": "password", + "password": "fr3sca", }, }, "zoneid": 2, @@ -93,7 +93,7 @@ class TestHosts(cloudstackTestCase): self.zone = get_zone(self.apiclient, self.services) self.pod = get_pod(self.apiclient, self.zone.id, self.services) self.cleanup = [] - + return def tearDown(self): diff --git a/tools/testClient/testcase/BVT-tests/test_iso.py b/tools/testClient/testcase/BVT-tests/test_iso.py index 7d6c12c19d2..bef711c3e7d 100644 --- a/tools/testClient/testcase/BVT-tests/test_iso.py +++ b/tools/testClient/testcase/BVT-tests/test_iso.py @@ -29,7 +29,7 @@ class Services: "username": "test", # Random characters are appended in create account to # ensure unique username generated each time - "password": "password", + "password": "fr3sca", }, "iso_1": { @@ -66,10 +66,6 @@ class Services: "timeout": 10, "ostypeid": 12, # CentOS 5.3 (64 bit) - "domainid": 1, - "zoneid": 1, - # Optional, if specified the mentioned zone will be - # used for tests "mode": 'advanced' # Networking mode: Basic or Advanced } @@ -82,12 +78,15 @@ class TestCreateIso(cloudstackTestCase): 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.services["domainid"] = self.domain.id self.services["iso_2"]["zoneid"] = self.zone.id self.account = Account.create( self.apiclient, - self.services["account"] + self.services["account"], + domainid=self.domain.id ) self.cleanup = [self.account] @@ -172,7 +171,10 @@ class TestISO(cloudstackTestCase): cls.api_client = fetch_api_client() # Get Zone, Domain and templates + cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) + + cls.services["domainid"] = cls.domain.id cls.services["iso_1"]["zoneid"] = cls.zone.id cls.services["iso_2"]["zoneid"] = cls.zone.id cls.services["sourcezoneid"] = cls.zone.id @@ -181,6 +183,7 @@ class TestISO(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name cls.iso_1 = Iso.create( @@ -259,7 +262,6 @@ class TestISO(cloudstackTestCase): cmd.name = new_name cmd.bootable = self.services["bootable"] cmd.passwordenabled = self.services["passwordenabled"] - cmd.ostypeid = self.services["ostypeid"] self.apiclient.updateIso(cmd) @@ -485,4 +487,4 @@ class TestISO(cloudstackTestCase): cmd.id = iso_response.id cmd.zoneid = self.services["destzoneid"] self.apiclient.deleteIso(cmd) - return \ No newline at end of file + return diff --git a/tools/testClient/testcase/BVT-tests/test_network.py b/tools/testClient/testcase/BVT-tests/test_network.py index 1ad4a9f1504..7a4e70991e6 100644 --- a/tools/testClient/testcase/BVT-tests/test_network.py +++ b/tools/testClient/testcase/BVT-tests/test_network.py @@ -24,9 +24,6 @@ class Services: self.services = { "ostypeid": 12, # Cent OS 5.3 (64 bit) - "zoneid": 1, - # Optional, if specified the mentioned zone will be - # used for tests "mode": 'advanced', # Networking mode: Basic or advanced "lb_switch_wait": 10, @@ -60,7 +57,6 @@ class Services: "username": "root", "password": "password", "hypervisor": 'XenServer', - "domainid": 1, "privateport": 22, "publicport": 22, "ssh_port": 22, @@ -94,18 +90,21 @@ class TestPublicIP(cloudstackTestCase): cls.api_client = fetch_api_client() 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) # Create Accounts & networks cls.account = Account.create( cls.api_client, cls.services["account"], - admin=True + admin=True, + domainid=cls.domain.id ) cls.user = Account.create( cls.api_client, cls.services["account"], + domainid=cls.domain.id ) cls.services["network"]["zoneid"] = cls.zone.id cls.account_network = Network.create( @@ -261,6 +260,7 @@ class TestPortForwarding(cloudstackTestCase): 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) template = get_template( cls.api_client, @@ -271,7 +271,8 @@ class TestPortForwarding(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], - admin=True + admin=True, + domainid=cls.domain.id ) cls.services["server"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( @@ -283,6 +284,7 @@ class TestPortForwarding(cloudstackTestCase): cls.services["server"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) cls._cleanup = [ @@ -537,6 +539,7 @@ class TestLoadBalancingRule(cloudstackTestCase): cls.api_client = fetch_api_client() 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) template = get_template( cls.api_client, @@ -549,7 +552,8 @@ class TestLoadBalancingRule(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], - admin=True + admin=True, + domainid=cls.domain.id ) cls.service_offering = ServiceOffering.create( cls.api_client, @@ -560,6 +564,7 @@ class TestLoadBalancingRule(cloudstackTestCase): cls.services["server"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) cls.vm_2 = VirtualMachine.create( @@ -567,6 +572,7 @@ class TestLoadBalancingRule(cloudstackTestCase): cls.services["server"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) cls.non_src_nat_ip = PublicIPAddress.create( @@ -689,7 +695,12 @@ class TestLoadBalancingRule(cloudstackTestCase): 0, "Check Load Balancer instances Rule in its List" ) - + self.debug("lb_instance_rules Ids: %s, %s" % ( + lb_instance_rules[0].id, + lb_instance_rules[1].id + )) + self.debug("VM ids: %s, %s" % (self.vm_1.id, self.vm_2.id)) + self.assertIn( lb_instance_rules[0].id, [self.vm_1.id, self.vm_2.id], @@ -744,6 +755,7 @@ class TestLoadBalancingRule(cloudstackTestCase): self.fail("%s: SSH failed for VM with IP Address: %s" % (e, src_nat_ip_addr.ipaddress)) + self.debug("Hostnames: %s" % str(hostnames)) self.assertIn( self.vm_1.name, hostnames, @@ -924,7 +936,7 @@ class TestLoadBalancingRule(cloudstackTestCase): ) hostnames.append(ssh_2.execute("hostname")[0]) - + self.debug("Hostnames after adding 2 VMs to LB rule: %s" % str(hostnames)) self.assertIn( self.vm_1.name, hostnames, @@ -952,7 +964,7 @@ class TestLoadBalancingRule(cloudstackTestCase): ) hostnames.append(ssh_1.execute("hostname")[0]) - + self.debug("Hostnames after removing VM2: %s" % str(hostnames)) except Exception as e: self.fail("%s: SSH failed for VM with IP Address: %s" % (e, self.non_src_nat_ip.ipaddress.ipaddress)) @@ -988,6 +1000,7 @@ class TestRebootRouter(cloudstackTestCase): self.services = Services().services # Get Zone, Domain and templates + self.domain = get_domain(self.apiclient, self.services) self.zone = get_zone(self.apiclient, self.services) template = get_template( self.apiclient, @@ -1000,7 +1013,8 @@ class TestRebootRouter(cloudstackTestCase): self.account = Account.create( self.apiclient, self.services["account"], - admin=True + admin=True, + domainid=self.domain.id ) self.service_offering = ServiceOffering.create( self.apiclient, @@ -1011,6 +1025,7 @@ class TestRebootRouter(cloudstackTestCase): self.services["server"], templateid=template.id, accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id ) @@ -1135,6 +1150,7 @@ class TestAssignRemoveLB(cloudstackTestCase): self.apiclient = self.testClient.getApiClient() self.services = Services().services # Get Zone, Domain and templates + self.domain = get_domain(self.apiclient, self.services) self.zone = get_zone(self.apiclient, self.services) template = get_template( self.apiclient, @@ -1147,7 +1163,8 @@ class TestAssignRemoveLB(cloudstackTestCase): self.account = Account.create( self.apiclient, self.services["account"], - admin=True + admin=True, + domainid=self.domain.id ) self.service_offering = ServiceOffering.create( self.apiclient, @@ -1159,6 +1176,7 @@ class TestAssignRemoveLB(cloudstackTestCase): self.services["server"], templateid=template.id, accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id ) @@ -1167,6 +1185,7 @@ class TestAssignRemoveLB(cloudstackTestCase): self.services["server"], templateid=template.id, accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id ) @@ -1175,6 +1194,7 @@ class TestAssignRemoveLB(cloudstackTestCase): self.services["server"], templateid=template.id, accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id ) @@ -1378,6 +1398,7 @@ class TestReleaseIP(cloudstackTestCase): self.services = Services().services # Get Zone, Domain and templates + self.domain = get_domain(self.apiclient, self.services) self.zone = get_zone(self.apiclient, self.services) template = get_template( self.apiclient, @@ -1390,7 +1411,8 @@ class TestReleaseIP(cloudstackTestCase): self.account = Account.create( self.apiclient, self.services["account"], - admin=True + admin=True, + domainid=self.domain.id ) self.service_offering = ServiceOffering.create( @@ -1403,6 +1425,7 @@ class TestReleaseIP(cloudstackTestCase): self.services["server"], templateid=template.id, accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id ) @@ -1514,6 +1537,7 @@ class TestDeleteAccount(cloudstackTestCase): self.services = Services().services # Get Zone, Domain and templates + self.domain = get_domain(self.apiclient, self.services) self.zone = get_zone(self.apiclient, self.services) template = get_template( self.apiclient, @@ -1526,7 +1550,8 @@ class TestDeleteAccount(cloudstackTestCase): self.account = Account.create( self.apiclient, self.services["account"], - admin=True + admin=True, + domainid=self.domain.id ) self.service_offering = ServiceOffering.create( self.apiclient, @@ -1537,6 +1562,7 @@ class TestDeleteAccount(cloudstackTestCase): self.services["server"], templateid=template.id, accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id ) @@ -1651,4 +1677,4 @@ class TestDeleteAccount(cloudstackTestCase): def tearDown(self): cleanup_resources(self.apiclient, self.cleanup) - return \ No newline at end of file + return diff --git a/tools/testClient/testcase/BVT-tests/test_routers.py b/tools/testClient/testcase/BVT-tests/test_routers.py index 3db9eeb7d87..1c65297a4b0 100644 --- a/tools/testClient/testcase/BVT-tests/test_routers.py +++ b/tools/testClient/testcase/BVT-tests/test_routers.py @@ -33,10 +33,9 @@ class Services: { "displayname": "Test VM", "username": "root", - "password": "password", + "password": "fr3sca", "ssh_port": 22, "hypervisor": 'XenServer', - "domainid": 1, "privateport": 22, "publicport": 22, "protocol": 'TCP', @@ -46,14 +45,11 @@ class Services: "firstname": "Test", "lastname": "User", "username": "testuser", - "password": "password", + "password": "fr3sca", }, "ostypeid":12, "sleep": 60, "timeout": 10, - "zoneid": 1, - # Optional, if specified the mentioned zone will be - # used for tests "mode": 'advanced', #Networking mode: Basic, Advanced } @@ -66,6 +62,7 @@ class TestRouterServices(cloudstackTestCase): cls.api_client = fetch_api_client() 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) template = get_template( cls.api_client, @@ -77,7 +74,8 @@ class TestRouterServices(cloudstackTestCase): #Create an account, network, VM and IP addresses cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.service_offering = ServiceOffering.create( cls.api_client, @@ -88,6 +86,7 @@ class TestRouterServices(cloudstackTestCase): cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) cls.cleanup = [ @@ -136,7 +135,6 @@ class TestRouterServices(cloudstackTestCase): hosts = list_hosts( self.apiclient, zoneid=router.zoneid, - hostid=router.hostid, type='Routing', state='Up' ) @@ -154,12 +152,6 @@ class TestRouterServices(cloudstackTestCase): 'Running', "Check list router response for router state" ) - self.debug("connecting to router %s on host %s with \ - (username,password) (%s,%s)" \ - %(router.linklocalip, host.ipaddress,\ - self.vm_1.username, self.vm_1.password)) - - result = get_process_status( host.ipaddress, @@ -204,7 +196,6 @@ class TestRouterServices(cloudstackTestCase): hosts = list_hosts( self.apiclient, zoneid=router.zoneid, - hostid=router.hostid, type='Routing', state='Up' ) @@ -222,11 +213,6 @@ class TestRouterServices(cloudstackTestCase): "Check list router response for router state" ) - self.debug("connecting to router %s on host %s with \ - (username,password) (%s,%s)" \ - %(router.linklocalip, host.ipaddress,\ - self.vm_1.username, self.vm_1.password)) - result = get_process_status( host.ipaddress, self.services['virtual_machine']["publicport"], @@ -243,11 +229,6 @@ class TestRouterServices(cloudstackTestCase): 1, "Check dnsmasq service is running or not" ) - self.debug("connecting to router %s on host %s with \ - (username,password) (%s,%s)" \ - %(router.linklocalip, host.ipaddress,\ - self.vm_1.username, self.vm_1.password)) - result = get_process_status( host.ipaddress, @@ -400,7 +381,6 @@ class TestRouterServices(cloudstackTestCase): hosts = list_hosts( self.apiclient, zoneid=router.zoneid, - hostid=router.hostid, type='Routing', state='Up' ) @@ -410,11 +390,6 @@ class TestRouterServices(cloudstackTestCase): "Check list response returns a valid list" ) host = hosts[0] - self.debug("connecting to router %s on host %s with \ - (username,password) (%s,%s)" \ - %(router.linklocalip, host.ipaddress,\ - self.vm_1.username, self.vm_1.password)) - res = get_process_status( host.ipaddress, @@ -778,7 +753,7 @@ class TestRouterServices(cloudstackTestCase): ) response = config[0] - # Wait for network.gc.interval * 3 time + # Wait for network.gc.interval * 3 time to cleanup all the resources time.sleep(int(response.value) * 3) timeout = self.services["timeout"] @@ -803,7 +778,7 @@ class TestRouterServices(cloudstackTestCase): ) router = list_router_response[0] - self.debug("waited for %s time. Router state after network.gc.interval: %s" % (int(response.value)*3, router.state)) + self.debug("Router state after network.gc.interval: %s" % router.state) self.assertEqual( router.state, 'Stopped', diff --git a/tools/testClient/testcase/BVT-tests/test_secondary_storage.py b/tools/testClient/testcase/BVT-tests/test_secondary_storage.py index 875b929dfef..36c7e62eea7 100644 --- a/tools/testClient/testcase/BVT-tests/test_secondary_storage.py +++ b/tools/testClient/testcase/BVT-tests/test_secondary_storage.py @@ -40,10 +40,6 @@ class Services: }, "sleep": 60, "timeout": 5, - "zoneid": 1, - # Optional, if specified the mentioned zone will be - # used for tests - "domainid": 1, } class TestSecStorageServices(cloudstackTestCase): @@ -70,6 +66,7 @@ class TestSecStorageServices(cloudstackTestCase): self.cleanup = [] self.services = Services().services # Get Zone and pod + self.domain = get_domain(self.apiclient, self.services) self.zone = get_zone(self.apiclient, self.services) self.pod = get_pod(self.apiclient, self.zone.id) return @@ -285,7 +282,7 @@ class TestSecStorageServices(cloudstackTestCase): zoneid=self.zone.id, templatefilter=v["templatefilter"], account='system', - domainid=self.services["domainid"] + domainid=self.domain.id ) # Ensure all BUILTIN templates are downloaded @@ -307,7 +304,7 @@ class TestSecStorageServices(cloudstackTestCase): zoneid=self.zone.id, templatefilter=v["templatefilter"], account='system', - domainid=self.services["domainid"] + domainid=self.domain.id ) if isinstance(template_response, list): @@ -342,7 +339,7 @@ class TestSecStorageServices(cloudstackTestCase): zoneid=self.zone.id, templatefilter=v["templatefilter"], account='system', - domainid=self.services["domainid"] + domainid=self.domain.id ) if isinstance(template_response, list): diff --git a/tools/testClient/testcase/BVT-tests/test_snapshots.py b/tools/testClient/testcase/BVT-tests/test_snapshots.py index 7d0f63970f6..6ef15306103 100644 --- a/tools/testClient/testcase/BVT-tests/test_snapshots.py +++ b/tools/testClient/testcase/BVT-tests/test_snapshots.py @@ -26,7 +26,7 @@ class Services: "username": "test", # Random characters are appended for unique # username - "password": "password", + "password": "fr3sca", }, "service_offering": { "name": "Tiny Instance", @@ -47,7 +47,6 @@ class Services: "password": "password", "ssh_port": 22, "hypervisor": 'XenServer', - "domainid": 1, "privateport": 22, "publicport": 22, "protocol": 'TCP', @@ -60,7 +59,6 @@ class Services: "password": "password", "ssh_port": 22, "hypervisor": 'XenServer', - "domainid": 1, "privateport": 22, # For NAT rule creation "publicport": 22, @@ -91,7 +89,6 @@ class Services: "diskname": "Test Disk", "size": 1, # GBs - "domainid": 1, "mount_dir": "/mnt/tmp", "sub_dir": "test", @@ -102,9 +99,6 @@ class Services: "username": "root", "password": "password", "ssh_port": 22, - "zoneid": 1, - # Optional, if specified the mentioned zone will be - # used for tests "sleep": 60, "timeout": 10, "mode": 'advanced', @@ -119,6 +113,7 @@ class TestSnapshotRootDisk(cloudstackTestCase): cls.api_client = fetch_api_client() 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) template = get_template( @@ -126,6 +121,7 @@ class TestSnapshotRootDisk(cloudstackTestCase): cls.zone.id, cls.services["ostypeid"] ) + cls.services["domainid"] = cls.domain.id cls.services["server_without_disk"]["zoneid"] = cls.zone.id cls.services["template"] = template.id cls.services["zoneid"] = cls.zone.id @@ -133,7 +129,8 @@ class TestSnapshotRootDisk(cloudstackTestCase): # Create VMs, NAT Rules etc cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -148,6 +145,7 @@ class TestSnapshotRootDisk(cloudstackTestCase): cls.services["server_without_disk"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) @@ -328,6 +326,7 @@ class TestSnapshots(cloudstackTestCase): cls.api_client = fetch_api_client() 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.disk_offering = DiskOffering.create( cls.api_client, @@ -338,6 +337,8 @@ class TestSnapshots(cloudstackTestCase): cls.zone.id, cls.services["ostypeid"] ) + + cls.services["domainid"] = cls.domain.id cls.services["server_with_disk"]["zoneid"] = cls.zone.id cls.services["server_with_disk"]["diskoffering"] = cls.disk_offering.id @@ -350,7 +351,8 @@ class TestSnapshots(cloudstackTestCase): # Create VMs, NAT Rules etc cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -365,6 +367,7 @@ class TestSnapshots(cloudstackTestCase): cls.services["server_with_disk"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) @@ -374,6 +377,7 @@ class TestSnapshots(cloudstackTestCase): cls.services["server_without_disk"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) @@ -1055,6 +1059,7 @@ class TestSnapshots(cloudstackTestCase): self.services["server_without_disk"], templateid=template.id, accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id, mode=self.services["mode"] ) diff --git a/tools/testClient/testcase/BVT-tests/test_ssvm.py b/tools/testClient/testcase/BVT-tests/test_ssvm.py index e1dc36e00a8..ce034cb0b95 100644 --- a/tools/testClient/testcase/BVT-tests/test_ssvm.py +++ b/tools/testClient/testcase/BVT-tests/test_ssvm.py @@ -24,12 +24,9 @@ class Services: self.services = { "host": { "username": 'root', # Credentials for SSH - "password": 'password', + "password": 'fr3sca', "publicport": 22, }, - "zoneid": 1, - # Optional, if specified the mentioned zone will be - # used for tests "sleep": 60, "timeout": 10, } diff --git a/tools/testClient/testcase/BVT-tests/test_templates.py b/tools/testClient/testcase/BVT-tests/test_templates.py index 8a1c0d8efc4..2f6641ce3c1 100644 --- a/tools/testClient/testcase/BVT-tests/test_templates.py +++ b/tools/testClient/testcase/BVT-tests/test_templates.py @@ -29,7 +29,7 @@ class Services: "username": "test", # Random characters are appended for unique # username - "password": "password", + "password": "fr3sca", }, "service_offering": { "name": "Tiny Instance", @@ -46,7 +46,6 @@ class Services: "virtual_machine": { "displayname": "testVM", "hypervisor": 'XenServer', - "domainid": 1, "protocol": 'TCP', "ssh_port": 22, "username": "root", @@ -80,10 +79,7 @@ class Services: "bootable": True, "passwordenabled": True, "ostypeid": 12, - "zoneid": 2, - # Optional, if specified the mentioned zone will be - # used for tests - "mode": 'basic', + "mode": 'advanced', # Networking mode: Advanced, basic "sleep": 30, "timeout": 10, @@ -115,6 +111,7 @@ class TestCreateTemplate(cloudstackTestCase): cls.api_client = fetch_api_client() # Get Zone, Domain and templates + cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) cls.disk_offering = DiskOffering.create( cls.api_client, @@ -132,7 +129,8 @@ class TestCreateTemplate(cloudstackTestCase): cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -146,6 +144,7 @@ class TestCreateTemplate(cloudstackTestCase): cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) @@ -273,6 +272,7 @@ class TestTemplates(cloudstackTestCase): cls.api_client = fetch_api_client() # Get Zone, Domain and templates + cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) cls.disk_offering = DiskOffering.create( cls.api_client, @@ -291,12 +291,15 @@ class TestTemplates(cloudstackTestCase): cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + admin=True, + domainid=cls.domain.id ) cls.user = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -311,6 +314,7 @@ class TestTemplates(cloudstackTestCase): cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) @@ -424,7 +428,6 @@ class TestTemplates(cloudstackTestCase): cmd.name = new_name cmd.bootable = self.services["bootable"] cmd.passwordenabled = self.services["passwordenabled"] - cmd.ostypeid = self.services["ostypeid"] self.apiclient.updateTemplate(cmd) diff --git a/tools/testClient/testcase/BVT-tests/test_vm_life_cycle.py b/tools/testClient/testcase/BVT-tests/test_vm_life_cycle.py index a183535b526..55244d1952c 100644 --- a/tools/testClient/testcase/BVT-tests/test_vm_life_cycle.py +++ b/tools/testClient/testcase/BVT-tests/test_vm_life_cycle.py @@ -33,7 +33,7 @@ class Services: "username": "test", # Random characters are appended in create account to # ensure unique username generated each time - "password": "password", + "password": "fr3sca", }, "small": # Create a small virtual machine instance with disk offering @@ -43,7 +43,6 @@ class Services: "password": "password", "ssh_port": 22, "hypervisor": 'XenServer', - "domainid": 1, "privateport": 22, "publicport": 22, "protocol": 'TCP', @@ -55,7 +54,6 @@ class Services: "password": "password", "ssh_port": 22, "hypervisor": 'XenServer', - "domainid": 1, "privateport": 22, "publicport": 22, "protocol": 'TCP', @@ -109,9 +107,6 @@ class Services: #Migrate VM to hostid "ostypeid": 12, # CentOS 5.3 (64-bit) - "zoneid": 2, - # Optional, if specified the mentioned zone will be - # used for tests "mode":'advanced', # Networking mode: Basic or Advanced } @@ -125,6 +120,7 @@ class TestDeployVM(cloudstackTestCase): self.dbclient = self.testClient.getDbConnection() self.services = Services().services # Get Zone, Domain and templates + domain = get_domain(self.apiclient, self.services) zone = get_zone(self.apiclient, self.services) template = get_template( @@ -143,7 +139,8 @@ class TestDeployVM(cloudstackTestCase): # Create Account, VMs, NAT Rules etc self.account = Account.create( self.apiclient, - self.services["account"] + self.services["account"], + domainid=domain.id ) self.service_offering = ServiceOffering.create( @@ -169,6 +166,7 @@ class TestDeployVM(cloudstackTestCase): self.apiclient, self.services["small"], accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id ) @@ -224,6 +222,7 @@ class TestVMLifeCycle(cloudstackTestCase): cls.services = Services().services # Get Zone, Domain and templates + domain = get_domain(cls.api_client, cls.services) zone = get_zone(cls.api_client, cls.services) template = get_template( cls.api_client, @@ -241,7 +240,8 @@ class TestVMLifeCycle(cloudstackTestCase): # Create VMs, NAT Rules etc cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=domain.id ) cls.small_offering = ServiceOffering.create( @@ -258,6 +258,7 @@ class TestVMLifeCycle(cloudstackTestCase): cls.api_client, cls.services["small"], accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.small_offering.id, mode=cls.services["mode"] ) @@ -265,6 +266,7 @@ class TestVMLifeCycle(cloudstackTestCase): cls.api_client, cls.services["medium"], accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.medium_offering.id, mode=cls.services["mode"] ) @@ -272,6 +274,7 @@ class TestVMLifeCycle(cloudstackTestCase): cls.api_client, cls.services["small"], accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.small_offering.id, mode=cls.services["mode"] ) @@ -322,7 +325,7 @@ class TestVMLifeCycle(cloudstackTestCase): self.assertNotEqual( len(list_vm_response), 0, - "Check VM avaliable in List Virtual Machines" + "Check VM available in List Virtual Machines" ) self.assertEqual( diff --git a/tools/testClient/testcase/BVT-tests/test_volumes.py b/tools/testClient/testcase/BVT-tests/test_volumes.py index 487fb890a3f..8809eeb40ce 100644 --- a/tools/testClient/testcase/BVT-tests/test_volumes.py +++ b/tools/testClient/testcase/BVT-tests/test_volumes.py @@ -31,7 +31,7 @@ class Services: "username": "test", # Random characters are appended for unique # username - "password": "password", + "password": "fr3sca", }, "service_offering": { "name": "Tiny Instance", @@ -48,7 +48,6 @@ class Services: "volume_offerings": { 0: { "diskname": "TestDiskServ", - "domainid": 1, }, }, "customdisksize": 1, # GBs @@ -57,16 +56,12 @@ class Services: "ssh_port": 22, "diskname": "TestDiskServ", "hypervisor": 'XenServer', - "domainid": 1, "privateport": 22, "publicport": 22, "protocol": 'TCP', "diskdevice": "/dev/xvdb", "ostypeid": 12, - "zoneid": 1, - # Optional, if specified the mentioned zone will be - # used for tests - "mode": 'basic', + "mode": 'advanced', "sleep": 60, "timeout": 10, } @@ -80,6 +75,7 @@ class TestCreateVolume(cloudstackTestCase): 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.disk_offering = DiskOffering.create( cls.api_client, @@ -95,6 +91,7 @@ class TestCreateVolume(cloudstackTestCase): cls.zone.id, cls.services["ostypeid"] ) + cls.services["domainid"] = cls.domain.id cls.services["zoneid"] = cls.zone.id cls.services["template"] = template.id cls.services["customdiskofferingid"] = cls.custom_disk_offering.id @@ -102,7 +99,8 @@ class TestCreateVolume(cloudstackTestCase): # Create VMs, NAT Rules etc cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -114,6 +112,7 @@ class TestCreateVolume(cloudstackTestCase): cls.api_client, cls.services, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) @@ -263,6 +262,7 @@ class TestVolumes(cloudstackTestCase): cls.api_client = fetch_api_client() 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.disk_offering = DiskOffering.create( cls.api_client, @@ -273,6 +273,7 @@ class TestVolumes(cloudstackTestCase): cls.zone.id, cls.services["ostypeid"] ) + cls.services["domainid"] = cls.domain.id cls.services["zoneid"] = cls.zone.id cls.services["template"] = template.id cls.services["diskofferingid"] = cls.disk_offering.id @@ -280,7 +281,8 @@ class TestVolumes(cloudstackTestCase): # Create VMs, VMs etc cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -292,6 +294,7 @@ class TestVolumes(cloudstackTestCase): cls.api_client, cls.services, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) diff --git a/tools/testClient/testcase/P1-tests/README b/tools/testClient/testcase/P1-tests/README index 94469d7eccd..ba0a04c6714 100644 --- a/tools/testClient/testcase/P1-tests/README +++ b/tools/testClient/testcase/P1-tests/README @@ -28,4 +28,9 @@ The following files contain these P1 cases: 1. test_snapshots.py - Snapshots related tests 2. test_routers.py - Router related tests 3. test_usage.py - Usage realted tests - +4. test_account.py - Account related tests +5. test_resource_limits.py - Resource limits tests +6. test_security_groups.py - Security groups related tests +7. test_templates - templates related tests +8. test_volumes - Volumes related tests +9. test_blocker_bugs - Blocker bugs tests diff --git a/tools/testClient/testcase/P1-tests/test_accounts.py b/tools/testClient/testcase/P1-tests/test_accounts.py index 073c3e68ef4..d9b1901653b 100644 --- a/tools/testClient/testcase/P1-tests/test_accounts.py +++ b/tools/testClient/testcase/P1-tests/test_accounts.py @@ -34,15 +34,15 @@ class Services: "name": "Test Pod", "gateway": '192.168.100.1', "netmask": '255.255.255.0', - "startip": '192.168.100.136', - "endip": '192.168.100.141', + "startip": '192.168.100.132', + "endip": '192.168.100.140', }, "public_ip": { "gateway": '192.168.100.1', "netmask": '255.255.255.0', "forvirtualnetwork": False, - "startip": '192.168.100.136', - "endip": '192.168.100.141', + "startip": '192.168.100.142', + "endip": '192.168.100.149', "vlan": "untagged", }, "cluster": { @@ -66,11 +66,11 @@ class Services: "primary_storage": { "name": "Test Primary", - "url": "nfs://192.168.100.131/Primary3", + "url": "nfs://192.168.100.150/mnt/DroboFS/Shares/nfsclo3", # Format: File_System_Type/Location/Path }, "sec_storage": { - "url": "nfs://192.168.100.131/SecStorage" + "url": "nfs://192.168.100.150/mnt/DroboFS/Shares/nfsclo4" # Format: File_System_Type/Location/Path @@ -83,7 +83,7 @@ class Services: }, "sysVM": { "mnt_dir": '/mnt/test', - "sec_storage": '192.168.100.131', + "sec_storage": '192.168.100.150', "path": 'TestSec', "command": '/usr/lib64/cloud/agent/scripts/storage/secondary/cloud-install-sys-tmplt', "download_url": 'http://download.cloud.com/releases/2.2.0/systemvm.vhd.bz2', @@ -122,7 +122,6 @@ class Services: "hypervisor": 'XenServer', # Hypervisor type should be same as # hypervisor type of cluster - "domainid": 1, "privateport": 22, "publicport": 22, "protocol": 'TCP', @@ -138,12 +137,8 @@ class Services: "ispublic": True, "isextractable": True, }, - "domainid": 1, "ostypeid": 12, # Cent OS 5.3 (64 bit) - "zoneid": 2, - # Optional, if specified the mentioned zone will be - # used for tests "sleep": 60, "timeout": 10, "mode":'advanced' @@ -360,6 +355,7 @@ class TestRemoveUserFromAccount(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id ) self.debug("Deployed VM in account: %s, ID: %s" % ( @@ -372,6 +368,7 @@ class TestRemoveUserFromAccount(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id ) self.debug("Deployed VM in account: %s, ID: %s" % ( @@ -425,7 +422,7 @@ class TestRemoveUserFromAccount(cloudstackTestCase): "Check state of VMs associated with account" ) return - + @unittest.skip("Open Questions") def test_02_remove_all_users(self): """Test Remove both users from the account """ @@ -742,8 +739,7 @@ class TestServiceOfferingSiblings(cloudstackTestCase): ) return - -@unittest.skip("Not tested") +@unittest.skip("Open Questions") class TestServiceOfferingHierarchy(cloudstackTestCase): @classmethod @@ -867,7 +863,7 @@ class TestServiceOfferingHierarchy(cloudstackTestCase): ) return -@unittest.skip("Not tested") +@unittest.skip("Open Questions") class TesttemplateHierarchy(cloudstackTestCase): @classmethod @@ -1003,7 +999,7 @@ class TesttemplateHierarchy(cloudstackTestCase): ) return -@unittest.skip("Not tested") +@unittest.skip("Open Questions") class TestAddVmToSubDomain(cloudstackTestCase): @classmethod @@ -1083,9 +1079,14 @@ class TestAddVmToSubDomain(cloudstackTestCase): ssvm_response = list_ssvms( cls.api_client, systemvmtype='secondarystoragevm', - hostid=cls.host.id + hostid=cls.host.id, + sleep=cls.services["sleep"] ) - ssvm = ssvm_response[0] + if isinstance(ssvm_response, list): + ssvm = ssvm_response[0] + else: + raise Exception("List SSVM failed") + # Download BUILTIN templates download_builtin_templates( cls.api_client, @@ -1126,7 +1127,7 @@ class TestAddVmToSubDomain(cloudstackTestCase): cls.zone.id, cls.services["ostypeid"] ) - + cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.vm_1 = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], @@ -1135,35 +1136,68 @@ class TestAddVmToSubDomain(cloudstackTestCase): domainid=cls.account_1.account.domainid, serviceofferingid=cls.service_offering.id ) - cls.sub_domain_path = str(cls.account_1.account.domainid) + '/' + \ - str(cls.account_2.account.domainid) + cls.vm_2 = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], templateid=cls.template.id, accountid=cls.account_2.account.name, - domainid=cls.sub_domain_path, + domainid=cls.account_2.account.domainid, serviceofferingid=cls.service_offering.id ) - cls._cleanup = [ - cls.account_1, - cls.account_2, - cls.service_offering, - cls.sub_domain, - cls.secondary_storage, - cls.primary_storage, - cls.host, - cls.cluster, - cls.pod, - cls.zone - ] + cls._cleanup = [] return @classmethod def tearDownClass(cls): try: - # Cleanup resources used - cleanup_resources(cls.api_client, cls._cleanup) + # Cleanup the accounts + cls.account_1.delete(cls.api_client) + cls.account_2.delete(cls.api_client) + + cleanup_wait = list_configurations( + cls.api_client, + name='account.cleanup.interval' + ) + # Sleep for account.cleanup.interval * 2 to wait for expunge of + # resources associated with that account + if isinstance(cleanup_wait, list): + sleep_time = int(cleanup_wait[0].value) * 2 + + time.sleep(sleep_time) + + # Delete Service offerings and sub-domains + cls.service_offering.delete(cls.api_client) + cls.sub_domain.delete(cls.api_client) + + # Enable maintenance mode of + cls.host.enableMaintenance(cls.api_client) + cls.primary_storage.enableMaintenance(cls.api_client) + + # Destroy SSVMs and wait for volumes to cleanup + ssvms = list_ssvms( + cls.api_client, + zoneid=cls.zone.id + ) + + if isinstance(ssvms, list): + for ssvm in ssvms: + cmd = destroySystemVm.destroySystemVmCmd() + cmd.id = ssvm.id + cls.api_client.destroySystemVm(cmd) + + # Sleep for account.cleanup.interval*2 to wait for SSVM volume + # to cleanup + time.sleep(sleep_time) + + # Cleanup Primary, secondary storage, hosts, zones etc. + cls.secondary_storage.delete(cls.api_client) + cls.host.delete(cls.api_client) + + cls.primary_storage.delete(cls.api_client) + cls.cluster.delete(cls.api_client) + cls.pod.delete(cls.api_client) + cls.zone.delete(cls.api_client) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return diff --git a/tools/testClient/testcase/P1-tests/test_blocker_bugs.py b/tools/testClient/testcase/P1-tests/test_blocker_bugs.py index c20248810e9..1240a28191c 100644 --- a/tools/testClient/testcase/P1-tests/test_blocker_bugs.py +++ b/tools/testClient/testcase/P1-tests/test_blocker_bugs.py @@ -50,7 +50,6 @@ class Services: "password": "password", "ssh_port": 22, "hypervisor": 'XenServer', - "domainid": 1, "privateport": 22, "publicport": 22, "protocol": 'TCP', @@ -87,9 +86,6 @@ class Services: }, "ostypeid": 12, # Cent OS 5.3 (64 bit) - "zoneid": 1, - # Optional, if specified the mentioned zone will be - # used for tests "sleep":60, "mode": 'advanced', # Networking mode, Advanced, Basic @@ -103,6 +99,7 @@ class TestSnapshots(cloudstackTestCase): cls.api_client = fetch_api_client() 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.disk_offering = DiskOffering.create( cls.api_client, @@ -122,7 +119,8 @@ class TestSnapshots(cloudstackTestCase): # Create VMs, NAT Rules etc cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -136,6 +134,7 @@ class TestSnapshots(cloudstackTestCase): cls.services["virtual_machine"], templateid=cls.template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) @@ -280,7 +279,7 @@ class TestSnapshots(cloudstackTestCase): account=self.account.account.name, domainid=self.account.account.domainid ) - self.debug("Created Volume from Snapshot: %s" % ( + self.debug("Created Volume: %s from Snapshot: %s" % ( volume_from_snapshot.id, snapshot.id)) volumes = Volume.list( @@ -309,6 +308,7 @@ class TestSnapshots(cloudstackTestCase): self.services["virtual_machine"], templateid=self.template.id, accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id, mode=self.services["mode"] ) @@ -378,7 +378,7 @@ class TestSnapshots(cloudstackTestCase): ssh_client.execute(c) return - +@unittest.skip("Open Questions") class TestTemplate(cloudstackTestCase): def setUp(self): @@ -404,6 +404,7 @@ class TestTemplate(cloudstackTestCase): cls.api_client = fetch_api_client() # Get Zone, Domain and templates + cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["templates"]["zoneid"] = cls.zone.id @@ -414,7 +415,8 @@ class TestTemplate(cloudstackTestCase): ) cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -450,6 +452,7 @@ class TestTemplate(cloudstackTestCase): template = Template.register( self.apiclient, self.services["templates"], + zoneid=self.zone.id, account=self.account.account.name, domainid=self.account.account.domainid ) @@ -499,6 +502,7 @@ class TestTemplate(cloudstackTestCase): self.services["virtual_machine"], templateid=template.id, accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id, ) self.debug("Deployed VM with ID: %s " % virtual_machine.id) @@ -519,6 +523,7 @@ class TestNATRules(cloudstackTestCase): 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) template = get_template( cls.api_client, @@ -529,7 +534,8 @@ class TestNATRules(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], - admin=True + admin=True, + domainid=cls.domain.id ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( @@ -541,6 +547,7 @@ class TestNATRules(cloudstackTestCase): cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) cls.public_ip = PublicIPAddress.create( @@ -573,7 +580,7 @@ class TestNATRules(cloudstackTestCase): def tearDown(self): cleanup_resources(self.apiclient, self.cleanup) return -# + def test_01_firewall_rules_port_fw(self): """"Checking firewall rules deletion after static NAT disable""" @@ -621,7 +628,6 @@ class TestNATRules(cloudstackTestCase): nat_rule.id, "Check Correct IP forwarding Rule is returned" ) - # Verify the entries made in firewall_rules tables self.debug( "select id, state from firewall_rules where ip_address_id = %s;" \ @@ -644,7 +650,7 @@ class TestNATRules(cloudstackTestCase): ) for qresult in qresultset: - self.assertNotEqual( + self.assertEqual( qresult[1], 'Active', "Check state of the static NAT rule in database" @@ -674,8 +680,8 @@ class TestNATRules(cloudstackTestCase): ) self.assertEqual( - qresultset, - None, + len(qresultset), + 0, "Check DB Query result set" ) return @@ -811,6 +817,7 @@ class TestRouterRestart(cloudstackTestCase): cls.api_client = fetch_api_client() 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) template = get_template( cls.api_client, @@ -822,7 +829,8 @@ class TestRouterRestart(cloudstackTestCase): #Create an account, network, VM and IP addresses cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.service_offering = ServiceOffering.create( cls.api_client, @@ -833,6 +841,7 @@ class TestRouterRestart(cloudstackTestCase): cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) cls.cleanup = [ @@ -936,6 +945,7 @@ class TestTemplates(cloudstackTestCase): cls.api_client = fetch_api_client() # Get Zone, templates etc + cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) template = get_template( @@ -946,7 +956,8 @@ class TestTemplates(cloudstackTestCase): cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -961,6 +972,7 @@ class TestTemplates(cloudstackTestCase): cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id, ) #Stop virtual machine diff --git a/tools/testClient/testcase/P1-tests/test_resource_limits.py b/tools/testClient/testcase/P1-tests/test_resource_limits.py index 4d369b69769..eaa4ec6cd6a 100644 --- a/tools/testClient/testcase/P1-tests/test_resource_limits.py +++ b/tools/testClient/testcase/P1-tests/test_resource_limits.py @@ -44,7 +44,6 @@ class Services: }, "volume": { "diskname": "TestDiskServ", - "domainid": 1, }, "server": { "displayname": "TestVM", @@ -52,7 +51,6 @@ class Services: "password": "password", "ssh_port": 22, "hypervisor": 'XenServer', - "domainid": 1, "privateport": 22, "publicport": 22, "protocol": 'TCP', @@ -63,12 +61,8 @@ class Services: "ostypeid": 12, "templatefilter": 'self', }, - "domainid": 1, "ostypeid": 12, # Cent OS 5.3 (64 bit) - "zoneid": 1, - # Optional, if specified the mentioned zone will be - # used for tests "sleep": 60, "timeout": 10, "mode": 'advanced', @@ -81,6 +75,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): cls.api_client = fetch_api_client() 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.template = get_template( @@ -94,11 +89,13 @@ class TestResourceLimitsAccount(cloudstackTestCase): cls.account_1 = Account.create( cls.api_client, cls.services["account"], + domainid=cls.domain.id ) # Create Account, VMs etc cls.account_2 = Account.create( cls.api_client, cls.services["account"], + domainid=cls.domain.id ) cls.service_offering = ServiceOffering.create( @@ -170,6 +167,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): self.services["server"], templateid=self.template.id, accountid=self.account_1.account.name, + domainid=self.account_1.account.domainid, serviceofferingid=self.service_offering.id ) self.cleanup.append(virtual_machine) @@ -188,6 +186,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): self.services["server"], templateid=self.template.id, accountid=self.account_1.account.name, + domainid=self.account_1.account.domainid, serviceofferingid=self.service_offering.id ) self.debug( @@ -199,6 +198,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): self.services["server"], templateid=self.template.id, accountid=self.account_2.account.name, + domainid=self.account_2.account.domainid, serviceofferingid=self.service_offering.id ) self.cleanup.append(virtual_machine_1) @@ -217,6 +217,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): self.services["server"], templateid=self.template.id, accountid=self.account_2.account.name, + domainid=self.account_2.account.domainid, serviceofferingid=self.service_offering.id ) self.cleanup.append(virtual_machine_2) @@ -261,6 +262,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): self.services["server"], templateid=self.template.id, accountid=self.account_1.account.name, + domainid=self.account_1.account.domainid, serviceofferingid=self.service_offering.id ) self.cleanup.append(virtual_machine_1) @@ -280,6 +282,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): self.services["server"], templateid=self.template.id, accountid=self.account_2.account.name, + domainid=self.account_2.account.domainid, serviceofferingid=self.service_offering.id ) self.cleanup.append(virtual_machine_2) @@ -401,6 +404,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): self.services["server"], templateid=self.template.id, accountid=self.account_1.account.name, + domainid=self.account_1.account.domainid, serviceofferingid=self.service_offering.id ) self.cleanup.append(virtual_machine_1) @@ -420,6 +424,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): self.services["server"], templateid=self.template.id, accountid=self.account_2.account.name, + domainid=self.account_2.account.domainid, serviceofferingid=self.service_offering.id ) self.cleanup.append(virtual_machine_2) @@ -541,7 +546,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): 2, # Volume account=self.account_1.account.name, domainid=self.account_1.account.domainid, - max=3 + max=2 ) self.debug( @@ -552,6 +557,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): self.services["server"], templateid=self.template.id, accountid=self.account_1.account.name, + domainid=self.account_1.account.domainid, serviceofferingid=self.service_offering.id ) self.cleanup.append(virtual_machine_1) @@ -571,6 +577,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): self.services["server"], templateid=self.template.id, accountid=self.account_2.account.name, + domainid=self.account_2.account.domainid, serviceofferingid=self.service_offering.id ) self.cleanup.append(virtual_machine_2) @@ -689,6 +696,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): self.services["server"], templateid=self.template.id, accountid=self.account_1.account.name, + domainid=self.account_1.account.domainid, serviceofferingid=self.service_offering.id ) self.cleanup.append(virtual_machine_1) @@ -708,6 +716,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): self.services["server"], templateid=self.template.id, accountid=self.account_2.account.name, + domainid=self.account_2.account.domainid, serviceofferingid=self.service_offering.id ) self.cleanup.append(virtual_machine_2) diff --git a/tools/testClient/testcase/P1-tests/test_routers.py b/tools/testClient/testcase/P1-tests/test_routers.py index cff0d95dd90..0aa34e1c011 100644 --- a/tools/testClient/testcase/P1-tests/test_routers.py +++ b/tools/testClient/testcase/P1-tests/test_routers.py @@ -33,16 +33,20 @@ class Services: { "displayname": "Test VM", "username": "root", - "password": "fr3sca", + "password": "password", "ssh_port": 22, "hypervisor": 'XenServer', # Hypervisor type should be same as # hypervisor type of cluster - "domainid": 1, "privateport": 22, "publicport": 22, "protocol": 'TCP', }, + "host": { + "username": "root", + "password": "fr3sca", + "publicport": 22, + }, "account": { "email": "test@test.com", "firstname": "Test", @@ -61,7 +65,7 @@ class Services: "name": "SSH", "alg": "roundrobin", # Algorithm used for load balancing - "privateport": 80, + "privateport": 22, "publicport": 2222, }, "fw_rule":{ @@ -72,9 +76,6 @@ class Services: }, "ostypeid":12, # Used for Get_Template : CentOS 5.3 (64 bit) - "zoneid": 1, - # Optional, if specified the mentioned zone will be - # used for tests "mode": 'advanced', # Networking mode: Advanced, basic } @@ -87,6 +88,7 @@ class TestRouterServices(cloudstackTestCase): cls.api_client = fetch_api_client() 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.template = get_template( cls.api_client, @@ -99,7 +101,8 @@ class TestRouterServices(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], - admin=True + admin=True, + domainid=cls.domain.id ) cls.service_offering = ServiceOffering.create( cls.api_client, @@ -110,6 +113,7 @@ class TestRouterServices(cloudstackTestCase): cls.services["virtual_machine"], templateid=cls.template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) cls.vm_2 = VirtualMachine.create( @@ -117,6 +121,7 @@ class TestRouterServices(cloudstackTestCase): cls.services["virtual_machine"], templateid=cls.template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) cls.cleanup = [ @@ -211,9 +216,9 @@ class TestRouterServices(cloudstackTestCase): "Check list networks response" ) for network in networks: - self.assertEqual( + self.assertIn( network.state, - 'Implemented', + ['Implemented','Allocated'], "Check list network response for network state" ) self.debug("Network ID: %s & Network state: %s" % ( @@ -359,9 +364,9 @@ class TestRouterServices(cloudstackTestCase): ) # Check if network in 'Implemented' state for network in networks: - self.assertEqual( + self.assertIn( network.state, - 'Implemented', + ['Implemented','Allocated'], "Check list network response for network state" ) self.debug("Network ID: %s & Network state: %s" % ( @@ -459,6 +464,7 @@ class TestRouterServices(cloudstackTestCase): self.services["virtual_machine"], templateid=self.template.id, accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id ) self.debug("Deployed a VM with ID: %s" % vm.id) @@ -581,6 +587,7 @@ class TestRouterStopAssociateIp(cloudstackTestCase): cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) cls.cleanup = [ @@ -767,6 +774,9 @@ class TestRouterStopAssociateIp(cloudstackTestCase): 'ip addr show' ) self.debug("ip addr show: %s" % str(result)) + self.debug("Public IP address: %s" % public_ip.ipaddress.ipaddress) + + res = str(result) self.assertEqual( result.count(str(public_ip.ipaddress.ipaddress)), 1, @@ -783,6 +793,7 @@ class TestRouterStopCreatePF(cloudstackTestCase): cls.api_client = fetch_api_client() 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) template = get_template( cls.api_client, @@ -795,7 +806,8 @@ class TestRouterStopCreatePF(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], - admin=True + admin=True, + domainid=cls.domain.id ) cls.service_offering = ServiceOffering.create( cls.api_client, @@ -806,6 +818,7 @@ class TestRouterStopCreatePF(cloudstackTestCase): cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) cls.cleanup = [ @@ -960,13 +973,11 @@ class TestRouterStopCreatePF(cloudstackTestCase): "Check list port forwarding rules" ) try: - remoteSSHClient.remoteSSHClient( - nat_rule.ipaddress, - nat_rule.publicport, - self.vm_1.username, - self.vm_1.password - ) + self.debug("SSH into VM with ID: %s" % nat_rule.ipaddress) + + self.vm_1.ssh_port = nat_rule.publicport + self.vm_1.get_ssh_client(nat_rule.ipaddress) except Exception as e: self.fail( "SSH Access failed for %s: %s" % \ @@ -982,7 +993,8 @@ class TestRouterStopCreateLB(cloudstackTestCase): cls.api_client = fetch_api_client() cls.services = Services().services # Get Zone, Domain and templates - cls.zone = get_zone(cls.api_client) + cls.domain = get_domain(cls.api_client, cls.services) + cls.zone = get_zone(cls.api_client, cls.services) template = get_template( cls.api_client, cls.zone.id, @@ -994,7 +1006,8 @@ class TestRouterStopCreateLB(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], - admin=True + admin=True, + domainid=cls.domain.id ) cls.service_offering = ServiceOffering.create( cls.api_client, @@ -1005,6 +1018,7 @@ class TestRouterStopCreateLB(cloudstackTestCase): cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) cls.cleanup = [ @@ -1161,13 +1175,9 @@ class TestRouterStopCreateLB(cloudstackTestCase): ) try: - remoteSSHClient.remoteSSHClient( - public_ip.ipaddress, - self.services["lb_rule"]["publicport"], - self.vm_1.username, - self.vm_1.password - ) self.debug("SSH into VM with IP: %s" % public_ip.ipaddress) + self.vm_1.ssh_port = self.services["lbrule"]["publicport"] + self.vm_1.get_ssh_client(public_ip.ipaddress) except Exception as e: self.fail( "SSH Access failed for %s: %s" % \ @@ -1175,7 +1185,7 @@ class TestRouterStopCreateLB(cloudstackTestCase): ) return -@unittest.skip("iptables does not return anything") + class TestRouterStopCreateFW(cloudstackTestCase): @classmethod @@ -1184,6 +1194,7 @@ class TestRouterStopCreateFW(cloudstackTestCase): cls.api_client = fetch_api_client() 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) template = get_template( cls.api_client, @@ -1195,7 +1206,8 @@ class TestRouterStopCreateFW(cloudstackTestCase): #Create an account, network, VM and IP addresses cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.service_offering = ServiceOffering.create( cls.api_client, @@ -1206,6 +1218,7 @@ class TestRouterStopCreateFW(cloudstackTestCase): cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) cls.cleanup = [ @@ -1342,7 +1355,7 @@ class TestRouterStopCreateFW(cloudstackTestCase): # After Router start, FW rule should be in Active state fw_rules = list_firewall_rules( self.apiclient, - ipaddressid=public_ip.id + id=fw_rule.id, ) self.assertEqual( isinstance(fw_rules, list), @@ -1379,16 +1392,17 @@ class TestRouterStopCreateFW(cloudstackTestCase): # For DNS and DHCP check 'dnsmasq' process status result = get_process_status( host.ipaddress, - self.services['virtual_machine']["publicport"], - self.vm_1.username, - self.vm_1.password, + self.services['host']["publicport"], + self.services['host']["username"], + self.services['host']["password"], router.linklocalip, - 'iptables -t nat -nvx' + 'iptables -t nat -L' ) - self.debug("iptables -t nat -nvx: %s" % result) - # TODO : Find assertion condition ) + self.debug("iptables -t nat -L: %s" % result) + self.debug("Public IP: %s" % public_ip.ipaddress) + res = str(result) self.assertEqual( - result.count(str(public_ip.ipaddress)), + res.count(str(public_ip.ipaddress)), 1, "Check public IP address" ) diff --git a/tools/testClient/testcase/P1-tests/test_security_groups.py b/tools/testClient/testcase/P1-tests/test_security_groups.py index 9a6de385289..0d043907de3 100644 --- a/tools/testClient/testcase/P1-tests/test_security_groups.py +++ b/tools/testClient/testcase/P1-tests/test_security_groups.py @@ -45,7 +45,6 @@ class Services: "password": "password", "ssh_port": 22, "hypervisor": 'XenServer', - "domainid": 1, "privateport": 22, "publicport": 22, "protocol": 'TCP', @@ -81,9 +80,6 @@ class Services: # CentOS 5.3 (64-bit) "sleep": 60, "timeout": 10, - "zoneid": 2, - # Optional, if specified the mentioned zone will be - # used for tests "mode":'basic', # Networking mode: Basic or Advanced } @@ -114,6 +110,7 @@ class TestDefaultSecurityGroup(cloudstackTestCase): cls.api_client = fetch_api_client() # Get Zone, Domain and templates + cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) template = get_template( @@ -121,7 +118,7 @@ class TestDefaultSecurityGroup(cloudstackTestCase): cls.zone.id, cls.services["ostypeid"] ) - + cls.services["domainid"] = cls.domain.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.id @@ -132,7 +129,8 @@ class TestDefaultSecurityGroup(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], - admin=True + admin=True, + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -167,6 +165,7 @@ class TestDefaultSecurityGroup(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id ) self.debug("Deployed VM with ID: %s" % self.virtual_machine.id) @@ -275,6 +274,7 @@ class TestDefaultSecurityGroup(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id ) self.debug("Deployed VM with ID: %s" % self.virtual_machine.id) @@ -376,6 +376,7 @@ class TestAuthorizeIngressRule(cloudstackTestCase): cls.api_client = fetch_api_client() # Get Zone, Domain and templates + cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) template = get_template( @@ -383,7 +384,7 @@ class TestAuthorizeIngressRule(cloudstackTestCase): cls.zone.id, cls.services["ostypeid"] ) - + cls.services["domainid"] = cls.domain.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.id @@ -393,7 +394,8 @@ class TestAuthorizeIngressRule(cloudstackTestCase): ) cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name cls._cleanup = [ @@ -508,6 +510,7 @@ class TestRevokeIngressRule(cloudstackTestCase): cls.api_client = fetch_api_client() # Get Zone, Domain and templates + cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) template = get_template( @@ -515,7 +518,7 @@ class TestRevokeIngressRule(cloudstackTestCase): cls.zone.id, cls.services["ostypeid"] ) - + cls.services["domainid"] = cls.domain.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.id @@ -525,7 +528,8 @@ class TestRevokeIngressRule(cloudstackTestCase): ) cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name cls._cleanup = [ @@ -620,35 +624,21 @@ class TestRevokeIngressRule(cloudstackTestCase): self.debug("Revoking ingress rule for sec group ID: %s for ssh access" % security_group.id) - # Revoke Ingress rule from security group - result = None - timeout = self.services["timeout"] - while not isinstance(result, list): - try: - # Revoke Security group to SSH to VM - result = security_group.revoke( + # Revoke Security group to SSH to VM + result = security_group.revoke( self.apiclient, - id = ssh_rule["ruleid"] + id=ssh_rule["ruleid"] ) - self.debug("Revoke ingress rule result: %s" % result) - except Exception as e: - break - - if isinstance(result, list): - break - - if timeout == 0: - raise Exception( - "Revoke ingress rule (ID: %s) failed" % - ssh_rule["ruleid"]) - time.sleep(5) - timeout = timeout - 1 - - + # SSH Attempt to VM should fail with self.assertRaises(Exception): self.debug("SSH into VM: %s" % self.virtual_machine.id) - self.virtual_machine.get_ssh_client(reconnect=True) + remoteSSHClient.remoteSSHClient( + self.virtual_machine.ssh_ip, + self.virtual_machine.ssh_port, + self.virtual_machine.username, + self.virtual_machine.password + ) return @@ -677,6 +667,7 @@ class TestDhcpOnlyRouter(cloudstackTestCase): cls.api_client = fetch_api_client() # Get Zone, Domain and templates + cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) template = get_template( @@ -685,6 +676,7 @@ class TestDhcpOnlyRouter(cloudstackTestCase): cls.services["ostypeid"] ) + cls.services["domainid"] = cls.domain.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.id @@ -694,7 +686,8 @@ class TestDhcpOnlyRouter(cloudstackTestCase): ) cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name cls.virtual_machine = VirtualMachine.create( @@ -806,6 +799,7 @@ class TestdeployVMWithUserData(cloudstackTestCase): cls.api_client = fetch_api_client() # Get Zone, Domain and templates + cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) template = get_template( @@ -814,6 +808,7 @@ class TestdeployVMWithUserData(cloudstackTestCase): cls.services["ostypeid"] ) + cls.services["domainid"] = cls.domain.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.id @@ -823,7 +818,8 @@ class TestdeployVMWithUserData(cloudstackTestCase): ) cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name cls._cleanup = [ @@ -959,6 +955,7 @@ class TestDeleteSecurityGroup(cloudstackTestCase): self.services = Services().services # Get Zone, Domain and templates + self.domain = get_domain(self.apiclient, self.services) self.zone = get_zone(self.apiclient, self.services) template = get_template( @@ -967,6 +964,7 @@ class TestDeleteSecurityGroup(cloudstackTestCase): self.services["ostypeid"] ) + self.services["domainid"] = self.domain.id self.services["virtual_machine"]["zoneid"] = self.zone.id self.services["virtual_machine"]["template"] = template.id @@ -976,7 +974,8 @@ class TestDeleteSecurityGroup(cloudstackTestCase): ) self.account = Account.create( self.apiclient, - self.services["account"] + self.services["account"], + domainid=self.domain.id ) self.services["account"] = self.account.account.name self.cleanup = [ @@ -1078,13 +1077,24 @@ class TestDeleteSecurityGroup(cloudstackTestCase): ) self.debug("Deploying VM in account: %s" % self.account.account.name) - # Deleting Security group should raise exception - with self.assertRaises(Exception): - security_group.delete(self.apiclient) + security_group.delete(self.apiclient) + + #sleep to ensure that Security group is deleted properly + time.sleep(self.services["sleep"]) + + # Default Security group should not have any ingress rule + sercurity_groups = SecurityGroup.list( + self.apiclient, + id=security_group.id + ) + self.assertNotEqual( + sercurity_groups, + None, + "Check List Security groups response" + ) return - - + def test_02_delete_security_grp_withoout_running_vm(self): """Test delete security group without running VM""" @@ -1187,6 +1197,7 @@ class TestIngressRule(cloudstackTestCase): self.services = Services().services # Get Zone, Domain and templates + self.domain = get_domain(self.apiclient, self.services) self.zone = get_zone(self.apiclient, self.services) template = get_template( @@ -1195,6 +1206,7 @@ class TestIngressRule(cloudstackTestCase): self.services["ostypeid"] ) + self.services["domainid"] = self.domain.id self.services["virtual_machine"]["zoneid"] = self.zone.id self.services["virtual_machine"]["template"] = template.id @@ -1204,7 +1216,8 @@ class TestIngressRule(cloudstackTestCase): ) self.account = Account.create( self.apiclient, - self.services["account"] + self.services["account"], + domainid=self.domain.id ) self.services["account"] = self.account.account.name self.cleanup = [ @@ -1241,7 +1254,6 @@ class TestIngressRule(cloudstackTestCase): raise Exception("Warning: Exception during cleanup : %s" % e) return - def test_01_authorizeIngressRule_AfterDeployVM(self): """Test delete security group with running VM""" @@ -1352,7 +1364,6 @@ class TestIngressRule(cloudstackTestCase): self.fail("Ping failed for ingress rule ID: %s, %s" \ % (ingress_rule_2["id"], e)) return - def test_02_revokeIngressRule_AfterDeployVM(self): """Test Revoke ingress rule after deploy VM""" @@ -1481,30 +1492,13 @@ class TestIngressRule(cloudstackTestCase): self.account.account.name )) - # Revoke Ingress rule from security group - result = None - timeout = self.services["timeout"] - while not isinstance(result, list): - try: - # Revoke Security group to SSH to VM - result = security_group.revoke( + # Revoke Security group to SSH to VM + result = security_group.revoke( self.apiclient, id = icmp_rule["ruleid"] ) - self.debug("Revoke ingress rule result: %s" % result) - except Exception as e: - break - - if isinstance(result, list): - break - - if timeout == 0: - raise Exception( - "Revoke ingress rule (ID: %s) failed" % - icmp_rule["ruleid"]) - time.sleep(5) - timeout = timeout - 1 - + self.debug("Revoke ingress rule result: %s" % result) + time.sleep(self.services["sleep"]) # User should not be able to ping VM try: diff --git a/tools/testClient/testcase/P1-tests/test_snapshots.py b/tools/testClient/testcase/P1-tests/test_snapshots.py index e26cb90ec91..0779fba0ba1 100644 --- a/tools/testClient/testcase/P1-tests/test_snapshots.py +++ b/tools/testClient/testcase/P1-tests/test_snapshots.py @@ -45,7 +45,6 @@ class Services: "password": "password", "ssh_port": 22, "hypervisor": 'XenServer', - "domainid": 1, "privateport": 22, "publicport": 22, "protocol": 'TCP', @@ -59,7 +58,7 @@ class Services: "recurring_snapshot": { "intervaltype": 'HOURLY', # Frequency of snapshots - "maxsnaps": 2, # Should be min 2 + "maxsnaps": 1, # Should be min 2 "schedule": 1, "timezone": 'US/Arizona', # Timezone Formats - http://cloud.mindtouch.us/CloudStack_Documentation/Developer's_Guide%3A_CloudStack @@ -73,7 +72,6 @@ class Services: "diskdevice": "/dev/xvda", "diskname": "TestDiskServ", "size": 1, # GBs - "domainid": 1, "mount_dir": "/mnt/tmp", "sub_dir": "test", @@ -81,14 +79,8 @@ class Services: "sub_lvl_dir2": "test2", "random_data": "random.data", - "sec_storage": '192.168.100.131', - # IP address of Sec storage where snapshots are stored - "exportpath": 'SecondaryStorage', "ostypeid": 12, # Cent OS 5.3 (64 bit) - "zoneid": 1, - # Optional, if specified the mentioned zone will be - # used for tests "sleep": 60, "timeout": 10, "mode" : 'advanced', # Networking mode: Advanced, Basic @@ -102,6 +94,7 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase): cls.api_client = fetch_api_client() 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.template = get_template( @@ -109,6 +102,7 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase): cls.zone.id, cls.services["ostypeid"] ) + cls.services["domainid"] = cls.domain.id cls.services["server"]["zoneid"] = cls.zone.id cls.services["template"] = cls.template.id @@ -117,6 +111,7 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -179,6 +174,7 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase): self.services["server"], templateid=self.template.id, accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id ) self.debug("Created VM with ID: %s" % self.virtual_machine.id) @@ -214,6 +210,8 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase): snapshot.id, "Check snapshot id in list resources call" ) + self.debug("select backup_snap_id, account_id, volume_id from snapshots where uuid = '%s';" \ + % snapshot.id) # Verify backup_snap_id is not NULL qresultset = self.dbclient.execute( "select backup_snap_id, account_id, volume_id from snapshots where id = %s;" \ @@ -265,6 +263,7 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase): self.services["server"], templateid=template.id, accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id ) self.debug("Created VM with ID: %s from template: %s" % ( @@ -381,6 +380,7 @@ class TestAccountSnapshotClean(cloudstackTestCase): cls.api_client = fetch_api_client() 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) template = get_template( @@ -396,6 +396,7 @@ class TestAccountSnapshotClean(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -409,6 +410,7 @@ class TestAccountSnapshotClean(cloudstackTestCase): cls.services["server"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) # Get the Root disk of VM @@ -689,7 +691,9 @@ class TestSnapshotDetachedDisk(cloudstackTestCase): cls.api_client = fetch_api_client() 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.disk_offering = DiskOffering.create( cls.api_client, cls.services["disk_offering"] @@ -708,6 +712,7 @@ class TestSnapshotDetachedDisk(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -721,6 +726,7 @@ class TestSnapshotDetachedDisk(cloudstackTestCase): cls.services["server"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) @@ -957,6 +963,7 @@ class TestSnapshotLimit(cloudstackTestCase): cls.api_client = fetch_api_client() 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) template = get_template( @@ -971,7 +978,8 @@ class TestSnapshotLimit(cloudstackTestCase): # Create VMs, NAT Rules etc cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -985,6 +993,7 @@ class TestSnapshotLimit(cloudstackTestCase): cls.services["server"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) cls._cleanup = [ @@ -1198,6 +1207,7 @@ class TestSnapshotEvents(cloudstackTestCase): cls.api_client = fetch_api_client() 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) template = get_template( @@ -1213,6 +1223,7 @@ class TestSnapshotEvents(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -1226,6 +1237,7 @@ class TestSnapshotEvents(cloudstackTestCase): cls.services["server"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) @@ -1306,7 +1318,7 @@ class TestSnapshotEvents(cloudstackTestCase): snapshot.delete(self.apiclient) # Sleep to ensure that snapshot is deleted properly - time.sleep(30) + time.sleep(self.services["sleep"]) events = list_events( self.apiclient, account=self.account.account.name, @@ -1323,9 +1335,9 @@ class TestSnapshotEvents(cloudstackTestCase): None, "Check if event exists in list events call" ) - self.assertEqual( + self.assertIn( events[0].state, - 'Completed', + ['Completed', 'Scheduled'], "Check events state in list events call" ) return diff --git a/tools/testClient/testcase/P1-tests/test_templates.py b/tools/testClient/testcase/P1-tests/test_templates.py index bb51c5d5943..f3442eb4fce 100644 --- a/tools/testClient/testcase/P1-tests/test_templates.py +++ b/tools/testClient/testcase/P1-tests/test_templates.py @@ -46,7 +46,6 @@ class Services: "virtual_machine": { "displayname": "testVM", "hypervisor": 'XenServer', - "domainid": 1, "protocol": 'TCP', "ssh_port": 22, "username": "root", @@ -83,14 +82,11 @@ class Services: "ostypeid": 12, "sleep": 60, "timeout": 10, - "zoneid": 1, - # Optional, if specified the mentioned zone will be - # used for tests "mode": 'advanced', # Networking mode: Advanced, basic } -@unittest.skip("Testing is pending") +@unittest.skip("Open questions") class TestCreateTemplate(cloudstackTestCase): def setUp(self): @@ -116,6 +112,7 @@ class TestCreateTemplate(cloudstackTestCase): cls.api_client = fetch_api_client() # Get Zone, Domain and templates + cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) cls.services["virtual_machine"]["zoneid"] = cls.zone.id @@ -125,7 +122,8 @@ class TestCreateTemplate(cloudstackTestCase): ) cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -170,6 +168,7 @@ class TestCreateTemplate(cloudstackTestCase): template = Template.register( self.apiclient, v, + zoneid=self.zone.id, account=self.account.account.name, domainid=self.account.account.domainid ) @@ -228,6 +227,7 @@ class TestCreateTemplate(cloudstackTestCase): self.services["virtual_machine"], templateid=template.id, accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id, mode=self.services["mode"] ) @@ -267,6 +267,7 @@ class TestTemplates(cloudstackTestCase): cls.api_client = fetch_api_client() # Get Zone, templates etc + cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) template = get_template( @@ -277,7 +278,8 @@ class TestTemplates(cloudstackTestCase): cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -292,6 +294,7 @@ class TestTemplates(cloudstackTestCase): cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id, ) #Stop virtual machine @@ -370,6 +373,7 @@ class TestTemplates(cloudstackTestCase): self.services["virtual_machine"], templateid=self.template.id, accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id, ) @@ -452,7 +456,6 @@ class TestTemplates(cloudstackTestCase): self.apiclient.deleteTemplate(cmd) return - def test_03_delete_template(self): """Test Delete template """ @@ -565,6 +568,7 @@ class TestTemplates(cloudstackTestCase): self.services["virtual_machine"], templateid=template.id, accountid=self.account.account.name, + domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id, ) self.cleanup.append(virtual_machine) diff --git a/tools/testClient/testcase/P1-tests/test_usage.py b/tools/testClient/testcase/P1-tests/test_usage.py index af776685ae3..71a833540f3 100644 --- a/tools/testClient/testcase/P1-tests/test_usage.py +++ b/tools/testClient/testcase/P1-tests/test_usage.py @@ -42,7 +42,6 @@ class Services: }, "volume": { "diskname": "TestDiskServ", - "domainid": 1, }, "server": { "displayname": "TestVM", @@ -50,19 +49,10 @@ class Services: "password": "password", "ssh_port": 22, "hypervisor": 'XenServer', - "domainid": 1, "privateport": 22, "publicport": 22, "protocol": 'TCP', }, - "recurring_snapshot": { - "intervaltype": 'HOURLY', - # Frequency of snapshots - "maxsnaps": 1, # Should be min 2 - "schedule": 1, - "timezone": 'US/Arizona', - # Timezone Formats - http://cloud.mindtouch.us/CloudStack_Documentation/Developer's_Guide%3A_CloudStack - }, "templates": { "displaytext": 'Template', "name": 'Template', @@ -84,8 +74,8 @@ class Services: "name": "SSH", "alg": "roundrobin", # Algorithm used for load balancing - "privateport": 80, - "publicport": 80, + "privateport": 22, + "publicport": 2222, }, "natrule": { "privateport": 22, @@ -96,17 +86,14 @@ class Services: "username": "test", "password": "test", }, - "domainid": 1, "ostypeid": 12, # Cent OS 5.3 (64 bit) - "zoneid": 1, - # Optional, if specified the mentioned zone will be - # used for tests "sleep": 60, "timeout": 10, "mode":'advanced' } + class TestVmUsage(cloudstackTestCase): @classmethod @@ -114,6 +101,7 @@ class TestVmUsage(cloudstackTestCase): cls.api_client = fetch_api_client() 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) template = get_template( @@ -129,6 +117,7 @@ class TestVmUsage(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -142,6 +131,7 @@ class TestVmUsage(cloudstackTestCase): cls.services["server"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) cls._cleanup = [ @@ -264,6 +254,7 @@ class TestVmUsage(cloudstackTestCase): ) return + class TestPublicIPUsage(cloudstackTestCase): @classmethod @@ -271,6 +262,7 @@ class TestPublicIPUsage(cloudstackTestCase): cls.api_client = fetch_api_client() 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) template = get_template( @@ -286,6 +278,7 @@ class TestPublicIPUsage(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -299,6 +292,7 @@ class TestPublicIPUsage(cloudstackTestCase): cls.services["server"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) @@ -350,7 +344,7 @@ class TestPublicIPUsage(cloudstackTestCase): # 3. Delete the newly created account self.debug("Deleting public IP: %s" % - self.public_ip.ipaddesss.ipaddress) + self.public_ip.ipaddress.ipaddress) # Release one of the IP self.public_ip.delete(self.apiclient) @@ -397,6 +391,7 @@ class TestVolumeUsage(cloudstackTestCase): cls.api_client = fetch_api_client() 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.disk_offering = DiskOffering.create( cls.api_client, @@ -415,6 +410,7 @@ class TestVolumeUsage(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -428,6 +424,7 @@ class TestVolumeUsage(cloudstackTestCase): cls.services["server"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) cls._cleanup = [ @@ -508,17 +505,19 @@ class TestVolumeUsage(cloudstackTestCase): "select type from usage_event where account_id = %s;" \ % self.account.account.id ) - self.assertNotEqual( - len(qresultset), - 0, - "Check DB Query result set" - ) + self.assertEqual( isinstance(qresultset, list), True, "Check DB query result set for valid data" ) - + + self.assertNotEqual( + len(qresultset), + 0, + "Check DB Query result set" + ) + qresult = str(qresultset) self.debug("Query result: %s" % qresult) # Check VOLUME.CREATE, VOLUME.DESTROY events in cloud.usage_event table @@ -543,6 +542,7 @@ class TestTemplateUsage(cloudstackTestCase): cls.api_client = fetch_api_client() 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.services["server"]["zoneid"] = cls.zone.id template = get_template( @@ -553,7 +553,8 @@ class TestTemplateUsage(cloudstackTestCase): cls.services["server"]["zoneid"] = cls.zone.id cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -567,6 +568,7 @@ class TestTemplateUsage(cloudstackTestCase): cls.services["server"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) @@ -581,8 +583,10 @@ class TestTemplateUsage(cloudstackTestCase): virtualmachineid=cls.virtual_machine.id, type='ROOT' ) - - cls.volume = list_volume[0] + if isinstance(list_volume, list): + cls.volume = list_volume[0] + else: + raise Exception("List Volumes failed!") cls._cleanup = [ cls.account, ] @@ -647,6 +651,7 @@ class TestTemplateUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) + self.assertNotEqual( len(qresultset), 0, @@ -678,6 +683,7 @@ class TestISOUsage(cloudstackTestCase): cls.api_client = fetch_api_client() 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.services["server"]["zoneid"] = cls.zone.id cls.services["iso"]["zoneid"] = cls.zone.id @@ -685,6 +691,7 @@ class TestISOUsage(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name cls.iso = Iso.create( @@ -789,6 +796,7 @@ class TestLBRuleUsage(cloudstackTestCase): cls.api_client = fetch_api_client() 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) template = get_template( cls.api_client, @@ -803,6 +811,7 @@ class TestLBRuleUsage(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -816,6 +825,7 @@ class TestLBRuleUsage(cloudstackTestCase): cls.services["server"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) cls.public_ip_1 = PublicIPAddress.create( @@ -924,6 +934,7 @@ class TestSnapshotUsage(cloudstackTestCase): cls.api_client = fetch_api_client() 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) template = get_template( @@ -939,6 +950,7 @@ class TestSnapshotUsage(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -952,6 +964,7 @@ class TestSnapshotUsage(cloudstackTestCase): cls.services["server"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) cls._cleanup = [ @@ -1063,6 +1076,7 @@ class TestNatRuleUsage(cloudstackTestCase): cls.api_client = fetch_api_client() 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) template = get_template( cls.api_client, @@ -1077,6 +1091,7 @@ class TestNatRuleUsage(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -1090,6 +1105,7 @@ class TestNatRuleUsage(cloudstackTestCase): cls.services["server"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) cls.public_ip_1 = PublicIPAddress.create( @@ -1198,6 +1214,7 @@ class TestVpnUsage(cloudstackTestCase): cls.api_client = fetch_api_client() 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) template = get_template( cls.api_client, @@ -1212,7 +1229,8 @@ class TestVpnUsage(cloudstackTestCase): cls.account = Account.create( cls.api_client, cls.services["account"], - admin=True + admin=True, + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -1226,6 +1244,7 @@ class TestVpnUsage(cloudstackTestCase): cls.services["server"], templateid=template.id, accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) cls.public_ip = PublicIPAddress.create( @@ -1292,7 +1311,7 @@ class TestVpnUsage(cloudstackTestCase): vpnuser = VpnUser.create( self.apiclient, self.services["vpn_user"]["username"], - self.services["vpn_user"]["username"], + self.services["vpn_user"]["password"], account=self.account.account.name, domainid=self.account.account.domainid ) @@ -1301,7 +1320,7 @@ class TestVpnUsage(cloudstackTestCase): vpnuser.delete(self.apiclient) # Delete VPN access - self.debug("Deleting VPN: %s" % vpn.id) + self.debug("Deleting VPN: %s" % vpn.publicipid) vpn.delete(self.apiclient) self.debug("select type from usage_event where account_id = %s;" \ diff --git a/tools/testClient/testcase/P1-tests/test_volumes.py b/tools/testClient/testcase/P1-tests/test_volumes.py index dd95623df40..c066e7adc6f 100644 --- a/tools/testClient/testcase/P1-tests/test_volumes.py +++ b/tools/testClient/testcase/P1-tests/test_volumes.py @@ -47,13 +47,11 @@ class Services: }, "volume": { "diskname": "TestDiskServ", - "domainid": 1, "max": 6, }, "virtual_machine": { "displayname": "testVM", "hypervisor": 'XenServer', - "domainid": 1, "protocol": 'TCP', "ssh_port": 22, "username": "root", @@ -70,12 +68,8 @@ class Services: "ostypeid": 76, }, "sleep": 50, - "domainid": 1, "ostypeid": 12, - "zoneid": 2, - # Optional, if specified the mentioned zone will be - # used for tests - "mode": 'basic', + "mode": 'advanced', } @@ -87,6 +81,7 @@ class TestAttachVolume(cloudstackTestCase): 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.disk_offering = DiskOffering.create( cls.api_client, @@ -104,7 +99,8 @@ class TestAttachVolume(cloudstackTestCase): # Create VMs, NAT Rules etc cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -116,6 +112,7 @@ class TestAttachVolume(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id, ) cls._cleanup = [ @@ -148,6 +145,7 @@ class TestAttachVolume(cloudstackTestCase): self.services["volume"], zoneid=self.zone.id, account=self.account.account.name, + domainid=self.account.account.domainid, diskofferingid=self.disk_offering.id ) self.debug("Created volume: %s for account: %s" % ( @@ -294,6 +292,7 @@ class TestAttachVolume(cloudstackTestCase): self.services["volume"], zoneid=self.zone.id, account=self.account.account.name, + domainid=self.account.account.domainid, diskofferingid=self.disk_offering.id ) self.debug("Created volume: %s for account: %s" % ( @@ -367,7 +366,8 @@ class TestAttachDetachVolume(cloudstackTestCase): # Create VMs, NAT Rules etc cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -379,6 +379,7 @@ class TestAttachDetachVolume(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id, ) cls._cleanup = [ @@ -426,6 +427,7 @@ class TestAttachDetachVolume(cloudstackTestCase): self.services["volume"], zoneid=self.zone.id, account=self.account.account.name, + domainid=self.account.account.domainid, diskofferingid=self.disk_offering.id ) self.debug("Created volume: %s for account: %s" % ( @@ -589,6 +591,7 @@ class TestAttachVolumeISO(cloudstackTestCase): 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.disk_offering = DiskOffering.create( cls.api_client, @@ -607,7 +610,8 @@ class TestAttachVolumeISO(cloudstackTestCase): # Create VMs, NAT Rules etc cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -619,6 +623,7 @@ class TestAttachVolumeISO(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id, ) cls._cleanup = [ @@ -664,6 +669,7 @@ class TestAttachVolumeISO(cloudstackTestCase): self.services["volume"], zoneid=self.zone.id, account=self.account.account.name, + domainid=self.account.account.domainid, diskofferingid=self.disk_offering.id ) self.debug("Created volume: %s for account: %s" % ( @@ -774,6 +780,7 @@ class TestVolumes(cloudstackTestCase): cls.api_client = fetch_api_client() 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.disk_offering = DiskOffering.create( cls.api_client, @@ -792,7 +799,8 @@ class TestVolumes(cloudstackTestCase): # Create VMs, VMs etc cls.account = Account.create( cls.api_client, - cls.services["account"] + cls.services["account"], + domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name @@ -804,6 +812,7 @@ class TestVolumes(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.account.name, + domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id, ) @@ -812,6 +821,7 @@ class TestVolumes(cloudstackTestCase): cls.services["volume"], zoneid=cls.zone.id, account=cls.account.account.name, + domainid=cls.account.account.domainid, diskofferingid=cls.disk_offering.id ) cls._cleanup = [ diff --git a/tools/testClient/testcase/libs/base.py b/tools/testClient/testcase/libs/base.py index 07c410f258e..1ab3b252355 100644 --- a/tools/testClient/testcase/libs/base.py +++ b/tools/testClient/testcase/libs/base.py @@ -264,13 +264,16 @@ class VirtualMachine: cmd.id = self.id apiclient.rebootVirtualMachine(cmd) - def get_ssh_client(self, ipaddress=None, reconnect=False): + def get_ssh_client(self, ipaddress=None, reconnect=False, port=None): """Get SSH object of VM""" # If NAT Rules are not created while VM deployment in Advanced mode # then, IP address must be passed if ipaddress != None: self.ssh_ip = ipaddress + if port: + self.ssh_port = port + if reconnect: self.ssh_client = is_server_ssh_ready( self.ssh_ip, @@ -469,7 +472,7 @@ class Template: return Template(apiclient.createTemplate(cmd).__dict__) @classmethod - def register(cls, apiclient, services, account=None, domainid=None): + def register(cls, apiclient, services, zoneid=None, account=None, domainid=None): """Create template from URL""" #Create template from Virtual machine and Volume ID @@ -480,7 +483,11 @@ class Template: cmd.hypervisor = services["hypervisor"] cmd.ostypeid = services["ostypeid"] cmd.url = services["url"] - cmd.zoneid = services["zoneid"] + + if zoneid: + cmd.zoneid = zoneid + else: + cmd.zoneid = services["zoneid"] cmd.isfeatured = services["isfeatured"] if "isfeatured" in services else False cmd.ispublic = services["ispublic"] if "ispublic" in services else False @@ -519,10 +526,10 @@ class Template: cmd.id = self.id apiclient.deleteTemplate(cmd) - def download(self, apiclient, timeout=5): + def download(self, apiclient, timeout=5, interval=60): """Download Template""" #Sleep to ensure template is in proper state before download - time.sleep(30) + time.sleep(interval) while True: template_response = Template.list( @@ -538,22 +545,20 @@ class Template: # template.status = Download Complete # Downloading - x% Downloaded # Error - Any other string - - if template.status == 'Download Complete' : + if template.status == 'Download Complete': break - elif 'Downloaded' not in template.status.split() or \ - 'Installing' not in template.status.split(): + elif 'Downloaded' in template.status: + time.sleep(interval) + + elif 'Installing' not in template.status: raise Exception("ErrorInDownload") - - elif 'Downloaded' in template.status.split(): - time.sleep(10) - + elif timeout == 0: break else: - time.sleep(10) + time.sleep(interval) timeout = timeout - 1 return @@ -607,11 +612,11 @@ class Iso: apiclient.deleteIso(cmd) return - def download(self, apiclient, timeout=5): + def download(self, apiclient, timeout=5, interval=60): """Download an ISO""" #Ensuring ISO is successfully downloaded while True: - time.sleep(60) + time.sleep(interval) cmd = listIsos.listIsosCmd() cmd.id = self.id @@ -626,8 +631,9 @@ class Iso: # or ISO is 'Successfully Installed' if response.status == 'Successfully Installed': return - elif 'Downloaded' not in response.status.split(): + elif 'Downloaded' not in response.status: raise Exception("ErrorInDownload") + elif timeout == 0: raise Exception("TimeoutException") else: @@ -1073,6 +1079,13 @@ class Host: apiclient.deleteHost(cmd) return + def enableMaintenance(self, apiclient): + """enables maintainance mode Host""" + + cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd() + cmd.id = self.id + return apiclient.prepareHostForMaintenance(cmd) + @classmethod def list(cls, apiclient, **kwargs): """List all Hosts matching criteria""" @@ -1126,6 +1139,13 @@ class StoragePool: apiclient.deleteStoragePool(cmd) return + def enableMaintenance(self, apiclient): + """enables maintainance mode Storage pool""" + + cmd = enableStorageMaintenance.enableStorageMaintenanceCmd() + cmd.id = self.id + return apiclient.enableStorageMaintenance(cmd) + @classmethod def list(cls, apiclient, **kwargs): """List all storage pools matching criteria""" @@ -1223,6 +1243,8 @@ class VpnUser: cmd = removeVpnUser.removeVpnUserCmd() cmd.username = self.username + cmd.account = self.account + cmd.domainid = self.domainid apiclient.removeVpnUser(cmd) @@ -1257,6 +1279,15 @@ class Zone: cmd.id = self.id apiclient.deleteZone(cmd) + def update(self, apiclient, **kwargs): + """Update the zone""" + + cmd = updateZone.updateZoneCmd() + cmd.id = self.id + [setattr(cmd, k, v) for k, v in kwargs.items()] + return apiclient.updateZone(cmd) + + @classmethod def list(cls, apiclient, **kwargs): """List all Zones matching criteria""" diff --git a/tools/testClient/testcase/libs/common.py b/tools/testClient/testcase/libs/common.py index 706f3c88ab6..701651c82d5 100644 --- a/tools/testClient/testcase/libs/common.py +++ b/tools/testClient/testcase/libs/common.py @@ -16,6 +16,21 @@ from base import * #Import System modules import time +def get_domain(apiclient, services=None): + "Returns a default domain" + + cmd = listDomains.listDomainsCmd() + if services: + if "domainid" in services: + cmd.id = services["domainid"] + + domains = apiclient.listDomains(cmd) + + if isinstance(domains, list): + return domains[0] + else: + raise Exception("Failed to find specified domain.") + def get_zone(apiclient, services=None): "Returns a default zone" @@ -99,9 +114,7 @@ def download_systemplates_sec_storage(server, services): ) ] for c in cmds: - print c result = ssh.execute(c) - print result res = str(result) @@ -114,10 +127,10 @@ def download_systemplates_sec_storage(server, services): raise Exception("Failed to download System Templates on Sec Storage") return -def wait_for_ssvms(apiclient, zoneid, podid): +def wait_for_ssvms(apiclient, zoneid, podid, interval=60): """After setup wait for SSVMs to come Up""" - time.sleep(30) + time.sleep(interval) timeout = 40 while True: list_ssvm_response = list_ssvms( @@ -134,10 +147,10 @@ def wait_for_ssvms(apiclient, zoneid, podid): elif ssvm.state == 'Running': break elif timeout == 0: - raise Exception("SSVM failled to come up") + raise Exception("SSVM failed to come up") break - timeout = 20 + timeout = 40 while True: list_ssvm_response = list_ssvms( apiclient, @@ -148,16 +161,16 @@ def wait_for_ssvms(apiclient, zoneid, podid): cpvm = list_ssvm_response[0] if cpvm.state != 'Running': # Sleep to ensure SSVMs are Up and Running - time.sleep(30) + time.sleep(interval) timeout = timeout - 1 elif cpvm.state == 'Running': break elif timeout == 0: - raise Exception("SSVM failled to come up") + raise Exception("CPVM failed to come up") break return -def download_builtin_templates(apiclient, zoneid, hypervisor, host, linklocalip): +def download_builtin_templates(apiclient, zoneid, hypervisor, host, linklocalip, interval=60): """After setup wait till builtin templates are downloaded""" # Change IPTABLES Rules @@ -169,7 +182,7 @@ def download_builtin_templates(apiclient, zoneid, hypervisor, host, linklocalip) linklocalip, "iptables -P INPUT ACCEPT" ) - + time.sleep(interval) # Find the BUILTIN Templates for given Zone, Hypervisor list_template_response = list_templates( apiclient, @@ -189,7 +202,7 @@ def download_builtin_templates(apiclient, zoneid, hypervisor, host, linklocalip) # Sleep to ensure that template is in downloading state after adding # Sec storage - time.sleep(30) + time.sleep(interval) while True: template_response = list_templates( apiclient, @@ -202,12 +215,15 @@ def download_builtin_templates(apiclient, zoneid, hypervisor, host, linklocalip) # template.status = Download Complete # Downloading - x% Downloaded # Error - Any other string - if template.status == 'Download Complete' : + if template.status == 'Download Complete': break - elif 'Downloaded' not in template.status.split(): + + elif 'Downloaded' in template.status: + time.sleep(interval) + + elif 'Installing' not in template.status: raise Exception("ErrorInDownload") - elif 'Downloaded' in template.status.split(): - time.sleep(30) + return def update_resource_limit(apiclient, resourcetype, account=None, domainid=None,