From b433b1afa605b4e8f25f0ff30032fee55a91121f Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Fri, 6 Jul 2012 16:50:20 +0530 Subject: [PATCH] Various fixes to tests - Configuration fixes in Security groups and Egress rules - Fixing white spaces in component test suite --- test/integration/component/test_accounts.py | 84 ++-- .../component/test_blocker_bugs.py | 148 +++--- .../component/test_egress_rules.py | 56 +-- test/integration/component/test_eip_elb.py | 22 +- .../component/test_high_availability.py | 18 +- .../component/test_network_offering.py | 58 ++- .../component/test_project_configs.py | 216 ++++----- .../component/test_project_limits.py | 83 ++-- .../component/test_project_resources.py | 149 +++--- .../component/test_project_usage.py | 163 ++++--- test/integration/component/test_projects.py | 347 +++++++------- .../component/test_resource_limits.py | 158 +++---- test/integration/component/test_routers.py | 27 +- .../component/test_security_groups.py | 426 +++++++++--------- test/integration/component/test_snapshots.py | 91 ++-- test/integration/component/test_templates.py | 54 +-- test/integration/component/test_usage.py | 133 +++--- test/integration/component/test_volumes.py | 56 +-- 18 files changed, 1176 insertions(+), 1113 deletions(-) diff --git a/test/integration/component/test_accounts.py b/test/integration/component/test_accounts.py index b8ce4c4b342..7aebbefc147 100644 --- a/test/integration/component/test_accounts.py +++ b/test/integration/component/test_accounts.py @@ -57,8 +57,8 @@ class Services: "name": "Tiny Instance", "displaytext": "Tiny Instance", "cpunumber": 1, - "cpuspeed": 100, # in MHz - "memory": 64, # In MBs + "cpuspeed": 100, # in MHz + "memory": 64, # In MBs }, "virtual_machine": { "displayname": "Test VM", @@ -78,7 +78,7 @@ class Services: "ostypeid": 'aaf6e8c9-b609-441d-9ebd-b4eaa030a275', "url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2", "hypervisor": 'XenServer', - "format" : 'VHD', + "format": 'VHD', "isfeatured": True, "ispublic": True, "isextractable": True, @@ -87,7 +87,7 @@ class Services: # Cent OS 5.3 (64 bit) "sleep": 60, "timeout": 10, - "mode":'advanced' + "mode": 'advanced' } @@ -138,9 +138,9 @@ class TestAccounts(cloudstackTestCase): return def test_01_create_account(self): - """Test Create Account and user for that account + """Test Create Account and user for that account """ - + tags = ["advanced", "basic", "eip", "advancedns", "sg"] # Validate the following @@ -273,9 +273,9 @@ class TestRemoveUserFromAccount(cloudstackTestCase): return def test_01_user_remove_VM_running(self): - """Test Remove one user from the account + """Test Remove one user from the account """ - + tags = ["advanced", "basic", "eip", "advancedns", "sg"] # Validate the following @@ -337,8 +337,8 @@ class TestRemoveUserFromAccount(cloudstackTestCase): id=self.account.account.id ) self.assertEqual( - isinstance(accounts_response, list), - True, + isinstance(accounts_response, list), + True, "Check for valid list accounts response" ) @@ -353,8 +353,8 @@ class TestRemoveUserFromAccount(cloudstackTestCase): domainid=self.account.account.domainid ) self.assertEqual( - isinstance(vm_response, list), - True, + isinstance(vm_response, list), + True, "Check for valid list VM response" ) @@ -372,11 +372,12 @@ 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 + """Test Remove both users from the account """ - + tags = ["advanced", "basic", "eip", "advancedns", "sg"] # Validate the following @@ -427,12 +428,12 @@ class TestRemoveUserFromAccount(cloudstackTestCase): domainid=self.account.account.domainid ) self.assertEqual( - isinstance(users, list), - True, + isinstance(users, list), + True, "Check for valid list users response" ) for user in users: - + self.debug("Deleting user: %s" % user.id) cmd = deleteUser.deleteUserCmd() cmd.id = user.id @@ -443,12 +444,12 @@ class TestRemoveUserFromAccount(cloudstackTestCase): name='account.cleanup.interval' ) self.assertEqual( - isinstance(interval, list), - True, + isinstance(interval, list), + True, "Check for valid list configurations response" ) self.debug("account.cleanup.interval: %s" % interval[0].value) - + # Sleep to ensure that all resources are deleted time.sleep(int(interval[0].value)) @@ -534,7 +535,7 @@ class TestNonRootAdminsPrivileges(cloudstackTestCase): def test_01_non_root_admin_Privileges(self): """Test to verify Non Root admin previleges""" - + tags = ["advanced", "basic", "eip", "advancedns", "sg"] # Validate the following @@ -562,11 +563,11 @@ class TestNonRootAdminsPrivileges(cloudstackTestCase): ) self.assertEqual( - isinstance(accounts_response, list), - True, + isinstance(accounts_response, list), + True, "Check list accounts response for valid data" ) - + self.assertEqual( len(accounts_response), 1, @@ -653,7 +654,7 @@ class TestServiceOfferingSiblings(cloudstackTestCase): def test_01_service_offering_siblings(self): """Test to verify service offerings at same level in hierarchy""" - + tags = ["advanced", "basic", "eip", "advancedns", "sg"] # Validate the following @@ -665,11 +666,11 @@ class TestServiceOfferingSiblings(cloudstackTestCase): domainid=self.domain_1.id ) self.assertEqual( - isinstance(service_offerings, list), - True, + isinstance(service_offerings, list), + True, "Check if valid list service offerings response" ) - + self.assertNotEqual( len(service_offerings), 0, @@ -695,6 +696,7 @@ class TestServiceOfferingSiblings(cloudstackTestCase): ) return + @unittest.skip("Open Questions") class TestServiceOfferingHierarchy(cloudstackTestCase): @@ -768,7 +770,7 @@ class TestServiceOfferingHierarchy(cloudstackTestCase): def test_01_service_offering_hierarchy(self): """Test to verify service offerings at same level in hierarchy""" - + tags = ["advanced", "basic", "eip", "advancedns", "sg"] # Validate the following @@ -821,6 +823,7 @@ class TestServiceOfferingHierarchy(cloudstackTestCase): ) return + @unittest.skip("Open Questions") class TesttemplateHierarchy(cloudstackTestCase): @@ -899,7 +902,7 @@ class TesttemplateHierarchy(cloudstackTestCase): def test_01_template_hierarchy(self): """Test to verify template at same level in hierarchy""" - + tags = ["advanced", "basic", "eip", "advancedns", "sg"] # Validate the following @@ -959,6 +962,7 @@ class TesttemplateHierarchy(cloudstackTestCase): ) return + class TestAddVmToSubDomain(cloudstackTestCase): @classmethod @@ -1026,19 +1030,20 @@ class TestAddVmToSubDomain(cloudstackTestCase): serviceofferingid=cls.service_offering.id ) cls._cleanup = [ - cls.account_2, - cls.account_1, - cls.sub_domain, - cls.service_offering - ] + cls.account_2, + cls.account_1, + cls.sub_domain, + cls.service_offering + ] return @classmethod def tearDownClass(cls): - try: + try: #Clean up, terminate the created resources - cleanup_resources(cls.api_client,cls._cleanup) - except Exception as e: + cleanup_resources(cls.api_client, cls._cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) return @@ -1056,11 +1061,10 @@ class TestAddVmToSubDomain(cloudstackTestCase): raise Exception("Warning: Exception during cleanup : %s" % e) return - def test_01_add_vm_to_subdomain(self): """ Test Sub domain allowed to launch VM when a Domain level zone is created""" - + tags = ["advanced", "basic", "eip", "advancedns", "sg"] # Validate the following diff --git a/test/integration/component/test_blocker_bugs.py b/test/integration/component/test_blocker_bugs.py index 755b3e2be28..63738198a6e 100644 --- a/test/integration/component/test_blocker_bugs.py +++ b/test/integration/component/test_blocker_bugs.py @@ -26,6 +26,7 @@ from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * from marvin.remoteSSHClient import remoteSSHClient + class Services: """Test Services """ @@ -48,8 +49,8 @@ class Services: "name": "Tiny Instance", "displaytext": "Tiny Instance", "cpunumber": 1, - "cpuspeed": 100, # in MHz - "memory": 64, # In MBs + "cpuspeed": 100, # in MHz + "memory": 64, # In MBs }, "disk_offering": { "displaytext": "Small", @@ -69,7 +70,7 @@ class Services: "volume": { "diskname": "APP Data Volume", "size": 1, # in GBs - "diskdevice": "/dev/xvdb", # Data Disk + "diskdevice": "/dev/xvdb", # Data Disk }, "templates": { "displaytext": 'Template from snapshot', @@ -78,11 +79,11 @@ class Services: "templatefilter": 'self', "url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2", "hypervisor": 'XenServer', - "format" : 'VHD', + "format": 'VHD', "isfeatured": True, "ispublic": True, "isextractable": True, - "passwordenabled":True, + "passwordenabled": True, }, "paths": { "mount_dir": "/mnt/tmp", @@ -97,12 +98,12 @@ class Services: "protocol": "TCP" }, "ostypeid": '144f66aa-7f74-4cfe-9799-80cc21439cb3', - # Cent OS 5.3 (64 bit) - "sleep":60, + # Cent OS 5.3 (64 bit) + "sleep": 60, "mode": 'advanced', # Networking mode, Advanced, Basic } - + class TestSnapshots(cloudstackTestCase): @@ -124,10 +125,10 @@ class TestSnapshots(cloudstackTestCase): ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["volume"]["zoneid"] = cls.zone.id - + cls.services["template"] = cls.template.id cls.services["zoneid"] = cls.zone.id - + # Create VMs, NAT Rules etc cls.account = Account.create( cls.api_client, @@ -184,9 +185,9 @@ class TestSnapshots(cloudstackTestCase): def test_01_volume_from_snapshot(self): """TS_BUG_001-Test Creating snapshot from volume having spaces in name(KVM) """ - + tags = ["advanced", "advancedns"] - + # Validate the following #1. Create a virtual machine and data volume #2. Attach data volume to VM @@ -195,31 +196,31 @@ class TestSnapshots(cloudstackTestCase): #5. Create another Volume from snapshot #6. Mount/Attach volume to another server #7. Compare data - + random_data_0 = random_gen(100) random_data_1 = random_gen(100) - + volume = Volume.create( - self.apiclient, - self.services["volume"], - zoneid=self.zone.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + self.apiclient, + 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 with ID: %s" % volume.id) self.virtual_machine.attach_volume( self.apiclient, volume - ) - self.debug("Attach volume: %s to VM: %s" % + ) + self.debug("Attach volume: %s to VM: %s" % (volume.id, self.virtual_machine.id)) try: ssh_client = self.virtual_machine.get_ssh_client() except Exception as e: - self.fail("SSH failed for VM: %s" % + self.fail("SSH failed for VM: %s" % self.virtual_machine.ipaddress) - + self.debug("Formatting volume: %s to ext3" % volume.id) #Format partition using ext3 format_volume_to_ext3( @@ -273,8 +274,8 @@ class TestSnapshots(cloudstackTestCase): ) self.assertEqual( - isinstance(list_volume_response, list), - True, + isinstance(list_volume_response, list), + True, "Check list volume response for valid data" ) volume_response = list_volume_response[0] @@ -295,7 +296,7 @@ class TestSnapshots(cloudstackTestCase): domainid=self.account.account.domainid ) self.debug("Created Volume: %s from Snapshot: %s" % ( - volume_from_snapshot.id, + volume_from_snapshot.id, snapshot.id)) volumes = Volume.list( self.apiclient, @@ -306,13 +307,13 @@ class TestSnapshots(cloudstackTestCase): True, "Check list response returns a valid list" ) - + self.assertNotEqual( len(volumes), None, "Check Volume list Length" ) - self.assertEqual ( + self.assertEqual( volumes[0].id, volume_from_snapshot.id, "Check Volume in the List Volumes" @@ -334,7 +335,7 @@ class TestSnapshots(cloudstackTestCase): volume_from_snapshot.id, new_virtual_machine.id )) - + cmd = attachVolume.attachVolumeCmd() cmd.id = volume_from_snapshot.id cmd.virtualmachineid = new_virtual_machine.id @@ -343,7 +344,7 @@ class TestSnapshots(cloudstackTestCase): try: #Login to VM to verify test directories and files ssh = new_virtual_machine.get_ssh_client() - + cmds = [ "mkdir -p %s" % self.services["paths"]["mount_dir"], "mount %s1 %s" % ( @@ -371,7 +372,7 @@ class TestSnapshots(cloudstackTestCase): self.services["paths"]["random_data"] )) except Exception as e: - self.fail("SSH access failed for VM: %s" % + self.fail("SSH access failed for VM: %s" % new_virtual_machine.ipaddress) #Verify returned data self.assertEqual( @@ -423,7 +424,7 @@ class TestTemplate(cloudstackTestCase): cls.zone = get_zone(cls.api_client, cls.services) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["templates"]["zoneid"] = cls.zone.id - + cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] @@ -456,7 +457,7 @@ class TestTemplate(cloudstackTestCase): def test_01_create_template(self): """TS_BUG_002-Test to create and deploy VM using password enabled template """ - + tags = ["advanced", "advancedns", "basic", "sg"] # Validate the following: @@ -479,13 +480,13 @@ class TestTemplate(cloudstackTestCase): template.download(self.apiclient) except Exception as e: self.fail("Exception while downloading template %s: %s"\ - % (template.id, e)) - + % (template.id, e)) + self.cleanup.append(template) # Wait for template status to be changed across time.sleep(self.services["sleep"]) - + list_template_response = Template.list( self.apiclient, templatefilter=\ @@ -493,7 +494,7 @@ class TestTemplate(cloudstackTestCase): id=template.id, zoneid=self.zone.id ) - + self.assertEqual( isinstance(list_template_response, list), True, @@ -524,7 +525,7 @@ class TestTemplate(cloudstackTestCase): ) self.debug("Deployed VM with ID: %s " % virtual_machine.id) self.assertEqual( - hasattr(virtual_machine,"password"), + hasattr(virtual_machine, "password"), True, "Check if the deployed VM returned a password" ) @@ -532,7 +533,7 @@ class TestTemplate(cloudstackTestCase): class TestNATRules(cloudstackTestCase): - + @classmethod def setUpClass(cls): @@ -568,10 +569,10 @@ class TestNATRules(cloudstackTestCase): serviceofferingid=cls.service_offering.id ) cls.public_ip = PublicIPAddress.create( - cls.api_client, - accountid=cls.account.account.name, - zoneid=cls.zone.id, - domainid=cls.account.account.domainid, + cls.api_client, + accountid=cls.account.account.name, + zoneid=cls.zone.id, + domainid=cls.account.account.domainid, services=cls.services["virtual_machine"] ) cls._cleanup = [ @@ -600,25 +601,25 @@ class TestNATRules(cloudstackTestCase): def test_01_firewall_rules_port_fw(self): """"Checking firewall rules deletion after static NAT disable""" - + tags = ["advanced"] # Validate the following: #1. Enable static NAT for a VM #2. Open up some ports. At this point there will be new rows in the - # firewall_rules table. + # firewall_rules table. #3. Disable static NAT for the VM. #4. Check fire wall rules are deleted from firewall_rules table. public_ip = self.public_ip.ipaddress - + # Enable Static NAT for VM StaticNATRule.enable( self.apiclient, public_ip.id, self.virtual_machine.id - ) - self.debug("Enabled static NAT for public IP ID: %s" % + ) + self.debug("Enabled static NAT for public IP ID: %s" % public_ip.id) #Create Static NAT rule nat_rule = StaticNATRule.create( @@ -661,7 +662,7 @@ class TestNATRules(cloudstackTestCase): True, "Check database query returns a valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -683,20 +684,20 @@ class TestNATRules(cloudstackTestCase): True, "Check database query returns a valid data for firewall rules" ) - + self.assertNotEqual( len(qresultset), 0, "Check DB Query result set" ) - + for qresult in qresultset: self.assertEqual( qresult[1], 'Active', "Check state of the static NAT rule in database" ) - + nat_rule.delete(self.apiclient) list_rules_repsonse = StaticNATRule.list( @@ -709,7 +710,7 @@ class TestNATRules(cloudstackTestCase): None, "Check Port Forwarding Rule is deleted" ) - + # Verify the entries made in firewall_rules tables self.debug( "select id, state from firewall_rules where ip_address_id = '%s';" \ @@ -719,7 +720,7 @@ class TestNATRules(cloudstackTestCase): "select id, state from firewall_rules where ip_address_id = '%s';" \ % public_ip.id ) - + self.assertEqual( len(qresultset), 0, @@ -741,7 +742,7 @@ class TestRouters(cloudstackTestCase): cls.zone.id, cls.services["ostypeid"] ) - + # Create an account, domain etc cls.domain = Domain.create( cls.api_client, @@ -753,7 +754,7 @@ class TestRouters(cloudstackTestCase): admin=True, domainid=cls.domain.id ) - + cls.user_account = Account.create( cls.api_client, cls.services["account"], @@ -802,13 +803,13 @@ class TestRouters(cloudstackTestCase): def test_01_list_routers_admin(self): """TS_BUG_007-Check listRouters() using Admin User """ - + tags = ["advanced", "advancedns"] # Validate the following # 1. PreReq: have rounters that are owned by other account - # 2. Create domain and create accounts in that domain - # 3. Create one VM for each account + # 2. Create domain and create accounts in that domain + # 3. Create one VM for each account # 4. Using Admin , run listRouters. It should return all the routers vm_1 = VirtualMachine.create( @@ -909,11 +910,10 @@ class TestRouterRestart(cloudstackTestCase): self.apiclient = self.testClient.getApiClient() return - def test_01_restart_network_cleanup(self): """TS_BUG_008-Test restart network """ - + tags = ["advanced", "basic", "sg", "advancedns", "eip"] # Validate the following @@ -1036,7 +1036,7 @@ class TestTemplates(cloudstackTestCase): cls.volume = list_volume[0] except Exception as e: raise Exception("Warning: Exception during setup : %s" % e) - + cls._cleanup = [ cls.service_offering, cls.account, @@ -1074,13 +1074,13 @@ class TestTemplates(cloudstackTestCase): def test_01_check_template_size(self): """TS_BUG_009-Test the size of template created from root disk """ - + tags = ["advanced", "advancedns", "basic", "sg", "eip"] # Validate the following: # 1. Deploy new VM using the template created from Volume # 2. VM should be in Up and Running state - + #Create template from volume template = Template.create( self.apiclient, @@ -1097,11 +1097,11 @@ class TestTemplates(cloudstackTestCase): "Check if size of template and volume are same" ) return - + def test_02_check_size_snapshotTemplate(self): """TS_BUG_010-Test check size of snapshot and template """ - + tags = ["advanced", "advancedns", "basic", "sg", "eip"] # Validate the following @@ -1113,7 +1113,7 @@ class TestTemplates(cloudstackTestCase): # Create a snapshot from the ROOTDISK snapshot = Snapshot.create( - self.apiclient, + self.apiclient, self.volume.id, account=self.account.account.name, domainid=self.account.account.domainid @@ -1146,7 +1146,7 @@ class TestTemplates(cloudstackTestCase): self.services["templates"] ) self.cleanup.append(template) - + self.debug("Created template from snapshot with ID: %s" % template.id) templates = Template.list( self.apiclient, @@ -1181,7 +1181,7 @@ class TestTemplates(cloudstackTestCase): def test_03_resuse_template_name(self): """TS_BUG_011-Test Reusing deleted template name """ - + tags = ["advanced", "advancedns", "basic", "sg", "eip"] # Validate the following @@ -1250,15 +1250,15 @@ class TestTemplates(cloudstackTestCase): True, "Check new template state in list templates call" ) - + self.debug("Deleting template: %s" % template.id) template.delete(self.apiclient) - - # Wait for some time to ensure template state is reflected in other calls + + # Wait for some time to ensure template state is reflected in other calls time.sleep(self.services["sleep"]) - + # Generate template from the snapshot - self.debug("Creating template from snapshot: %s with same name" % + self.debug("Creating template from snapshot: %s with same name" % template.id) template = Template.create_from_snapshot( self.apiclient, diff --git a/test/integration/component/test_egress_rules.py b/test/integration/component/test_egress_rules.py index f7a9b11361d..9a9c08f6a84 100644 --- a/test/integration/component/test_egress_rules.py +++ b/test/integration/component/test_egress_rules.py @@ -37,7 +37,7 @@ class Services: def __init__(self): self.services = { - "disk_offering":{ + "disk_offering": { "displaytext": "Small", "name": "Small", "disksize": 1 @@ -67,8 +67,8 @@ class Services: "name": "Tiny Instance", "displaytext": "Tiny Instance", "cpunumber": 1, - "cpuspeed": 100, # in MHz - "memory": 64, # In MBs + "cpuspeed": 100, # in MHz + "memory": 64, # In MBs }, "security_group": { "name": 'SSH', @@ -110,8 +110,9 @@ class Services: "protocol": 'TCP', "startport": 22, "endport": 22, + "cidrlist": '0.0.0.0/0' }, - "mgmt_server": { + "mgmt_server": { "username": "root", "password": "fr3sca", "ipaddress": "192.168.100.21" @@ -120,7 +121,7 @@ class Services: # CentOS 5.3 (64-bit) "sleep": 60, "timeout": 10, - "mode":'basic', + "mode": 'basic', # Networking mode: Basic or Advanced } @@ -197,7 +198,7 @@ class TestDefaultSecurityGroupEgress(cloudstackTestCase): def test_deployVM_InDefaultSecurityGroup(self): """Test deploy VM in default security group with no egress rules """ - + tags = ["sg", "eip"] # Validate the following: @@ -354,7 +355,7 @@ class TestAuthorizeIngressRule(cloudstackTestCase): def test_authorizeIngressRule(self): """Test authorize ingress rule """ - + tags = ["sg", "eip"] # Validate the following: @@ -512,7 +513,7 @@ class TestDefaultGroupEgress(cloudstackTestCase): def test_01_default_group_with_egress(self): """Test default group with egress rule before VM deploy and ping, ssh """ - + tags = ["sg", "eip"] # Validate the following: @@ -714,7 +715,7 @@ class TestDefaultGroupEgressAfterDeploy(cloudstackTestCase): """ Test default group with egress rule added after vm deploy and ping, ssh test """ - + tags = ["sg", "eip"] # Validate the following: @@ -811,7 +812,7 @@ class TestDefaultGroupEgressAfterDeploy(cloudstackTestCase): # --- www.l.google.com ping statistics --- # 1 packets transmitted, 1 received, 0% packet loss, time 0ms # rtt min/avg/max/mdev = 25.970/25.970/25.970/0.000 ms - self.debug("SSH result: %s" % str(res)) + self.debug("SSH result: %s" % str(res)) except Exception as e: self.fail("SSH Access failed for %s: %s" % \ (self.virtual_machine.ipaddress, e) @@ -896,7 +897,7 @@ class TestRevokeEgressRule(cloudstackTestCase): def test_revoke_egress_rule(self): """Test revoke security group egress rule """ - + tags = ["sg", "eip"] # Validate the following: @@ -997,7 +998,7 @@ class TestRevokeEgressRule(cloudstackTestCase): # --- www.l.google.com ping statistics --- # 1 packets transmitted, 1 received, 0% packet loss, time 0ms # rtt min/avg/max/mdev = 25.970/25.970/25.970/0.000 ms - self.debug("SSH result: %s" % str(res)) + self.debug("SSH result: %s" % str(res)) except Exception as e: self.fail("SSH Access failed for %s: %s" % \ (self.virtual_machine.ipaddress, e) @@ -1038,7 +1039,7 @@ class TestRevokeEgressRule(cloudstackTestCase): result = security_group.revokeEgress( self.apiclient, - id = ssh_egress_rule["ruleid"] + id=ssh_egress_rule["ruleid"] ) self.debug("Revoke egress rule result: %s" % result) @@ -1158,7 +1159,7 @@ class TestInvalidAccountAuthroize(cloudstackTestCase): def test_invalid_account_authroize(self): """Test invalid account authroize """ - + tags = ["sg", "eip"] # Validate the following: @@ -1286,7 +1287,7 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase): def test_multiple_account_egress_rule_negative(self): """Test multiple account egress rules negative case """ - + tags = ["sg", "eip"] # Validate the following: @@ -1335,14 +1336,14 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase): "Authorizing egress rule for sec group ID: %s for ssh access" % security_group.id) # Authorize to only account not CIDR - user_secgrp_list = {self.accountB.account.name: 'default'} + user_secgrp_list = {self.accountB.account.name: 'default'} egress_rule = security_group.authorizeEgress( self.apiclient, self.services["sg_account"], account=self.accountA.account.name, domainid=self.accountA.account.domainid, - user_secgrp_list=user_secgrp_list + user_secgrp_list=user_secgrp_list ) self.assertEqual( @@ -1438,7 +1439,7 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase): try: self.debug("SSHing into VM type B from VM A") - self.debug("VM IP: %s" % self.virtual_machineB.ssh_ip) + self.debug("VM IP: %s" % self.virtual_machineB.ssh_ip) res = ssh.execute("ssh %s@%s" % ( self.services["virtual_machine"]["username"], self.virtual_machineB.ssh_ip @@ -1534,7 +1535,7 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase): def test_multiple_account_egress_rule_positive(self): """Test multiple account egress rules positive case """ - + tags = ["sg", "eip"] # Validate the following: @@ -1610,14 +1611,14 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase): "Authorizing egress rule for sec group ID: %s for ssh access" % security_groupA.id) # Authorize to only account not CIDR - user_secgrp_list = {self.accountB.account.name: security_groupB.name} + user_secgrp_list = {self.accountB.account.name: security_groupB.name} egress_rule = security_groupA.authorizeEgress( self.apiclient, self.services["sg_account"], account=self.accountA.account.name, domainid=self.accountA.account.domainid, - user_secgrp_list=user_secgrp_list + user_secgrp_list=user_secgrp_list ) self.assertEqual( @@ -1734,7 +1735,7 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase): try: self.debug("SSHing into VB type B from VM A") - self.debug("VM IP: %s" % self.virtual_machineB.ssh_ip) + self.debug("VM IP: %s" % self.virtual_machineB.ssh_ip) res = ssh.execute("ssh %s@%s" % ( self.services["virtual_machine"]["username"], @@ -1825,7 +1826,7 @@ class TestStartStopVMWithEgressRule(cloudstackTestCase): def test_start_stop_vm_egress(self): """ Test stop start Vm with egress rules """ - + tags = ["sg", "eip"] # Validate the following: @@ -1965,6 +1966,7 @@ class TestStartStopVMWithEgressRule(cloudstackTestCase): ) return + @unittest.skip("Valid bug- ID: CS-12647") class TestInvalidParametersForEgress(cloudstackTestCase): @@ -2036,7 +2038,7 @@ class TestInvalidParametersForEgress(cloudstackTestCase): def test_invalid_parameters(self): """ Test invalid parameters for egress rules """ - + tags = ["sg", "eip"] # Validate the following: @@ -2223,7 +2225,7 @@ class TestEgressAfterHostMaintainance(cloudstackTestCase): def test_egress_after_host_maintainance(self): """Test maintenance case for egress """ - + tags = ["sg", "eip"] # Validate the following: @@ -2329,12 +2331,12 @@ class TestEgressAfterHostMaintainance(cloudstackTestCase): ) vm = vms[0] - self.debug("Enabling host maintainance for ID: %s" % host.id) + self.debug("Enabling host maintainance for ID: %s" % vm.hostid) cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd() cmd.id = vm.hostid self.apiclient.prepareHostForMaintenance(cmd) - self.debug("Canceling host maintainance for ID: %s" % host.id) + self.debug("Canceling host maintainance for ID: %s" % vm.hostid) cmd = cancelHostMaintenance.cancelHostMaintenanceCmd() cmd.id = vm.hostid self.apiclient.cancelHostMaintenance(cmd) diff --git a/test/integration/component/test_eip_elb.py b/test/integration/component/test_eip_elb.py index b43db01f425..7107c60f8bc 100644 --- a/test/integration/component/test_eip_elb.py +++ b/test/integration/component/test_eip_elb.py @@ -47,8 +47,8 @@ class Services: "name": "Tiny Instance", "displaytext": "Tiny Instance", "cpunumber": 1, - "cpuspeed": 100, # in MHz - "memory": 64, # In MBs + "cpuspeed": 100, # in MHz + "memory": 64, # In MBs }, "lbrule": { "name": "SSH", @@ -183,7 +183,7 @@ class TestEIP(cloudstackTestCase): def test_01_eip_by_deploying_instance(self): """Test EIP by deploying an instance """ - + tags = ["eip"] # Validate the following @@ -350,7 +350,7 @@ class TestEIP(cloudstackTestCase): def test_02_acquire_ip_enable_static_nat(self): """Test associate new IP and enable static NAT for new IP and the VM """ - + tags = ["eip"] # Validate the following @@ -494,7 +494,7 @@ class TestEIP(cloudstackTestCase): def test_03_disable_static_nat(self): """Test disable static NAT and release EIP acquired """ - + tags = ["eip"] # Validate the following @@ -693,7 +693,7 @@ class TestEIP(cloudstackTestCase): def test_04_disable_static_nat_system(self): """Test disable static NAT with system = True """ - + tags = ["eip"] # Validate the following @@ -762,7 +762,7 @@ class TestEIP(cloudstackTestCase): def test_05_destroy_instance(self): """Test EIO after destroying instance """ - + tags = ["eip"] # Validate the following @@ -1000,7 +1000,7 @@ class TestELB(cloudstackTestCase): def test_01_elb_create(self): """Test ELB by creating a LB rule """ - + tags = ["eip"] # Validate the following @@ -1173,7 +1173,7 @@ class TestELB(cloudstackTestCase): def test_02_elb_acquire_and_create(self): """Test ELB by acquiring IP and then creating a LB rule """ - + tags = ["eip"] # Validate the following @@ -1321,7 +1321,7 @@ class TestELB(cloudstackTestCase): def test_03_elb_delete_lb_system(self): """Test delete LB rule generated with public IP with is_system = 1 """ - + tags = ["eip"] # Validate the following @@ -1425,7 +1425,7 @@ class TestELB(cloudstackTestCase): def test_04_delete_lb_on_eip(self): """Test delete LB rule generated on EIP """ - + tags = ["eip"] # Validate the following diff --git a/test/integration/component/test_high_availability.py b/test/integration/component/test_high_availability.py index 4c1446f32d4..ff0ee613f78 100644 --- a/test/integration/component/test_high_availability.py +++ b/test/integration/component/test_high_availability.py @@ -47,8 +47,8 @@ class Services: "name": "Tiny Instance", "displaytext": "Tiny Instance", "cpunumber": 1, - "cpuspeed": 100, # in MHz - "memory": 64, # In MBs + "cpuspeed": 100, # in MHz + "memory": 64, # In MBs }, "lbrule": { "name": "SSH", @@ -62,7 +62,7 @@ class Services: "publicport": 22, "protocol": "TCP" }, - "fw_rule":{ + "fw_rule": { "startport": 1, "endport": 6000, "cidr": '55.55.0.0/11', @@ -86,7 +86,7 @@ class Services: "ostypeid": '946b031b-0e10-4f4a-a3fc-d212ae2ea07f', "url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2", "hypervisor": 'XenServer', - "format" : 'VHD', + "format": 'VHD', "isfeatured": True, "ispublic": True, "isextractable": True, @@ -96,7 +96,7 @@ class Services: # Cent OS 5.3 (64 bit) "sleep": 60, "timeout": 100, - "mode":'advanced' + "mode": 'advanced' } @@ -175,7 +175,7 @@ class TestHighAvailability(cloudstackTestCase): def test_01_host_maintenance_mode(self): """Test host maintenance mode """ - + tags = ["advanced", "advancedns"] # Validate the following @@ -575,7 +575,7 @@ class TestHighAvailability(cloudstackTestCase): def test_02_host_maintenance_mode_with_activities(self): """Test host maintenance mode with activities """ - + tags = ["advanced", "advancedns"] # Validate the following @@ -714,7 +714,7 @@ class TestHighAvailability(cloudstackTestCase): self.fail("SSH Access failed for %s: %s" % \ (virtual_machine.ipaddress, e) ) - # Get the Root disk of VM + # Get the Root disk of VM volumes = list_volumes( self.apiclient, virtualmachineid=virtual_machine.id, @@ -883,7 +883,7 @@ class TestHighAvailability(cloudstackTestCase): self.apiclient.cancelHostMaintenance(cmd) self.debug("Maintenance mode canceled for host: %s" % first_host) - # Get the Root disk of VM + # Get the Root disk of VM volumes = list_volumes( self.apiclient, virtualmachineid=virtual_machine_2.id, diff --git a/test/integration/component/test_network_offering.py b/test/integration/component/test_network_offering.py index 6dd4f4c182b..cc24d46ac46 100644 --- a/test/integration/component/test_network_offering.py +++ b/test/integration/component/test_network_offering.py @@ -47,8 +47,8 @@ class Services: "name": "Tiny Instance", "displaytext": "Tiny Instance", "cpunumber": 1, - "cpuspeed": 100, # in MHz - "memory": 64, # In MBs + "cpuspeed": 100, # in MHz + "memory": 64, # In MBs }, "network_offering": { "name": 'Network offering-VR services', @@ -57,16 +57,16 @@ class Services: "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat', "traffictype": 'GUEST', "availability": 'Optional', - "serviceProviderList" : { + "serviceProviderList": { "Dhcp": 'VirtualRouter', "Dns": 'VirtualRouter', "SourceNat": 'VirtualRouter', "PortForwarding": 'VirtualRouter', - "Vpn": 'VirtualRouter', - "Firewall": 'VirtualRouter', - "Lb": 'VirtualRouter', - "UserData": 'VirtualRouter', - "StaticNat": 'VirtualRouter', + "Vpn": 'VirtualRouter', + "Firewall": 'VirtualRouter', + "Lb": 'VirtualRouter', + "UserData": 'VirtualRouter', + "StaticNat": 'VirtualRouter', }, }, "network_offering_netscaler": { @@ -76,7 +76,7 @@ class Services: "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat', "traffictype": 'GUEST', "availability": 'Optional', - "serviceProviderList" : { + "serviceProviderList": { "Dhcp": 'VirtualRouter', "Dns": 'VirtualRouter', "SourceNat": 'VirtualRouter', @@ -118,7 +118,7 @@ class Services: "publicport": 66, "protocol": "TCP" }, - "fw_rule":{ + "fw_rule": { "startport": 1, "endport": 6000, "cidr": '55.55.0.0/11', @@ -140,7 +140,7 @@ class Services: # Cent OS 5.3 (64 bit) "sleep": 60, "timeout": 10, - "mode":'advanced' + "mode": 'advanced' } @@ -212,7 +212,7 @@ class TestNOVirtualRouter(cloudstackTestCase): def test_01_network_off_without_conserve_mode(self): """Test Network offering with Conserve mode off and VR - All services """ - + tags = ["advanced"] # Validate the following @@ -245,7 +245,7 @@ class TestNOVirtualRouter(cloudstackTestCase): self.debug("Created n/w offering with ID: %s" % self.network_offering.id) - # Enable Network offering + # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') # Creating network using the network offering created @@ -257,7 +257,7 @@ class TestNOVirtualRouter(cloudstackTestCase): accountid=self.account.account.name, domainid=self.account.account.domainid, networkofferingid=self.network_offering.id, - zoneid=self.zone.id + zoneid=self.zone.id ) self.debug("Created network with ID: %s" % self.network.id) @@ -334,7 +334,7 @@ class TestNOVirtualRouter(cloudstackTestCase): ip_with_nat_rule.ipaddress.ipaddress) NATRule.create( self.apiclient, - virtual_machine, + virtual_machine, self.services["natrule"], ipaddressid=ip_with_nat_rule.ipaddress.id ) @@ -457,7 +457,7 @@ class TestNOVirtualRouter(cloudstackTestCase): def test_02_network_off_with_conserve_mode(self): """Test Network offering with Conserve mode ON and VR - All services """ - + tags = ["advanced"] # Validate the following @@ -488,7 +488,7 @@ class TestNOVirtualRouter(cloudstackTestCase): self.debug("Created n/w offering with ID: %s" % self.network_offering.id) - # Enable Network offering + # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') # Creating network using the network offering created @@ -500,7 +500,7 @@ class TestNOVirtualRouter(cloudstackTestCase): accountid=self.account.account.name, domainid=self.account.account.domainid, networkofferingid=self.network_offering.id, - zoneid=self.zone.id + zoneid=self.zone.id ) self.debug("Created network with ID: %s" % self.network.id) @@ -705,7 +705,7 @@ class TestNOVirtualRouter(cloudstackTestCase): vpns = Vpn.list( self.apiclient, publicipid=src_nat.id, - listall=True, + listall=True, ) self.assertEqual( @@ -790,7 +790,7 @@ class TestNOWithNetscaler(cloudstackTestCase): def test_01_network_off_without_conserve_mode(self): """Test Nw off with Conserve mode off, VR-All services, LB-netscaler """ - + tags = ["advancedns"] # Validate the following @@ -802,14 +802,13 @@ class TestNOWithNetscaler(cloudstackTestCase): # 5. On an ipaddress that has Lb rules , we should NOT allow firewall # rules to be programmed. # 6. On an ipaddress that has Lb rules , we should NOT allow PF rules - # to be programmed. + # to be programmed. # 7. We should be allowed to program multiple PF rules on the same Ip # address on different public ports. # 8. We should be allowed to program multiple LB rules on the same Ip - # address for different public port ranges. + # address for different public port ranges. # 9. On source NAT ipaddress, we should NOT be allowed to Enable VPN. - # Create a network offering with all virtual router services enabled self.debug( "Creating n/w offering with all services in VR & conserve mode:ON" @@ -897,7 +896,7 @@ class TestNOWithNetscaler(cloudstackTestCase): ) self.debug("Creating firewall rule on source NAT: %s" % src_nat.ipaddress) - #Create Firewall rule on source NAT + #Create Firewall rule on source NAT fw_rule = FireWallRule.create( self.apiclient, ipaddressid=src_nat.id, @@ -1060,7 +1059,7 @@ class TestNOWithNetscaler(cloudstackTestCase): def test_02_network_off_with_conserve_mode_netscaler(self): """Test NW off with Conserve mode ON, LB-Netscaler and VR-All services """ - + tags = ["advancedns"] # Validate the following @@ -1073,14 +1072,13 @@ class TestNOWithNetscaler(cloudstackTestCase): # 5. On an ipaddress that has Lb rules , we should NOT allow firewall # rules to be programmed. # 6. On an ipaddress that has Lb rules , we should NOT allow PF rules - # to be programmed. + # to be programmed. # 7. We should be allowed to program multiple PF rules on the same Ip # address on different public ports. # 8. We should be allowed to program multiple LB rules on the same Ip - # address for different public port ranges. + # address for different public port ranges. # 9. On source NAT ipaddress, we should be allowed to Enable VPN. - # Create a network offering with all virtual router services enabled self.debug( "Creating n/w offering with all services in VR & conserve mode:ON" @@ -1436,7 +1434,7 @@ class TestNetworkUpgrade(cloudstackTestCase): def test_01_nwupgrade_netscaler_conserve_on(self): """Test Nw upgrade to netscaler lb service and conserve mode ON """ - + tags = ["advancedns"] # Validate the following @@ -1635,7 +1633,7 @@ class TestNetworkUpgrade(cloudstackTestCase): def test_02_nwupgrade_netscaler_conserve_off(self): """Test Nw upgrade to netscaler lb service and conserve mode OFF """ - + tags = ["advancedns"] # Validate the following diff --git a/test/integration/component/test_project_configs.py b/test/integration/component/test_project_configs.py index 6fd4470fd2d..ceb62c436e2 100644 --- a/test/integration/component/test_project_configs.py +++ b/test/integration/component/test_project_configs.py @@ -68,8 +68,8 @@ class Services: "name": "Tiny Instance", "displaytext": "Tiny Instance", "cpunumber": 1, - "cpuspeed": 100, # in MHz - "memory": 64, # In MBs + "cpuspeed": 100, # in MHz + "memory": 64, # In MBs }, "virtual_machine": { "displayname": "Test VM", @@ -89,7 +89,7 @@ class Services: "ostypeid": 'f9b709f2-e0fc-4c0f-80f1-b0494168f58d', "url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2", "hypervisor": 'XenServer', - "format" : 'VHD', + "format": 'VHD', "isfeatured": True, "ispublic": True, "isextractable": True, @@ -107,7 +107,7 @@ class Services: # Cent OS 5.3 (64 bit) "sleep": 60, "timeout": 10, - "mode":'advanced' + "mode": 'advanced' } @@ -169,11 +169,14 @@ class TestUserProjectCreation(cloudstackTestCase): raise Exception("Warning: Exception during cleanup : %s" % e) return - def test_01_admin_project_creation(self): """Test create project as a domain admin and domain user """ +<<<<<<< HEAD +======= + tags = ["advanced", "basic", "sg", "eip", "advancedns"] +>>>>>>> 6d17e21... This commit has following fixes: # Validate the following # 1. Check if 'allow.user.create.projects' configuration is true # 2. Create a Project as domain admin @@ -207,9 +210,9 @@ class TestUserProjectCreation(cloudstackTestCase): self.cleanup.append(project) self.debug("Created project with domain admin with ID: %s" % project.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -243,9 +246,9 @@ class TestUserProjectCreation(cloudstackTestCase): self.cleanup.append(project) self.debug("Created project with domain user with ID: %s" % project.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -263,6 +266,7 @@ class TestUserProjectCreation(cloudstackTestCase): "Check list project response returns a valid project" ) return + @unittest.skip("Known bug-able to create project as a domain user") def test_02_user_project_creation(self): """Test create project as a domain admin and domain user @@ -301,9 +305,9 @@ class TestUserProjectCreation(cloudstackTestCase): self.cleanup.append(project) self.debug("Created project with domain admin with ID: %s" % project.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -346,24 +350,24 @@ class TestProjectInviteRequired(cloudstackTestCase): cls.services = Services().services # Get Zone cls.zone = get_zone(cls.api_client, cls.services) - + # Create domains, account etc. cls.domain = get_domain(cls.api_client, cls.services) - + cls.account = Account.create( cls.api_client, cls.services["account"], admin=True, domainid=cls.domain.id ) - + cls.user = Account.create( cls.api_client, cls.services["user"], admin=True, domainid=cls.domain.id ) - + cls._cleanup = [cls.account, cls.user] return @@ -390,14 +394,17 @@ class TestProjectInviteRequired(cloudstackTestCase): raise Exception("Warning: Exception during cleanup : %s" % e) return - def test_03_add_user_to_project(self): """Add user to project when 'project.invite.required' is false""" +<<<<<<< HEAD +======= + tags = ["advanced", "basic", "sg", "eip", "advancedns"] +>>>>>>> 6d17e21... This commit has following fixes: # Validate the following: # 1. Create a Project # 2. Add users to the project. Verify user is added to project - # as regular user + # as regular user # Verify 'project.invite.required' is set to false configs = Configurations.list( @@ -427,9 +434,9 @@ class TestProjectInviteRequired(cloudstackTestCase): self.cleanup.append(project) self.debug("Created project with domain admin with ID: %s" % project.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -458,14 +465,14 @@ class TestProjectInviteRequired(cloudstackTestCase): )) # Add user to the project project.addAccount( - self.apiclient, - self.user.account.name, + self.apiclient, + self.user.account.name, self.user.account.email ) - + # listProjectAccount to verify the user is added to project or not accounts_reponse = Project.listAccounts( - self.apiclient, + self.apiclient, projectid=project.id, account=self.user.account.name, ) @@ -475,20 +482,20 @@ class TestProjectInviteRequired(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.role, 'Regular', "Newly added user is not added as a regular user" ) - + return def test_04_add_user_to_project(self): @@ -524,12 +531,12 @@ class TestProjectInviteRequired(cloudstackTestCase): ) # Cleanup created project at end of test self.cleanup.append(project) - - self.debug("Created project with domain admin with ID: %s" % + + self.debug("Created project with domain admin with ID: %s" % project.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -558,11 +565,11 @@ class TestProjectInviteRequired(cloudstackTestCase): )) # Add user to the project project.addAccount( - self.apiclient, - self.user.account.name, + self.apiclient, + self.user.account.name, self.user.account.email ) - + # listProjectAccount to verify the user is added to project or not accounts_reponse = ProjectInvitation.list( self.apiclient, @@ -575,14 +582,14 @@ class TestProjectInviteRequired(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.state, 'Pending', @@ -595,11 +602,11 @@ class TestProjectInviteRequired(cloudstackTestCase): # Validate the following: # 1. Set configuration to 5 mins - # 2. Create a Project + # 2. Create a Project # 3. Add users to the project # 4. As a user accept invitation within 5 mins. Verify invitation is # accepted and user become regular user of project - + # Verify 'project.invite.required' is set to false configs = Configurations.list( self.apiclient, @@ -615,7 +622,7 @@ class TestProjectInviteRequired(cloudstackTestCase): int(config.value), self.services["configs"]["project.invite.timeout"], "'project.invite.timeout' should be %s" % - self.services["configs"]["project.invite.timeout"] + self.services["configs"]["project.invite.timeout"] ) # Create project as a domain admin @@ -627,12 +634,12 @@ class TestProjectInviteRequired(cloudstackTestCase): ) # Cleanup created project at end of test self.cleanup.append(project) - - self.debug("Created project with domain admin with ID: %s" % + + self.debug("Created project with domain admin with ID: %s" % project.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -661,11 +668,11 @@ class TestProjectInviteRequired(cloudstackTestCase): )) # Add user to the project project.addAccount( - self.apiclient, - self.user.account.name, + self.apiclient, + self.user.account.name, self.user.account.email ) - + # listProjectAccount to verify the user is added to project or not accounts_reponse = ProjectInvitation.list( self.apiclient, @@ -678,24 +685,24 @@ class TestProjectInviteRequired(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.state, 'Pending', "Newly added user is not added as a regular user" ) - + # Accept the invite ProjectInvitation.update( self.apiclient, - projectid=project.id, + projectid=project.id, accept=True, account=self.user.account.name ) @@ -706,7 +713,7 @@ class TestProjectInviteRequired(cloudstackTestCase): )) # listProjectAccount to verify the user is added to project or not accounts_reponse = Project.listAccounts( - self.apiclient, + self.apiclient, projectid=project.id, account=self.user.account.name, ) @@ -716,14 +723,14 @@ class TestProjectInviteRequired(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.role, 'Regular', @@ -736,11 +743,11 @@ class TestProjectInviteRequired(cloudstackTestCase): # Validate the following: # 1. Set configuration to 5 mins - # 2. Create a Project + # 2. Create a Project # 3. Add users to the project # 4. As a user accept invitation after 5 mins. Verify invitation is # not accepted and is shown as expired - + # Verify 'project.invite.required' is set to false configs = Configurations.list( self.apiclient, @@ -756,7 +763,7 @@ class TestProjectInviteRequired(cloudstackTestCase): int(config.value), self.services["configs"]["project.invite.timeout"], "'project.invite.timeout' should be %s" % - self.services["configs"]["project.invite.timeout"] + self.services["configs"]["project.invite.timeout"] ) # Create project as a domain admin @@ -768,12 +775,12 @@ class TestProjectInviteRequired(cloudstackTestCase): ) # Cleanup created project at end of test self.cleanup.append(project) - - self.debug("Created project with domain admin with ID: %s" % + + self.debug("Created project with domain admin with ID: %s" % project.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -802,11 +809,11 @@ class TestProjectInviteRequired(cloudstackTestCase): )) # Add user to the project project.addAccount( - self.apiclient, - self.user.account.name, + self.apiclient, + self.user.account.name, self.user.account.email ) - + # listProjectAccount to verify the user is added to project or not accounts_reponse = ProjectInvitation.list( self.apiclient, @@ -819,20 +826,20 @@ class TestProjectInviteRequired(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.state, 'Pending', "Newly added user is not added as a regular user" ) - + # sleep for 'project.invite.timeout' * 2 interval to wait for invite # to expire time.sleep(int(config.value) * 2) @@ -841,7 +848,7 @@ class TestProjectInviteRequired(cloudstackTestCase): # Accept the invite ProjectInvitation.update( self.apiclient, - projectid=project.id, + projectid=project.id, accept=True, account=self.user.account.name ) @@ -862,14 +869,14 @@ class TestProjectInviteRequired(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.state, 'Expired', @@ -882,7 +889,7 @@ class TestProjectInviteRequired(cloudstackTestCase): # Validate the following: # 1. Set configuration to 5 mins - # 2. Create a Project + # 2. Create a Project # 3. Add users to the project # 4. As a user accept invitation after 5 mins. # 5. Resend the invitation @@ -903,7 +910,7 @@ class TestProjectInviteRequired(cloudstackTestCase): int(config.value), self.services["configs"]["project.invite.timeout"], "'project.invite.timeout' should be %s" % - self.services["configs"]["project.invite.timeout"] + self.services["configs"]["project.invite.timeout"] ) # Create project as a domain admin @@ -915,12 +922,12 @@ class TestProjectInviteRequired(cloudstackTestCase): ) # Cleanup created project at end of test self.cleanup.append(project) - - self.debug("Created project with domain admin with ID: %s" % + + self.debug("Created project with domain admin with ID: %s" % project.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -949,11 +956,11 @@ class TestProjectInviteRequired(cloudstackTestCase): )) # Add user to the project project.addAccount( - self.apiclient, - self.user.account.name, + self.apiclient, + self.user.account.name, self.user.account.email ) - + # listProjectAccount to verify the user is added to project or not accounts_reponse = ProjectInvitation.list( self.apiclient, @@ -966,20 +973,20 @@ class TestProjectInviteRequired(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.state, 'Pending', "Newly added user is not added as a regular user" ) - + # sleep for 'project.invite.timeout' * 2 interval to wait for invite # to expire time.sleep(int(config.value) * 2) @@ -990,11 +997,11 @@ class TestProjectInviteRequired(cloudstackTestCase): )) # Add user to the project project.addAccount( - self.apiclient, - self.user.account.name, + self.apiclient, + self.user.account.name, self.user.account.email ) - + # listProjectAccount to verify the user is added to project or not accounts_reponse = ProjectInvitation.list( self.apiclient, @@ -1007,14 +1014,14 @@ class TestProjectInviteRequired(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.state, 'Pending', @@ -1027,7 +1034,7 @@ class TestProjectInviteRequired(cloudstackTestCase): # Validate the following: # 1. Set configuration to 5 mins - # 2. Create a Project + # 2. Create a Project # 3. Add users to the project # 4. As a user decline invitation within 5 mins. # 5. Verify invitation is rejected and user doesn't become regular @@ -1048,7 +1055,7 @@ class TestProjectInviteRequired(cloudstackTestCase): int(config.value), self.services["configs"]["project.invite.timeout"], "'project.invite.timeout' should be %s" % - self.services["configs"]["project.invite.timeout"] + self.services["configs"]["project.invite.timeout"] ) # Create project as a domain admin @@ -1060,12 +1067,12 @@ class TestProjectInviteRequired(cloudstackTestCase): ) # Cleanup created project at end of test self.cleanup.append(project) - - self.debug("Created project with domain admin with ID: %s" % + + self.debug("Created project with domain admin with ID: %s" % project.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -1094,11 +1101,11 @@ class TestProjectInviteRequired(cloudstackTestCase): )) # Add user to the project project.addAccount( - self.apiclient, - self.user.account.name, + self.apiclient, + self.user.account.name, self.user.account.email ) - + # listProjectAccount to verify the user is added to project or not accounts_reponse = ProjectInvitation.list( self.apiclient, @@ -1111,14 +1118,14 @@ class TestProjectInviteRequired(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.state, 'Pending', @@ -1127,7 +1134,7 @@ class TestProjectInviteRequired(cloudstackTestCase): # Accept the invite ProjectInvitation.update( self.apiclient, - projectid=project.id, + projectid=project.id, accept=False, account=self.user.account.name ) @@ -1138,7 +1145,7 @@ class TestProjectInviteRequired(cloudstackTestCase): )) # listProjectAccount to verify the user is added to project or not accounts_reponse = Project.listAccounts( - self.apiclient, + self.apiclient, projectid=project.id, account=self.user.account.name, ) @@ -1148,13 +1155,14 @@ class TestProjectInviteRequired(cloudstackTestCase): "Check for a valid list accounts response" ) return + @unittest.skip("Requires SMPT configs") def test_09_invite_to_project_by_email(self): """Test invite user to project by email""" # Validate the following: # 1. Set configuration to 5 mins - # 2. Create a Project + # 2. Create a Project # 3. Add users to the project # 4. As a user decline invitation within 5 mins. # 5. Verify invitation is rejected and user doesn't become regular @@ -1175,7 +1183,7 @@ class TestProjectInviteRequired(cloudstackTestCase): int(config.value), self.services["configs"]["project.invite.timeout"], "'project.invite.timeout' should be %s" % - self.services["configs"]["project.invite.timeout"] + self.services["configs"]["project.invite.timeout"] ) # Create project as a domain admin @@ -1187,12 +1195,12 @@ class TestProjectInviteRequired(cloudstackTestCase): ) # Cleanup created project at end of test self.cleanup.append(project) - - self.debug("Created project with domain admin with ID: %s" % + + self.debug("Created project with domain admin with ID: %s" % project.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) diff --git a/test/integration/component/test_project_limits.py b/test/integration/component/test_project_limits.py index 9e41789e7cd..3817c7682ca 100644 --- a/test/integration/component/test_project_limits.py +++ b/test/integration/component/test_project_limits.py @@ -25,6 +25,7 @@ from integration.lib.base import * from integration.lib.common import * import datetime + class Services: """Test Resource Limits Services """ @@ -60,8 +61,8 @@ class Services: "name": "Tiny Instance", "displaytext": "Tiny Instance", "cpunumber": 1, - "cpuspeed": 100, # in MHz - "memory": 64, # In MBs + "cpuspeed": 100, # in MHz + "memory": 64, # In MBs }, "disk_offering": { "displaytext": "Tiny Disk Offering", @@ -100,13 +101,13 @@ class TestProjectLimits(cloudstackTestCase): @classmethod def setUpClass(cls): cls.api_client = super( - TestProjectLimits, + TestProjectLimits, cls ).getClsTestClient().getApiClient() cls.services = Services().services # Get Zone cls.zone = get_zone(cls.api_client, cls.services) - + # Create domains, account etc. cls.domain = Domain.create( cls.api_client, @@ -125,10 +126,10 @@ class TestProjectLimits(cloudstackTestCase): domainid=cls.domain.id ) cls._cleanup = [ - cls.admin, - cls.user, - cls.domain - ] + cls.admin, + cls.user, + cls.domain + ] return @classmethod @@ -183,9 +184,9 @@ class TestProjectLimits(cloudstackTestCase): self.cleanup.append(project) self.debug("Created project with domain admin with ID: %s" % project.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -223,7 +224,7 @@ class TestProjectLimits(cloudstackTestCase): ) # Reduce resource limits for project - # Resource: 0 - Instance. Number of instances a user can create. + # Resource: 0 - Instance. Number of instances a user can create. # Resource: 1 - IP. Number of public IP addresses a user can own. # Resource: 2 - Volume. Number of disk volumes a user can create. # Resource: 3 - Snapshot. Number of snapshots a user can create. @@ -261,7 +262,7 @@ class TestProjectLimits(cloudstackTestCase): 1, "Resource limit should be updated to 1" ) - + # Get the resource limits for domain resource_limits = list_resource_limits( self.apiclient, @@ -277,7 +278,7 @@ class TestProjectLimits(cloudstackTestCase): 0, "List resource API response should not be empty" ) - + for resource in resource_limits: # Update domain resource limits to 2 update_resource_limit( @@ -300,6 +301,7 @@ class TestProjectLimits(cloudstackTestCase): projectid=project.id ) return + @unittest.skip("No provision for updating resource limits from account through API") def test_02_project_limits_normal_user(self): """ Test project limits @@ -323,9 +325,9 @@ class TestProjectLimits(cloudstackTestCase): self.cleanup.append(project) self.debug("Created project with domain admin with ID: %s" % project.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -363,7 +365,7 @@ class TestProjectLimits(cloudstackTestCase): ) # Reduce resource limits for project - # Resource: 0 - Instance. Number of instances a user can create. + # Resource: 0 - Instance. Number of instances a user can create. # Resource: 1 - IP. Number of public IP addresses a user can own. # Resource: 2 - Volume. Number of disk volumes a user can create. # Resource: 3 - Snapshot. Number of snapshots a user can create. @@ -401,7 +403,7 @@ class TestProjectLimits(cloudstackTestCase): 1, "Resource limit should be updated to 1" ) - + self.debug("Adding %s user to project: %s" % ( self.user.account.name, project.name @@ -409,10 +411,10 @@ class TestProjectLimits(cloudstackTestCase): # Add user to the project project.addAccount( - self.apiclient, - self.user.account.name, + self.apiclient, + self.user.account.name, ) - + # Get the resource limits for domain resource_limits = list_resource_limits( self.apiclient, @@ -428,7 +430,7 @@ class TestProjectLimits(cloudstackTestCase): 0, "List resource API response should not be empty" ) - + for resource in resource_limits: #with self.assertRaises(Exception): self.debug( @@ -535,12 +537,12 @@ class TestResourceLimitsProject(cloudstackTestCase): # should be raised self.debug( - "Updating instance resource limits for project: %s" % + "Updating instance resource limits for project: %s" % self.project.id) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, - 0, # Instance + 0, # Instance max=2, projectid=self.project.id ) @@ -589,7 +591,11 @@ class TestResourceLimitsProject(cloudstackTestCase): def test_04_publicip_per_project(self): """Test Public IP limit per project """ +<<<<<<< HEAD +======= + tags = ["advanced", "eip", "advancedns"] +>>>>>>> 6d17e21... This commit has following fixes: # Validate the following # 1. set max no of IPs per project to 2. # 2. Create an account in this domain @@ -599,12 +605,12 @@ class TestResourceLimitsProject(cloudstackTestCase): # appropriate error and an alert should be generated. self.debug( - "Updating public IP resource limits for project: %s" % + "Updating public IP resource limits for project: %s" % self.project.id) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, - 1, # Public Ip + 1, # Public Ip max=2, projectid=self.project.id ) @@ -625,7 +631,7 @@ class TestResourceLimitsProject(cloudstackTestCase): "Check VM state is Running or not" ) networks = Network.list( - self.apiclient, + self.apiclient, projectid=self.project.id, listall=True ) @@ -640,7 +646,7 @@ class TestResourceLimitsProject(cloudstackTestCase): "Check list networks response returns a valid network" ) network = networks[0] - self.debug("Associating public IP for project: %s" % + self.debug("Associating public IP for project: %s" % self.project.id) public_ip_1 = PublicIPAddress.create( self.apiclient, @@ -679,16 +685,16 @@ class TestResourceLimitsProject(cloudstackTestCase): # 1. set max no of snapshots per project to 1. # 2. Create one snapshot in the project. Snapshot should be # successfully created - # 5. Try to create another snapshot in this project. It should give + # 5. Try to create another snapshot in this project. It should give # user an appropriate error and an alert should be generated. self.debug( - "Updating snapshot resource limits for project: %s" % + "Updating snapshot resource limits for project: %s" % self.project.id) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, - 3, # Snapshot + 3, # Snapshot max=1, projectid=self.project.id ) @@ -760,12 +766,12 @@ class TestResourceLimitsProject(cloudstackTestCase): # should be generated. self.debug( - "Updating volume resource limits for project: %s" % + "Updating volume resource limits for project: %s" % self.project.id) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, - 2, # Volume + 2, # Volume max=2, projectid=self.project.id ) @@ -796,12 +802,17 @@ class TestResourceLimitsProject(cloudstackTestCase): projectid=self.project.id ) return - + def test_07_templates_per_project(self): """Test Templates limit per project """ +<<<<<<< HEAD # Validate the following +======= + tags = ["advanced", "basic", "sg", "eip", "advancedns"] + # Validate the following +>>>>>>> 6d17e21... This commit has following fixes: # 1. set max no of templates per project to 1. # 2. Create a template in this project. Both template should be in # ready state @@ -811,17 +822,17 @@ class TestResourceLimitsProject(cloudstackTestCase): # Reset the volume limits update_resource_limit( self.apiclient, - 2, # Volume + 2, # Volume max=5, projectid=self.project.id ) self.debug( - "Updating template resource limits for domain: %s" % + "Updating template resource limits for domain: %s" % self.account.account.domainid) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, - 4, # Template + 4, # Template max=1, projectid=self.project.id ) diff --git a/test/integration/component/test_project_resources.py b/test/integration/component/test_project_resources.py index 90c14cedc44..a8c9d852774 100644 --- a/test/integration/component/test_project_resources.py +++ b/test/integration/component/test_project_resources.py @@ -26,6 +26,7 @@ from integration.lib.common import * from marvin.remoteSSHClient import remoteSSHClient import datetime + class Services: """Test Resource creation Services """ @@ -61,8 +62,8 @@ class Services: "name": "Tiny Instance", "displaytext": "Tiny Instance", "cpunumber": 1, - "cpuspeed": 100, # in MHz - "memory": 64, # In MBs + "cpuspeed": 100, # in MHz + "memory": 64, # In MBs }, "disk_offering": { "displaytext": "Tiny Disk Offering", @@ -97,7 +98,7 @@ class Services: "name": "Domainwide Network", "displaytext": "Domainwide Network", "gateway": '192.168.100.1', - "netmask": '255.255.255.0', + "netmask": '255.255.255.0', "startip": '192.168.100.200', "endip": '192.168.100.201', "vlan": 4001, @@ -134,7 +135,7 @@ class Services: "timeout": 10, "mode": 'advanced', } - + class TestOfferings(cloudstackTestCase): @@ -176,7 +177,7 @@ class TestOfferings(cloudstackTestCase): cls.services["disk_offering"] ) cls._cleanup = [ - cls.account, + cls.account, cls.service_offering, cls.disk_offering ] @@ -225,9 +226,9 @@ class TestOfferings(cloudstackTestCase): self.cleanup.append(project) self.debug("Created project with domain admin with ID: %s" % project.id) - + self.debug( - "Deploying VM instance for project: %s & service offering: %s" % ( + "Deploying VM instance for project: %s & service offering: %s" % ( project.id, self.service_offering.id )) @@ -267,9 +268,9 @@ class TestOfferings(cloudstackTestCase): self.cleanup.append(project) self.debug("Created project with domain admin with ID: %s" % project.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -351,7 +352,7 @@ class TestNetwork(cloudstackTestCase): domainid=cls.domain.id ) cls._cleanup = [ - cls.account, + cls.account, cls.service_offering, ] return @@ -382,7 +383,11 @@ class TestNetwork(cloudstackTestCase): def test_03_network_create(self): """ Test create network in project """ +<<<<<<< HEAD +======= + tags = ["advanced", "advancedns"] +>>>>>>> 6d17e21... This commit has following fixes: # Validate the following # 1. Create a project. # 2. Add virtual/direct network resource to the project. User shared @@ -403,7 +408,7 @@ class TestNetwork(cloudstackTestCase): self.cleanup.append(project) self.debug("Created project with domain admin with ID: %s" % project.id) - + network_offerings = list_network_offerings( self.apiclient, projectid=project.id, @@ -412,36 +417,36 @@ class TestNetwork(cloudstackTestCase): state='Enabled' ) self.assertEqual( - isinstance(network_offerings, list), - True, + isinstance(network_offerings, list), + True, "Check for the valid network offerings" ) network_offering = network_offerings[0] - - self.debug("creating a network with network offering ID: %s" % + + self.debug("creating a network with network offering ID: %s" % network_offering.id) self.services["network"]["zoneid"] = self.zone.id network = Network.create( - self.apiclient, - self.services["network"], - networkofferingid=network_offering.id, + self.apiclient, + self.services["network"], + networkofferingid=network_offering.id, projectid=project.id ) self.debug("Created network with ID: %s" % network.id) - networks= Network.list( - self.apiclient, - projectid=project.id, + networks = Network.list( + self.apiclient, + projectid=project.id, listall=True ) self.assertEqual( - isinstance(networks, list), - True, + isinstance(networks, list), + True, "Check for the valid network list response" ) network_response = networks[0] - + self.debug("Deploying VM with network: %s" % network.id) - + virtual_machine = VirtualMachine.create( self.apiclient, self.services["server"], @@ -466,24 +471,24 @@ class TestNetwork(cloudstackTestCase): displaytext='Offering for Shared networks' ) self.assertEqual( - isinstance(network_offerings, list), - True, + isinstance(network_offerings, list), + True, "Check for the valid network offerings" ) network_offering = network_offerings[0] - - self.debug("creating a shared network in domain: %s" % + + self.debug("creating a shared network in domain: %s" % self.domain.id) domain_network = Network.create( - self.apiclient, + self.apiclient, self.services["domain_network"], domainid=self.domain.id, networkofferingid=network_offering.id, - zoneid=self.zone.id + zoneid=self.zone.id ) self._cleanup.append(domain_network) self.debug("Created network with ID: %s" % domain_network.id) - + virtual_machine = VirtualMachine.create( self.apiclient, self.services["server"], @@ -586,14 +591,19 @@ class TestTemplates(cloudstackTestCase): def test_04_public_template_use_in_project(self): """Test Templates creation in projects """ +<<<<<<< HEAD # Validate the following +======= + tags = ["advanced", "basic", "sg", "eip", "advancedns"] + # Validate the following +>>>>>>> 6d17e21... This commit has following fixes: # 1. Create a project # 2. Verify Public templates can be used without any restriction # 3. Verify that template created in project can be used in project # without any restrictions - - self.debug("Deploying VM for with public template: %s" % + + self.debug("Deploying VM for with public template: %s" % self.template.id) virtual_machine_1 = VirtualMachine.create( self.apiclient, @@ -645,15 +655,20 @@ class TestTemplates(cloudstackTestCase): def test_05_use_private_template_in_project(self): """Test use of private template in a project """ +<<<<<<< HEAD # Validate the following +======= + tags = ["advanced", "basic", "sg", "eip", "advancedns"] + # Validate the following +>>>>>>> 6d17e21... This commit has following fixes: # 1. Create a project # 2. Verify that in order to use somebody’s Private template for vm # creation in the project, permission to use the template has to # be granted to the Project (use API “updateTemplatePermissions” # with project id to achieve that). - - self.debug("Deploying VM for with public template: %s" % + + self.debug("Deploying VM for with public template: %s" % self.template.id) virtual_machine_1 = VirtualMachine.create( self.apiclient, @@ -701,7 +716,7 @@ class TestTemplates(cloudstackTestCase): True, "Check Template is in ready state or not" ) - + # Update template permissions to grant permission to project self.debug( "Updating template permissions:%s to grant access to project: %s" % ( @@ -714,7 +729,7 @@ class TestTemplates(cloudstackTestCase): op='add', projectids=self.project.id ) - self.debug("Deploying VM for with privileged template: %s" % + self.debug("Deploying VM for with privileged template: %s" % self.template.id) virtual_machine_2 = VirtualMachine.create( self.apiclient, @@ -864,7 +879,7 @@ class TestSnapshots(cloudstackTestCase): True, "Check Snapshot state is Running or not" ) - + snapshots = Snapshot.list( self.apiclient, account=self.account.account.name, @@ -929,7 +944,7 @@ class TestPublicIpAddress(cloudstackTestCase): serviceofferingid=cls.service_offering.id, projectid=cls.project.id ) - + cls._cleanup = [ cls.project, cls.service_offering, @@ -964,7 +979,11 @@ class TestPublicIpAddress(cloudstackTestCase): def test_07_associate_public_ip(self): """Test associate public IP within the project """ +<<<<<<< HEAD +======= + tags = ["advanced", "eip", "advancedns"] +>>>>>>> 6d17e21... This commit has following fixes: # Validate the following # 1. Create a project # 2. Add some public Ips to the project @@ -972,7 +991,7 @@ class TestPublicIpAddress(cloudstackTestCase): # inside project networks = Network.list( - self.apiclient, + self.apiclient, projectid=self.project.id, listall=True ) @@ -996,10 +1015,10 @@ class TestPublicIpAddress(cloudstackTestCase): projectid=self.project.id ) self.cleanup.append(public_ip) - + #Create NAT rule self.debug( - "Creating a NAT rule within project, VM ID: %s" % + "Creating a NAT rule within project, VM ID: %s" % self.virtual_machine.id) nat_rule = NATRule.create( self.apiclient, @@ -1028,9 +1047,9 @@ class TestPublicIpAddress(cloudstackTestCase): nat_rule.id, "Check Correct Port forwarding Rule is returned" ) - + #Create Load Balancer rule and assign VMs to rule - self.debug("Created LB rule for public IP: %s" % + self.debug("Created LB rule for public IP: %s" % public_ip.ipaddress.ipaddress) lb_rule = LoadBalancerRule.create( self.apiclient, @@ -1065,7 +1084,7 @@ class TestPublicIpAddress(cloudstackTestCase): lb_rule.id, "Check List Load Balancer Rules returns valid Rule" ) - + #Create Firewall rule with configurations from settings file fw_rule = FireWallRule.create( self.apiclient, @@ -1077,7 +1096,7 @@ class TestPublicIpAddress(cloudstackTestCase): projectid=self.project.id ) self.debug("Created firewall rule: %s" % fw_rule.id) - + # After Router start, FW rule should be in Active state fw_rules = FireWallRule.list( self.apiclient, @@ -1088,7 +1107,7 @@ class TestPublicIpAddress(cloudstackTestCase): True, "Check for list FW rules response return valid data" ) - + self.assertEqual( fw_rules[0].state, 'Active', @@ -1105,7 +1124,7 @@ class TestPublicIpAddress(cloudstackTestCase): str(self.services["fw_rule"]["endport"]), "Check end port of firewall rule" ) - + self.debug("Deploying VM for account: %s" % self.account.account.name) virtual_machine_1 = VirtualMachine.create( self.apiclient, @@ -1116,7 +1135,7 @@ class TestPublicIpAddress(cloudstackTestCase): serviceofferingid=self.service_offering.id, ) self.cleanup.append(virtual_machine_1) - + self.debug("VM state after deploy: %s" % virtual_machine_1.state) # Verify VM state self.assertEqual( @@ -1124,7 +1143,7 @@ class TestPublicIpAddress(cloudstackTestCase): 'Running', "Check VM state is Running or not" ) - + self.debug("Creating NAT rule for VM (ID: %s) outside project" % virtual_machine_1.id) with self.assertRaises(Exception): @@ -1134,7 +1153,7 @@ class TestPublicIpAddress(cloudstackTestCase): self.services["natrule"], public_ip.ipaddress.id, ) - + self.debug("Creating LB rule for public IP: %s outside project" % public_ip.ipaddress.ipaddress) with self.assertRaises(Exception): @@ -1160,7 +1179,7 @@ class TestPublicIpAddress(cloudstackTestCase): class TestSecurityGroup(cloudstackTestCase): - + def setUp(self): self.apiclient = self.testClient.getApiClient() @@ -1189,7 +1208,7 @@ class TestSecurityGroup(cloudstackTestCase): # 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, cls.zone.id, @@ -1198,7 +1217,7 @@ class TestSecurityGroup(cloudstackTestCase): cls.services["domainid"] = cls.domain.id cls.services["server"]["zoneid"] = cls.zone.id cls.services["server"]["template"] = template.id - + cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] @@ -1248,8 +1267,8 @@ class TestSecurityGroup(cloudstackTestCase): # to that project. security_group = SecurityGroup.create( - self.apiclient, - self.services["security_group"], + self.apiclient, + self.services["security_group"], projectid=self.project.id ) self.debug("Created security group with ID: %s" % security_group.id) @@ -1263,16 +1282,16 @@ class TestSecurityGroup(cloudstackTestCase): True, "Check for list security groups response" ) - + self.assertNotEqual( - len(sercurity_groups), - 0, + len(sercurity_groups), + 0, "Check List Security groups response" ) # Authorize Security group to SSH to VM ingress_rule = security_group.authorize( self.apiclient, - self.services["security_group"], + self.services["security_group"], projectid=self.project.id ) self.assertEqual( @@ -1280,9 +1299,9 @@ class TestSecurityGroup(cloudstackTestCase): True, "Check ingress rule created properly" ) - + self.debug( - "Authorizing ingress rule for sec group ID: %s for ssh access" + "Authorizing ingress rule for sec group ID: %s for ssh access" % security_group.id) self.virtual_machine = VirtualMachine.create( self.apiclient, @@ -1296,8 +1315,8 @@ class TestSecurityGroup(cloudstackTestCase): self.project.id )) self.assertEqual( - self.virtual_machine.state, - 'Running', + self.virtual_machine.state, + 'Running', "VM state should be running after deployment" ) # Deploy another VM with same security group outside the project diff --git a/test/integration/component/test_project_usage.py b/test/integration/component/test_project_usage.py index ef646e1314c..7c337737b6c 100644 --- a/test/integration/component/test_project_usage.py +++ b/test/integration/component/test_project_usage.py @@ -26,6 +26,7 @@ from integration.lib.common import * from marvin.remoteSSHClient import remoteSSHClient import datetime + class Services: """Test Snapshots Services """ @@ -49,8 +50,8 @@ class Services: "name": "Tiny Instance", "displaytext": "Tiny Instance", "cpunumber": 1, - "cpuspeed": 100, # in MHz - "memory": 64, # In MBs + "cpuspeed": 100, # in MHz + "memory": 64, # In MBs }, "disk_offering": { "displaytext": "Small", @@ -107,7 +108,7 @@ class Services: # Cent OS 5.3 (64 bit) "sleep": 60, "timeout": 10, - "mode":'advanced' + "mode": 'advanced' } @@ -141,14 +142,14 @@ class TestVmUsage(cloudstackTestCase): ) cls.services["account"] = cls.account.account.name - + cls.project = Project.create( cls.api_client, cls.services["project"], account=cls.account.account.name, domainid=cls.account.account.domainid ) - + cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] @@ -206,17 +207,17 @@ class TestVmUsage(cloudstackTestCase): self.debug("Stopping the VM: %s" % self.virtual_machine.id) # Stop the VM self.virtual_machine.stop(self.apiclient) - + time.sleep(self.services["sleep"]) # Destroy the VM self.debug("Destroying the VM: %s" % self.virtual_machine.id) self.virtual_machine.delete(self.apiclient) - # Fetch project account ID from project UUID + # Fetch project account ID from project UUID self.debug( "select project_account_id from projects where uuid = '%s';" \ % self.project.id) - + qresultset = self.dbclient.execute( "select project_account_id from projects where uuid = '%s';" \ % self.project.id @@ -226,7 +227,7 @@ class TestVmUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -237,7 +238,7 @@ class TestVmUsage(cloudstackTestCase): account_id = qresult[0] self.debug("select type from usage_event where account_id = '%s';" \ % account_id) - + qresultset = self.dbclient.execute( "select type from usage_event where account_id = '%s';" \ % account_id @@ -247,7 +248,7 @@ class TestVmUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -335,14 +336,14 @@ class TestPublicIPUsage(cloudstackTestCase): ) cls.services["account"] = cls.account.account.name - + cls.project = Project.create( cls.api_client, cls.services["project"], account=cls.account.account.name, domainid=cls.account.account.domainid ) - + cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] @@ -355,7 +356,7 @@ class TestPublicIPUsage(cloudstackTestCase): projectid=cls.project.id ) networks = Network.list( - cls.api_client, + cls.api_client, projectid=cls.project.id, listall=True ) @@ -402,7 +403,7 @@ class TestPublicIPUsage(cloudstackTestCase): return def test_01_public_ip_usage(self): - """Test Assign new IP and verify usage calculation + """Test Assign new IP and verify usage calculation """ # Validate the following @@ -412,17 +413,17 @@ class TestPublicIPUsage(cloudstackTestCase): # has IP.Release event for released IP for this account # 3. Delete the newly created account - self.debug("Deleting public IP: %s" % + self.debug("Deleting public IP: %s" % self.public_ip.ipaddress.ipaddress) # Release one of the IP self.public_ip.delete(self.apiclient) - # Fetch project account ID from project UUID + # Fetch project account ID from project UUID self.debug( "select project_account_id from projects where uuid = '%s';" \ % self.project.id) - + qresultset = self.dbclient.execute( "select project_account_id from projects where uuid = '%s';" \ % self.project.id @@ -442,12 +443,12 @@ class TestPublicIPUsage(cloudstackTestCase): account_id = qresult[0] self.debug("select type from usage_event where account_id = '%s';" \ % account_id) - + qresultset = self.dbclient.execute( "select type from usage_event where account_id = '%s';" \ % account_id ) - + self.assertEqual( isinstance(qresultset, list), True, @@ -582,8 +583,8 @@ class TestVolumeUsage(cloudstackTestCase): listall=True ) self.assertEqual( - isinstance(volume_response, list), - True, + isinstance(volume_response, list), + True, "Check for valid list volumes response" ) data_volume = volume_response[0] @@ -601,11 +602,11 @@ class TestVolumeUsage(cloudstackTestCase): cmd.id = data_volume.id self.apiclient.deleteVolume(cmd) - # Fetch project account ID from project UUID + # Fetch project account ID from project UUID self.debug( "select project_account_id from projects where uuid = '%s';" \ % self.project.id) - + qresultset = self.dbclient.execute( "select project_account_id from projects where uuid = '%s';" \ % self.project.id @@ -615,7 +616,7 @@ class TestVolumeUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -626,12 +627,12 @@ class TestVolumeUsage(cloudstackTestCase): account_id = qresult[0] self.debug("select type from usage_event where account_id = '%s';" \ % account_id) - + qresultset = self.dbclient.execute( "select type from usage_event where account_id = '%s';" \ % account_id ) - + self.assertNotEqual( len(qresultset), 0, @@ -642,7 +643,7 @@ class TestVolumeUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + qresult = str(qresultset) self.debug("Query result: %s" % qresult) # Check VOLUME.CREATE, VOLUME.DESTROY events in cloud.usage_event table @@ -717,7 +718,7 @@ class TestTemplateUsage(cloudstackTestCase): type='ROOT', listall=True ) - if isinstance(list_volume, list): + if isinstance(list_volume, list): cls.volume = list_volume[0] else: raise Exception("List Volumes failed!") @@ -775,11 +776,11 @@ class TestTemplateUsage(cloudstackTestCase): self.template.delete(self.apiclient) self.debug("Deleted template with ID: %s" % self.template.id) - # Fetch project account ID from project UUID + # Fetch project account ID from project UUID self.debug( "select project_account_id from projects where uuid = '%s';" \ % self.project.id) - + qresultset = self.dbclient.execute( "select project_account_id from projects where uuid = '%s';" \ % self.project.id @@ -789,7 +790,7 @@ class TestTemplateUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -800,7 +801,7 @@ class TestTemplateUsage(cloudstackTestCase): account_id = qresult[0] self.debug("select type from usage_event where account_id = '%s';" \ % account_id) - + qresultset = self.dbclient.execute( "select type from usage_event where account_id = '%s';" \ % account_id @@ -816,10 +817,10 @@ class TestTemplateUsage(cloudstackTestCase): 0, "Check DB Query result set" ) - + qresult = str(qresultset) self.debug("Query result: %s" % qresult) - + # Check for TEMPLATE.CREATE, TEMPLATE.DELETE in cloud.usage_event table self.assertEqual( qresult.count('TEMPLATE.CREATE'), @@ -846,7 +847,7 @@ class TestISOUsage(cloudstackTestCase): cls.zone = get_zone(cls.api_client, cls.services) cls.services["server"]["zoneid"] = cls.zone.id cls.services["iso"]["zoneid"] = cls.zone.id - # Create Account, ISO image etc + # Create Account, ISO image etc cls.account = Account.create( cls.api_client, cls.services["account"], @@ -917,12 +918,12 @@ class TestISOUsage(cloudstackTestCase): # Delete the ISO self.debug("Deleting ISO with ID: %s" % self.iso.id) self.iso.delete(self.apiclient) - - # Fetch project account ID from project UUID + + # Fetch project account ID from project UUID self.debug( "select project_account_id from projects where uuid = '%s';" \ % self.project.id) - + qresultset = self.dbclient.execute( "select project_account_id from projects where uuid = '%s';" \ % self.project.id @@ -932,7 +933,7 @@ class TestISOUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -943,18 +944,18 @@ class TestISOUsage(cloudstackTestCase): account_id = qresult[0] self.debug("select type from usage_event where account_id = '%s';" \ % account_id) - + qresultset = self.dbclient.execute( "select type from usage_event where account_id = '%s';" \ % account_id ) - + self.assertEqual( isinstance(qresultset, list), True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -984,7 +985,7 @@ class TestLBRuleUsage(cloudstackTestCase): @classmethod def setUpClass(cls): cls.api_client = super( - TestLBRuleUsage, + TestLBRuleUsage, cls ).getClsTestClient().getApiClient() cls.services = Services().services @@ -1028,7 +1029,7 @@ class TestLBRuleUsage(cloudstackTestCase): projectid=cls.project.id ) networks = Network.list( - cls.api_client, + cls.api_client, projectid=cls.project.id, listall=True ) @@ -1077,7 +1078,11 @@ class TestLBRuleUsage(cloudstackTestCase): def test_01_lb_usage(self): """Test Create/Delete a LB rule and verify correct usage is recorded """ +<<<<<<< HEAD +======= + tags = ["advanced", "eip", "advancedns"] +>>>>>>> 6d17e21... This commit has following fixes: # Validate the following # 1. Acquire a IP for this account. lb.rule.create event is registered # for this account in cloud.usage_event table @@ -1087,7 +1092,7 @@ class TestLBRuleUsage(cloudstackTestCase): # 4. Delete this account. self.debug( - "Creating load balancer rule for public IP: %s" % + "Creating load balancer rule for public IP: %s" % self.public_ip_1.ipaddress.id) #Create Load Balancer rule and assign VMs to rule lb_rule = LoadBalancerRule.create( @@ -1100,11 +1105,11 @@ class TestLBRuleUsage(cloudstackTestCase): self.debug("Deleting LB rule with ID: %s" % lb_rule.id) lb_rule.delete(self.apiclient) - # Fetch project account ID from project UUID + # Fetch project account ID from project UUID self.debug( "select project_account_id from projects where uuid = '%s';" \ % self.project.id) - + qresultset = self.dbclient.execute( "select project_account_id from projects where uuid = '%s';" \ % self.project.id @@ -1114,7 +1119,7 @@ class TestLBRuleUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -1125,7 +1130,7 @@ class TestLBRuleUsage(cloudstackTestCase): account_id = qresult[0] self.debug("select type from usage_event where account_id = '%s';" \ % account_id) - + qresultset = self.dbclient.execute( "select type from usage_event where account_id = '%s';" \ % account_id @@ -1146,7 +1151,7 @@ class TestLBRuleUsage(cloudstackTestCase): qresult = str(qresultset) self.debug("Query result: %s" % qresult) - # Check for LB.CREATE, LB.DELETE in cloud.usage_event table + # Check for LB.CREATE, LB.DELETE in cloud.usage_event table self.assertEqual( qresult.count('LB.CREATE'), 1, @@ -1242,7 +1247,7 @@ class TestSnapshotUsage(cloudstackTestCase): def test_01_snapshot_usage(self): """Test Create/Delete a manual snap shot and verify - correct usage is recorded + correct usage is recorded """ # Validate the following @@ -1252,7 +1257,7 @@ class TestSnapshotUsage(cloudstackTestCase): # generated for the destroyed Snapshot # 3. Delete the account - # Get the Root disk of VM + # Get the Root disk of VM volumes = list_volumes( self.apiclient, projectid=self.project.id, @@ -1264,7 +1269,7 @@ class TestSnapshotUsage(cloudstackTestCase): True, "Check if list volumes return a valid data" ) - + volume = volumes[0] # Create a snapshot from the ROOTDISK @@ -1275,11 +1280,11 @@ class TestSnapshotUsage(cloudstackTestCase): self.debug("Deleting snapshot: %s" % snapshot.id) snapshot.delete(self.apiclient) - # Fetch project account ID from project UUID + # Fetch project account ID from project UUID self.debug( "select project_account_id from projects where uuid = '%s';" \ % self.project.id) - + qresultset = self.dbclient.execute( "select project_account_id from projects where uuid = '%s';" \ % self.project.id @@ -1289,7 +1294,7 @@ class TestSnapshotUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -1300,12 +1305,12 @@ class TestSnapshotUsage(cloudstackTestCase): account_id = qresult[0] self.debug("select type from usage_event where account_id = '%s';" \ % account_id) - + qresultset = self.dbclient.execute( "select type from usage_event where account_id = '%s';" \ % account_id ) - + self.assertEqual( isinstance(qresultset, list), True, @@ -1386,7 +1391,7 @@ class TestNatRuleUsage(cloudstackTestCase): projectid=cls.project.id ) networks = Network.list( - cls.api_client, + cls.api_client, projectid=cls.project.id, listall=True ) @@ -1435,7 +1440,11 @@ class TestNatRuleUsage(cloudstackTestCase): def test_01_nat_usage(self): """Test Create/Delete a PF rule and verify correct usage is recorded """ +<<<<<<< HEAD +======= + tags = ["advanced", "advancedns"] +>>>>>>> 6d17e21... This commit has following fixes: # Validate the following # 1. Acquire a IP for this account # 2. Create a PF rule on the IP associated with this account. @@ -1445,7 +1454,7 @@ class TestNatRuleUsage(cloudstackTestCase): # is registered for this account in cloud.usage_event table # 4. Delete this account. - self.debug("Creating NAT rule with public IP: %s" % + self.debug("Creating NAT rule with public IP: %s" % self.public_ip_1.ipaddress.id) #Create NAT rule nat_rule = NATRule.create( @@ -1459,11 +1468,11 @@ class TestNatRuleUsage(cloudstackTestCase): self.debug("Deleting NAT rule: %s" % nat_rule.id) nat_rule.delete(self.apiclient) - # Fetch project account ID from project UUID + # Fetch project account ID from project UUID self.debug( "select project_account_id from projects where uuid = '%s';" \ % self.project.id) - + qresultset = self.dbclient.execute( "select project_account_id from projects where uuid = '%s';" \ % self.project.id @@ -1473,7 +1482,7 @@ class TestNatRuleUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -1484,7 +1493,7 @@ class TestNatRuleUsage(cloudstackTestCase): account_id = qresult[0] self.debug("select type from usage_event where account_id = '%s';" \ % account_id) - + qresultset = self.dbclient.execute( "select type from usage_event where account_id = '%s';" \ % account_id @@ -1569,7 +1578,7 @@ class TestVpnUsage(cloudstackTestCase): projectid=cls.project.id ) networks = Network.list( - cls.api_client, + cls.api_client, projectid=cls.project.id, listall=True ) @@ -1618,16 +1627,20 @@ class TestVpnUsage(cloudstackTestCase): def test_01_vpn_usage(self): """Test Create/Delete a VPN and verify correct usage is recorded """ +<<<<<<< HEAD +======= + tags = ["advanced", "advancedns"] +>>>>>>> 6d17e21... This commit has following fixes: # Validate the following # 1. Enable VPN for this IP. vpn.add.user event is registered for this # account in cloud.usage_event table - # 2. Add user to this vpn + # 2. Add user to this vpn # 3. Delete user for this VPN. vpn.user.delete event is registered for # this account in cloud.usage_event table # 4. Delete this account. - self.debug("Created VPN with public IP: %s" % + self.debug("Created VPN with public IP: %s" % self.public_ip.ipaddress.id) #Assign VPN to Public IP vpn = Vpn.create( @@ -1636,7 +1649,7 @@ class TestVpnUsage(cloudstackTestCase): projectid=self.project.id ) - self.debug("Created VPN user for account: %s" % + self.debug("Created VPN user for account: %s" % self.account.account.name) vpnuser = VpnUser.create( @@ -1654,11 +1667,11 @@ class TestVpnUsage(cloudstackTestCase): self.debug("Deleting VPN: %s" % vpn.publicipid) vpn.delete(self.apiclient) - # Fetch project account ID from project UUID + # Fetch project account ID from project UUID self.debug( "select project_account_id from projects where uuid = '%s';" \ % self.project.id) - + qresultset = self.dbclient.execute( "select project_account_id from projects where uuid = '%s';" \ % self.project.id @@ -1668,7 +1681,7 @@ class TestVpnUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -1679,7 +1692,7 @@ class TestVpnUsage(cloudstackTestCase): account_id = qresult[0] self.debug("select type from usage_event where account_id = '%s';" \ % account_id) - + qresultset = self.dbclient.execute( "select type from usage_event where account_id = '%s';" \ % account_id @@ -1698,8 +1711,8 @@ class TestVpnUsage(cloudstackTestCase): qresult = str(qresultset) self.debug("Query result: %s" % qresult) - - # Check for VPN user related events + + # Check for VPN user related events self.assertEqual( qresult.count('VPN.USER.ADD'), 1, diff --git a/test/integration/component/test_projects.py b/test/integration/component/test_projects.py index 463cb4a24a4..f0af670a194 100644 --- a/test/integration/component/test_projects.py +++ b/test/integration/component/test_projects.py @@ -44,7 +44,7 @@ class Services: "ipaddress": '192.168.100.21', "username": 'root', "password": 'fr3sca', - "port": 22, + "port": 22, }, "account": { "email": "administrator@clogeny.com", @@ -76,8 +76,8 @@ class Services: "name": "Tiny Instance", "displaytext": "Tiny Instance", "cpunumber": 1, - "cpuspeed": 100, # in MHz - "memory": 64, # In MBs + "cpuspeed": 100, # in MHz + "memory": 64, # In MBs }, "virtual_machine": { "displayname": "Test VM", @@ -95,7 +95,7 @@ class Services: # Cent OS 5.3 (64 bit) "sleep": 60, "timeout": 10, - "mode":'advanced' + "mode": 'advanced' } @@ -110,7 +110,7 @@ class TestMultipleProjectCreation(cloudstackTestCase): cls.services = Services().services # Get Zone cls.zone = get_zone(cls.api_client, cls.services) - + # Create domains, account etc. cls.domain = get_domain( cls.api_client, @@ -123,14 +123,14 @@ class TestMultipleProjectCreation(cloudstackTestCase): admin=True, domainid=cls.domain.id ) - + cls.user = Account.create( cls.api_client, cls.services["account"], admin=True, domainid=cls.domain.id ) - + cls._cleanup = [cls.account, cls.user] return @@ -164,7 +164,7 @@ class TestMultipleProjectCreation(cloudstackTestCase): # Validate the following # 1. Create multiple project. Verify at step 1 An account is allowed - # to create multiple projects + # to create multiple projects # 2. add one account to multiple project. Verify at step 2 an account # is allowed to added to multiple project @@ -182,7 +182,7 @@ class TestMultipleProjectCreation(cloudstackTestCase): self.assertEqual( (config.value).lower(), 'false', - "'project.invite.required' should be set to false" + "'project.invite.required' should be set to false" ) # Create project as a domain admin @@ -196,9 +196,9 @@ class TestMultipleProjectCreation(cloudstackTestCase): self.cleanup.append(project_1) self.debug("Created project with domain admin with ID: %s" % project_1.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project_1.id, listall=True ) @@ -231,9 +231,9 @@ class TestMultipleProjectCreation(cloudstackTestCase): self.cleanup.append(project_2) self.debug("Created project with domain user with ID: %s" % project_2.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project_2.id, listall=True ) @@ -250,17 +250,17 @@ class TestMultipleProjectCreation(cloudstackTestCase): 0, "Check list project response returns a valid project" ) - + # Add user to the project project_1.addAccount( - self.apiclient, - self.user.account.name, + self.apiclient, + self.user.account.name, self.user.account.email ) - + # listProjectAccount to verify the user is added to project or not accounts_reponse = Project.listAccounts( - self.apiclient, + self.apiclient, projectid=project_1.id, account=self.user.account.name, ) @@ -270,14 +270,14 @@ class TestMultipleProjectCreation(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.role, 'Regular', @@ -285,14 +285,14 @@ class TestMultipleProjectCreation(cloudstackTestCase): ) # Add user to the project project_2.addAccount( - self.apiclient, - self.user.account.name, + self.apiclient, + self.user.account.name, self.user.account.email ) - + # listProjectAccount to verify the user is added to project or not accounts_reponse = Project.listAccounts( - self.apiclient, + self.apiclient, projectid=project_2.id, account=self.user.account.name, ) @@ -302,14 +302,14 @@ class TestMultipleProjectCreation(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.role, 'Regular', @@ -346,14 +346,14 @@ class TestCrossDomainAccountAdd(cloudstackTestCase): admin=True, domainid=cls.domain.id ) - + cls.user = Account.create( cls.api_client, cls.services["account"], admin=True, domainid=cls.new_domain.id ) - + cls._cleanup = [cls.account, cls.user] return @@ -403,7 +403,7 @@ class TestCrossDomainAccountAdd(cloudstackTestCase): self.assertEqual( (config.value).lower(), 'false', - "'project.invite.required' should be set to false" + "'project.invite.required' should be set to false" ) # Create project as a domain admin @@ -417,9 +417,9 @@ class TestCrossDomainAccountAdd(cloudstackTestCase): self.cleanup.append(project) self.debug("Created project with domain admin with ID: %s" % project.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -442,8 +442,8 @@ class TestCrossDomainAccountAdd(cloudstackTestCase): list_project.name, "Check project name from list response" ) - - self.debug("Adding user: %s from domain: %s to project: %s" %( + + self.debug("Adding user: %s from domain: %s to project: %s" % ( self.user.account.name, self.user.account.domainid, project.id @@ -451,12 +451,12 @@ class TestCrossDomainAccountAdd(cloudstackTestCase): with self.assertRaises(Exception): # Add user to the project from different domain project.addAccount( - self.apiclient, + self.apiclient, self.user.account.name ) self.debug("User add to project failed!") return - + class TestDeleteAccountWithProject(cloudstackTestCase): @@ -530,7 +530,7 @@ class TestDeleteAccountWithProject(cloudstackTestCase): self.assertEqual( (config.value).lower(), 'false', - "'project.invite.required' should be set to false" + "'project.invite.required' should be set to false" ) # Create project as a domain admin @@ -544,9 +544,9 @@ class TestDeleteAccountWithProject(cloudstackTestCase): self.cleanup.append(project) self.debug("Created project with domain admin with ID: %s" % project.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -572,10 +572,11 @@ class TestDeleteAccountWithProject(cloudstackTestCase): # Deleting account who is owner of the project with self.assertRaises(Exception): self.account.delete(self.apiclient) - self.debug("Deleting account %s failed!" % + self.debug("Deleting account %s failed!" % self.account.account.name) return + @unittest.skip("Deleting domain doesn't cleanup account") class TestDeleteDomainWithProject(cloudstackTestCase): @@ -592,7 +593,7 @@ class TestDeleteDomainWithProject(cloudstackTestCase): cls.domain = Domain.create( cls.api_client, cls.services["domain"] - ) + ) cls.account = Account.create( cls.api_client, @@ -650,7 +651,7 @@ class TestDeleteDomainWithProject(cloudstackTestCase): self.assertEqual( (config.value).lower(), 'false', - "'project.invite.required' should be set to false" + "'project.invite.required' should be set to false" ) # Create project as a domain admin @@ -663,9 +664,9 @@ class TestDeleteDomainWithProject(cloudstackTestCase): # Cleanup created project at end of test self.debug("Created project with domain admin with ID: %s" % project.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -688,12 +689,12 @@ class TestDeleteDomainWithProject(cloudstackTestCase): list_project.name, "Check project name from list response" ) - + self.debug("Deleting domain: %s forcefully" % self.domain.name) # Delete domain with cleanup=True self.domain.delete(self.apiclient, cleanup=True) self.debug("Removed domain: %s" % self.domain.name) - + interval = list_configurations( self.apiclient, name='account.cleanup.interval' @@ -704,14 +705,14 @@ class TestDeleteDomainWithProject(cloudstackTestCase): "Check if account.cleanup.interval config present" ) self.debug( - "Sleep for account cleanup interval: %s" % + "Sleep for account cleanup interval: %s" % interval[0].value) # Sleep to ensure that all resources are deleted time.sleep(int(interval[0].value)) - + # Project should be deleted as part of domain cleanup list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -738,7 +739,7 @@ class TestProjectOwners(cloudstackTestCase): cls.services ) cls.zone = get_zone(cls.api_client, cls.services) - + # Create accounts cls.admin = Account.create( cls.api_client, @@ -777,7 +778,7 @@ class TestProjectOwners(cloudstackTestCase): except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return - + def test_05_user_project_owner_promotion(self): """ Test Verify a project user can be later promoted to become a owner @@ -803,7 +804,7 @@ class TestProjectOwners(cloudstackTestCase): self.assertEqual( (config.value).lower(), 'false', - "'project.invite.required' should be set to false" + "'project.invite.required' should be set to false" ) # Create project as a domain admin @@ -817,9 +818,9 @@ class TestProjectOwners(cloudstackTestCase): # Cleanup created project at end of test self.debug("Created project with domain admin with ID: %s" % project.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -848,13 +849,13 @@ class TestProjectOwners(cloudstackTestCase): )) # Add user to the project project.addAccount( - self.apiclient, - self.new_admin.account.name, + self.apiclient, + self.new_admin.account.name, ) - + # listProjectAccount to verify the user is added to project or not accounts_reponse = Project.listAccounts( - self.apiclient, + self.apiclient, projectid=project.id, account=self.new_admin.account.name, ) @@ -864,29 +865,29 @@ class TestProjectOwners(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.role, 'Regular', "Newly added user is not added as a regular user" ) - + # Update the project with new admin project.update( - self.apiclient, + self.apiclient, account=self.new_admin.account.name ) - + # listProjectAccount to verify the user is new admin of the project accounts_reponse = Project.listAccounts( - self.apiclient, + self.apiclient, projectid=project.id, account=self.new_admin.account.name, ) @@ -896,23 +897,23 @@ class TestProjectOwners(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.role, 'Admin', "Newly added user is not added as a regular user" ) - + # listProjectAccount to verify old user becomes a regular user accounts_reponse = Project.listAccounts( - self.apiclient, + self.apiclient, projectid=project.id, account=self.admin.account.name, ) @@ -922,14 +923,14 @@ class TestProjectOwners(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.role, 'Regular', @@ -944,7 +945,7 @@ class TestProjectOwners(cloudstackTestCase): # Validate the following # 1. Create a project. # 2. Add account to the project. Edit account to make it a project - # owner. + # owner. # 3. Update project to add another account as an owner # Verify 'project.invite.required' is set to false @@ -961,7 +962,7 @@ class TestProjectOwners(cloudstackTestCase): self.assertEqual( (config.value).lower(), 'false', - "'project.invite.required' should be set to false" + "'project.invite.required' should be set to false" ) # Create project as a domain admin @@ -976,9 +977,9 @@ class TestProjectOwners(cloudstackTestCase): self.debug("Created project with domain admin with ID: %s" % project.id) self.user = Account.create( - self.apiclient, + self.apiclient, self.services["account"], - admin=True, + admin=True, domainid=self.domain.id ) self.cleanup.append(self.user) @@ -986,7 +987,7 @@ class TestProjectOwners(cloudstackTestCase): self.user.account.name) list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -1015,13 +1016,13 @@ class TestProjectOwners(cloudstackTestCase): )) # Add user to the project project.addAccount( - self.apiclient, - self.new_admin.account.name, + self.apiclient, + self.new_admin.account.name, ) - + # listProjectAccount to verify the user is added to project or not accounts_reponse = Project.listAccounts( - self.apiclient, + self.apiclient, projectid=project.id, account=self.new_admin.account.name, ) @@ -1031,30 +1032,30 @@ class TestProjectOwners(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.role, 'Regular', "Newly added user is not added as a regular user" ) - self.debug("Updating project with new Admin: %s" % + self.debug("Updating project with new Admin: %s" % self.new_admin.account.name) # Update the project with new admin project.update( - self.apiclient, + self.apiclient, account=self.new_admin.account.name ) - + # listProjectAccount to verify the user is new admin of the project accounts_reponse = Project.listAccounts( - self.apiclient, + self.apiclient, projectid=project.id, account=self.new_admin.account.name, ) @@ -1063,33 +1064,33 @@ class TestProjectOwners(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.role, 'Admin', "Newly added user is not added as a regular user" ) - + self.debug("Adding %s user to project: %s" % ( self.user.account.name, project.name )) # Add user to the project project.addAccount( - self.apiclient, - self.user.account.name, + self.apiclient, + self.user.account.name, ) - + # listProjectAccount to verify the user is added to project or not accounts_reponse = Project.listAccounts( - self.apiclient, + self.apiclient, projectid=project.id, account=self.user.account.name, ) @@ -1098,32 +1099,32 @@ class TestProjectOwners(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.role, 'Regular', "Newly added user is not added as a regular user" ) - self.debug("Updating project with new Admin: %s" % + self.debug("Updating project with new Admin: %s" % self.user.account.name) # Update the project with new admin project.update( - self.apiclient, + self.apiclient, account=self.user.account.name ) - + # listProjectAccount to verify the user is new admin of the project accounts_reponse = Project.listAccounts( - self.apiclient, + self.apiclient, projectid=project.id, account=self.user.account.name, ) @@ -1133,23 +1134,23 @@ class TestProjectOwners(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.role, 'Admin', "Newly added user is not added as a regular user" ) - + # listProjectAccount to verify old user becomes a regular user accounts_reponse = Project.listAccounts( - self.apiclient, + self.apiclient, projectid=project.id, account=self.new_admin.account.name, ) @@ -1158,14 +1159,14 @@ class TestProjectOwners(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.role, 'Regular', @@ -1195,7 +1196,7 @@ class TestProjectResources(cloudstackTestCase): cls.api_client, cls.services["disk_offering"] ) - + cls.account = Account.create( cls.api_client, cls.services["account"], @@ -1233,7 +1234,7 @@ class TestProjectResources(cloudstackTestCase): except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return - + def test_07_project_resources_account_delete(self): """ Test Verify after an account is removed from the project, all his resources stay with the project. @@ -1259,7 +1260,7 @@ class TestProjectResources(cloudstackTestCase): self.assertEqual( (config.value).lower(), 'false', - "'project.invite.required' should be set to false" + "'project.invite.required' should be set to false" ) # Create project as a domain admin @@ -1273,9 +1274,9 @@ class TestProjectResources(cloudstackTestCase): self.cleanup.append(project) self.debug("Created project with domain admin with ID: %s" % project.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -1304,13 +1305,13 @@ class TestProjectResources(cloudstackTestCase): )) # Add user to the project project.addAccount( - self.apiclient, - self.user.account.name, + self.apiclient, + self.user.account.name, ) - + # listProjectAccount to verify the user is added to project or not accounts_reponse = Project.listAccounts( - self.apiclient, + self.apiclient, projectid=project.id, account=self.user.account.name, ) @@ -1319,14 +1320,14 @@ class TestProjectResources(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.role, 'Regular', @@ -1334,39 +1335,39 @@ class TestProjectResources(cloudstackTestCase): ) # Create some resources(volumes) for the projects volume = Volume.create( - self.apiclient, - self.services["volume"], - zoneid=self.zone.id, - diskofferingid=self.disk_offering.id, + self.apiclient, + self.services["volume"], + zoneid=self.zone.id, + diskofferingid=self.disk_offering.id, projectid=project.id ) self.cleanup.append(volume) # Delete the project user self.user.delete(self.apiclient) - + volumes = Volume.list(self.apiclient, id=volume.id) - + self.assertEqual( isinstance(volumes, list), True, "Check for a valid list volumes response" ) - + self.assertNotEqual( len(volumes), 0, "Check list volumes API response returns a valid list" ) volume_response = volumes[0] - + self.assertEqual( volume_response.name, volume.name, "Volume should exist after project user deletion." ) return - + def test_08_cleanup_after_project_delete(self): """ Test accounts are unassigned from project after project deletion """ @@ -1392,7 +1393,7 @@ class TestProjectResources(cloudstackTestCase): self.assertEqual( (config.value).lower(), 'false', - "'project.invite.required' should be set to false" + "'project.invite.required' should be set to false" ) # Create project as a domain admin @@ -1405,9 +1406,9 @@ class TestProjectResources(cloudstackTestCase): # Cleanup created project at end of test self.debug("Created project with domain admin with ID: %s" % project.id) - + list_projects_reponse = Project.list( - self.apiclient, + self.apiclient, id=project.id, listall=True ) @@ -1443,13 +1444,13 @@ class TestProjectResources(cloudstackTestCase): )) # Add user to the project project.addAccount( - self.apiclient, + self.apiclient, self.user.account.name ) - + # listProjectAccount to verify the user is added to project or not accounts_reponse = Project.listAccounts( - self.apiclient, + self.apiclient, projectid=project.id, account=self.user.account.name, ) @@ -1458,14 +1459,14 @@ class TestProjectResources(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(list_projects_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.role, 'Regular', @@ -1473,10 +1474,10 @@ class TestProjectResources(cloudstackTestCase): ) # Create some resources(volumes) for the projects volume = Volume.create( - self.apiclient, - self.services["volume"], - zoneid=self.zone.id, - diskofferingid=self.disk_offering.id, + self.apiclient, + self.services["volume"], + zoneid=self.zone.id, + diskofferingid=self.disk_offering.id, projectid=project.id ) self.debug("Created a volume: %s for project: %s" % ( @@ -1487,17 +1488,17 @@ class TestProjectResources(cloudstackTestCase): self.debug("Deleting project: %s" % project.name) project.delete(self.apiclient) self.debug("Successfully deleted project: %s" % project.name) - + volumes = Volume.list(self.apiclient, id=volume.id) - + self.assertEqual( volumes, None, "Resources (volume) should be deleted as part of cleanup" ) - + accounts = Project.listAccounts(self.apiclient, projectid=project.id) - + self.assertEqual( accounts, None, @@ -1522,8 +1523,8 @@ class TestProjectSuspendActivate(cloudstackTestCase): cls.services ) cls.template = get_template( - cls.api_client, - cls.zone.id, + cls.api_client, + cls.zone.id, cls.services["ostypeid"] ) # Create account, service offering, disk offering etc. @@ -1548,7 +1549,7 @@ class TestProjectSuspendActivate(cloudstackTestCase): admin=True, domainid=cls.domain.id ) - + # Create project as a domain admin cls.project = Project.create( cls.api_client, @@ -1587,7 +1588,7 @@ class TestProjectSuspendActivate(cloudstackTestCase): except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return - + def test_09_project_suspend(self): """ Test Verify after an account is removed from the project, all his resources stay with the project. @@ -1613,7 +1614,7 @@ class TestProjectSuspendActivate(cloudstackTestCase): self.assertEqual( (config.value).lower(), 'false', - "'project.invite.required' should be set to false" + "'project.invite.required' should be set to false" ) self.debug("Adding %s user to project: %s" % ( @@ -1622,13 +1623,13 @@ class TestProjectSuspendActivate(cloudstackTestCase): )) # Add user to the project self.project.addAccount( - self.apiclient, - self.user.account.name, + self.apiclient, + self.user.account.name, ) - + # listProjectAccount to verify the user is added to project or not accounts_reponse = Project.listAccounts( - self.apiclient, + self.apiclient, projectid=self.project.id, account=self.user.account.name, ) @@ -1637,20 +1638,20 @@ class TestProjectSuspendActivate(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(accounts_reponse), 0, "Check list project response returns a valid project" ) account = accounts_reponse[0] - + self.assertEqual( account.role, 'Regular', "Newly added user is not added as a regular user" ) - + virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], @@ -1664,7 +1665,7 @@ class TestProjectSuspendActivate(cloudstackTestCase): )) self.debug("Suspending a project: %s" % self.project.name) self.project.suspend(self.apiclient) - + # Check status of all VMs associated with project vms = VirtualMachine.list( self.apiclient, @@ -1676,13 +1677,13 @@ class TestProjectSuspendActivate(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(vms), 0, "Check list project response returns a valid project" ) - + for vm in vms: self.debug("VM ID: %s state: %s" % (vm.id, vm.state)) self.assertEqual( @@ -1691,30 +1692,30 @@ class TestProjectSuspendActivate(cloudstackTestCase): "VM should be in stopped state after project suspension" ) - self.debug("Attempting to create volume in suspended project") + self.debug("Attempting to create volume in suspended project") with self.assertRaises(Exception): # Create some resources(volumes) for the projects volume = Volume.create( - self.apiclient, - self.services["volume"], - zoneid=self.zone.id, - diskofferingid=self.disk_offering.id, + self.apiclient, + self.services["volume"], + zoneid=self.zone.id, + diskofferingid=self.disk_offering.id, projectid=self.project.id ) - + self.debug("Volume creation failed") # Start the stopped VM - self.debug("Attempting to start VM: %s in suspended project" % - virtual_machine.id) + self.debug("Attempting to start VM: %s in suspended project" % + virtual_machine.id) with self.assertRaises(Exception): virtual_machine.start(self.apiclient) self.debug("VM start failed!") - + # Destroy Stopped VM virtual_machine.delete(self.apiclient) self.debug("Destroying VM: %s" % virtual_machine.id) - + # Check status of all VMs associated with project vms = VirtualMachine.list( self.apiclient, @@ -1726,13 +1727,13 @@ class TestProjectSuspendActivate(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(vms), 0, "Check list project response returns a valid project" ) - + for vm in vms: self.debug("VM ID: %s state: %s" % (vm.id, vm.state)) self.assertEqual( @@ -1743,12 +1744,12 @@ class TestProjectSuspendActivate(cloudstackTestCase): return def test_10_project_activation(self): - """ Test project activation after suspension + """ Test project activation after suspension """ # Validate the following # 1. Activate the project - # 2. Verify project is activated and we are able to add resources + # 2. Verify project is activated and we are able to add resources # Verify 'project.invite.required' is set to false configs = Configurations.list( @@ -1764,13 +1765,13 @@ class TestProjectSuspendActivate(cloudstackTestCase): self.assertEqual( (config.value).lower(), 'false', - "'project.invite.required' should be set to false" + "'project.invite.required' should be set to false" ) # Activating the project self.debug("Activating project: %s" % self.project.name) self.project.activate(self.apiclient) - + virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], @@ -1778,7 +1779,7 @@ class TestProjectSuspendActivate(cloudstackTestCase): serviceofferingid=self.service_offering.id, projectid=self.project.id ) - + self.cleanup.append(virtual_machine) self.debug("Created a VM: %s for project: %s" % ( virtual_machine.id, @@ -1795,13 +1796,13 @@ class TestProjectSuspendActivate(cloudstackTestCase): True, "Check for a valid list accounts response" ) - + self.assertNotEqual( len(vms), 0, "Check list project response returns a valid project" ) - + for vm in vms: self.debug("VM ID: %s state: %s" % (vm.id, vm.state)) self.assertEqual( diff --git a/test/integration/component/test_resource_limits.py b/test/integration/component/test_resource_limits.py index c7290ba0d5c..12a8105363a 100644 --- a/test/integration/component/test_resource_limits.py +++ b/test/integration/component/test_resource_limits.py @@ -25,6 +25,7 @@ from integration.lib.base import * from integration.lib.common import * import datetime + class Services: """Test Resource Limits Services """ @@ -47,8 +48,8 @@ class Services: "name": "Tiny Instance", "displaytext": "Tiny Instance", "cpunumber": 1, - "cpuspeed": 100, # in MHz - "memory": 64, # In MBs + "cpuspeed": 100, # in MHz + "memory": 64, # In MBs }, "disk_offering": { "displaytext": "Small", @@ -81,6 +82,7 @@ class Services: "mode": 'advanced', } + class TestResourceLimitsAccount(cloudstackTestCase): @classmethod @@ -153,7 +155,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): def test_01_vm_per_account(self): """Test VM limit per account """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. Set user_vm=1 limit for account 1. @@ -162,18 +164,18 @@ class TestResourceLimitsAccount(cloudstackTestCase): # 3. Try to start 2 VMs account 2. Verify 2 SM are started properly self.debug( - "Updating instance resource limit for account: %s" % + "Updating instance resource limit for account: %s" % self.account_1.account.name) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, - 0, # Instance + 0, # Instance account=self.account_1.account.name, domainid=self.account_1.account.domainid, max=1 ) self.debug( - "Deploying VM instance in account: %s" % + "Deploying VM instance in account: %s" % self.account_1.account.name) virtual_machine = VirtualMachine.create( @@ -204,7 +206,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): serviceofferingid=self.service_offering.id ) self.debug( - "Deploying VM instance in account: %s" % + "Deploying VM instance in account: %s" % self.account_2.account.name) # Start 2 instances for account_2 virtual_machine_1 = VirtualMachine.create( @@ -224,7 +226,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): ) self.debug( - "Deploying VM instance in account: %s" % + "Deploying VM instance in account: %s" % self.account_2.account.name) virtual_machine_2 = VirtualMachine.create( self.apiclient, @@ -246,7 +248,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): def test_02_publicip_per_account(self): """Test Public IP limit per account """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. Set Public_IP= 2 limit for account 1. @@ -256,21 +258,21 @@ class TestResourceLimitsAccount(cloudstackTestCase): # denied to acquire more than one IP. # 5. Acquire 2 IP in account 2. Verify account 2 should be able to # Acquire IP without any warning - + self.debug( - "Updating public IP resource limit for account: %s" % + "Updating public IP resource limit for account: %s" % self.account_1.account.name) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, - 1, # Public Ip + 1, # Public Ip account=self.account_1.account.name, domainid=self.account_1.account.domainid, max=2 ) self.debug( - "Deploying VM instance in account: %s" % + "Deploying VM instance in account: %s" % self.account_1.account.name) virtual_machine_1 = VirtualMachine.create( self.apiclient, @@ -289,7 +291,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): ) self.debug( - "Deploying VM instance in account: %s" % + "Deploying VM instance in account: %s" % self.account_2.account.name) # Create VM for second account virtual_machine_2 = VirtualMachine.create( @@ -308,7 +310,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): "Check VM state is Running or not" ) self.debug( - "Associating public IP for account: %s" % + "Associating public IP for account: %s" % virtual_machine_1.account) public_ip_1 = PublicIPAddress.create( self.apiclient, @@ -343,7 +345,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): ) self.debug( - "Associating public IP for account: %s" % + "Associating public IP for account: %s" % virtual_machine_2.account) # Assign Public IP for account 2 public_ip_3 = PublicIPAddress.create( @@ -365,7 +367,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): "Check Public IP state is allocated or not" ) self.debug( - "Associating public IP for account: %s" % + "Associating public IP for account: %s" % virtual_machine_2.account) public_ip_4 = PublicIPAddress.create( self.apiclient, @@ -389,7 +391,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): def test_03_snapshots_per_account(self): """Test Snapshot limit per account """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. Set snapshot= 2 limit for account 1. @@ -401,19 +403,19 @@ class TestResourceLimitsAccount(cloudstackTestCase): # create snapshots without any warning self.debug( - "Updating public IP resource limit for account: %s" % + "Updating public IP resource limit for account: %s" % self.account_1.account.name) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, - 3, # Snapshot + 3, # Snapshot account=self.account_1.account.name, domainid=self.account_1.account.domainid, max=1 ) self.debug( - "Deploying VM instance in account: %s" % + "Deploying VM instance in account: %s" % self.account_1.account.name) virtual_machine_1 = VirtualMachine.create( self.apiclient, @@ -432,7 +434,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): ) self.debug( - "Deploying VM instance in account: %s" % + "Deploying VM instance in account: %s" % self.account_1.account.name) # Create VM for second account virtual_machine_2 = VirtualMachine.create( @@ -504,7 +506,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): "Check for list volume response return valid data" ) volume = volumes[0] - + self.debug("Creating snapshot from volume: %s" % volumes[0].id) # Create a snapshot from the ROOTDISK (Account 2) snapshot_2 = Snapshot.create(self.apiclient, @@ -545,7 +547,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): def test_04_volumes_per_account(self): """Test Volumes limit per account """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. Set volumes=2 limit for account 1. @@ -557,12 +559,12 @@ class TestResourceLimitsAccount(cloudstackTestCase): # create Volume without any warning self.debug( - "Updating volume resource limit for account: %s" % + "Updating volume resource limit for account: %s" % self.account_1.account.name) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, - 2, # Volume + 2, # Volume account=self.account_1.account.name, domainid=self.account_1.account.domainid, max=2 @@ -687,7 +689,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): def test_05_templates_per_account(self): """Test Templates limit per account """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. Set templates=1 limit for account 1. @@ -697,19 +699,19 @@ class TestResourceLimitsAccount(cloudstackTestCase): # able to create template without any error self.debug( - "Updating template resource limit for account: %s" % + "Updating template resource limit for account: %s" % self.account_1.account.name) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, - 4, # Template + 4, # Template account=self.account_1.account.name, domainid=self.account_1.account.domainid, max=1 ) self.debug( - "Updating volume resource limit for account: %s" % + "Updating volume resource limit for account: %s" % self.account_1.account.name) virtual_machine_1 = VirtualMachine.create( self.apiclient, @@ -728,7 +730,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): ) self.debug( - "Deploying virtual machine for account: %s" % + "Deploying virtual machine for account: %s" % self.account_2.account.name) # Create VM for second account virtual_machine_2 = VirtualMachine.create( @@ -917,7 +919,7 @@ class TestResourceLimitsDomain(cloudstackTestCase): def test_01_vm_per_domain(self): """Test VM limit per domain """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. Set max VM per domain to 2 @@ -926,12 +928,12 @@ class TestResourceLimitsDomain(cloudstackTestCase): # should be raised self.debug( - "Updating instance resource limits for domain: %s" % + "Updating instance resource limits for domain: %s" % self.account.account.domainid) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, - 0, # Instance + 0, # Instance domainid=self.account.account.domainid, max=2 ) @@ -983,7 +985,7 @@ class TestResourceLimitsDomain(cloudstackTestCase): def test_01_publicip_per_domain(self): """Test Public IP limit per domain """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. set max no of IPs per domain to 2. @@ -994,12 +996,12 @@ class TestResourceLimitsDomain(cloudstackTestCase): # appropriate error and an alert should be generated. self.debug( - "Updating public IP resource limits for domain: %s" % + "Updating public IP resource limits for domain: %s" % self.account.account.domainid) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, - 1, # Public Ip + 1, # Public Ip domainid=self.account.account.domainid, max=2 ) @@ -1053,7 +1055,7 @@ class TestResourceLimitsDomain(cloudstackTestCase): def test_03_snapshots_per_domain(self): """Test Snapshot limit per domain """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. set max no of snapshots per domain to 1. @@ -1065,12 +1067,12 @@ class TestResourceLimitsDomain(cloudstackTestCase): # user an appropriate error and an alert should be generated. self.debug( - "Updating snapshot resource limits for domain: %s" % + "Updating snapshot resource limits for domain: %s" % self.account.account.domainid) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, - 3, # Snapshot + 3, # Snapshot domainid=self.account.account.domainid, max=1 ) @@ -1136,7 +1138,7 @@ class TestResourceLimitsDomain(cloudstackTestCase): def test_04_volumes_per_domain(self): """Test Volumes limit per domain """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. set max no of volume per domain to 1. @@ -1147,12 +1149,12 @@ class TestResourceLimitsDomain(cloudstackTestCase): # should be generated. self.debug( - "Updating volume resource limits for domain: %s" % + "Updating volume resource limits for domain: %s" % self.account.account.domainid) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, - 2, # Volume + 2, # Volume domainid=self.account.account.domainid, max=2 ) @@ -1189,9 +1191,9 @@ class TestResourceLimitsDomain(cloudstackTestCase): def test_05_templates_per_domain(self): """Test Templates limit per domain """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] - # Validate the following + # Validate the following # 1. set max no of templates per domain to 2. # 2. Create an account in this domain # 3. Create 2 templates in this domain. Both template should be in @@ -1202,18 +1204,18 @@ class TestResourceLimitsDomain(cloudstackTestCase): # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, - 2, # Volume + 2, # Volume domainid=self.account.account.domainid, max=5 ) self.debug( - "Updating template resource limits for domain: %s" % + "Updating template resource limits for domain: %s" % self.account.account.domainid) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, - 4, # Template + 4, # Template domainid=self.account.account.domainid, max=2 ) @@ -1301,14 +1303,14 @@ class TestResources(cloudstackTestCase): @classmethod def setUpClass(cls): cls.api_client = super( - TestResources, + TestResources, cls ).getClsTestClient().getApiClient() cls.services = Services().services # Get Zone, Domain and templates cls.zone = get_zone(cls.api_client, cls.services) cls._cleanup = [] - return + return @classmethod def tearDownClass(cls): @@ -1335,16 +1337,16 @@ class TestResources(cloudstackTestCase): def test_01_zones(self): """Check the status of zones""" - tags = ["advanced","advancedns"] - + tags = ["advanced", "advancedns"] + # Validate the following # 1. List zones # 2. Check allocation state is "enabled" or not - + zones = Zone.list( self.apiclient, id=self.zone.id, - listall=True + listall=True ) self.assertEqual( isinstance(zones, list), @@ -1361,16 +1363,16 @@ class TestResources(cloudstackTestCase): def test_02_pods(self): """Check the status of pods""" - tags = ["advanced","advancedns"] - + tags = ["advanced", "advancedns"] + # Validate the following # 1. List pods # 2. Check allocation state is "enabled" or not - + pods = Pod.list( self.apiclient, zoneid=self.zone.id, - listall=True + listall=True ) self.assertEqual( isinstance(pods, list), @@ -1384,19 +1386,19 @@ class TestResources(cloudstackTestCase): "Pods allocation state should be enabled" ) return - + def test_03_clusters(self): """Check the status of clusters""" - tags = ["advanced","advancedns"] - + tags = ["advanced", "advancedns"] + # Validate the following # 1. List clusters # 2. Check allocation state is "enabled" or not - + clusters = Cluster.list( self.apiclient, zoneid=self.zone.id, - listall=True + listall=True ) self.assertEqual( isinstance(clusters, list), @@ -1410,20 +1412,20 @@ class TestResources(cloudstackTestCase): "Clusters allocation state should be enabled" ) return - + def test_04_hosts(self): """Check the status of hosts""" - tags = ["advanced","advancedns"] - + tags = ["advanced", "advancedns"] + # Validate the following # 1. List hosts with type=Routing # 2. Check state is "Up" or not - + hosts = Host.list( self.apiclient, zoneid=self.zone.id, type='Routing', - listall=True + listall=True ) self.assertEqual( isinstance(hosts, list), @@ -1437,19 +1439,19 @@ class TestResources(cloudstackTestCase): "Host should be in Up state and running" ) return - + def test_05_storage_pools(self): """Check the status of Storage pools""" - tags = ["advanced","advancedns"] - + tags = ["advanced", "advancedns"] + # Validate the following # 1. List storage pools for the zone # 2. Check state is "enabled" or not - + storage_pools = StoragePool.list( self.apiclient, zoneid=self.zone.id, - listall=True + listall=True ) self.assertEqual( isinstance(storage_pools, list), @@ -1463,20 +1465,20 @@ class TestResources(cloudstackTestCase): "storage pool should be in Up state and running" ) return - + def test_06_secondary_storage(self): """Check the status of secondary storage""" - tags = ["advanced","advancedns"] - + tags = ["advanced", "advancedns"] + # Validate the following # 1. List secondary storage # 2. Check state is "Up" or not - + sec_storages = Host.list( self.apiclient, zoneid=self.zone.id, type='SecondaryStorage', - listall=True + listall=True ) self.assertEqual( isinstance(sec_storages, list), diff --git a/test/integration/component/test_routers.py b/test/integration/component/test_routers.py index b6ff3072a17..f8260011c65 100644 --- a/test/integration/component/test_routers.py +++ b/test/integration/component/test_routers.py @@ -82,7 +82,7 @@ class Services: "publicport": 2222, "protocol": 'TCP', }, - "fw_rule":{ + "fw_rule": { "startport": 1, "endport": 6000, "cidr": '55.55.0.0/11', @@ -90,7 +90,7 @@ class Services: }, "ostypeid": '5776c0d2-f331-42db-ba3a-29f1f8319bc9', # Used for Get_Template : CentOS 5.3 (64 bit) - "mode": 'advanced', # Networking mode: Advanced, basic + "mode": 'advanced', # Networking mode: Advanced, basic } @@ -180,7 +180,7 @@ class TestRouterServices(cloudstackTestCase): # e. LB # f. VPN # g. userdata - # 2. wait for router to start and guest network to be created + # 2. wait for router to start and guest network to be created # a. listRouters account=user, domainid=1 (router state=Running) # b. listNetworks account=user domainid=1 (network state=Implemented) # c. listVirtualMachines account=user domainid=1 (VM state=Running) @@ -318,7 +318,7 @@ class TestRouterServices(cloudstackTestCase): """ tags = ["advanced"] # Validate the following - # 1. wait for router to start and guest network to be created + # 1. wait for router to start and guest network to be created # a.listRouters account=user, domainid=1 (router state=Running) # b.listNetworks account=user domainid=1 (network state=Implemented) # c.listVirtualMachines account=user domainid=1 (VM states=Running) @@ -436,9 +436,9 @@ class TestRouterServices(cloudstackTestCase): ) self.debug("network.gc.wait: %s" % gcwait[0].value) - total_wait = int(gcinterval[0].value) + int (gcwait[0].value) + total_wait = int(gcinterval[0].value) + int(gcwait[0].value) # Router is stopped after (network.gc.interval *2) time. Wait for - # (network.gc.interval+network.gc.wait) * 2 for moving router to 'Stopped' + # (network.gc.interval+network.gc.wait) * 2 for moving router to 'Stopped' time.sleep(total_wait * 2) routers = list_routers( @@ -580,7 +580,6 @@ class TestRouterServices(cloudstackTestCase): return - class TestRouterStopCreatePF(cloudstackTestCase): @classmethod @@ -657,10 +656,10 @@ class TestRouterStopCreatePF(cloudstackTestCase): # 2. stopRouter for this account # 3. wait for listRouters to report Router as 'Stopped' # 4. listPublicIpAddresses account=user, domainid=1 - pick ipaddressid - # 5. createPortForwardingRule (ipaddressid from step 5.) + # 5. createPortForwardingRule (ipaddressid from step 5.) # a. for port 22 (ssh) for user VM deployed in step 1. # b. public port 222 , private port 22 - # 6. startRouter stopped for this account + # 6. startRouter stopped for this account # 7. wait for listRouters to show router as Running # Get router details associated for that account @@ -720,7 +719,7 @@ class TestRouterStopCreatePF(cloudstackTestCase): ) public_ip = public_ips[0] - # Open up firewall port for SSH + # Open up firewall port for SSH fw_rule = FireWallRule.create( self.apiclient, ipaddressid=public_ip.id, @@ -791,6 +790,7 @@ class TestRouterStopCreatePF(cloudstackTestCase): ) return + class TestRouterStopCreateLB(cloudstackTestCase): @classmethod @@ -923,8 +923,8 @@ class TestRouterStopCreateLB(cloudstackTestCase): "Check for list public IPs response return valid data" ) public_ip = public_ips[0] - - # Open up firewall port for SSH + + # Open up firewall port for SSH fw_rule = FireWallRule.create( self.apiclient, ipaddressid=public_ip.id, @@ -1076,7 +1076,7 @@ class TestRouterStopCreateFW(cloudstackTestCase): # (optional backend) # 3. verify on router using iptables -t nat -nvx if rules are applied - # Get the router details associated with account + # Get the router details associated with account routers = list_routers( self.apiclient, account=self.account.account.name, @@ -1223,4 +1223,3 @@ class TestRouterStopCreateFW(cloudstackTestCase): "Check public IP address" ) return - diff --git a/test/integration/component/test_security_groups.py b/test/integration/component/test_security_groups.py index 71e7a29696d..85c96d326b5 100644 --- a/test/integration/component/test_security_groups.py +++ b/test/integration/component/test_security_groups.py @@ -37,7 +37,7 @@ class Services: def __init__(self): self.services = { - "disk_offering":{ + "disk_offering": { "displaytext": "Small", "name": "Small", "disksize": 1 @@ -47,12 +47,12 @@ class Services: "firstname": "Test", "lastname": "User", "username": "test", - # Random characters are appended in create account to + # Random characters are appended in create account to # ensure unique username generated each time "password": "fr3sca", }, "virtual_machine": { - # Create a small virtual machine instance with disk offering + # Create a small virtual machine instance with disk offering "displayname": "Test VM", "username": "root", # VM creds for SSH "password": "password", @@ -65,15 +65,15 @@ class Services: }, "host": { "publicport": 22, - "username": "root", # Host creds for SSH + "username": "root", # Host creds for SSH "password": "fr3sca", }, "service_offering": { "name": "Tiny Instance", "displaytext": "Tiny Instance", "cpunumber": 1, - "cpuspeed": 100, # in MHz - "memory": 64, # In MBs + "cpuspeed": 100, # in MHz + "memory": 64, # In MBs }, "security_group": { "name": 'SSH', @@ -87,19 +87,19 @@ class Services: "protocol": 'ICMP', "startport": -1, "endport": -1, - "cidrlist": '0.0.0.0/0', + "cidrlist": '0.0.0.0/0', }, "ostypeid": '0c2c5d19-525b-41be-a8c3-c6607412f82b', # CentOS 5.3 (64-bit) "sleep": 60, "timeout": 10, - "mode":'basic', + "mode": 'basic', # Networking mode: Basic or Advanced } class TestDefaultSecurityGroup(cloudstackTestCase): - + def setUp(self): self.apiclient = self.testClient.getApiClient() @@ -125,7 +125,7 @@ class TestDefaultSecurityGroup(cloudstackTestCase): # 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, cls.zone.id, @@ -134,7 +134,7 @@ class TestDefaultSecurityGroup(cloudstackTestCase): cls.services["domainid"] = cls.domain.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.id - + cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] @@ -168,12 +168,12 @@ class TestDefaultSecurityGroup(cloudstackTestCase): def test_01_deployVM_InDefaultSecurityGroup(self): """Test deploy VM in default security group """ - + tags = ["sg", "eip"] # Validate the following: # 1. deploy Virtual machine using admin user - # 2. listVM should show a VM in Running state + # 2. listVM should show a VM in Running state # 3. listRouters should show one router running self.virtual_machine = VirtualMachine.create( @@ -185,7 +185,7 @@ class TestDefaultSecurityGroup(cloudstackTestCase): ) self.debug("Deployed VM with ID: %s" % self.virtual_machine.id) self.cleanup.append(self.virtual_machine) - + list_vm_response = list_virtual_machines( self.apiclient, id=self.virtual_machine.id @@ -219,8 +219,8 @@ class TestDefaultSecurityGroup(cloudstackTestCase): self.virtual_machine.displayname, "Check virtual machine displayname in listVirtualMachines" ) - - # Verify List Routers response for account + + # Verify List Routers response for account self.debug( "Verify list routers response for account: %s" \ % self.account.account.name @@ -235,11 +235,11 @@ class TestDefaultSecurityGroup(cloudstackTestCase): True, "Check for list Routers response" ) - + self.debug("Router Response: %s" % routers) self.assertEqual( - len(routers), - 1, + len(routers), + 1, "Check virtual router is created for account or not" ) return @@ -247,14 +247,14 @@ class TestDefaultSecurityGroup(cloudstackTestCase): def test_02_listSecurityGroups(self): """Test list security groups for admin account """ - + tags = ["sg", "eip"] # Validate the following: # 1. listSecurityGroups in admin account # 2. There should be one security group (default) listed for the admin account # 3. No Ingress Rules should be part of the default security group - + sercurity_groups = SecurityGroup.list( self.apiclient, account=self.account.account.name, @@ -266,11 +266,11 @@ class TestDefaultSecurityGroup(cloudstackTestCase): "Check for list security groups response" ) self.assertNotEqual( - len(sercurity_groups), - 0, + len(sercurity_groups), + 0, "Check List Security groups response" ) - self.debug("List Security groups response: %s" % + self.debug("List Security groups response: %s" % str(sercurity_groups)) self.assertEqual( hasattr(sercurity_groups, 'ingressrule'), @@ -278,16 +278,16 @@ class TestDefaultSecurityGroup(cloudstackTestCase): "Check ingress rule attribute for default security group" ) return - + def test_03_accessInDefaultSecurityGroup(self): """Test access in default security group """ - + tags = ["sg", "eip"] # Validate the following: # 1. deploy Virtual machine using admin user - # 2. listVM should show a VM in Running state + # 2. listVM should show a VM in Running state # 3. listRouters should show one router running self.virtual_machine = VirtualMachine.create( @@ -299,7 +299,7 @@ class TestDefaultSecurityGroup(cloudstackTestCase): ) self.debug("Deployed VM with ID: %s" % self.virtual_machine.id) self.cleanup.append(self.virtual_machine) - + list_vm_response = list_virtual_machines( self.apiclient, id=self.virtual_machine.id @@ -309,7 +309,7 @@ class TestDefaultSecurityGroup(cloudstackTestCase): True, "Check for list VM response" ) - + self.debug( "Verify listVirtualMachines response for virtual machine: %s" \ % self.virtual_machine.id @@ -345,12 +345,12 @@ class TestDefaultSecurityGroup(cloudstackTestCase): True, "Check for list security groups response" ) - - self.debug("List Security groups response: %s" % + + self.debug("List Security groups response: %s" % str(sercurity_groups)) self.assertNotEqual( - len(sercurity_groups), - 0, + len(sercurity_groups), + 0, "Check List Security groups response" ) self.assertEqual( @@ -358,7 +358,7 @@ class TestDefaultSecurityGroup(cloudstackTestCase): False, "Check ingress rule attribute for default security group" ) - + # SSH Attempt to VM should fail with self.assertRaises(Exception): self.debug("SSH into VM: %s" % self.virtual_machine.ssh_ip) @@ -369,10 +369,10 @@ class TestDefaultSecurityGroup(cloudstackTestCase): self.virtual_machine.password ) return - + class TestAuthorizeIngressRule(cloudstackTestCase): - + def setUp(self): self.apiclient = self.testClient.getApiClient() @@ -398,7 +398,7 @@ class TestAuthorizeIngressRule(cloudstackTestCase): # 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, cls.zone.id, @@ -407,7 +407,7 @@ class TestAuthorizeIngressRule(cloudstackTestCase): cls.services["domainid"] = cls.domain.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.id - + cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] @@ -439,7 +439,7 @@ class TestAuthorizeIngressRule(cloudstackTestCase): def test_01_authorizeIngressRule(self): """Test authorize ingress rule """ - + tags = ["sg", "eip"] # Validate the following: @@ -447,11 +447,11 @@ class TestAuthorizeIngressRule(cloudstackTestCase): #2. Createsecuritygroup (ssh-incoming) for this account #3. authorizeSecurityGroupIngress to allow ssh access to the VM #4. deployVirtualMachine into this security group (ssh-incoming) - + security_group = SecurityGroup.create( - self.apiclient, - self.services["security_group"], - account=self.account.account.name, + self.apiclient, + self.services["security_group"], + account=self.account.account.name, domainid=self.account.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) @@ -466,17 +466,17 @@ class TestAuthorizeIngressRule(cloudstackTestCase): True, "Check for list security groups response" ) - + self.assertEqual( - len(sercurity_groups), - 2, + len(sercurity_groups), + 2, "Check List Security groups response" ) # Authorize Security group to SSH to VM ingress_rule = security_group.authorize( self.apiclient, - self.services["security_group"], - account=self.account.account.name, + self.services["security_group"], + account=self.account.account.name, domainid=self.account.account.domainid ) self.assertEqual( @@ -484,8 +484,8 @@ class TestAuthorizeIngressRule(cloudstackTestCase): True, "Check ingress rule created properly" ) - - self.debug("Authorizing ingress rule for sec group ID: %s for ssh access" + + self.debug("Authorizing ingress rule for sec group ID: %s for ssh access" % security_group.id) self.virtual_machine = VirtualMachine.create( self.apiclient, @@ -508,7 +508,7 @@ class TestAuthorizeIngressRule(cloudstackTestCase): class TestRevokeIngressRule(cloudstackTestCase): - + def setUp(self): self.apiclient = self.testClient.getApiClient() @@ -534,7 +534,7 @@ class TestRevokeIngressRule(cloudstackTestCase): # 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, cls.zone.id, @@ -543,7 +543,7 @@ class TestRevokeIngressRule(cloudstackTestCase): cls.services["domainid"] = cls.domain.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.id - + cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] @@ -575,7 +575,7 @@ class TestRevokeIngressRule(cloudstackTestCase): def test_01_revokeIngressRule(self): """Test revoke ingress rule """ - + tags = ["sg", "eip"] # Validate the following: @@ -584,15 +584,15 @@ class TestRevokeIngressRule(cloudstackTestCase): #3. authorizeSecurityGroupIngress to allow ssh access to the VM #4. deployVirtualMachine into this security group (ssh-incoming) #5. Revoke the ingress rule, SSH access should fail - + security_group = SecurityGroup.create( - self.apiclient, - self.services["security_group"], - account=self.account.account.name, + self.apiclient, + self.services["security_group"], + account=self.account.account.name, domainid=self.account.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) - + # Default Security group should not have any ingress rule sercurity_groups = SecurityGroup.list( self.apiclient, @@ -604,28 +604,28 @@ class TestRevokeIngressRule(cloudstackTestCase): True, "Check for list security groups response" ) - + self.assertEqual( - len(sercurity_groups), - 2, + len(sercurity_groups), + 2, "Check List Security groups response" ) # Authorize Security group to SSH to VM - self.debug("Authorizing ingress rule for sec group ID: %s for ssh access" + self.debug("Authorizing ingress rule for sec group ID: %s for ssh access" % security_group.id) ingress_rule = security_group.authorize( self.apiclient, - self.services["security_group"], - account=self.account.account.name, + self.services["security_group"], + account=self.account.account.name, domainid=self.account.account.domainid ) - + self.assertEqual( isinstance(ingress_rule, dict), True, "Check ingress rule created properly" ) - + ssh_rule = (ingress_rule["ingressrule"][0]).__dict__ self.virtual_machine = VirtualMachine.create( self.apiclient, @@ -636,7 +636,7 @@ class TestRevokeIngressRule(cloudstackTestCase): securitygroupids=[security_group.id] ) self.debug("Deploying VM in account: %s" % self.account.account.name) - + # Should be able to SSH VM try: self.debug("SSH into VM: %s" % self.virtual_machine.id) @@ -645,12 +645,12 @@ class TestRevokeIngressRule(cloudstackTestCase): self.fail("SSH Access failed for %s: %s" % \ (self.virtual_machine.ipaddress, e) ) - - self.debug("Revoking ingress rule for sec group ID: %s for ssh access" + + self.debug("Revoking ingress rule for sec group ID: %s for ssh access" % security_group.id) # Revoke Security group to SSH to VM result = security_group.revoke( - self.apiclient, + self.apiclient, id=ssh_rule["ruleid"] ) @@ -667,7 +667,7 @@ class TestRevokeIngressRule(cloudstackTestCase): class TestDhcpOnlyRouter(cloudstackTestCase): - + def setUp(self): self.apiclient = self.testClient.getApiClient() @@ -693,17 +693,17 @@ class TestDhcpOnlyRouter(cloudstackTestCase): # 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, 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 - + cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] @@ -742,13 +742,13 @@ class TestDhcpOnlyRouter(cloudstackTestCase): def test_01_dhcpOnlyRouter(self): """Test router services for user account """ - + tags = ["sg", "eip", "basic"] - + # Validate the following #1. List routers for any user account #2. The only service supported by this router should be dhcp - + # Find router associated with user account list_router_response = list_routers( self.apiclient, @@ -767,7 +767,7 @@ class TestDhcpOnlyRouter(cloudstackTestCase): zoneid=router.zoneid, type='Routing', state='Up', - virtualmachineid=self.virtual_machine.id + id=router.hostid ) self.assertEqual( isinstance(hosts, list), @@ -775,7 +775,7 @@ class TestDhcpOnlyRouter(cloudstackTestCase): "Check list host returns a valid list" ) host = hosts[0] - + self.debug("Router ID: %s, state: %s" % (router.id, router.state)) self.assertEqual( @@ -801,10 +801,10 @@ class TestDhcpOnlyRouter(cloudstackTestCase): "Check dnsmasq service is running or not" ) return - + class TestdeployVMWithUserData(cloudstackTestCase): - + def setUp(self): self.apiclient = self.testClient.getApiClient() @@ -830,17 +830,17 @@ class TestdeployVMWithUserData(cloudstackTestCase): # 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, 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 - + cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] @@ -868,12 +868,12 @@ class TestdeployVMWithUserData(cloudstackTestCase): raise Exception("Warning: Exception during cleanup : %s" % e) return - + def test_01_deployVMWithUserData(self): """Test Deploy VM with User data""" - + tags = ["sg", "eip"] - + # Validate the following # 1. CreateAccount of type user # 2. CreateSecurityGroup ssh-incoming @@ -881,7 +881,7 @@ class TestdeployVMWithUserData(cloudstackTestCase): # 4. deployVirtualMachine into this group with some base64 encoded user-data # 5. wget http://10.1.1.1/latest/user-data to get the latest userdata from the # router for this VM - + # Find router associated with user account list_router_response = list_routers( self.apiclient, @@ -894,11 +894,11 @@ class TestdeployVMWithUserData(cloudstackTestCase): "Check list response returns a valid list" ) router = list_router_response[0] - + security_group = SecurityGroup.create( - self.apiclient, - self.services["security_group"], - account=self.account.account.name, + self.apiclient, + self.services["security_group"], + account=self.account.account.name, domainid=self.account.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) @@ -914,23 +914,23 @@ class TestdeployVMWithUserData(cloudstackTestCase): "Check for list security groups response" ) self.assertEqual( - len(sercurity_groups), - 2, + len(sercurity_groups), + 2, "Check List Security groups response" ) - + self.debug( "Authorize Ingress Rule for Security Group %s for account: %s" \ % ( security_group.id, self.account.account.name )) - + # Authorize Security group to SSH to VM ingress_rule = security_group.authorize( self.apiclient, - self.services["security_group"], - account=self.account.account.name, + self.services["security_group"], + account=self.account.account.name, domainid=self.account.account.domainid ) self.assertEqual( @@ -953,13 +953,13 @@ class TestdeployVMWithUserData(cloudstackTestCase): "SSH to VM with IP Address: %s"\ % self.virtual_machine.ssh_ip ) - + ssh = self.virtual_machine.get_ssh_client() except Exception as e: self.fail("SSH Access failed for %s: %s" % \ (self.virtual_machine.ipaddress, e) ) - + cmds = [ "wget http://%s/latest/user-data" % router.guestipaddress, "cat user-data", @@ -967,39 +967,39 @@ class TestdeployVMWithUserData(cloudstackTestCase): for c in cmds: result = ssh.execute(c) self.debug("%s: %s" % (c, result)) - + res = str(result) self.assertEqual( res.count(self.services["virtual_machine"]["userdata"]), - 1, + 1, "Verify user data" ) return class TestDeleteSecurityGroup(cloudstackTestCase): - + def setUp(self): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() - + 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, self.zone.id, self.services["ostypeid"] ) - + self.services["domainid"] = self.domain.id self.services["virtual_machine"]["zoneid"] = self.zone.id self.services["virtual_machine"]["template"] = template.id - + self.service_offering = ServiceOffering.create( self.apiclient, self.services["service_offering"] @@ -1044,23 +1044,23 @@ class TestDeleteSecurityGroup(cloudstackTestCase): raise Exception("Warning: Exception during cleanup : %s" % e) return - + def test_01_delete_security_grp_running_vm(self): """Test delete security group with running VM""" - + tags = ["sg", "eip"] - + # Validate the following # 1. createsecuritygroup (ssh-incoming) for this account # 2. authorizeSecurityGroupIngress to allow ssh access to the VM # 3. deployVirtualMachine into this security group (ssh-incoming) # 4. deleteSecurityGroup created in step 1. Deletion should fail # complaining there are running VMs in this group - + security_group = SecurityGroup.create( - self.apiclient, - self.services["security_group"], - account=self.account.account.name, + self.apiclient, + self.services["security_group"], + account=self.account.account.name, domainid=self.account.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) @@ -1075,10 +1075,10 @@ class TestDeleteSecurityGroup(cloudstackTestCase): True, "Check for list security groups response" ) - + self.assertEqual( - len(sercurity_groups), - 2, + len(sercurity_groups), + 2, "Check List Security groups response" ) self.debug( @@ -1087,12 +1087,12 @@ class TestDeleteSecurityGroup(cloudstackTestCase): security_group.id, self.account.account.name )) - + # Authorize Security group to SSH to VM ingress_rule = security_group.authorize( self.apiclient, - self.services["security_group"], - account=self.account.account.name, + self.services["security_group"], + account=self.account.account.name, domainid=self.account.account.domainid ) self.assertEqual( @@ -1100,7 +1100,7 @@ class TestDeleteSecurityGroup(cloudstackTestCase): True, "Check ingress rule created properly" ) - + self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], @@ -1110,41 +1110,41 @@ class TestDeleteSecurityGroup(cloudstackTestCase): securitygroupids=[security_group.id] ) self.debug("Deploying VM in account: %s" % self.account.account.name) - + # Deleting Security group should raise exception 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, + 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""" - + tags = ["sg", "eip"] - + # Validate the following # 1. createsecuritygroup (ssh-incoming) for this account # 2. authorizeSecurityGroupIngress to allow ssh access to the VM # 3. deployVirtualMachine into this security group (ssh-incoming) # 4. deleteSecurityGroup created in step 1. Deletion should fail # complaining there are running VMs in this group - + security_group = SecurityGroup.create( - self.apiclient, - self.services["security_group"], - account=self.account.account.name, + self.apiclient, + self.services["security_group"], + account=self.account.account.name, domainid=self.account.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) @@ -1160,11 +1160,11 @@ class TestDeleteSecurityGroup(cloudstackTestCase): "Check for list security groups response" ) self.assertEqual( - len(sercurity_groups), - 2, + len(sercurity_groups), + 2, "Check List Security groups response" ) - + self.debug( "Authorize Ingress Rule for Security Group %s for account: %s" \ % ( @@ -1174,8 +1174,8 @@ class TestDeleteSecurityGroup(cloudstackTestCase): # Authorize Security group to SSH to VM ingress_rule = security_group.authorize( self.apiclient, - self.services["security_group"], - account=self.account.account.name, + self.services["security_group"], + account=self.account.account.name, domainid=self.account.account.domainid ) self.assertEqual( @@ -1183,7 +1183,7 @@ class TestDeleteSecurityGroup(cloudstackTestCase): True, "Check ingress rule created properly" ) - + self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], @@ -1193,10 +1193,10 @@ class TestDeleteSecurityGroup(cloudstackTestCase): securitygroupids=[security_group.id] ) self.debug("Deploying VM in account: %s" % self.account.account.name) - + # Destroy the VM self.virtual_machine.delete(self.apiclient) - + config = list_configurations( self.apiclient, name='expunge.delay' @@ -1210,7 +1210,7 @@ class TestDeleteSecurityGroup(cloudstackTestCase): self.debug("expunge.delay: %s" % response.value) # Wait for some time more than expunge.delay time.sleep(int(response.value) * 2) - + # Deleting Security group should raise exception try: self.debug("Deleting Security Group: %s" % security_group.id) @@ -1220,32 +1220,32 @@ class TestDeleteSecurityGroup(cloudstackTestCase): % security_group.id ) return - + class TestIngressRule(cloudstackTestCase): - + def setUp(self): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() self.cleanup = [] - + 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, self.zone.id, self.services["ostypeid"] ) - + self.services["domainid"] = self.domain.id self.services["virtual_machine"]["zoneid"] = self.zone.id self.services["virtual_machine"]["template"] = template.id - + self.service_offering = ServiceOffering.create( self.apiclient, self.services["service_offering"] @@ -1293,20 +1293,20 @@ class TestIngressRule(cloudstackTestCase): def test_01_authorizeIngressRule_AfterDeployVM(self): """Test delete security group with running VM""" - + tags = ["sg", "eip"] - + # Validate the following # 1. createsecuritygroup (ssh-incoming, 22via22) for this account # 2. authorizeSecurityGroupIngress to allow ssh access to the VM # 3. deployVirtualMachine into this security group (ssh-incoming) # 4. authorizeSecurityGroupIngress to allow ssh access (startport:222 to # endport:22) to the VM - + security_group = SecurityGroup.create( - self.apiclient, - self.services["security_group"], - account=self.account.account.name, + self.apiclient, + self.services["security_group"], + account=self.account.account.name, domainid=self.account.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) @@ -1322,8 +1322,8 @@ class TestIngressRule(cloudstackTestCase): "Check for list security groups response" ) self.assertEqual( - len(sercurity_groups), - 2, + len(sercurity_groups), + 2, "Check List Security groups response" ) self.debug( @@ -1332,12 +1332,12 @@ class TestIngressRule(cloudstackTestCase): security_group.id, self.account.account.name )) - + # Authorize Security group to SSH to VM ingress_rule_1 = security_group.authorize( self.apiclient, - self.services["security_group"], - account=self.account.account.name, + self.services["security_group"], + account=self.account.account.name, domainid=self.account.account.domainid ) self.assertEqual( @@ -1354,7 +1354,7 @@ class TestIngressRule(cloudstackTestCase): securitygroupids=[security_group.id] ) self.debug("Deploying VM in account: %s" % self.account.account.name) - + self.debug( "Authorize Ingress Rule for Security Group %s for account: %s" \ % ( @@ -1364,8 +1364,8 @@ class TestIngressRule(cloudstackTestCase): # Authorize Security group to SSH to VM ingress_rule_2 = security_group.authorize( self.apiclient, - self.services["security_group_2"], - account=self.account.account.name, + self.services["security_group_2"], + account=self.account.account.name, domainid=self.account.account.domainid ) self.assertEqual( @@ -1380,16 +1380,16 @@ class TestIngressRule(cloudstackTestCase): self.services["security_group"]["endport"] )) self.virtual_machine.get_ssh_client() - + except Exception as e: self.fail("SSH access failed for ingress rule ID: %s, %s" \ % (ingress_rule_1["id"], e)) - + # User should be able to ping VM try: self.debug("Trying to ping VM %s" % self.virtual_machine.ssh_ip) result = subprocess.call(['ping', '-c 1', self.virtual_machine.ssh_ip]) - + self.debug("Ping result: %s" % result) # if ping successful, then result should be 0 self.assertEqual( @@ -1397,7 +1397,7 @@ class TestIngressRule(cloudstackTestCase): 0, "Check if ping is successful or not" ) - + except Exception as e: self.fail("Ping failed for ingress rule ID: %s, %s" \ % (ingress_rule_2["id"], e)) @@ -1405,9 +1405,9 @@ class TestIngressRule(cloudstackTestCase): def test_02_revokeIngressRule_AfterDeployVM(self): """Test Revoke ingress rule after deploy VM""" - + tags = ["sg", "eip"] - + # Validate the following # 1. createsecuritygroup (ssh-incoming, 22via22) for this account # 2. authorizeSecurityGroupIngress to allow ssh access to the VM @@ -1420,13 +1420,13 @@ class TestIngressRule(cloudstackTestCase): # but allowed through port 22 security_group = SecurityGroup.create( - self.apiclient, - self.services["security_group"], - account=self.account.account.name, + self.apiclient, + self.services["security_group"], + account=self.account.account.name, domainid=self.account.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) - + # Default Security group should not have any ingress rule sercurity_groups = SecurityGroup.list( self.apiclient, @@ -1439,23 +1439,23 @@ class TestIngressRule(cloudstackTestCase): "Check for list security groups response" ) self.assertEqual( - len(sercurity_groups), - 2, + len(sercurity_groups), + 2, "Check List Security groups response" ) - + self.debug( "Authorize Ingress Rule for Security Group %s for account: %s" \ % ( security_group.id, self.account.account.name )) - + # Authorize Security group to SSH to VM ingress_rule = security_group.authorize( self.apiclient, - self.services["security_group"], - account=self.account.account.name, + self.services["security_group"], + account=self.account.account.name, domainid=self.account.account.domainid ) self.assertEqual( @@ -1472,19 +1472,19 @@ class TestIngressRule(cloudstackTestCase): securitygroupids=[security_group.id] ) self.debug("Deploying VM in account: %s" % self.account.account.name) - + self.debug( "Authorize Ingress Rule for Security Group %s for account: %s" \ % ( security_group.id, self.account.account.name )) - + # Authorize Security group to SSH to VM ingress_rule_2 = security_group.authorize( self.apiclient, - self.services["security_group_2"], - account=self.account.account.name, + self.services["security_group_2"], + account=self.account.account.name, domainid=self.account.account.domainid ) self.assertEqual( @@ -1492,10 +1492,10 @@ class TestIngressRule(cloudstackTestCase): True, "Check ingress rule created properly" ) - + ssh_rule = (ingress_rule["ingressrule"][0]).__dict__ icmp_rule = (ingress_rule_2["ingressrule"][0]).__dict__ - + # SSH should be allowed on 22 try: self.debug("Trying to SSH into VM %s on port %s" % ( @@ -1503,16 +1503,16 @@ class TestIngressRule(cloudstackTestCase): self.services["security_group"]["endport"] )) self.virtual_machine.get_ssh_client() - + except Exception as e: self.fail("SSH access failed for ingress rule ID: %s, %s" \ % (ssh_rule["ruleid"], e)) - + # User should be able to ping VM try: self.debug("Trying to ping VM %s" % self.virtual_machine.ssh_ip) result = subprocess.call(['ping', '-c 1', self.virtual_machine.ssh_ip]) - + self.debug("Ping result: %s" % result) # if ping successful, then result should be 0 self.assertEqual( @@ -1520,21 +1520,21 @@ class TestIngressRule(cloudstackTestCase): 0, "Check if ping is successful or not" ) - + except Exception as e: self.fail("Ping failed for ingress rule ID: %s, %s" \ % (icmp_rule["ruleid"], e)) - + self.debug( "Revoke Ingress Rule for Security Group %s for account: %s" \ % ( security_group.id, self.account.account.name )) - + result = security_group.revoke( - self.apiclient, - id = icmp_rule["ruleid"] + self.apiclient, + id=icmp_rule["ruleid"] ) self.debug("Revoke ingress rule result: %s" % result) @@ -1543,7 +1543,7 @@ class TestIngressRule(cloudstackTestCase): try: self.debug("Trying to ping VM %s" % self.virtual_machine.ssh_ip) result = subprocess.call(['ping', '-c 1', self.virtual_machine.ssh_ip]) - + self.debug("Ping result: %s" % result) # if ping successful, then result should be 0 self.assertNotEqual( @@ -1551,7 +1551,7 @@ class TestIngressRule(cloudstackTestCase): 0, "Check if ping is successful or not" ) - + except Exception as e: self.fail("Ping failed for ingress rule ID: %s, %s" \ % (icmp_rule["ruleid"], e)) @@ -1559,9 +1559,9 @@ class TestIngressRule(cloudstackTestCase): def test_03_stopStartVM_verifyIngressAccess(self): """Test Start/Stop VM and Verify ingress rule""" - + tags = ["sg", "eip"] - + # Validate the following # 1. createsecuritygroup (ssh-incoming, 22via22) for this account # 2. authorizeSecurityGroupIngress to allow ssh access to the VM @@ -1572,9 +1572,9 @@ class TestIngressRule(cloudstackTestCase): # verify that ssh-access to the VM is allowed security_group = SecurityGroup.create( - self.apiclient, - self.services["security_group"], - account=self.account.account.name, + self.apiclient, + self.services["security_group"], + account=self.account.account.name, domainid=self.account.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) @@ -1589,25 +1589,25 @@ class TestIngressRule(cloudstackTestCase): True, "Check for list security groups response" ) - + self.assertEqual( - len(sercurity_groups), - 2, + len(sercurity_groups), + 2, "Check List Security groups response" ) - + self.debug( "Authorize Ingress Rule for Security Group %s for account: %s" \ % ( security_group.id, self.account.account.name )) - + # Authorize Security group to SSH to VM ingress_rule = security_group.authorize( self.apiclient, - self.services["security_group"], - account=self.account.account.name, + self.services["security_group"], + account=self.account.account.name, domainid=self.account.account.domainid ) self.assertEqual( @@ -1615,7 +1615,7 @@ class TestIngressRule(cloudstackTestCase): True, "Check ingress rule created properly" ) - + self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], @@ -1625,7 +1625,7 @@ class TestIngressRule(cloudstackTestCase): securitygroupids=[security_group.id] ) self.debug("Deploying VM in account: %s" % self.account.account.name) - + # SSH should be allowed on 22 port try: self.debug("Trying to SSH into VM %s" % self.virtual_machine.ssh_ip) @@ -1634,17 +1634,17 @@ class TestIngressRule(cloudstackTestCase): self.fail("SSH access failed for ingress rule ID: %s" \ % ingress_rule["id"] ) - + self.virtual_machine.stop(self.apiclient) - + # Sleep to ensure that VM is in stopped state time.sleep(self.services["sleep"]) - + self.virtual_machine.start(self.apiclient) - + # Sleep to ensure that VM is in running state time.sleep(self.services["sleep"]) - + # SSH should be allowed on 22 port after restart try: self.debug("Trying to SSH into VM %s" % self.virtual_machine.ssh_ip) diff --git a/test/integration/component/test_snapshots.py b/test/integration/component/test_snapshots.py index 9273919d360..dc98983774b 100644 --- a/test/integration/component/test_snapshots.py +++ b/test/integration/component/test_snapshots.py @@ -25,6 +25,7 @@ from integration.lib.base import * from integration.lib.common import * from marvin.remoteSSHClient import remoteSSHClient + class Services: """Test Snapshots Services """ @@ -44,8 +45,8 @@ class Services: "name": "Tiny Instance", "displaytext": "Tiny Instance", "cpunumber": 1, - "cpuspeed": 200, # in MHz - "memory": 256, # In MBs + "cpuspeed": 200, # in MHz + "memory": 256, # In MBs }, "disk_offering": { "displaytext": "Small Disk", @@ -71,10 +72,10 @@ class Services: "recurring_snapshot": { "intervaltype": 'HOURLY', # Frequency of snapshots - "maxsnaps": 1, # 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 + # Timezone Formats - http://cloud.mindtouch.us/CloudStack_Documentation/Developer's_Guide%3A_CloudStack }, "templates": { "displaytext": 'Template', @@ -84,7 +85,7 @@ class Services: }, "diskdevice": "/dev/xvda", "diskname": "TestDiskServ", - "size": 1, # GBs + "size": 1, # GBs "mount_dir": "/mnt/tmp", "sub_dir": "test", @@ -96,7 +97,7 @@ class Services: # Cent OS 5.3 (64 bit) "sleep": 60, "timeout": 10, - "mode" : 'advanced', # Networking mode: Advanced, Basic + "mode": 'advanced', # Networking mode: Advanced, Basic } @@ -165,7 +166,7 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase): def test_01_createVM_snapshotTemplate(self): """Test create VM, Snapshot and Template """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. Deploy VM using default template, small service offering # and small data disk offering. @@ -191,7 +192,7 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase): serviceofferingid=self.service_offering.id ) self.debug("Created VM with ID: %s" % self.virtual_machine.id) - # Get the Root disk of VM + # Get the Root disk of VM volumes = list_volumes( self.apiclient, virtualmachineid=self.virtual_machine.id, @@ -332,7 +333,7 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase): export_path = '/'.join(parse_url[3:]) # Export path: export/test - + # Sleep to ensure that snapshot is reflected in sec storage time.sleep(self.services["sleep"]) try: @@ -344,7 +345,7 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase): self.services["mgmt_server"]["password"], ) - cmds = [ + cmds = [ "mkdir -p %s" % self.services["mount_dir"], "mount %s/%s %s" % ( sec_storage_ip, @@ -361,7 +362,7 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase): self.debug("command: %s" % c) result = ssh_client.execute(c) self.debug("Result: %s" % result) - + except Exception as e: self.fail("SSH failed for Management server: %s" % self.services["mgmt_server"]["ipaddress"]) @@ -379,7 +380,7 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase): except Exception as e: self.fail("SSH failed for Management server: %s" % self.services["mgmt_server"]["ipaddress"]) - + res = str(uuids) self.assertEqual( res.count(snapshot_uuid), @@ -430,7 +431,7 @@ class TestAccountSnapshotClean(cloudstackTestCase): domainid=cls.account.account.domainid, serviceofferingid=cls.service_offering.id ) - # Get the Root disk of VM + # Get the Root disk of VM volumes = list_volumes( cls.api_client, virtualmachineid=cls.virtual_machine.id, @@ -473,7 +474,7 @@ class TestAccountSnapshotClean(cloudstackTestCase): def test_02_accountSnapshotClean(self): """Test snapshot cleanup after account deletion """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. listAccounts API should list out the newly created account # 2. listVirtualMachines() command should return the deployed VM. @@ -518,7 +519,7 @@ class TestAccountSnapshotClean(cloudstackTestCase): for virtual_machine in virtual_machines: self.debug("VM ID: %s, VM state: %s" % ( virtual_machine.id, - virtual_machine.state + virtual_machine.state )) self.assertEqual( virtual_machine.state, @@ -591,7 +592,7 @@ class TestAccountSnapshotClean(cloudstackTestCase): export_path = '/'.join(parse_url[3:]) # Export path: export/test - + # Sleep to ensure that snapshot is reflected in sec storage time.sleep(self.services["sleep"]) try: @@ -621,7 +622,7 @@ class TestAccountSnapshotClean(cloudstackTestCase): self.debug("command: %s" % c) result = ssh_client.execute(c) self.debug("Result: %s" % result) - + uuids.append(result) # Unmount the Sec Storage @@ -633,14 +634,14 @@ class TestAccountSnapshotClean(cloudstackTestCase): except Exception: self.fail("SSH failed for management server: %s" % self.services["mgmt_server"]["ipaddress"]) - + res = str(uuids) self.assertEqual( res.count(snapshot_uuid), 1, "Check snapshot UUID in secondary storage and database" ) - + self.debug("Deleting account: %s" % self.account.account.name) # Delete account self.account.delete(self.apiclient) @@ -655,7 +656,7 @@ class TestAccountSnapshotClean(cloudstackTestCase): "Check list response returns a valid list" ) self.debug("account.cleanup.interval: %s" % interval[0].value) - + # Wait for account cleanup interval time.sleep(int(interval[0].value) * 2) @@ -663,14 +664,14 @@ class TestAccountSnapshotClean(cloudstackTestCase): self.apiclient, id=self.account.account.id ) - - self.assertEqual( - accounts, - None, - "List accounts should return empty list after account deletion" - ) - uuids = [] + self.assertEqual( + accounts, + None, + "List accounts should return empty list after account deletion" + ) + + uuids = [] for host in hosts: # hosts[0].name = "nfs://192.168.100.21/export/test" parse_url = (host.name).split('/') @@ -684,7 +685,7 @@ class TestAccountSnapshotClean(cloudstackTestCase): # Export path: export/test try: - cmds = [ + cmds = [ "mount %s/%s %s" % ( sec_storage_ip, export_path, @@ -701,7 +702,7 @@ class TestAccountSnapshotClean(cloudstackTestCase): self.debug("command: %s" % c) result = ssh_client.execute(c) self.debug("Result: %s" % result) - + uuids.append(result) # Unmount the Sec Storage cmds = [ @@ -715,7 +716,7 @@ class TestAccountSnapshotClean(cloudstackTestCase): except Exception: self.fail("SSH failed for management server: %s" % self.services["mgmt_server"]["ipaddress"]) - + res = str(uuids) self.assertNotEqual( res.count(snapshot_uuid), @@ -804,7 +805,7 @@ class TestSnapshotDetachedDisk(cloudstackTestCase): def test_03_snapshot_detachedDisk(self): """Test snapshot from detached disk """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. login in VM and write some data on data disk(use fdisk to # partition datadisk,fdisk /dev/sdb, and make filesystem using @@ -863,7 +864,7 @@ class TestSnapshotDetachedDisk(cloudstackTestCase): self.services["sub_lvl_dir2"], self.services["random_data"] ), - "sync", + "sync", ] for c in cmds: self.debug(ssh_client.execute(c)) @@ -908,7 +909,7 @@ class TestSnapshotDetachedDisk(cloudstackTestCase): except Exception as e: self.fail("SSH failed for VM with IP: %s" % self.virtual_machine.ipaddress) - + # Fetch values from database qresultset = self.dbclient.execute( "select backup_snap_id, account_id, volume_id from snapshots where uuid = '%s';" \ @@ -954,7 +955,7 @@ class TestSnapshotDetachedDisk(cloudstackTestCase): export_path = '/'.join(parse_url[3:]) # Export path: export/test - + # Sleep to ensure that snapshot is reflected in sec storage time.sleep(self.services["sleep"]) try: @@ -983,7 +984,7 @@ class TestSnapshotDetachedDisk(cloudstackTestCase): for c in cmds: result = ssh_client.execute(c) - + uuids.append(result) # Unmount the Sec Storage cmds = [ @@ -994,7 +995,7 @@ class TestSnapshotDetachedDisk(cloudstackTestCase): except Exception as e: self.fail("SSH failed for management server: %s" % self.services["mgmt_server"]["ipaddress"]) - + res = str(uuids) self.assertEqual( res.count(snapshot_uuid), @@ -1076,15 +1077,15 @@ class TestSnapshotLimit(cloudstackTestCase): def test_04_snapshot_limit(self): """Test snapshot limit in snapshot policies """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. Perform hourly recurring snapshot on the root disk of VM and keep # the maxsnapshots as 1 - # 2. listSnapshots should list the snapshot that was created - # snapshot folder in secondary storage should contain only one + # 2. listSnapshots should list the snapshot that was created + # snapshot folder in secondary storage should contain only one # snapshot image(/secondary/snapshots/$accountid/$volumeid/) - # Get the Root disk of VM + # Get the Root disk of VM volumes = list_volumes( self.apiclient, virtualmachineid=self.virtual_machine.id, @@ -1116,7 +1117,7 @@ class TestSnapshotLimit(cloudstackTestCase): True, "Check list response returns a valid list" ) - + self.assertNotEqual( snapshot_policy, None, @@ -1148,7 +1149,7 @@ class TestSnapshotLimit(cloudstackTestCase): snapshottype='RECURRING', listall=True ) - + self.assertEqual( isinstance(snapshots, list), True, @@ -1159,7 +1160,7 @@ class TestSnapshotLimit(cloudstackTestCase): self.services["recurring_snapshot"]["maxsnaps"], "Check maximum number of recurring snapshots retained" ) - snapshot = snapshots[0] + snapshot = snapshots[0] # Sleep to ensure that snapshot is reflected in sec storage time.sleep(self.services["sleep"]) @@ -1328,13 +1329,13 @@ class TestSnapshotEvents(cloudstackTestCase): def test_05_snapshot_events(self): """Test snapshot events """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. Perform snapshot on the root disk of this VM and check the events/alerts. # 2. delete the snapshots and check the events/alerts # 3. listEvents() shows created/deleted snapshot events - # Get the Root disk of VM + # Get the Root disk of VM volumes = list_volumes( self.apiclient, virtualmachineid=self.virtual_machine.id, diff --git a/test/integration/component/test_templates.py b/test/integration/component/test_templates.py index 8016a4349d2..4d74e0c07c0 100644 --- a/test/integration/component/test_templates.py +++ b/test/integration/component/test_templates.py @@ -49,8 +49,8 @@ class Services: "name": "Tiny Instance", "displaytext": "Tiny Instance", "cpunumber": 1, - "cpuspeed": 100, # in MHz - "memory": 64, # In MBs + "cpuspeed": 100, # in MHz + "memory": 64, # In MBs }, "disk_offering": { "displaytext": "Small", @@ -71,15 +71,15 @@ class Services: "diskname": "Test Volume", }, "templates": { - # Configs for different Template formats + # Configs for different Template formats # For Eg. raw image, zip etc - 0:{ + 0: { "displaytext": "Public Template", "name": "Public template", "ostypeid": '5776c0d2-f331-42db-ba3a-29f1f8319bc9', "url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2", "hypervisor": 'XenServer', - "format" : 'VHD', + "format": 'VHD', "isfeatured": True, "ispublic": True, "isextractable": True, @@ -92,11 +92,11 @@ class Services: "templatefilter": 'self', }, "templatefilter": 'self', - "destzoneid": 2, # For Copy template (Destination zone) + "destzoneid": 2, # For Copy template (Destination zone) "ostypeid": '5776c0d2-f331-42db-ba3a-29f1f8319bc9', "sleep": 60, "timeout": 10, - "mode": 'advanced', # Networking mode: Advanced, basic + "mode": 'advanced', # Networking mode: Advanced, basic } @@ -162,7 +162,7 @@ class TestCreateTemplate(cloudstackTestCase): def test_01_create_template(self): """Test create public & private template """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following: # 1. Upload a templates in raw img format. Create a Vm instances from # raw img template. @@ -212,7 +212,7 @@ class TestCreateTemplate(cloudstackTestCase): break elif timeout == 0: raise Exception("List template failed!") - + time.sleep(5) timeout = timeout - 1 #Verify template response to check whether template added successfully @@ -221,13 +221,13 @@ class TestCreateTemplate(cloudstackTestCase): True, "Check for list template response return valid data" ) - + self.assertNotEqual( len(list_template_response), 0, "Check template available in List Templates" ) - + template_response = list_template_response[0] self.assertEqual( template_response.isready, @@ -314,10 +314,10 @@ class TestTemplates(cloudstackTestCase): #Stop virtual machine cls.virtual_machine.stop(cls.api_client) - timeout = cls.services["timeout"] + timeout = cls.services["timeout"] #Wait before server has be successfully stopped time.sleep(cls.services["sleep"]) - + while True: list_volume = list_volumes( cls.api_client, @@ -329,10 +329,10 @@ class TestTemplates(cloudstackTestCase): break elif timeout == 0: raise Exception("List volumes failed.") - + time.sleep(5) - timeout = timeout -1 - + timeout = timeout - 1 + cls.volume = list_volume[0] #Create template from volume @@ -378,7 +378,7 @@ class TestTemplates(cloudstackTestCase): def test_01_create_template_volume(self): """Test Create template from volume """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following: # 1. Deploy new VM using the template created from Volume @@ -392,7 +392,7 @@ class TestTemplates(cloudstackTestCase): domainid=self.account.account.domainid, serviceofferingid=self.service_offering.id, ) - + self.debug("creating an instance with template ID: %s" % self.template.id) self.cleanup.append(virtual_machine) vm_response = list_virtual_machines( @@ -417,12 +417,12 @@ class TestTemplates(cloudstackTestCase): def test_02_copy_template(self): """Test for copy template from one zone to another""" - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. copy template should be successful and # secondary storage should contain new copied template. - + self.debug( "Copying template from zone: %s to %s" % ( self.template.id, @@ -447,7 +447,7 @@ class TestTemplates(cloudstackTestCase): True, "Check for list template response return valid list" ) - + self.assertNotEqual( len(list_template_response), 0, @@ -476,7 +476,7 @@ class TestTemplates(cloudstackTestCase): def test_03_delete_template(self): """Test Delete template """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following: # 1. Create a template and verify it is shown in list templates response @@ -495,7 +495,7 @@ class TestTemplates(cloudstackTestCase): True, "Check for list template response return valid list" ) - + self.assertNotEqual( len(list_template_response), 0, @@ -508,12 +508,12 @@ class TestTemplates(cloudstackTestCase): self.template.id, "Check display text of updated template" ) - + self.debug("Deleting template: %s" % self.template) # Delete the template self.template.delete(self.apiclient) self.debug("Delete template: %s successful" % self.template) - + list_template_response = list_templates( self.apiclient, templatefilter=\ @@ -531,7 +531,7 @@ class TestTemplates(cloudstackTestCase): def test_04_template_from_snapshot(self): """Create Template from snapshot """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 2. Snapshot the Root disk @@ -546,7 +546,7 @@ class TestTemplates(cloudstackTestCase): listall=True ) volume = volumes[0] - + self.debug("Creating a snapshot from volume: %s" % volume.id) #Create a snapshot of volume snapshot = Snapshot.create( diff --git a/test/integration/component/test_usage.py b/test/integration/component/test_usage.py index 8cd450c79f9..355fa444e95 100644 --- a/test/integration/component/test_usage.py +++ b/test/integration/component/test_usage.py @@ -26,6 +26,7 @@ from integration.lib.common import * from marvin.remoteSSHClient import remoteSSHClient import datetime + class Services: """Test Snapshots Services """ @@ -103,7 +104,7 @@ class Services: # Cent OS 5.3 (64 bit) "sleep": 60, "timeout": 10, - "mode":'advanced' + "mode": 'advanced' } @@ -192,16 +193,16 @@ class TestVmUsage(cloudstackTestCase): self.debug("Stopping the VM: %s" % self.virtual_machine.id) # Stop the VM self.virtual_machine.stop(self.apiclient) - + time.sleep(self.services["sleep"]) # Destroy the VM self.debug("Destroying the VM: %s" % self.virtual_machine.id) self.virtual_machine.delete(self.apiclient) - # Fetch account ID from account_uuid + # Fetch account ID from account_uuid self.debug("select id from account where uuid = '%s';" \ % self.account.account.id) - + qresultset = self.dbclient.execute( "select id from account where uuid = '%s';" \ % self.account.account.id @@ -211,7 +212,7 @@ class TestVmUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -222,7 +223,7 @@ class TestVmUsage(cloudstackTestCase): account_id = qresult[0] self.debug("select type from usage_event where account_id = '%s';" \ % account_id) - + qresultset = self.dbclient.execute( "select type from usage_event where account_id = '%s';" \ % account_id @@ -232,7 +233,7 @@ class TestVmUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -368,7 +369,7 @@ class TestPublicIPUsage(cloudstackTestCase): return def test_01_public_ip_usage(self): - """Test Assign new IP and verify usage calculation + """Test Assign new IP and verify usage calculation """ # Validate the following @@ -378,16 +379,16 @@ class TestPublicIPUsage(cloudstackTestCase): # has IP.Release event for released IP for this account # 3. Delete the newly created account - self.debug("Deleting public IP: %s" % + self.debug("Deleting public IP: %s" % self.public_ip.ipaddress.ipaddress) # Release one of the IP self.public_ip.delete(self.apiclient) - # Fetch account ID from account_uuid + # Fetch account ID from account_uuid self.debug("select id from account where uuid = '%s';" \ % self.account.account.id) - + qresultset = self.dbclient.execute( "select id from account where uuid = '%s';" \ % self.account.account.id @@ -407,12 +408,12 @@ class TestPublicIPUsage(cloudstackTestCase): account_id = qresult[0] self.debug("select type from usage_event where account_id = '%s';" \ % account_id) - + qresultset = self.dbclient.execute( "select type from usage_event where account_id = '%s';" \ % account_id ) - + self.assertEqual( isinstance(qresultset, list), True, @@ -537,8 +538,8 @@ class TestVolumeUsage(cloudstackTestCase): listall=True ) self.assertEqual( - isinstance(volume_response, list), - True, + isinstance(volume_response, list), + True, "Check for valid list volumes response" ) data_volume = volume_response[0] @@ -556,10 +557,10 @@ class TestVolumeUsage(cloudstackTestCase): cmd.id = data_volume.id self.apiclient.deleteVolume(cmd) - # Fetch account ID from account_uuid + # Fetch account ID from account_uuid self.debug("select id from account where uuid = '%s';" \ % self.account.account.id) - + qresultset = self.dbclient.execute( "select id from account where uuid = '%s';" \ % self.account.account.id @@ -569,7 +570,7 @@ class TestVolumeUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -580,12 +581,12 @@ class TestVolumeUsage(cloudstackTestCase): account_id = qresult[0] self.debug("select type from usage_event where account_id = '%s';" \ % account_id) - + qresultset = self.dbclient.execute( "select type from usage_event where account_id = '%s';" \ % account_id ) - + self.assertNotEqual( len(qresultset), 0, @@ -596,7 +597,7 @@ class TestVolumeUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + qresult = str(qresultset) self.debug("Query result: %s" % qresult) # Check VOLUME.CREATE, VOLUME.DESTROY events in cloud.usage_event table @@ -663,7 +664,7 @@ class TestTemplateUsage(cloudstackTestCase): type='ROOT', listall=True ) - if isinstance(list_volume, list): + if isinstance(list_volume, list): cls.volume = list_volume[0] else: raise Exception("List Volumes failed!") @@ -719,10 +720,10 @@ class TestTemplateUsage(cloudstackTestCase): self.template.delete(self.apiclient) self.debug("Deleted template with ID: %s" % self.template.id) - # Fetch account ID from account_uuid + # Fetch account ID from account_uuid self.debug("select id from account where uuid = '%s';" \ % self.account.account.id) - + qresultset = self.dbclient.execute( "select id from account where uuid = '%s';" \ % self.account.account.id @@ -732,7 +733,7 @@ class TestTemplateUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -743,7 +744,7 @@ class TestTemplateUsage(cloudstackTestCase): account_id = qresult[0] self.debug("select type from usage_event where account_id = '%s';" \ % account_id) - + qresultset = self.dbclient.execute( "select type from usage_event where account_id = '%s';" \ % account_id @@ -759,10 +760,10 @@ class TestTemplateUsage(cloudstackTestCase): 0, "Check DB Query result set" ) - + qresult = str(qresultset) self.debug("Query result: %s" % qresult) - + # Check for TEMPLATE.CREATE, TEMPLATE.DELETE in cloud.usage_event table self.assertEqual( qresult.count('TEMPLATE.CREATE'), @@ -789,7 +790,7 @@ class TestISOUsage(cloudstackTestCase): cls.zone = get_zone(cls.api_client, cls.services) cls.services["server"]["zoneid"] = cls.zone.id cls.services["iso"]["zoneid"] = cls.zone.id - # Create Account, ISO image etc + # Create Account, ISO image etc cls.account = Account.create( cls.api_client, cls.services["account"], @@ -853,11 +854,11 @@ class TestISOUsage(cloudstackTestCase): # Delete the ISO self.debug("Deleting ISO with ID: %s" % self.iso.id) self.iso.delete(self.apiclient) - - # Fetch account ID from account_uuid + + # Fetch account ID from account_uuid self.debug("select id from account where uuid = '%s';" \ % self.account.account.id) - + qresultset = self.dbclient.execute( "select id from account where uuid = '%s';" \ % self.account.account.id @@ -867,7 +868,7 @@ class TestISOUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -878,18 +879,18 @@ class TestISOUsage(cloudstackTestCase): account_id = qresult[0] self.debug("select type from usage_event where account_id = '%s';" \ % account_id) - + qresultset = self.dbclient.execute( "select type from usage_event where account_id = '%s';" \ % account_id ) - + self.assertEqual( isinstance(qresultset, list), True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -1002,7 +1003,7 @@ class TestLBRuleUsage(cloudstackTestCase): # 4. Delete this account. self.debug( - "Creating load balancer rule for public IP: %s" % + "Creating load balancer rule for public IP: %s" % self.public_ip_1.ipaddress.id) #Create Load Balancer rule and assign VMs to rule lb_rule = LoadBalancerRule.create( @@ -1015,10 +1016,10 @@ class TestLBRuleUsage(cloudstackTestCase): self.debug("Deleting LB rule with ID: %s" % lb_rule.id) lb_rule.delete(self.apiclient) - # Fetch account ID from account_uuid + # Fetch account ID from account_uuid self.debug("select id from account where uuid = '%s';" \ % self.account.account.id) - + qresultset = self.dbclient.execute( "select id from account where uuid = '%s';" \ % self.account.account.id @@ -1028,7 +1029,7 @@ class TestLBRuleUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -1039,7 +1040,7 @@ class TestLBRuleUsage(cloudstackTestCase): account_id = qresult[0] self.debug("select type from usage_event where account_id = '%s';" \ % account_id) - + qresultset = self.dbclient.execute( "select type from usage_event where account_id = '%s';" \ % account_id @@ -1060,7 +1061,7 @@ class TestLBRuleUsage(cloudstackTestCase): qresult = str(qresultset) self.debug("Query result: %s" % qresult) - # Check for LB.CREATE, LB.DELETE in cloud.usage_event table + # Check for LB.CREATE, LB.DELETE in cloud.usage_event table self.assertEqual( qresult.count('LB.CREATE'), 1, @@ -1146,7 +1147,7 @@ class TestSnapshotUsage(cloudstackTestCase): def test_01_snapshot_usage(self): """Test Create/Delete a manual snap shot and verify - correct usage is recorded + correct usage is recorded """ # Validate the following @@ -1156,7 +1157,7 @@ class TestSnapshotUsage(cloudstackTestCase): # generated for the destroyed Snapshot # 3. Delete the account - # Get the Root disk of VM + # Get the Root disk of VM volumes = list_volumes( self.apiclient, virtualmachineid=self.virtual_machine.id, @@ -1168,7 +1169,7 @@ class TestSnapshotUsage(cloudstackTestCase): True, "Check if list volumes return a valid data" ) - + volume = volumes[0] # Create a snapshot from the ROOTDISK @@ -1179,10 +1180,10 @@ class TestSnapshotUsage(cloudstackTestCase): self.debug("Deleting snapshot: %s" % snapshot.id) snapshot.delete(self.apiclient) - # Fetch account ID from account_uuid + # Fetch account ID from account_uuid self.debug("select id from account where uuid = '%s';" \ % self.account.account.id) - + qresultset = self.dbclient.execute( "select id from account where uuid = '%s';" \ % self.account.account.id @@ -1192,7 +1193,7 @@ class TestSnapshotUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -1203,12 +1204,12 @@ class TestSnapshotUsage(cloudstackTestCase): account_id = qresult[0] self.debug("select type from usage_event where account_id = '%s';" \ % account_id) - + qresultset = self.dbclient.execute( "select type from usage_event where account_id = '%s';" \ % account_id ) - + self.assertEqual( isinstance(qresultset, list), True, @@ -1318,7 +1319,11 @@ class TestNatRuleUsage(cloudstackTestCase): def test_01_nat_usage(self): """Test Create/Delete a PF rule and verify correct usage is recorded """ +<<<<<<< HEAD +======= + tags = ["advanced", "advancedns"] +>>>>>>> 6d17e21... This commit has following fixes: # Validate the following # 1. Acquire a IP for this account # 2. Create a PF rule on the IP associated with this account. @@ -1328,7 +1333,7 @@ class TestNatRuleUsage(cloudstackTestCase): # is registered for this account in cloud.usage_event table # 4. Delete this account. - self.debug("Creating NAT rule with public IP: %s" % + self.debug("Creating NAT rule with public IP: %s" % self.public_ip_1.ipaddress.id) #Create NAT rule nat_rule = NATRule.create( @@ -1342,10 +1347,10 @@ class TestNatRuleUsage(cloudstackTestCase): self.debug("Deleting NAT rule: %s" % nat_rule.id) nat_rule.delete(self.apiclient) - # Fetch account ID from account_uuid + # Fetch account ID from account_uuid self.debug("select id from account where uuid = '%s';" \ % self.account.account.id) - + qresultset = self.dbclient.execute( "select id from account where uuid = '%s';" \ % self.account.account.id @@ -1355,7 +1360,7 @@ class TestNatRuleUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -1366,7 +1371,7 @@ class TestNatRuleUsage(cloudstackTestCase): account_id = qresult[0] self.debug("select type from usage_event where account_id = '%s';" \ % account_id) - + qresultset = self.dbclient.execute( "select type from usage_event where account_id = '%s';" \ % account_id @@ -1484,12 +1489,12 @@ class TestVpnUsage(cloudstackTestCase): # Validate the following # 1. Enable VPN for this IP. vpn.add.user event is registered for this # account in cloud.usage_event table - # 2. Add user to this vpn + # 2. Add user to this vpn # 3. Delete user for this VPN. vpn.user.delete event is registered for # this account in cloud.usage_event table # 4. Delete this account. - self.debug("Created VPN with public IP: %s" % + self.debug("Created VPN with public IP: %s" % self.public_ip.ipaddress.id) #Assign VPN to Public IP vpn = Vpn.create( @@ -1499,7 +1504,7 @@ class TestVpnUsage(cloudstackTestCase): domainid=self.account.account.domainid ) - self.debug("Created VPN user for account: %s" % + self.debug("Created VPN user for account: %s" % self.account.account.name) vpnuser = VpnUser.create( @@ -1518,10 +1523,10 @@ class TestVpnUsage(cloudstackTestCase): self.debug("Deleting VPN: %s" % vpn.publicipid) vpn.delete(self.apiclient) - # Fetch account ID from account_uuid + # Fetch account ID from account_uuid self.debug("select id from account where uuid = '%s';" \ % self.account.account.id) - + qresultset = self.dbclient.execute( "select id from account where uuid = '%s';" \ % self.account.account.id @@ -1531,7 +1536,7 @@ class TestVpnUsage(cloudstackTestCase): True, "Check DB query result set for valid data" ) - + self.assertNotEqual( len(qresultset), 0, @@ -1542,7 +1547,7 @@ class TestVpnUsage(cloudstackTestCase): account_id = qresult[0] self.debug("select type from usage_event where account_id = '%s';" \ % account_id) - + qresultset = self.dbclient.execute( "select type from usage_event where account_id = '%s';" \ % account_id @@ -1561,8 +1566,8 @@ class TestVpnUsage(cloudstackTestCase): qresult = str(qresultset) self.debug("Query result: %s" % qresult) - - # Check for VPN user related events + + # Check for VPN user related events self.assertEqual( qresult.count('VPN.USER.ADD'), 1, diff --git a/test/integration/component/test_volumes.py b/test/integration/component/test_volumes.py index 82fcfc96d7b..697b945ac73 100644 --- a/test/integration/component/test_volumes.py +++ b/test/integration/component/test_volumes.py @@ -50,8 +50,8 @@ class Services: "name": "Tiny Instance", "displaytext": "Tiny Instance", "cpunumber": 1, - "cpuspeed": 100, # in MHz - "memory": 64, # In MBs + "cpuspeed": 100, # in MHz + "memory": 64, # In MBs }, "disk_offering": { "displaytext": "Small", @@ -143,7 +143,7 @@ class TestAttachVolume(cloudstackTestCase): def test_01_volume_attach(self): """Test Attach volumes (max capacity) """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. Deploy a vm and create 5 data disk # 2. Attach all the created Volume to the vm. @@ -163,7 +163,7 @@ class TestAttachVolume(cloudstackTestCase): ) self.debug("Created volume: %s for account: %s" % ( volume.id, - self.account.account.name + self.account.account.name )) # Check List Volume response for newly created volume list_volume_response = list_volumes( @@ -182,7 +182,7 @@ class TestAttachVolume(cloudstackTestCase): ) self.debug("Attach volume: %s to VM: %s" % ( volume.id, - self.virtual_machine.id + self.virtual_machine.id )) # Check all volumes attached to same VM list_volume_response = list_volumes( @@ -196,7 +196,7 @@ class TestAttachVolume(cloudstackTestCase): True, "Check list volumes response for valid list" ) - + self.assertNotEqual( list_volume_response, None, @@ -246,7 +246,7 @@ class TestAttachVolume(cloudstackTestCase): True, "Check list VM response for valid list" ) - + #Verify VM response to check whether VM deployment was successful self.assertNotEqual( len(vm_response), @@ -276,7 +276,7 @@ class TestAttachVolume(cloudstackTestCase): True, "Check list VM response for valid list" ) - + #Verify VM response to check whether VM deployment was successful self.assertNotEqual( len(vm_response), @@ -295,7 +295,7 @@ class TestAttachVolume(cloudstackTestCase): def test_02_volume_attach_max(self): """Test attach volumes (more than max) to an instance """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. Attach one more data volume to VM (Already 5 attached) @@ -312,7 +312,7 @@ class TestAttachVolume(cloudstackTestCase): ) self.debug("Created volume: %s for account: %s" % ( volume.id, - self.account.account.name + self.account.account.name )) # Check List Volume response for newly created volume list_volume_response = list_volumes( @@ -324,7 +324,7 @@ class TestAttachVolume(cloudstackTestCase): True, "Check list volumes response for valid list" ) - + self.assertNotEqual( list_volume_response, None, @@ -334,7 +334,7 @@ class TestAttachVolume(cloudstackTestCase): with self.assertRaises(Exception): self.debug("Trying to Attach volume: %s to VM: %s" % ( volume.id, - self.virtual_machine.id + self.virtual_machine.id )) self.virtual_machine.attach_volume( self.apiclient, @@ -426,7 +426,7 @@ class TestAttachDetachVolume(cloudstackTestCase): def test_01_volume_attach_detach(self): """Test Volume attach/detach to VM (5 data volumes) """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. Deploy a vm and create 5 data disk @@ -449,7 +449,7 @@ class TestAttachDetachVolume(cloudstackTestCase): ) self.debug("Created volume: %s for account: %s" % ( volume.id, - self.account.account.name + self.account.account.name )) self.cleanup.append(volume) volumes.append(volume) @@ -464,7 +464,7 @@ class TestAttachDetachVolume(cloudstackTestCase): True, "Check list volumes response for valid list" ) - + self.assertNotEqual( list_volume_response, None, @@ -472,7 +472,7 @@ class TestAttachDetachVolume(cloudstackTestCase): ) self.debug("Attach volume: %s to VM: %s" % ( volume.id, - self.virtual_machine.id + self.virtual_machine.id )) # Attach volume to VM self.virtual_machine.attach_volume( @@ -492,7 +492,7 @@ class TestAttachDetachVolume(cloudstackTestCase): True, "Check list volumes response for valid list" ) - + self.assertNotEqual( list_volume_response, None, @@ -508,7 +508,7 @@ class TestAttachDetachVolume(cloudstackTestCase): for volume in volumes: self.debug("Detach volume: %s to VM: %s" % ( volume.id, - self.virtual_machine.id + self.virtual_machine.id )) self.virtual_machine.detach_volume( self.apiclient, @@ -530,7 +530,7 @@ class TestAttachDetachVolume(cloudstackTestCase): True, "Check list VM response for valid list" ) - + self.assertNotEqual( len(vm_response), 0, @@ -542,7 +542,7 @@ class TestAttachDetachVolume(cloudstackTestCase): 'Running', "Check the state of VM" ) - + # Stop VM self.debug("Stopping the VM: %s" % self.virtual_machine.id) self.virtual_machine.stop(self.apiclient) @@ -674,7 +674,7 @@ class TestAttachVolumeISO(cloudstackTestCase): def test_01_volume_iso_attach(self): """Test Volumes and ISO attach """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. Create and attach 5 data volumes to VM @@ -693,7 +693,7 @@ class TestAttachVolumeISO(cloudstackTestCase): ) self.debug("Created volume: %s for account: %s" % ( volume.id, - self.account.account.name + self.account.account.name )) # Check List Volume response for newly created volume list_volume_response = list_volumes( @@ -746,7 +746,7 @@ class TestAttachVolumeISO(cloudstackTestCase): domainid=self.account.account.domainid, ) self.debug("Created ISO with ID: %s for account: %s" % ( - iso.id, + iso.id, self.account.account.name )) @@ -778,7 +778,7 @@ class TestAttachVolumeISO(cloudstackTestCase): True, "Check list VM response for valid list" ) - + self.assertNotEqual( len(vm_response), 0, @@ -870,7 +870,7 @@ class TestVolumes(cloudstackTestCase): def test_01_attach_volume(self): """Attach a created Volume to a Running VM """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. Create a data volume. # 2. List Volumes should not have vmname and virtualmachineid fields in @@ -954,7 +954,7 @@ class TestVolumes(cloudstackTestCase): def test_02_detach_volume(self): """Detach a Volume attached to a VM """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. Data disk should be detached from instance @@ -979,7 +979,7 @@ class TestVolumes(cloudstackTestCase): True, "Check list volumes response for valid list" ) - + self.assertNotEqual( list_volume_response, None, @@ -1002,7 +1002,7 @@ class TestVolumes(cloudstackTestCase): def test_03_delete_detached_volume(self): """Delete a Volume unattached to an VM """ - tags = ["advanced","advancedns"] + tags = ["advanced", "advancedns"] # Validate the following # 1. volume should be deleted successfully and listVolume should not # contain the deleted volume details.