Various fixes to tests

- Configuration fixes in Security groups and Egress rules
- Fixing white spaces in component test suite
This commit is contained in:
Prasanna Santhanam 2012-07-06 16:50:20 +05:30
parent a725fdc3ab
commit b433b1afa6
18 changed files with 1176 additions and 1113 deletions

View File

@ -57,8 +57,8 @@ class Services:
"name": "Tiny Instance", "name": "Tiny Instance",
"displaytext": "Tiny Instance", "displaytext": "Tiny Instance",
"cpunumber": 1, "cpunumber": 1,
"cpuspeed": 100, # in MHz "cpuspeed": 100, # in MHz
"memory": 64, # In MBs "memory": 64, # In MBs
}, },
"virtual_machine": { "virtual_machine": {
"displayname": "Test VM", "displayname": "Test VM",
@ -78,7 +78,7 @@ class Services:
"ostypeid": 'aaf6e8c9-b609-441d-9ebd-b4eaa030a275', "ostypeid": 'aaf6e8c9-b609-441d-9ebd-b4eaa030a275',
"url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2", "url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2",
"hypervisor": 'XenServer', "hypervisor": 'XenServer',
"format" : 'VHD', "format": 'VHD',
"isfeatured": True, "isfeatured": True,
"ispublic": True, "ispublic": True,
"isextractable": True, "isextractable": True,
@ -87,7 +87,7 @@ class Services:
# Cent OS 5.3 (64 bit) # Cent OS 5.3 (64 bit)
"sleep": 60, "sleep": 60,
"timeout": 10, "timeout": 10,
"mode":'advanced' "mode": 'advanced'
} }
@ -138,9 +138,9 @@ class TestAccounts(cloudstackTestCase):
return return
def test_01_create_account(self): 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"] tags = ["advanced", "basic", "eip", "advancedns", "sg"]
# Validate the following # Validate the following
@ -273,9 +273,9 @@ class TestRemoveUserFromAccount(cloudstackTestCase):
return return
def test_01_user_remove_VM_running(self): 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"] tags = ["advanced", "basic", "eip", "advancedns", "sg"]
# Validate the following # Validate the following
@ -337,8 +337,8 @@ class TestRemoveUserFromAccount(cloudstackTestCase):
id=self.account.account.id id=self.account.account.id
) )
self.assertEqual( self.assertEqual(
isinstance(accounts_response, list), isinstance(accounts_response, list),
True, True,
"Check for valid list accounts response" "Check for valid list accounts response"
) )
@ -353,8 +353,8 @@ class TestRemoveUserFromAccount(cloudstackTestCase):
domainid=self.account.account.domainid domainid=self.account.account.domainid
) )
self.assertEqual( self.assertEqual(
isinstance(vm_response, list), isinstance(vm_response, list),
True, True,
"Check for valid list VM response" "Check for valid list VM response"
) )
@ -372,11 +372,12 @@ class TestRemoveUserFromAccount(cloudstackTestCase):
"Check state of VMs associated with account" "Check state of VMs associated with account"
) )
return return
@unittest.skip("Open Questions") @unittest.skip("Open Questions")
def test_02_remove_all_users(self): 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"] tags = ["advanced", "basic", "eip", "advancedns", "sg"]
# Validate the following # Validate the following
@ -427,12 +428,12 @@ class TestRemoveUserFromAccount(cloudstackTestCase):
domainid=self.account.account.domainid domainid=self.account.account.domainid
) )
self.assertEqual( self.assertEqual(
isinstance(users, list), isinstance(users, list),
True, True,
"Check for valid list users response" "Check for valid list users response"
) )
for user in users: for user in users:
self.debug("Deleting user: %s" % user.id) self.debug("Deleting user: %s" % user.id)
cmd = deleteUser.deleteUserCmd() cmd = deleteUser.deleteUserCmd()
cmd.id = user.id cmd.id = user.id
@ -443,12 +444,12 @@ class TestRemoveUserFromAccount(cloudstackTestCase):
name='account.cleanup.interval' name='account.cleanup.interval'
) )
self.assertEqual( self.assertEqual(
isinstance(interval, list), isinstance(interval, list),
True, True,
"Check for valid list configurations response" "Check for valid list configurations response"
) )
self.debug("account.cleanup.interval: %s" % interval[0].value) self.debug("account.cleanup.interval: %s" % interval[0].value)
# Sleep to ensure that all resources are deleted # Sleep to ensure that all resources are deleted
time.sleep(int(interval[0].value)) time.sleep(int(interval[0].value))
@ -534,7 +535,7 @@ class TestNonRootAdminsPrivileges(cloudstackTestCase):
def test_01_non_root_admin_Privileges(self): def test_01_non_root_admin_Privileges(self):
"""Test to verify Non Root admin previleges""" """Test to verify Non Root admin previleges"""
tags = ["advanced", "basic", "eip", "advancedns", "sg"] tags = ["advanced", "basic", "eip", "advancedns", "sg"]
# Validate the following # Validate the following
@ -562,11 +563,11 @@ class TestNonRootAdminsPrivileges(cloudstackTestCase):
) )
self.assertEqual( self.assertEqual(
isinstance(accounts_response, list), isinstance(accounts_response, list),
True, True,
"Check list accounts response for valid data" "Check list accounts response for valid data"
) )
self.assertEqual( self.assertEqual(
len(accounts_response), len(accounts_response),
1, 1,
@ -653,7 +654,7 @@ class TestServiceOfferingSiblings(cloudstackTestCase):
def test_01_service_offering_siblings(self): def test_01_service_offering_siblings(self):
"""Test to verify service offerings at same level in hierarchy""" """Test to verify service offerings at same level in hierarchy"""
tags = ["advanced", "basic", "eip", "advancedns", "sg"] tags = ["advanced", "basic", "eip", "advancedns", "sg"]
# Validate the following # Validate the following
@ -665,11 +666,11 @@ class TestServiceOfferingSiblings(cloudstackTestCase):
domainid=self.domain_1.id domainid=self.domain_1.id
) )
self.assertEqual( self.assertEqual(
isinstance(service_offerings, list), isinstance(service_offerings, list),
True, True,
"Check if valid list service offerings response" "Check if valid list service offerings response"
) )
self.assertNotEqual( self.assertNotEqual(
len(service_offerings), len(service_offerings),
0, 0,
@ -695,6 +696,7 @@ class TestServiceOfferingSiblings(cloudstackTestCase):
) )
return return
@unittest.skip("Open Questions") @unittest.skip("Open Questions")
class TestServiceOfferingHierarchy(cloudstackTestCase): class TestServiceOfferingHierarchy(cloudstackTestCase):
@ -768,7 +770,7 @@ class TestServiceOfferingHierarchy(cloudstackTestCase):
def test_01_service_offering_hierarchy(self): def test_01_service_offering_hierarchy(self):
"""Test to verify service offerings at same level in hierarchy""" """Test to verify service offerings at same level in hierarchy"""
tags = ["advanced", "basic", "eip", "advancedns", "sg"] tags = ["advanced", "basic", "eip", "advancedns", "sg"]
# Validate the following # Validate the following
@ -821,6 +823,7 @@ class TestServiceOfferingHierarchy(cloudstackTestCase):
) )
return return
@unittest.skip("Open Questions") @unittest.skip("Open Questions")
class TesttemplateHierarchy(cloudstackTestCase): class TesttemplateHierarchy(cloudstackTestCase):
@ -899,7 +902,7 @@ class TesttemplateHierarchy(cloudstackTestCase):
def test_01_template_hierarchy(self): def test_01_template_hierarchy(self):
"""Test to verify template at same level in hierarchy""" """Test to verify template at same level in hierarchy"""
tags = ["advanced", "basic", "eip", "advancedns", "sg"] tags = ["advanced", "basic", "eip", "advancedns", "sg"]
# Validate the following # Validate the following
@ -959,6 +962,7 @@ class TesttemplateHierarchy(cloudstackTestCase):
) )
return return
class TestAddVmToSubDomain(cloudstackTestCase): class TestAddVmToSubDomain(cloudstackTestCase):
@classmethod @classmethod
@ -1026,19 +1030,20 @@ class TestAddVmToSubDomain(cloudstackTestCase):
serviceofferingid=cls.service_offering.id serviceofferingid=cls.service_offering.id
) )
cls._cleanup = [ cls._cleanup = [
cls.account_2, cls.account_2,
cls.account_1, cls.account_1,
cls.sub_domain, cls.sub_domain,
cls.service_offering cls.service_offering
] ]
return return
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: try:
#Clean up, terminate the created resources #Clean up, terminate the created resources
cleanup_resources(cls.api_client,cls._cleanup) cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
return return
@ -1056,11 +1061,10 @@ class TestAddVmToSubDomain(cloudstackTestCase):
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
return return
def test_01_add_vm_to_subdomain(self): def test_01_add_vm_to_subdomain(self):
""" Test Sub domain allowed to launch VM when a Domain level zone is """ Test Sub domain allowed to launch VM when a Domain level zone is
created""" created"""
tags = ["advanced", "basic", "eip", "advancedns", "sg"] tags = ["advanced", "basic", "eip", "advancedns", "sg"]
# Validate the following # Validate the following

View File

@ -26,6 +26,7 @@ from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import * from marvin.cloudstackAPI import *
from marvin.remoteSSHClient import remoteSSHClient from marvin.remoteSSHClient import remoteSSHClient
class Services: class Services:
"""Test Services """Test Services
""" """
@ -48,8 +49,8 @@ class Services:
"name": "Tiny Instance", "name": "Tiny Instance",
"displaytext": "Tiny Instance", "displaytext": "Tiny Instance",
"cpunumber": 1, "cpunumber": 1,
"cpuspeed": 100, # in MHz "cpuspeed": 100, # in MHz
"memory": 64, # In MBs "memory": 64, # In MBs
}, },
"disk_offering": { "disk_offering": {
"displaytext": "Small", "displaytext": "Small",
@ -69,7 +70,7 @@ class Services:
"volume": { "volume": {
"diskname": "APP Data Volume", "diskname": "APP Data Volume",
"size": 1, # in GBs "size": 1, # in GBs
"diskdevice": "/dev/xvdb", # Data Disk "diskdevice": "/dev/xvdb", # Data Disk
}, },
"templates": { "templates": {
"displaytext": 'Template from snapshot', "displaytext": 'Template from snapshot',
@ -78,11 +79,11 @@ class Services:
"templatefilter": 'self', "templatefilter": 'self',
"url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2", "url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2",
"hypervisor": 'XenServer', "hypervisor": 'XenServer',
"format" : 'VHD', "format": 'VHD',
"isfeatured": True, "isfeatured": True,
"ispublic": True, "ispublic": True,
"isextractable": True, "isextractable": True,
"passwordenabled":True, "passwordenabled": True,
}, },
"paths": { "paths": {
"mount_dir": "/mnt/tmp", "mount_dir": "/mnt/tmp",
@ -97,12 +98,12 @@ class Services:
"protocol": "TCP" "protocol": "TCP"
}, },
"ostypeid": '144f66aa-7f74-4cfe-9799-80cc21439cb3', "ostypeid": '144f66aa-7f74-4cfe-9799-80cc21439cb3',
# Cent OS 5.3 (64 bit) # Cent OS 5.3 (64 bit)
"sleep":60, "sleep": 60,
"mode": 'advanced', "mode": 'advanced',
# Networking mode, Advanced, Basic # Networking mode, Advanced, Basic
} }
class TestSnapshots(cloudstackTestCase): class TestSnapshots(cloudstackTestCase):
@ -124,10 +125,10 @@ class TestSnapshots(cloudstackTestCase):
) )
cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["volume"]["zoneid"] = cls.zone.id cls.services["volume"]["zoneid"] = cls.zone.id
cls.services["template"] = cls.template.id cls.services["template"] = cls.template.id
cls.services["zoneid"] = cls.zone.id cls.services["zoneid"] = cls.zone.id
# Create VMs, NAT Rules etc # Create VMs, NAT Rules etc
cls.account = Account.create( cls.account = Account.create(
cls.api_client, cls.api_client,
@ -184,9 +185,9 @@ class TestSnapshots(cloudstackTestCase):
def test_01_volume_from_snapshot(self): def test_01_volume_from_snapshot(self):
"""TS_BUG_001-Test Creating snapshot from volume having spaces in name(KVM) """TS_BUG_001-Test Creating snapshot from volume having spaces in name(KVM)
""" """
tags = ["advanced", "advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
#1. Create a virtual machine and data volume #1. Create a virtual machine and data volume
#2. Attach data volume to VM #2. Attach data volume to VM
@ -195,31 +196,31 @@ class TestSnapshots(cloudstackTestCase):
#5. Create another Volume from snapshot #5. Create another Volume from snapshot
#6. Mount/Attach volume to another server #6. Mount/Attach volume to another server
#7. Compare data #7. Compare data
random_data_0 = random_gen(100) random_data_0 = random_gen(100)
random_data_1 = random_gen(100) random_data_1 = random_gen(100)
volume = Volume.create( volume = Volume.create(
self.apiclient, self.apiclient,
self.services["volume"], self.services["volume"],
zoneid=self.zone.id, zoneid=self.zone.id,
account=self.account.account.name, account=self.account.account.name,
domainid=self.account.account.domainid, domainid=self.account.account.domainid,
diskofferingid=self.disk_offering.id diskofferingid=self.disk_offering.id
) )
self.debug("Created volume with ID: %s" % volume.id) self.debug("Created volume with ID: %s" % volume.id)
self.virtual_machine.attach_volume( self.virtual_machine.attach_volume(
self.apiclient, self.apiclient,
volume volume
) )
self.debug("Attach volume: %s to VM: %s" % self.debug("Attach volume: %s to VM: %s" %
(volume.id, self.virtual_machine.id)) (volume.id, self.virtual_machine.id))
try: try:
ssh_client = self.virtual_machine.get_ssh_client() ssh_client = self.virtual_machine.get_ssh_client()
except Exception as e: except Exception as e:
self.fail("SSH failed for VM: %s" % self.fail("SSH failed for VM: %s" %
self.virtual_machine.ipaddress) self.virtual_machine.ipaddress)
self.debug("Formatting volume: %s to ext3" % volume.id) self.debug("Formatting volume: %s to ext3" % volume.id)
#Format partition using ext3 #Format partition using ext3
format_volume_to_ext3( format_volume_to_ext3(
@ -273,8 +274,8 @@ class TestSnapshots(cloudstackTestCase):
) )
self.assertEqual( self.assertEqual(
isinstance(list_volume_response, list), isinstance(list_volume_response, list),
True, True,
"Check list volume response for valid data" "Check list volume response for valid data"
) )
volume_response = list_volume_response[0] volume_response = list_volume_response[0]
@ -295,7 +296,7 @@ class TestSnapshots(cloudstackTestCase):
domainid=self.account.account.domainid domainid=self.account.account.domainid
) )
self.debug("Created Volume: %s from Snapshot: %s" % ( self.debug("Created Volume: %s from Snapshot: %s" % (
volume_from_snapshot.id, volume_from_snapshot.id,
snapshot.id)) snapshot.id))
volumes = Volume.list( volumes = Volume.list(
self.apiclient, self.apiclient,
@ -306,13 +307,13 @@ class TestSnapshots(cloudstackTestCase):
True, True,
"Check list response returns a valid list" "Check list response returns a valid list"
) )
self.assertNotEqual( self.assertNotEqual(
len(volumes), len(volumes),
None, None,
"Check Volume list Length" "Check Volume list Length"
) )
self.assertEqual ( self.assertEqual(
volumes[0].id, volumes[0].id,
volume_from_snapshot.id, volume_from_snapshot.id,
"Check Volume in the List Volumes" "Check Volume in the List Volumes"
@ -334,7 +335,7 @@ class TestSnapshots(cloudstackTestCase):
volume_from_snapshot.id, volume_from_snapshot.id,
new_virtual_machine.id new_virtual_machine.id
)) ))
cmd = attachVolume.attachVolumeCmd() cmd = attachVolume.attachVolumeCmd()
cmd.id = volume_from_snapshot.id cmd.id = volume_from_snapshot.id
cmd.virtualmachineid = new_virtual_machine.id cmd.virtualmachineid = new_virtual_machine.id
@ -343,7 +344,7 @@ class TestSnapshots(cloudstackTestCase):
try: try:
#Login to VM to verify test directories and files #Login to VM to verify test directories and files
ssh = new_virtual_machine.get_ssh_client() ssh = new_virtual_machine.get_ssh_client()
cmds = [ cmds = [
"mkdir -p %s" % self.services["paths"]["mount_dir"], "mkdir -p %s" % self.services["paths"]["mount_dir"],
"mount %s1 %s" % ( "mount %s1 %s" % (
@ -371,7 +372,7 @@ class TestSnapshots(cloudstackTestCase):
self.services["paths"]["random_data"] self.services["paths"]["random_data"]
)) ))
except Exception as e: except Exception as e:
self.fail("SSH access failed for VM: %s" % self.fail("SSH access failed for VM: %s" %
new_virtual_machine.ipaddress) new_virtual_machine.ipaddress)
#Verify returned data #Verify returned data
self.assertEqual( self.assertEqual(
@ -423,7 +424,7 @@ class TestTemplate(cloudstackTestCase):
cls.zone = get_zone(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services)
cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["templates"]["zoneid"] = cls.zone.id cls.services["templates"]["zoneid"] = cls.zone.id
cls.service_offering = ServiceOffering.create( cls.service_offering = ServiceOffering.create(
cls.api_client, cls.api_client,
cls.services["service_offering"] cls.services["service_offering"]
@ -456,7 +457,7 @@ class TestTemplate(cloudstackTestCase):
def test_01_create_template(self): def test_01_create_template(self):
"""TS_BUG_002-Test to create and deploy VM using password enabled template """TS_BUG_002-Test to create and deploy VM using password enabled template
""" """
tags = ["advanced", "advancedns", "basic", "sg"] tags = ["advanced", "advancedns", "basic", "sg"]
# Validate the following: # Validate the following:
@ -479,13 +480,13 @@ class TestTemplate(cloudstackTestCase):
template.download(self.apiclient) template.download(self.apiclient)
except Exception as e: except Exception as e:
self.fail("Exception while downloading template %s: %s"\ self.fail("Exception while downloading template %s: %s"\
% (template.id, e)) % (template.id, e))
self.cleanup.append(template) self.cleanup.append(template)
# Wait for template status to be changed across # Wait for template status to be changed across
time.sleep(self.services["sleep"]) time.sleep(self.services["sleep"])
list_template_response = Template.list( list_template_response = Template.list(
self.apiclient, self.apiclient,
templatefilter=\ templatefilter=\
@ -493,7 +494,7 @@ class TestTemplate(cloudstackTestCase):
id=template.id, id=template.id,
zoneid=self.zone.id zoneid=self.zone.id
) )
self.assertEqual( self.assertEqual(
isinstance(list_template_response, list), isinstance(list_template_response, list),
True, True,
@ -524,7 +525,7 @@ class TestTemplate(cloudstackTestCase):
) )
self.debug("Deployed VM with ID: %s " % virtual_machine.id) self.debug("Deployed VM with ID: %s " % virtual_machine.id)
self.assertEqual( self.assertEqual(
hasattr(virtual_machine,"password"), hasattr(virtual_machine, "password"),
True, True,
"Check if the deployed VM returned a password" "Check if the deployed VM returned a password"
) )
@ -532,7 +533,7 @@ class TestTemplate(cloudstackTestCase):
class TestNATRules(cloudstackTestCase): class TestNATRules(cloudstackTestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
@ -568,10 +569,10 @@ class TestNATRules(cloudstackTestCase):
serviceofferingid=cls.service_offering.id serviceofferingid=cls.service_offering.id
) )
cls.public_ip = PublicIPAddress.create( cls.public_ip = PublicIPAddress.create(
cls.api_client, cls.api_client,
accountid=cls.account.account.name, accountid=cls.account.account.name,
zoneid=cls.zone.id, zoneid=cls.zone.id,
domainid=cls.account.account.domainid, domainid=cls.account.account.domainid,
services=cls.services["virtual_machine"] services=cls.services["virtual_machine"]
) )
cls._cleanup = [ cls._cleanup = [
@ -600,25 +601,25 @@ class TestNATRules(cloudstackTestCase):
def test_01_firewall_rules_port_fw(self): def test_01_firewall_rules_port_fw(self):
""""Checking firewall rules deletion after static NAT disable""" """"Checking firewall rules deletion after static NAT disable"""
tags = ["advanced"] tags = ["advanced"]
# Validate the following: # Validate the following:
#1. Enable static NAT for a VM #1. Enable static NAT for a VM
#2. Open up some ports. At this point there will be new rows in the #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. #3. Disable static NAT for the VM.
#4. Check fire wall rules are deleted from firewall_rules table. #4. Check fire wall rules are deleted from firewall_rules table.
public_ip = self.public_ip.ipaddress public_ip = self.public_ip.ipaddress
# Enable Static NAT for VM # Enable Static NAT for VM
StaticNATRule.enable( StaticNATRule.enable(
self.apiclient, self.apiclient,
public_ip.id, public_ip.id,
self.virtual_machine.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) public_ip.id)
#Create Static NAT rule #Create Static NAT rule
nat_rule = StaticNATRule.create( nat_rule = StaticNATRule.create(
@ -661,7 +662,7 @@ class TestNATRules(cloudstackTestCase):
True, True,
"Check database query returns a valid data" "Check database query returns a valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -683,20 +684,20 @@ class TestNATRules(cloudstackTestCase):
True, True,
"Check database query returns a valid data for firewall rules" "Check database query returns a valid data for firewall rules"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
"Check DB Query result set" "Check DB Query result set"
) )
for qresult in qresultset: for qresult in qresultset:
self.assertEqual( self.assertEqual(
qresult[1], qresult[1],
'Active', 'Active',
"Check state of the static NAT rule in database" "Check state of the static NAT rule in database"
) )
nat_rule.delete(self.apiclient) nat_rule.delete(self.apiclient)
list_rules_repsonse = StaticNATRule.list( list_rules_repsonse = StaticNATRule.list(
@ -709,7 +710,7 @@ class TestNATRules(cloudstackTestCase):
None, None,
"Check Port Forwarding Rule is deleted" "Check Port Forwarding Rule is deleted"
) )
# Verify the entries made in firewall_rules tables # Verify the entries made in firewall_rules tables
self.debug( self.debug(
"select id, state from firewall_rules where ip_address_id = '%s';" \ "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';" \ "select id, state from firewall_rules where ip_address_id = '%s';" \
% public_ip.id % public_ip.id
) )
self.assertEqual( self.assertEqual(
len(qresultset), len(qresultset),
0, 0,
@ -741,7 +742,7 @@ class TestRouters(cloudstackTestCase):
cls.zone.id, cls.zone.id,
cls.services["ostypeid"] cls.services["ostypeid"]
) )
# Create an account, domain etc # Create an account, domain etc
cls.domain = Domain.create( cls.domain = Domain.create(
cls.api_client, cls.api_client,
@ -753,7 +754,7 @@ class TestRouters(cloudstackTestCase):
admin=True, admin=True,
domainid=cls.domain.id domainid=cls.domain.id
) )
cls.user_account = Account.create( cls.user_account = Account.create(
cls.api_client, cls.api_client,
cls.services["account"], cls.services["account"],
@ -802,13 +803,13 @@ class TestRouters(cloudstackTestCase):
def test_01_list_routers_admin(self): def test_01_list_routers_admin(self):
"""TS_BUG_007-Check listRouters() using Admin User """TS_BUG_007-Check listRouters() using Admin User
""" """
tags = ["advanced", "advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. PreReq: have rounters that are owned by other account # 1. PreReq: have rounters that are owned by other account
# 2. Create domain and create accounts in that domain # 2. Create domain and create accounts in that domain
# 3. Create one VM for each account # 3. Create one VM for each account
# 4. Using Admin , run listRouters. It should return all the routers # 4. Using Admin , run listRouters. It should return all the routers
vm_1 = VirtualMachine.create( vm_1 = VirtualMachine.create(
@ -909,11 +910,10 @@ class TestRouterRestart(cloudstackTestCase):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
return return
def test_01_restart_network_cleanup(self): def test_01_restart_network_cleanup(self):
"""TS_BUG_008-Test restart network """TS_BUG_008-Test restart network
""" """
tags = ["advanced", "basic", "sg", "advancedns", "eip"] tags = ["advanced", "basic", "sg", "advancedns", "eip"]
# Validate the following # Validate the following
@ -1036,7 +1036,7 @@ class TestTemplates(cloudstackTestCase):
cls.volume = list_volume[0] cls.volume = list_volume[0]
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during setup : %s" % e) raise Exception("Warning: Exception during setup : %s" % e)
cls._cleanup = [ cls._cleanup = [
cls.service_offering, cls.service_offering,
cls.account, cls.account,
@ -1074,13 +1074,13 @@ class TestTemplates(cloudstackTestCase):
def test_01_check_template_size(self): def test_01_check_template_size(self):
"""TS_BUG_009-Test the size of template created from root disk """TS_BUG_009-Test the size of template created from root disk
""" """
tags = ["advanced", "advancedns", "basic", "sg", "eip"] tags = ["advanced", "advancedns", "basic", "sg", "eip"]
# Validate the following: # Validate the following:
# 1. Deploy new VM using the template created from Volume # 1. Deploy new VM using the template created from Volume
# 2. VM should be in Up and Running state # 2. VM should be in Up and Running state
#Create template from volume #Create template from volume
template = Template.create( template = Template.create(
self.apiclient, self.apiclient,
@ -1097,11 +1097,11 @@ class TestTemplates(cloudstackTestCase):
"Check if size of template and volume are same" "Check if size of template and volume are same"
) )
return return
def test_02_check_size_snapshotTemplate(self): def test_02_check_size_snapshotTemplate(self):
"""TS_BUG_010-Test check size of snapshot and template """TS_BUG_010-Test check size of snapshot and template
""" """
tags = ["advanced", "advancedns", "basic", "sg", "eip"] tags = ["advanced", "advancedns", "basic", "sg", "eip"]
# Validate the following # Validate the following
@ -1113,7 +1113,7 @@ class TestTemplates(cloudstackTestCase):
# Create a snapshot from the ROOTDISK # Create a snapshot from the ROOTDISK
snapshot = Snapshot.create( snapshot = Snapshot.create(
self.apiclient, self.apiclient,
self.volume.id, self.volume.id,
account=self.account.account.name, account=self.account.account.name,
domainid=self.account.account.domainid domainid=self.account.account.domainid
@ -1146,7 +1146,7 @@ class TestTemplates(cloudstackTestCase):
self.services["templates"] self.services["templates"]
) )
self.cleanup.append(template) self.cleanup.append(template)
self.debug("Created template from snapshot with ID: %s" % template.id) self.debug("Created template from snapshot with ID: %s" % template.id)
templates = Template.list( templates = Template.list(
self.apiclient, self.apiclient,
@ -1181,7 +1181,7 @@ class TestTemplates(cloudstackTestCase):
def test_03_resuse_template_name(self): def test_03_resuse_template_name(self):
"""TS_BUG_011-Test Reusing deleted template name """TS_BUG_011-Test Reusing deleted template name
""" """
tags = ["advanced", "advancedns", "basic", "sg", "eip"] tags = ["advanced", "advancedns", "basic", "sg", "eip"]
# Validate the following # Validate the following
@ -1250,15 +1250,15 @@ class TestTemplates(cloudstackTestCase):
True, True,
"Check new template state in list templates call" "Check new template state in list templates call"
) )
self.debug("Deleting template: %s" % template.id) self.debug("Deleting template: %s" % template.id)
template.delete(self.apiclient) 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"]) time.sleep(self.services["sleep"])
# Generate template from the snapshot # 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.id)
template = Template.create_from_snapshot( template = Template.create_from_snapshot(
self.apiclient, self.apiclient,

View File

@ -37,7 +37,7 @@ class Services:
def __init__(self): def __init__(self):
self.services = { self.services = {
"disk_offering":{ "disk_offering": {
"displaytext": "Small", "displaytext": "Small",
"name": "Small", "name": "Small",
"disksize": 1 "disksize": 1
@ -67,8 +67,8 @@ class Services:
"name": "Tiny Instance", "name": "Tiny Instance",
"displaytext": "Tiny Instance", "displaytext": "Tiny Instance",
"cpunumber": 1, "cpunumber": 1,
"cpuspeed": 100, # in MHz "cpuspeed": 100, # in MHz
"memory": 64, # In MBs "memory": 64, # In MBs
}, },
"security_group": { "security_group": {
"name": 'SSH', "name": 'SSH',
@ -110,8 +110,9 @@ class Services:
"protocol": 'TCP', "protocol": 'TCP',
"startport": 22, "startport": 22,
"endport": 22, "endport": 22,
"cidrlist": '0.0.0.0/0'
}, },
"mgmt_server": { "mgmt_server": {
"username": "root", "username": "root",
"password": "fr3sca", "password": "fr3sca",
"ipaddress": "192.168.100.21" "ipaddress": "192.168.100.21"
@ -120,7 +121,7 @@ class Services:
# CentOS 5.3 (64-bit) # CentOS 5.3 (64-bit)
"sleep": 60, "sleep": 60,
"timeout": 10, "timeout": 10,
"mode":'basic', "mode": 'basic',
# Networking mode: Basic or Advanced # Networking mode: Basic or Advanced
} }
@ -197,7 +198,7 @@ class TestDefaultSecurityGroupEgress(cloudstackTestCase):
def test_deployVM_InDefaultSecurityGroup(self): def test_deployVM_InDefaultSecurityGroup(self):
"""Test deploy VM in default security group with no egress rules """Test deploy VM in default security group with no egress rules
""" """
tags = ["sg", "eip"] tags = ["sg", "eip"]
# Validate the following: # Validate the following:
@ -354,7 +355,7 @@ class TestAuthorizeIngressRule(cloudstackTestCase):
def test_authorizeIngressRule(self): def test_authorizeIngressRule(self):
"""Test authorize ingress rule """Test authorize ingress rule
""" """
tags = ["sg", "eip"] tags = ["sg", "eip"]
# Validate the following: # Validate the following:
@ -512,7 +513,7 @@ class TestDefaultGroupEgress(cloudstackTestCase):
def test_01_default_group_with_egress(self): def test_01_default_group_with_egress(self):
"""Test default group with egress rule before VM deploy and ping, ssh """Test default group with egress rule before VM deploy and ping, ssh
""" """
tags = ["sg", "eip"] tags = ["sg", "eip"]
# Validate the following: # Validate the following:
@ -714,7 +715,7 @@ class TestDefaultGroupEgressAfterDeploy(cloudstackTestCase):
""" Test default group with egress rule added after vm deploy and ping, """ Test default group with egress rule added after vm deploy and ping,
ssh test ssh test
""" """
tags = ["sg", "eip"] tags = ["sg", "eip"]
# Validate the following: # Validate the following:
@ -811,7 +812,7 @@ class TestDefaultGroupEgressAfterDeploy(cloudstackTestCase):
# --- www.l.google.com ping statistics --- # --- www.l.google.com ping statistics ---
# 1 packets transmitted, 1 received, 0% packet loss, time 0ms # 1 packets transmitted, 1 received, 0% packet loss, time 0ms
# rtt min/avg/max/mdev = 25.970/25.970/25.970/0.000 ms # 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: except Exception as e:
self.fail("SSH Access failed for %s: %s" % \ self.fail("SSH Access failed for %s: %s" % \
(self.virtual_machine.ipaddress, e) (self.virtual_machine.ipaddress, e)
@ -896,7 +897,7 @@ class TestRevokeEgressRule(cloudstackTestCase):
def test_revoke_egress_rule(self): def test_revoke_egress_rule(self):
"""Test revoke security group egress rule """Test revoke security group egress rule
""" """
tags = ["sg", "eip"] tags = ["sg", "eip"]
# Validate the following: # Validate the following:
@ -997,7 +998,7 @@ class TestRevokeEgressRule(cloudstackTestCase):
# --- www.l.google.com ping statistics --- # --- www.l.google.com ping statistics ---
# 1 packets transmitted, 1 received, 0% packet loss, time 0ms # 1 packets transmitted, 1 received, 0% packet loss, time 0ms
# rtt min/avg/max/mdev = 25.970/25.970/25.970/0.000 ms # 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: except Exception as e:
self.fail("SSH Access failed for %s: %s" % \ self.fail("SSH Access failed for %s: %s" % \
(self.virtual_machine.ipaddress, e) (self.virtual_machine.ipaddress, e)
@ -1038,7 +1039,7 @@ class TestRevokeEgressRule(cloudstackTestCase):
result = security_group.revokeEgress( result = security_group.revokeEgress(
self.apiclient, self.apiclient,
id = ssh_egress_rule["ruleid"] id=ssh_egress_rule["ruleid"]
) )
self.debug("Revoke egress rule result: %s" % result) self.debug("Revoke egress rule result: %s" % result)
@ -1158,7 +1159,7 @@ class TestInvalidAccountAuthroize(cloudstackTestCase):
def test_invalid_account_authroize(self): def test_invalid_account_authroize(self):
"""Test invalid account authroize """Test invalid account authroize
""" """
tags = ["sg", "eip"] tags = ["sg", "eip"]
# Validate the following: # Validate the following:
@ -1286,7 +1287,7 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase):
def test_multiple_account_egress_rule_negative(self): def test_multiple_account_egress_rule_negative(self):
"""Test multiple account egress rules negative case """Test multiple account egress rules negative case
""" """
tags = ["sg", "eip"] tags = ["sg", "eip"]
# Validate the following: # Validate the following:
@ -1335,14 +1336,14 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase):
"Authorizing egress rule for sec group ID: %s for ssh access" "Authorizing egress rule for sec group ID: %s for ssh access"
% security_group.id) % security_group.id)
# Authorize to only account not CIDR # 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( egress_rule = security_group.authorizeEgress(
self.apiclient, self.apiclient,
self.services["sg_account"], self.services["sg_account"],
account=self.accountA.account.name, account=self.accountA.account.name,
domainid=self.accountA.account.domainid, domainid=self.accountA.account.domainid,
user_secgrp_list=user_secgrp_list user_secgrp_list=user_secgrp_list
) )
self.assertEqual( self.assertEqual(
@ -1438,7 +1439,7 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase):
try: try:
self.debug("SSHing into VM type B from VM A") 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" % ( res = ssh.execute("ssh %s@%s" % (
self.services["virtual_machine"]["username"], self.services["virtual_machine"]["username"],
self.virtual_machineB.ssh_ip self.virtual_machineB.ssh_ip
@ -1534,7 +1535,7 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
def test_multiple_account_egress_rule_positive(self): def test_multiple_account_egress_rule_positive(self):
"""Test multiple account egress rules positive case """Test multiple account egress rules positive case
""" """
tags = ["sg", "eip"] tags = ["sg", "eip"]
# Validate the following: # Validate the following:
@ -1610,14 +1611,14 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
"Authorizing egress rule for sec group ID: %s for ssh access" "Authorizing egress rule for sec group ID: %s for ssh access"
% security_groupA.id) % security_groupA.id)
# Authorize to only account not CIDR # 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( egress_rule = security_groupA.authorizeEgress(
self.apiclient, self.apiclient,
self.services["sg_account"], self.services["sg_account"],
account=self.accountA.account.name, account=self.accountA.account.name,
domainid=self.accountA.account.domainid, domainid=self.accountA.account.domainid,
user_secgrp_list=user_secgrp_list user_secgrp_list=user_secgrp_list
) )
self.assertEqual( self.assertEqual(
@ -1734,7 +1735,7 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
try: try:
self.debug("SSHing into VB type B from VM A") 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" % ( res = ssh.execute("ssh %s@%s" % (
self.services["virtual_machine"]["username"], self.services["virtual_machine"]["username"],
@ -1825,7 +1826,7 @@ class TestStartStopVMWithEgressRule(cloudstackTestCase):
def test_start_stop_vm_egress(self): def test_start_stop_vm_egress(self):
""" Test stop start Vm with egress rules """ Test stop start Vm with egress rules
""" """
tags = ["sg", "eip"] tags = ["sg", "eip"]
# Validate the following: # Validate the following:
@ -1965,6 +1966,7 @@ class TestStartStopVMWithEgressRule(cloudstackTestCase):
) )
return return
@unittest.skip("Valid bug- ID: CS-12647") @unittest.skip("Valid bug- ID: CS-12647")
class TestInvalidParametersForEgress(cloudstackTestCase): class TestInvalidParametersForEgress(cloudstackTestCase):
@ -2036,7 +2038,7 @@ class TestInvalidParametersForEgress(cloudstackTestCase):
def test_invalid_parameters(self): def test_invalid_parameters(self):
""" Test invalid parameters for egress rules """ Test invalid parameters for egress rules
""" """
tags = ["sg", "eip"] tags = ["sg", "eip"]
# Validate the following: # Validate the following:
@ -2223,7 +2225,7 @@ class TestEgressAfterHostMaintainance(cloudstackTestCase):
def test_egress_after_host_maintainance(self): def test_egress_after_host_maintainance(self):
"""Test maintenance case for egress """Test maintenance case for egress
""" """
tags = ["sg", "eip"] tags = ["sg", "eip"]
# Validate the following: # Validate the following:
@ -2329,12 +2331,12 @@ class TestEgressAfterHostMaintainance(cloudstackTestCase):
) )
vm = vms[0] 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 = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
cmd.id = vm.hostid cmd.id = vm.hostid
self.apiclient.prepareHostForMaintenance(cmd) 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 = cancelHostMaintenance.cancelHostMaintenanceCmd()
cmd.id = vm.hostid cmd.id = vm.hostid
self.apiclient.cancelHostMaintenance(cmd) self.apiclient.cancelHostMaintenance(cmd)

View File

@ -47,8 +47,8 @@ class Services:
"name": "Tiny Instance", "name": "Tiny Instance",
"displaytext": "Tiny Instance", "displaytext": "Tiny Instance",
"cpunumber": 1, "cpunumber": 1,
"cpuspeed": 100, # in MHz "cpuspeed": 100, # in MHz
"memory": 64, # In MBs "memory": 64, # In MBs
}, },
"lbrule": { "lbrule": {
"name": "SSH", "name": "SSH",
@ -183,7 +183,7 @@ class TestEIP(cloudstackTestCase):
def test_01_eip_by_deploying_instance(self): def test_01_eip_by_deploying_instance(self):
"""Test EIP by deploying an instance """Test EIP by deploying an instance
""" """
tags = ["eip"] tags = ["eip"]
# Validate the following # Validate the following
@ -350,7 +350,7 @@ class TestEIP(cloudstackTestCase):
def test_02_acquire_ip_enable_static_nat(self): def test_02_acquire_ip_enable_static_nat(self):
"""Test associate new IP and enable static NAT for new IP and the VM """Test associate new IP and enable static NAT for new IP and the VM
""" """
tags = ["eip"] tags = ["eip"]
# Validate the following # Validate the following
@ -494,7 +494,7 @@ class TestEIP(cloudstackTestCase):
def test_03_disable_static_nat(self): def test_03_disable_static_nat(self):
"""Test disable static NAT and release EIP acquired """Test disable static NAT and release EIP acquired
""" """
tags = ["eip"] tags = ["eip"]
# Validate the following # Validate the following
@ -693,7 +693,7 @@ class TestEIP(cloudstackTestCase):
def test_04_disable_static_nat_system(self): def test_04_disable_static_nat_system(self):
"""Test disable static NAT with system = True """Test disable static NAT with system = True
""" """
tags = ["eip"] tags = ["eip"]
# Validate the following # Validate the following
@ -762,7 +762,7 @@ class TestEIP(cloudstackTestCase):
def test_05_destroy_instance(self): def test_05_destroy_instance(self):
"""Test EIO after destroying instance """Test EIO after destroying instance
""" """
tags = ["eip"] tags = ["eip"]
# Validate the following # Validate the following
@ -1000,7 +1000,7 @@ class TestELB(cloudstackTestCase):
def test_01_elb_create(self): def test_01_elb_create(self):
"""Test ELB by creating a LB rule """Test ELB by creating a LB rule
""" """
tags = ["eip"] tags = ["eip"]
# Validate the following # Validate the following
@ -1173,7 +1173,7 @@ class TestELB(cloudstackTestCase):
def test_02_elb_acquire_and_create(self): def test_02_elb_acquire_and_create(self):
"""Test ELB by acquiring IP and then creating a LB rule """Test ELB by acquiring IP and then creating a LB rule
""" """
tags = ["eip"] tags = ["eip"]
# Validate the following # Validate the following
@ -1321,7 +1321,7 @@ class TestELB(cloudstackTestCase):
def test_03_elb_delete_lb_system(self): def test_03_elb_delete_lb_system(self):
"""Test delete LB rule generated with public IP with is_system = 1 """Test delete LB rule generated with public IP with is_system = 1
""" """
tags = ["eip"] tags = ["eip"]
# Validate the following # Validate the following
@ -1425,7 +1425,7 @@ class TestELB(cloudstackTestCase):
def test_04_delete_lb_on_eip(self): def test_04_delete_lb_on_eip(self):
"""Test delete LB rule generated on EIP """Test delete LB rule generated on EIP
""" """
tags = ["eip"] tags = ["eip"]
# Validate the following # Validate the following

View File

@ -47,8 +47,8 @@ class Services:
"name": "Tiny Instance", "name": "Tiny Instance",
"displaytext": "Tiny Instance", "displaytext": "Tiny Instance",
"cpunumber": 1, "cpunumber": 1,
"cpuspeed": 100, # in MHz "cpuspeed": 100, # in MHz
"memory": 64, # In MBs "memory": 64, # In MBs
}, },
"lbrule": { "lbrule": {
"name": "SSH", "name": "SSH",
@ -62,7 +62,7 @@ class Services:
"publicport": 22, "publicport": 22,
"protocol": "TCP" "protocol": "TCP"
}, },
"fw_rule":{ "fw_rule": {
"startport": 1, "startport": 1,
"endport": 6000, "endport": 6000,
"cidr": '55.55.0.0/11', "cidr": '55.55.0.0/11',
@ -86,7 +86,7 @@ class Services:
"ostypeid": '946b031b-0e10-4f4a-a3fc-d212ae2ea07f', "ostypeid": '946b031b-0e10-4f4a-a3fc-d212ae2ea07f',
"url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2", "url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2",
"hypervisor": 'XenServer', "hypervisor": 'XenServer',
"format" : 'VHD', "format": 'VHD',
"isfeatured": True, "isfeatured": True,
"ispublic": True, "ispublic": True,
"isextractable": True, "isextractable": True,
@ -96,7 +96,7 @@ class Services:
# Cent OS 5.3 (64 bit) # Cent OS 5.3 (64 bit)
"sleep": 60, "sleep": 60,
"timeout": 100, "timeout": 100,
"mode":'advanced' "mode": 'advanced'
} }
@ -175,7 +175,7 @@ class TestHighAvailability(cloudstackTestCase):
def test_01_host_maintenance_mode(self): def test_01_host_maintenance_mode(self):
"""Test host maintenance mode """Test host maintenance mode
""" """
tags = ["advanced", "advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
@ -575,7 +575,7 @@ class TestHighAvailability(cloudstackTestCase):
def test_02_host_maintenance_mode_with_activities(self): def test_02_host_maintenance_mode_with_activities(self):
"""Test host maintenance mode with activities """Test host maintenance mode with activities
""" """
tags = ["advanced", "advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
@ -714,7 +714,7 @@ class TestHighAvailability(cloudstackTestCase):
self.fail("SSH Access failed for %s: %s" % \ self.fail("SSH Access failed for %s: %s" % \
(virtual_machine.ipaddress, e) (virtual_machine.ipaddress, e)
) )
# Get the Root disk of VM # Get the Root disk of VM
volumes = list_volumes( volumes = list_volumes(
self.apiclient, self.apiclient,
virtualmachineid=virtual_machine.id, virtualmachineid=virtual_machine.id,
@ -883,7 +883,7 @@ class TestHighAvailability(cloudstackTestCase):
self.apiclient.cancelHostMaintenance(cmd) self.apiclient.cancelHostMaintenance(cmd)
self.debug("Maintenance mode canceled for host: %s" % first_host) 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( volumes = list_volumes(
self.apiclient, self.apiclient,
virtualmachineid=virtual_machine_2.id, virtualmachineid=virtual_machine_2.id,

View File

@ -47,8 +47,8 @@ class Services:
"name": "Tiny Instance", "name": "Tiny Instance",
"displaytext": "Tiny Instance", "displaytext": "Tiny Instance",
"cpunumber": 1, "cpunumber": 1,
"cpuspeed": 100, # in MHz "cpuspeed": 100, # in MHz
"memory": 64, # In MBs "memory": 64, # In MBs
}, },
"network_offering": { "network_offering": {
"name": 'Network offering-VR services', "name": 'Network offering-VR services',
@ -57,16 +57,16 @@ class Services:
"supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat', "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat',
"traffictype": 'GUEST', "traffictype": 'GUEST',
"availability": 'Optional', "availability": 'Optional',
"serviceProviderList" : { "serviceProviderList": {
"Dhcp": 'VirtualRouter', "Dhcp": 'VirtualRouter',
"Dns": 'VirtualRouter', "Dns": 'VirtualRouter',
"SourceNat": 'VirtualRouter', "SourceNat": 'VirtualRouter',
"PortForwarding": 'VirtualRouter', "PortForwarding": 'VirtualRouter',
"Vpn": 'VirtualRouter', "Vpn": 'VirtualRouter',
"Firewall": 'VirtualRouter', "Firewall": 'VirtualRouter',
"Lb": 'VirtualRouter', "Lb": 'VirtualRouter',
"UserData": 'VirtualRouter', "UserData": 'VirtualRouter',
"StaticNat": 'VirtualRouter', "StaticNat": 'VirtualRouter',
}, },
}, },
"network_offering_netscaler": { "network_offering_netscaler": {
@ -76,7 +76,7 @@ class Services:
"supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat', "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat',
"traffictype": 'GUEST', "traffictype": 'GUEST',
"availability": 'Optional', "availability": 'Optional',
"serviceProviderList" : { "serviceProviderList": {
"Dhcp": 'VirtualRouter', "Dhcp": 'VirtualRouter',
"Dns": 'VirtualRouter', "Dns": 'VirtualRouter',
"SourceNat": 'VirtualRouter', "SourceNat": 'VirtualRouter',
@ -118,7 +118,7 @@ class Services:
"publicport": 66, "publicport": 66,
"protocol": "TCP" "protocol": "TCP"
}, },
"fw_rule":{ "fw_rule": {
"startport": 1, "startport": 1,
"endport": 6000, "endport": 6000,
"cidr": '55.55.0.0/11', "cidr": '55.55.0.0/11',
@ -140,7 +140,7 @@ class Services:
# Cent OS 5.3 (64 bit) # Cent OS 5.3 (64 bit)
"sleep": 60, "sleep": 60,
"timeout": 10, "timeout": 10,
"mode":'advanced' "mode": 'advanced'
} }
@ -212,7 +212,7 @@ class TestNOVirtualRouter(cloudstackTestCase):
def test_01_network_off_without_conserve_mode(self): def test_01_network_off_without_conserve_mode(self):
"""Test Network offering with Conserve mode off and VR - All services """Test Network offering with Conserve mode off and VR - All services
""" """
tags = ["advanced"] tags = ["advanced"]
# Validate the following # Validate the following
@ -245,7 +245,7 @@ class TestNOVirtualRouter(cloudstackTestCase):
self.debug("Created n/w offering with ID: %s" % self.debug("Created n/w offering with ID: %s" %
self.network_offering.id) self.network_offering.id)
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
# Creating network using the network offering created # Creating network using the network offering created
@ -257,7 +257,7 @@ class TestNOVirtualRouter(cloudstackTestCase):
accountid=self.account.account.name, accountid=self.account.account.name,
domainid=self.account.account.domainid, domainid=self.account.account.domainid,
networkofferingid=self.network_offering.id, networkofferingid=self.network_offering.id,
zoneid=self.zone.id zoneid=self.zone.id
) )
self.debug("Created network with ID: %s" % self.network.id) self.debug("Created network with ID: %s" % self.network.id)
@ -334,7 +334,7 @@ class TestNOVirtualRouter(cloudstackTestCase):
ip_with_nat_rule.ipaddress.ipaddress) ip_with_nat_rule.ipaddress.ipaddress)
NATRule.create( NATRule.create(
self.apiclient, self.apiclient,
virtual_machine, virtual_machine,
self.services["natrule"], self.services["natrule"],
ipaddressid=ip_with_nat_rule.ipaddress.id ipaddressid=ip_with_nat_rule.ipaddress.id
) )
@ -457,7 +457,7 @@ class TestNOVirtualRouter(cloudstackTestCase):
def test_02_network_off_with_conserve_mode(self): def test_02_network_off_with_conserve_mode(self):
"""Test Network offering with Conserve mode ON and VR - All services """Test Network offering with Conserve mode ON and VR - All services
""" """
tags = ["advanced"] tags = ["advanced"]
# Validate the following # Validate the following
@ -488,7 +488,7 @@ class TestNOVirtualRouter(cloudstackTestCase):
self.debug("Created n/w offering with ID: %s" % self.debug("Created n/w offering with ID: %s" %
self.network_offering.id) self.network_offering.id)
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
# Creating network using the network offering created # Creating network using the network offering created
@ -500,7 +500,7 @@ class TestNOVirtualRouter(cloudstackTestCase):
accountid=self.account.account.name, accountid=self.account.account.name,
domainid=self.account.account.domainid, domainid=self.account.account.domainid,
networkofferingid=self.network_offering.id, networkofferingid=self.network_offering.id,
zoneid=self.zone.id zoneid=self.zone.id
) )
self.debug("Created network with ID: %s" % self.network.id) self.debug("Created network with ID: %s" % self.network.id)
@ -705,7 +705,7 @@ class TestNOVirtualRouter(cloudstackTestCase):
vpns = Vpn.list( vpns = Vpn.list(
self.apiclient, self.apiclient,
publicipid=src_nat.id, publicipid=src_nat.id,
listall=True, listall=True,
) )
self.assertEqual( self.assertEqual(
@ -790,7 +790,7 @@ class TestNOWithNetscaler(cloudstackTestCase):
def test_01_network_off_without_conserve_mode(self): def test_01_network_off_without_conserve_mode(self):
"""Test Nw off with Conserve mode off, VR-All services, LB-netscaler """Test Nw off with Conserve mode off, VR-All services, LB-netscaler
""" """
tags = ["advancedns"] tags = ["advancedns"]
# Validate the following # Validate the following
@ -802,14 +802,13 @@ class TestNOWithNetscaler(cloudstackTestCase):
# 5. On an ipaddress that has Lb rules , we should NOT allow firewall # 5. On an ipaddress that has Lb rules , we should NOT allow firewall
# rules to be programmed. # rules to be programmed.
# 6. On an ipaddress that has Lb rules , we should NOT allow PF rules # 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 # 7. We should be allowed to program multiple PF rules on the same Ip
# address on different public ports. # address on different public ports.
# 8. We should be allowed to program multiple LB rules on the same Ip # 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. # 9. On source NAT ipaddress, we should NOT be allowed to Enable VPN.
# Create a network offering with all virtual router services enabled # Create a network offering with all virtual router services enabled
self.debug( self.debug(
"Creating n/w offering with all services in VR & conserve mode:ON" "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" % self.debug("Creating firewall rule on source NAT: %s" %
src_nat.ipaddress) src_nat.ipaddress)
#Create Firewall rule on source NAT #Create Firewall rule on source NAT
fw_rule = FireWallRule.create( fw_rule = FireWallRule.create(
self.apiclient, self.apiclient,
ipaddressid=src_nat.id, ipaddressid=src_nat.id,
@ -1060,7 +1059,7 @@ class TestNOWithNetscaler(cloudstackTestCase):
def test_02_network_off_with_conserve_mode_netscaler(self): def test_02_network_off_with_conserve_mode_netscaler(self):
"""Test NW off with Conserve mode ON, LB-Netscaler and VR-All services """Test NW off with Conserve mode ON, LB-Netscaler and VR-All services
""" """
tags = ["advancedns"] tags = ["advancedns"]
# Validate the following # Validate the following
@ -1073,14 +1072,13 @@ class TestNOWithNetscaler(cloudstackTestCase):
# 5. On an ipaddress that has Lb rules , we should NOT allow firewall # 5. On an ipaddress that has Lb rules , we should NOT allow firewall
# rules to be programmed. # rules to be programmed.
# 6. On an ipaddress that has Lb rules , we should NOT allow PF rules # 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 # 7. We should be allowed to program multiple PF rules on the same Ip
# address on different public ports. # address on different public ports.
# 8. We should be allowed to program multiple LB rules on the same Ip # 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. # 9. On source NAT ipaddress, we should be allowed to Enable VPN.
# Create a network offering with all virtual router services enabled # Create a network offering with all virtual router services enabled
self.debug( self.debug(
"Creating n/w offering with all services in VR & conserve mode:ON" "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): def test_01_nwupgrade_netscaler_conserve_on(self):
"""Test Nw upgrade to netscaler lb service and conserve mode ON """Test Nw upgrade to netscaler lb service and conserve mode ON
""" """
tags = ["advancedns"] tags = ["advancedns"]
# Validate the following # Validate the following
@ -1635,7 +1633,7 @@ class TestNetworkUpgrade(cloudstackTestCase):
def test_02_nwupgrade_netscaler_conserve_off(self): def test_02_nwupgrade_netscaler_conserve_off(self):
"""Test Nw upgrade to netscaler lb service and conserve mode OFF """Test Nw upgrade to netscaler lb service and conserve mode OFF
""" """
tags = ["advancedns"] tags = ["advancedns"]
# Validate the following # Validate the following

View File

@ -68,8 +68,8 @@ class Services:
"name": "Tiny Instance", "name": "Tiny Instance",
"displaytext": "Tiny Instance", "displaytext": "Tiny Instance",
"cpunumber": 1, "cpunumber": 1,
"cpuspeed": 100, # in MHz "cpuspeed": 100, # in MHz
"memory": 64, # In MBs "memory": 64, # In MBs
}, },
"virtual_machine": { "virtual_machine": {
"displayname": "Test VM", "displayname": "Test VM",
@ -89,7 +89,7 @@ class Services:
"ostypeid": 'f9b709f2-e0fc-4c0f-80f1-b0494168f58d', "ostypeid": 'f9b709f2-e0fc-4c0f-80f1-b0494168f58d',
"url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2", "url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2",
"hypervisor": 'XenServer', "hypervisor": 'XenServer',
"format" : 'VHD', "format": 'VHD',
"isfeatured": True, "isfeatured": True,
"ispublic": True, "ispublic": True,
"isextractable": True, "isextractable": True,
@ -107,7 +107,7 @@ class Services:
# Cent OS 5.3 (64 bit) # Cent OS 5.3 (64 bit)
"sleep": 60, "sleep": 60,
"timeout": 10, "timeout": 10,
"mode":'advanced' "mode": 'advanced'
} }
@ -169,11 +169,14 @@ class TestUserProjectCreation(cloudstackTestCase):
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
return return
def test_01_admin_project_creation(self): def test_01_admin_project_creation(self):
"""Test create project as a domain admin and domain user """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 # Validate the following
# 1. Check if 'allow.user.create.projects' configuration is true # 1. Check if 'allow.user.create.projects' configuration is true
# 2. Create a Project as domain admin # 2. Create a Project as domain admin
@ -207,9 +210,9 @@ class TestUserProjectCreation(cloudstackTestCase):
self.cleanup.append(project) 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) project.id)
list_projects_reponse = Project.list( list_projects_reponse = Project.list(
self.apiclient, self.apiclient,
id=project.id, id=project.id,
listall=True listall=True
) )
@ -243,9 +246,9 @@ class TestUserProjectCreation(cloudstackTestCase):
self.cleanup.append(project) self.cleanup.append(project)
self.debug("Created project with domain user with ID: %s" % self.debug("Created project with domain user with ID: %s" %
project.id) project.id)
list_projects_reponse = Project.list( list_projects_reponse = Project.list(
self.apiclient, self.apiclient,
id=project.id, id=project.id,
listall=True listall=True
) )
@ -263,6 +266,7 @@ class TestUserProjectCreation(cloudstackTestCase):
"Check list project response returns a valid project" "Check list project response returns a valid project"
) )
return return
@unittest.skip("Known bug-able to create project as a domain user") @unittest.skip("Known bug-able to create project as a domain user")
def test_02_user_project_creation(self): def test_02_user_project_creation(self):
"""Test create project as a domain admin and domain user """Test create project as a domain admin and domain user
@ -301,9 +305,9 @@ class TestUserProjectCreation(cloudstackTestCase):
self.cleanup.append(project) 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) project.id)
list_projects_reponse = Project.list( list_projects_reponse = Project.list(
self.apiclient, self.apiclient,
id=project.id, id=project.id,
listall=True listall=True
) )
@ -346,24 +350,24 @@ class TestProjectInviteRequired(cloudstackTestCase):
cls.services = Services().services cls.services = Services().services
# Get Zone # Get Zone
cls.zone = get_zone(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services)
# Create domains, account etc. # Create domains, account etc.
cls.domain = get_domain(cls.api_client, cls.services) cls.domain = get_domain(cls.api_client, cls.services)
cls.account = Account.create( cls.account = Account.create(
cls.api_client, cls.api_client,
cls.services["account"], cls.services["account"],
admin=True, admin=True,
domainid=cls.domain.id domainid=cls.domain.id
) )
cls.user = Account.create( cls.user = Account.create(
cls.api_client, cls.api_client,
cls.services["user"], cls.services["user"],
admin=True, admin=True,
domainid=cls.domain.id domainid=cls.domain.id
) )
cls._cleanup = [cls.account, cls.user] cls._cleanup = [cls.account, cls.user]
return return
@ -390,14 +394,17 @@ class TestProjectInviteRequired(cloudstackTestCase):
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
return return
def test_03_add_user_to_project(self): def test_03_add_user_to_project(self):
"""Add user to project when 'project.invite.required' is false""" """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: # Validate the following:
# 1. Create a Project # 1. Create a Project
# 2. Add users to the project. Verify user is added to 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 # Verify 'project.invite.required' is set to false
configs = Configurations.list( configs = Configurations.list(
@ -427,9 +434,9 @@ class TestProjectInviteRequired(cloudstackTestCase):
self.cleanup.append(project) 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) project.id)
list_projects_reponse = Project.list( list_projects_reponse = Project.list(
self.apiclient, self.apiclient,
id=project.id, id=project.id,
listall=True listall=True
) )
@ -458,14 +465,14 @@ class TestProjectInviteRequired(cloudstackTestCase):
)) ))
# Add user to the project # Add user to the project
project.addAccount( project.addAccount(
self.apiclient, self.apiclient,
self.user.account.name, self.user.account.name,
self.user.account.email self.user.account.email
) )
# listProjectAccount to verify the user is added to project or not # listProjectAccount to verify the user is added to project or not
accounts_reponse = Project.listAccounts( accounts_reponse = Project.listAccounts(
self.apiclient, self.apiclient,
projectid=project.id, projectid=project.id,
account=self.user.account.name, account=self.user.account.name,
) )
@ -475,20 +482,20 @@ class TestProjectInviteRequired(cloudstackTestCase):
True, True,
"Check for a valid list accounts response" "Check for a valid list accounts response"
) )
self.assertNotEqual( self.assertNotEqual(
len(list_projects_reponse), len(list_projects_reponse),
0, 0,
"Check list project response returns a valid project" "Check list project response returns a valid project"
) )
account = accounts_reponse[0] account = accounts_reponse[0]
self.assertEqual( self.assertEqual(
account.role, account.role,
'Regular', 'Regular',
"Newly added user is not added as a regular user" "Newly added user is not added as a regular user"
) )
return return
def test_04_add_user_to_project(self): def test_04_add_user_to_project(self):
@ -524,12 +531,12 @@ class TestProjectInviteRequired(cloudstackTestCase):
) )
# Cleanup created project at end of test # Cleanup created project at end of test
self.cleanup.append(project) 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) project.id)
list_projects_reponse = Project.list( list_projects_reponse = Project.list(
self.apiclient, self.apiclient,
id=project.id, id=project.id,
listall=True listall=True
) )
@ -558,11 +565,11 @@ class TestProjectInviteRequired(cloudstackTestCase):
)) ))
# Add user to the project # Add user to the project
project.addAccount( project.addAccount(
self.apiclient, self.apiclient,
self.user.account.name, self.user.account.name,
self.user.account.email self.user.account.email
) )
# listProjectAccount to verify the user is added to project or not # listProjectAccount to verify the user is added to project or not
accounts_reponse = ProjectInvitation.list( accounts_reponse = ProjectInvitation.list(
self.apiclient, self.apiclient,
@ -575,14 +582,14 @@ class TestProjectInviteRequired(cloudstackTestCase):
True, True,
"Check for a valid list accounts response" "Check for a valid list accounts response"
) )
self.assertNotEqual( self.assertNotEqual(
len(list_projects_reponse), len(list_projects_reponse),
0, 0,
"Check list project response returns a valid project" "Check list project response returns a valid project"
) )
account = accounts_reponse[0] account = accounts_reponse[0]
self.assertEqual( self.assertEqual(
account.state, account.state,
'Pending', 'Pending',
@ -595,11 +602,11 @@ class TestProjectInviteRequired(cloudstackTestCase):
# Validate the following: # Validate the following:
# 1. Set configuration to 5 mins # 1. Set configuration to 5 mins
# 2. Create a Project # 2. Create a Project
# 3. Add users to the project # 3. Add users to the project
# 4. As a user accept invitation within 5 mins. Verify invitation is # 4. As a user accept invitation within 5 mins. Verify invitation is
# accepted and user become regular user of project # accepted and user become regular user of project
# Verify 'project.invite.required' is set to false # Verify 'project.invite.required' is set to false
configs = Configurations.list( configs = Configurations.list(
self.apiclient, self.apiclient,
@ -615,7 +622,7 @@ class TestProjectInviteRequired(cloudstackTestCase):
int(config.value), int(config.value),
self.services["configs"]["project.invite.timeout"], self.services["configs"]["project.invite.timeout"],
"'project.invite.timeout' should be %s" % "'project.invite.timeout' should be %s" %
self.services["configs"]["project.invite.timeout"] self.services["configs"]["project.invite.timeout"]
) )
# Create project as a domain admin # Create project as a domain admin
@ -627,12 +634,12 @@ class TestProjectInviteRequired(cloudstackTestCase):
) )
# Cleanup created project at end of test # Cleanup created project at end of test
self.cleanup.append(project) 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) project.id)
list_projects_reponse = Project.list( list_projects_reponse = Project.list(
self.apiclient, self.apiclient,
id=project.id, id=project.id,
listall=True listall=True
) )
@ -661,11 +668,11 @@ class TestProjectInviteRequired(cloudstackTestCase):
)) ))
# Add user to the project # Add user to the project
project.addAccount( project.addAccount(
self.apiclient, self.apiclient,
self.user.account.name, self.user.account.name,
self.user.account.email self.user.account.email
) )
# listProjectAccount to verify the user is added to project or not # listProjectAccount to verify the user is added to project or not
accounts_reponse = ProjectInvitation.list( accounts_reponse = ProjectInvitation.list(
self.apiclient, self.apiclient,
@ -678,24 +685,24 @@ class TestProjectInviteRequired(cloudstackTestCase):
True, True,
"Check for a valid list accounts response" "Check for a valid list accounts response"
) )
self.assertNotEqual( self.assertNotEqual(
len(list_projects_reponse), len(list_projects_reponse),
0, 0,
"Check list project response returns a valid project" "Check list project response returns a valid project"
) )
account = accounts_reponse[0] account = accounts_reponse[0]
self.assertEqual( self.assertEqual(
account.state, account.state,
'Pending', 'Pending',
"Newly added user is not added as a regular user" "Newly added user is not added as a regular user"
) )
# Accept the invite # Accept the invite
ProjectInvitation.update( ProjectInvitation.update(
self.apiclient, self.apiclient,
projectid=project.id, projectid=project.id,
accept=True, accept=True,
account=self.user.account.name account=self.user.account.name
) )
@ -706,7 +713,7 @@ class TestProjectInviteRequired(cloudstackTestCase):
)) ))
# listProjectAccount to verify the user is added to project or not # listProjectAccount to verify the user is added to project or not
accounts_reponse = Project.listAccounts( accounts_reponse = Project.listAccounts(
self.apiclient, self.apiclient,
projectid=project.id, projectid=project.id,
account=self.user.account.name, account=self.user.account.name,
) )
@ -716,14 +723,14 @@ class TestProjectInviteRequired(cloudstackTestCase):
True, True,
"Check for a valid list accounts response" "Check for a valid list accounts response"
) )
self.assertNotEqual( self.assertNotEqual(
len(list_projects_reponse), len(list_projects_reponse),
0, 0,
"Check list project response returns a valid project" "Check list project response returns a valid project"
) )
account = accounts_reponse[0] account = accounts_reponse[0]
self.assertEqual( self.assertEqual(
account.role, account.role,
'Regular', 'Regular',
@ -736,11 +743,11 @@ class TestProjectInviteRequired(cloudstackTestCase):
# Validate the following: # Validate the following:
# 1. Set configuration to 5 mins # 1. Set configuration to 5 mins
# 2. Create a Project # 2. Create a Project
# 3. Add users to the project # 3. Add users to the project
# 4. As a user accept invitation after 5 mins. Verify invitation is # 4. As a user accept invitation after 5 mins. Verify invitation is
# not accepted and is shown as expired # not accepted and is shown as expired
# Verify 'project.invite.required' is set to false # Verify 'project.invite.required' is set to false
configs = Configurations.list( configs = Configurations.list(
self.apiclient, self.apiclient,
@ -756,7 +763,7 @@ class TestProjectInviteRequired(cloudstackTestCase):
int(config.value), int(config.value),
self.services["configs"]["project.invite.timeout"], self.services["configs"]["project.invite.timeout"],
"'project.invite.timeout' should be %s" % "'project.invite.timeout' should be %s" %
self.services["configs"]["project.invite.timeout"] self.services["configs"]["project.invite.timeout"]
) )
# Create project as a domain admin # Create project as a domain admin
@ -768,12 +775,12 @@ class TestProjectInviteRequired(cloudstackTestCase):
) )
# Cleanup created project at end of test # Cleanup created project at end of test
self.cleanup.append(project) 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) project.id)
list_projects_reponse = Project.list( list_projects_reponse = Project.list(
self.apiclient, self.apiclient,
id=project.id, id=project.id,
listall=True listall=True
) )
@ -802,11 +809,11 @@ class TestProjectInviteRequired(cloudstackTestCase):
)) ))
# Add user to the project # Add user to the project
project.addAccount( project.addAccount(
self.apiclient, self.apiclient,
self.user.account.name, self.user.account.name,
self.user.account.email self.user.account.email
) )
# listProjectAccount to verify the user is added to project or not # listProjectAccount to verify the user is added to project or not
accounts_reponse = ProjectInvitation.list( accounts_reponse = ProjectInvitation.list(
self.apiclient, self.apiclient,
@ -819,20 +826,20 @@ class TestProjectInviteRequired(cloudstackTestCase):
True, True,
"Check for a valid list accounts response" "Check for a valid list accounts response"
) )
self.assertNotEqual( self.assertNotEqual(
len(list_projects_reponse), len(list_projects_reponse),
0, 0,
"Check list project response returns a valid project" "Check list project response returns a valid project"
) )
account = accounts_reponse[0] account = accounts_reponse[0]
self.assertEqual( self.assertEqual(
account.state, account.state,
'Pending', 'Pending',
"Newly added user is not added as a regular user" "Newly added user is not added as a regular user"
) )
# sleep for 'project.invite.timeout' * 2 interval to wait for invite # sleep for 'project.invite.timeout' * 2 interval to wait for invite
# to expire # to expire
time.sleep(int(config.value) * 2) time.sleep(int(config.value) * 2)
@ -841,7 +848,7 @@ class TestProjectInviteRequired(cloudstackTestCase):
# Accept the invite # Accept the invite
ProjectInvitation.update( ProjectInvitation.update(
self.apiclient, self.apiclient,
projectid=project.id, projectid=project.id,
accept=True, accept=True,
account=self.user.account.name account=self.user.account.name
) )
@ -862,14 +869,14 @@ class TestProjectInviteRequired(cloudstackTestCase):
True, True,
"Check for a valid list accounts response" "Check for a valid list accounts response"
) )
self.assertNotEqual( self.assertNotEqual(
len(list_projects_reponse), len(list_projects_reponse),
0, 0,
"Check list project response returns a valid project" "Check list project response returns a valid project"
) )
account = accounts_reponse[0] account = accounts_reponse[0]
self.assertEqual( self.assertEqual(
account.state, account.state,
'Expired', 'Expired',
@ -882,7 +889,7 @@ class TestProjectInviteRequired(cloudstackTestCase):
# Validate the following: # Validate the following:
# 1. Set configuration to 5 mins # 1. Set configuration to 5 mins
# 2. Create a Project # 2. Create a Project
# 3. Add users to the project # 3. Add users to the project
# 4. As a user accept invitation after 5 mins. # 4. As a user accept invitation after 5 mins.
# 5. Resend the invitation # 5. Resend the invitation
@ -903,7 +910,7 @@ class TestProjectInviteRequired(cloudstackTestCase):
int(config.value), int(config.value),
self.services["configs"]["project.invite.timeout"], self.services["configs"]["project.invite.timeout"],
"'project.invite.timeout' should be %s" % "'project.invite.timeout' should be %s" %
self.services["configs"]["project.invite.timeout"] self.services["configs"]["project.invite.timeout"]
) )
# Create project as a domain admin # Create project as a domain admin
@ -915,12 +922,12 @@ class TestProjectInviteRequired(cloudstackTestCase):
) )
# Cleanup created project at end of test # Cleanup created project at end of test
self.cleanup.append(project) 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) project.id)
list_projects_reponse = Project.list( list_projects_reponse = Project.list(
self.apiclient, self.apiclient,
id=project.id, id=project.id,
listall=True listall=True
) )
@ -949,11 +956,11 @@ class TestProjectInviteRequired(cloudstackTestCase):
)) ))
# Add user to the project # Add user to the project
project.addAccount( project.addAccount(
self.apiclient, self.apiclient,
self.user.account.name, self.user.account.name,
self.user.account.email self.user.account.email
) )
# listProjectAccount to verify the user is added to project or not # listProjectAccount to verify the user is added to project or not
accounts_reponse = ProjectInvitation.list( accounts_reponse = ProjectInvitation.list(
self.apiclient, self.apiclient,
@ -966,20 +973,20 @@ class TestProjectInviteRequired(cloudstackTestCase):
True, True,
"Check for a valid list accounts response" "Check for a valid list accounts response"
) )
self.assertNotEqual( self.assertNotEqual(
len(list_projects_reponse), len(list_projects_reponse),
0, 0,
"Check list project response returns a valid project" "Check list project response returns a valid project"
) )
account = accounts_reponse[0] account = accounts_reponse[0]
self.assertEqual( self.assertEqual(
account.state, account.state,
'Pending', 'Pending',
"Newly added user is not added as a regular user" "Newly added user is not added as a regular user"
) )
# sleep for 'project.invite.timeout' * 2 interval to wait for invite # sleep for 'project.invite.timeout' * 2 interval to wait for invite
# to expire # to expire
time.sleep(int(config.value) * 2) time.sleep(int(config.value) * 2)
@ -990,11 +997,11 @@ class TestProjectInviteRequired(cloudstackTestCase):
)) ))
# Add user to the project # Add user to the project
project.addAccount( project.addAccount(
self.apiclient, self.apiclient,
self.user.account.name, self.user.account.name,
self.user.account.email self.user.account.email
) )
# listProjectAccount to verify the user is added to project or not # listProjectAccount to verify the user is added to project or not
accounts_reponse = ProjectInvitation.list( accounts_reponse = ProjectInvitation.list(
self.apiclient, self.apiclient,
@ -1007,14 +1014,14 @@ class TestProjectInviteRequired(cloudstackTestCase):
True, True,
"Check for a valid list accounts response" "Check for a valid list accounts response"
) )
self.assertNotEqual( self.assertNotEqual(
len(list_projects_reponse), len(list_projects_reponse),
0, 0,
"Check list project response returns a valid project" "Check list project response returns a valid project"
) )
account = accounts_reponse[0] account = accounts_reponse[0]
self.assertEqual( self.assertEqual(
account.state, account.state,
'Pending', 'Pending',
@ -1027,7 +1034,7 @@ class TestProjectInviteRequired(cloudstackTestCase):
# Validate the following: # Validate the following:
# 1. Set configuration to 5 mins # 1. Set configuration to 5 mins
# 2. Create a Project # 2. Create a Project
# 3. Add users to the project # 3. Add users to the project
# 4. As a user decline invitation within 5 mins. # 4. As a user decline invitation within 5 mins.
# 5. Verify invitation is rejected and user doesn't become regular # 5. Verify invitation is rejected and user doesn't become regular
@ -1048,7 +1055,7 @@ class TestProjectInviteRequired(cloudstackTestCase):
int(config.value), int(config.value),
self.services["configs"]["project.invite.timeout"], self.services["configs"]["project.invite.timeout"],
"'project.invite.timeout' should be %s" % "'project.invite.timeout' should be %s" %
self.services["configs"]["project.invite.timeout"] self.services["configs"]["project.invite.timeout"]
) )
# Create project as a domain admin # Create project as a domain admin
@ -1060,12 +1067,12 @@ class TestProjectInviteRequired(cloudstackTestCase):
) )
# Cleanup created project at end of test # Cleanup created project at end of test
self.cleanup.append(project) 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) project.id)
list_projects_reponse = Project.list( list_projects_reponse = Project.list(
self.apiclient, self.apiclient,
id=project.id, id=project.id,
listall=True listall=True
) )
@ -1094,11 +1101,11 @@ class TestProjectInviteRequired(cloudstackTestCase):
)) ))
# Add user to the project # Add user to the project
project.addAccount( project.addAccount(
self.apiclient, self.apiclient,
self.user.account.name, self.user.account.name,
self.user.account.email self.user.account.email
) )
# listProjectAccount to verify the user is added to project or not # listProjectAccount to verify the user is added to project or not
accounts_reponse = ProjectInvitation.list( accounts_reponse = ProjectInvitation.list(
self.apiclient, self.apiclient,
@ -1111,14 +1118,14 @@ class TestProjectInviteRequired(cloudstackTestCase):
True, True,
"Check for a valid list accounts response" "Check for a valid list accounts response"
) )
self.assertNotEqual( self.assertNotEqual(
len(list_projects_reponse), len(list_projects_reponse),
0, 0,
"Check list project response returns a valid project" "Check list project response returns a valid project"
) )
account = accounts_reponse[0] account = accounts_reponse[0]
self.assertEqual( self.assertEqual(
account.state, account.state,
'Pending', 'Pending',
@ -1127,7 +1134,7 @@ class TestProjectInviteRequired(cloudstackTestCase):
# Accept the invite # Accept the invite
ProjectInvitation.update( ProjectInvitation.update(
self.apiclient, self.apiclient,
projectid=project.id, projectid=project.id,
accept=False, accept=False,
account=self.user.account.name account=self.user.account.name
) )
@ -1138,7 +1145,7 @@ class TestProjectInviteRequired(cloudstackTestCase):
)) ))
# listProjectAccount to verify the user is added to project or not # listProjectAccount to verify the user is added to project or not
accounts_reponse = Project.listAccounts( accounts_reponse = Project.listAccounts(
self.apiclient, self.apiclient,
projectid=project.id, projectid=project.id,
account=self.user.account.name, account=self.user.account.name,
) )
@ -1148,13 +1155,14 @@ class TestProjectInviteRequired(cloudstackTestCase):
"Check for a valid list accounts response" "Check for a valid list accounts response"
) )
return return
@unittest.skip("Requires SMPT configs") @unittest.skip("Requires SMPT configs")
def test_09_invite_to_project_by_email(self): def test_09_invite_to_project_by_email(self):
"""Test invite user to project by email""" """Test invite user to project by email"""
# Validate the following: # Validate the following:
# 1. Set configuration to 5 mins # 1. Set configuration to 5 mins
# 2. Create a Project # 2. Create a Project
# 3. Add users to the project # 3. Add users to the project
# 4. As a user decline invitation within 5 mins. # 4. As a user decline invitation within 5 mins.
# 5. Verify invitation is rejected and user doesn't become regular # 5. Verify invitation is rejected and user doesn't become regular
@ -1175,7 +1183,7 @@ class TestProjectInviteRequired(cloudstackTestCase):
int(config.value), int(config.value),
self.services["configs"]["project.invite.timeout"], self.services["configs"]["project.invite.timeout"],
"'project.invite.timeout' should be %s" % "'project.invite.timeout' should be %s" %
self.services["configs"]["project.invite.timeout"] self.services["configs"]["project.invite.timeout"]
) )
# Create project as a domain admin # Create project as a domain admin
@ -1187,12 +1195,12 @@ class TestProjectInviteRequired(cloudstackTestCase):
) )
# Cleanup created project at end of test # Cleanup created project at end of test
self.cleanup.append(project) 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) project.id)
list_projects_reponse = Project.list( list_projects_reponse = Project.list(
self.apiclient, self.apiclient,
id=project.id, id=project.id,
listall=True listall=True
) )

View File

@ -25,6 +25,7 @@ from integration.lib.base import *
from integration.lib.common import * from integration.lib.common import *
import datetime import datetime
class Services: class Services:
"""Test Resource Limits Services """Test Resource Limits Services
""" """
@ -60,8 +61,8 @@ class Services:
"name": "Tiny Instance", "name": "Tiny Instance",
"displaytext": "Tiny Instance", "displaytext": "Tiny Instance",
"cpunumber": 1, "cpunumber": 1,
"cpuspeed": 100, # in MHz "cpuspeed": 100, # in MHz
"memory": 64, # In MBs "memory": 64, # In MBs
}, },
"disk_offering": { "disk_offering": {
"displaytext": "Tiny Disk Offering", "displaytext": "Tiny Disk Offering",
@ -100,13 +101,13 @@ class TestProjectLimits(cloudstackTestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.api_client = super( cls.api_client = super(
TestProjectLimits, TestProjectLimits,
cls cls
).getClsTestClient().getApiClient() ).getClsTestClient().getApiClient()
cls.services = Services().services cls.services = Services().services
# Get Zone # Get Zone
cls.zone = get_zone(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services)
# Create domains, account etc. # Create domains, account etc.
cls.domain = Domain.create( cls.domain = Domain.create(
cls.api_client, cls.api_client,
@ -125,10 +126,10 @@ class TestProjectLimits(cloudstackTestCase):
domainid=cls.domain.id domainid=cls.domain.id
) )
cls._cleanup = [ cls._cleanup = [
cls.admin, cls.admin,
cls.user, cls.user,
cls.domain cls.domain
] ]
return return
@classmethod @classmethod
@ -183,9 +184,9 @@ class TestProjectLimits(cloudstackTestCase):
self.cleanup.append(project) 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) project.id)
list_projects_reponse = Project.list( list_projects_reponse = Project.list(
self.apiclient, self.apiclient,
id=project.id, id=project.id,
listall=True listall=True
) )
@ -223,7 +224,7 @@ class TestProjectLimits(cloudstackTestCase):
) )
# Reduce resource limits for project # 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: 1 - IP. Number of public IP addresses a user can own.
# Resource: 2 - Volume. Number of disk volumes a user can create. # Resource: 2 - Volume. Number of disk volumes a user can create.
# Resource: 3 - Snapshot. Number of snapshots a user can create. # Resource: 3 - Snapshot. Number of snapshots a user can create.
@ -261,7 +262,7 @@ class TestProjectLimits(cloudstackTestCase):
1, 1,
"Resource limit should be updated to 1" "Resource limit should be updated to 1"
) )
# Get the resource limits for domain # Get the resource limits for domain
resource_limits = list_resource_limits( resource_limits = list_resource_limits(
self.apiclient, self.apiclient,
@ -277,7 +278,7 @@ class TestProjectLimits(cloudstackTestCase):
0, 0,
"List resource API response should not be empty" "List resource API response should not be empty"
) )
for resource in resource_limits: for resource in resource_limits:
# Update domain resource limits to 2 # Update domain resource limits to 2
update_resource_limit( update_resource_limit(
@ -300,6 +301,7 @@ class TestProjectLimits(cloudstackTestCase):
projectid=project.id projectid=project.id
) )
return return
@unittest.skip("No provision for updating resource limits from account through API") @unittest.skip("No provision for updating resource limits from account through API")
def test_02_project_limits_normal_user(self): def test_02_project_limits_normal_user(self):
""" Test project limits """ Test project limits
@ -323,9 +325,9 @@ class TestProjectLimits(cloudstackTestCase):
self.cleanup.append(project) 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) project.id)
list_projects_reponse = Project.list( list_projects_reponse = Project.list(
self.apiclient, self.apiclient,
id=project.id, id=project.id,
listall=True listall=True
) )
@ -363,7 +365,7 @@ class TestProjectLimits(cloudstackTestCase):
) )
# Reduce resource limits for project # 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: 1 - IP. Number of public IP addresses a user can own.
# Resource: 2 - Volume. Number of disk volumes a user can create. # Resource: 2 - Volume. Number of disk volumes a user can create.
# Resource: 3 - Snapshot. Number of snapshots a user can create. # Resource: 3 - Snapshot. Number of snapshots a user can create.
@ -401,7 +403,7 @@ class TestProjectLimits(cloudstackTestCase):
1, 1,
"Resource limit should be updated to 1" "Resource limit should be updated to 1"
) )
self.debug("Adding %s user to project: %s" % ( self.debug("Adding %s user to project: %s" % (
self.user.account.name, self.user.account.name,
project.name project.name
@ -409,10 +411,10 @@ class TestProjectLimits(cloudstackTestCase):
# Add user to the project # Add user to the project
project.addAccount( project.addAccount(
self.apiclient, self.apiclient,
self.user.account.name, self.user.account.name,
) )
# Get the resource limits for domain # Get the resource limits for domain
resource_limits = list_resource_limits( resource_limits = list_resource_limits(
self.apiclient, self.apiclient,
@ -428,7 +430,7 @@ class TestProjectLimits(cloudstackTestCase):
0, 0,
"List resource API response should not be empty" "List resource API response should not be empty"
) )
for resource in resource_limits: for resource in resource_limits:
#with self.assertRaises(Exception): #with self.assertRaises(Exception):
self.debug( self.debug(
@ -535,12 +537,12 @@ class TestResourceLimitsProject(cloudstackTestCase):
# should be raised # should be raised
self.debug( self.debug(
"Updating instance resource limits for project: %s" % "Updating instance resource limits for project: %s" %
self.project.id) self.project.id)
# Set usage_vm=1 for Account 1 # Set usage_vm=1 for Account 1
update_resource_limit( update_resource_limit(
self.apiclient, self.apiclient,
0, # Instance 0, # Instance
max=2, max=2,
projectid=self.project.id projectid=self.project.id
) )
@ -589,7 +591,11 @@ class TestResourceLimitsProject(cloudstackTestCase):
def test_04_publicip_per_project(self): def test_04_publicip_per_project(self):
"""Test Public IP limit per project """Test Public IP limit per project
""" """
<<<<<<< HEAD
=======
tags = ["advanced", "eip", "advancedns"]
>>>>>>> 6d17e21... This commit has following fixes:
# Validate the following # Validate the following
# 1. set max no of IPs per project to 2. # 1. set max no of IPs per project to 2.
# 2. Create an account in this domain # 2. Create an account in this domain
@ -599,12 +605,12 @@ class TestResourceLimitsProject(cloudstackTestCase):
# appropriate error and an alert should be generated. # appropriate error and an alert should be generated.
self.debug( self.debug(
"Updating public IP resource limits for project: %s" % "Updating public IP resource limits for project: %s" %
self.project.id) self.project.id)
# Set usage_vm=1 for Account 1 # Set usage_vm=1 for Account 1
update_resource_limit( update_resource_limit(
self.apiclient, self.apiclient,
1, # Public Ip 1, # Public Ip
max=2, max=2,
projectid=self.project.id projectid=self.project.id
) )
@ -625,7 +631,7 @@ class TestResourceLimitsProject(cloudstackTestCase):
"Check VM state is Running or not" "Check VM state is Running or not"
) )
networks = Network.list( networks = Network.list(
self.apiclient, self.apiclient,
projectid=self.project.id, projectid=self.project.id,
listall=True listall=True
) )
@ -640,7 +646,7 @@ class TestResourceLimitsProject(cloudstackTestCase):
"Check list networks response returns a valid network" "Check list networks response returns a valid network"
) )
network = networks[0] network = networks[0]
self.debug("Associating public IP for project: %s" % self.debug("Associating public IP for project: %s" %
self.project.id) self.project.id)
public_ip_1 = PublicIPAddress.create( public_ip_1 = PublicIPAddress.create(
self.apiclient, self.apiclient,
@ -679,16 +685,16 @@ class TestResourceLimitsProject(cloudstackTestCase):
# 1. set max no of snapshots per project to 1. # 1. set max no of snapshots per project to 1.
# 2. Create one snapshot in the project. Snapshot should be # 2. Create one snapshot in the project. Snapshot should be
# successfully created # 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. # user an appropriate error and an alert should be generated.
self.debug( self.debug(
"Updating snapshot resource limits for project: %s" % "Updating snapshot resource limits for project: %s" %
self.project.id) self.project.id)
# Set usage_vm=1 for Account 1 # Set usage_vm=1 for Account 1
update_resource_limit( update_resource_limit(
self.apiclient, self.apiclient,
3, # Snapshot 3, # Snapshot
max=1, max=1,
projectid=self.project.id projectid=self.project.id
) )
@ -760,12 +766,12 @@ class TestResourceLimitsProject(cloudstackTestCase):
# should be generated. # should be generated.
self.debug( self.debug(
"Updating volume resource limits for project: %s" % "Updating volume resource limits for project: %s" %
self.project.id) self.project.id)
# Set usage_vm=1 for Account 1 # Set usage_vm=1 for Account 1
update_resource_limit( update_resource_limit(
self.apiclient, self.apiclient,
2, # Volume 2, # Volume
max=2, max=2,
projectid=self.project.id projectid=self.project.id
) )
@ -796,12 +802,17 @@ class TestResourceLimitsProject(cloudstackTestCase):
projectid=self.project.id projectid=self.project.id
) )
return return
def test_07_templates_per_project(self): def test_07_templates_per_project(self):
"""Test Templates limit per project """Test Templates limit per project
""" """
<<<<<<< HEAD
# Validate the following # 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. # 1. set max no of templates per project to 1.
# 2. Create a template in this project. Both template should be in # 2. Create a template in this project. Both template should be in
# ready state # ready state
@ -811,17 +822,17 @@ class TestResourceLimitsProject(cloudstackTestCase):
# Reset the volume limits # Reset the volume limits
update_resource_limit( update_resource_limit(
self.apiclient, self.apiclient,
2, # Volume 2, # Volume
max=5, max=5,
projectid=self.project.id projectid=self.project.id
) )
self.debug( self.debug(
"Updating template resource limits for domain: %s" % "Updating template resource limits for domain: %s" %
self.account.account.domainid) self.account.account.domainid)
# Set usage_vm=1 for Account 1 # Set usage_vm=1 for Account 1
update_resource_limit( update_resource_limit(
self.apiclient, self.apiclient,
4, # Template 4, # Template
max=1, max=1,
projectid=self.project.id projectid=self.project.id
) )

View File

@ -26,6 +26,7 @@ from integration.lib.common import *
from marvin.remoteSSHClient import remoteSSHClient from marvin.remoteSSHClient import remoteSSHClient
import datetime import datetime
class Services: class Services:
"""Test Resource creation Services """Test Resource creation Services
""" """
@ -61,8 +62,8 @@ class Services:
"name": "Tiny Instance", "name": "Tiny Instance",
"displaytext": "Tiny Instance", "displaytext": "Tiny Instance",
"cpunumber": 1, "cpunumber": 1,
"cpuspeed": 100, # in MHz "cpuspeed": 100, # in MHz
"memory": 64, # In MBs "memory": 64, # In MBs
}, },
"disk_offering": { "disk_offering": {
"displaytext": "Tiny Disk Offering", "displaytext": "Tiny Disk Offering",
@ -97,7 +98,7 @@ class Services:
"name": "Domainwide Network", "name": "Domainwide Network",
"displaytext": "Domainwide Network", "displaytext": "Domainwide Network",
"gateway": '192.168.100.1', "gateway": '192.168.100.1',
"netmask": '255.255.255.0', "netmask": '255.255.255.0',
"startip": '192.168.100.200', "startip": '192.168.100.200',
"endip": '192.168.100.201', "endip": '192.168.100.201',
"vlan": 4001, "vlan": 4001,
@ -134,7 +135,7 @@ class Services:
"timeout": 10, "timeout": 10,
"mode": 'advanced', "mode": 'advanced',
} }
class TestOfferings(cloudstackTestCase): class TestOfferings(cloudstackTestCase):
@ -176,7 +177,7 @@ class TestOfferings(cloudstackTestCase):
cls.services["disk_offering"] cls.services["disk_offering"]
) )
cls._cleanup = [ cls._cleanup = [
cls.account, cls.account,
cls.service_offering, cls.service_offering,
cls.disk_offering cls.disk_offering
] ]
@ -225,9 +226,9 @@ class TestOfferings(cloudstackTestCase):
self.cleanup.append(project) 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) project.id)
self.debug( self.debug(
"Deploying VM instance for project: %s & service offering: %s" % ( "Deploying VM instance for project: %s & service offering: %s" % (
project.id, project.id,
self.service_offering.id self.service_offering.id
)) ))
@ -267,9 +268,9 @@ class TestOfferings(cloudstackTestCase):
self.cleanup.append(project) 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) project.id)
list_projects_reponse = Project.list( list_projects_reponse = Project.list(
self.apiclient, self.apiclient,
id=project.id, id=project.id,
listall=True listall=True
) )
@ -351,7 +352,7 @@ class TestNetwork(cloudstackTestCase):
domainid=cls.domain.id domainid=cls.domain.id
) )
cls._cleanup = [ cls._cleanup = [
cls.account, cls.account,
cls.service_offering, cls.service_offering,
] ]
return return
@ -382,7 +383,11 @@ class TestNetwork(cloudstackTestCase):
def test_03_network_create(self): def test_03_network_create(self):
""" Test create network in project """ Test create network in project
""" """
<<<<<<< HEAD
=======
tags = ["advanced", "advancedns"]
>>>>>>> 6d17e21... This commit has following fixes:
# Validate the following # Validate the following
# 1. Create a project. # 1. Create a project.
# 2. Add virtual/direct network resource to the project. User shared # 2. Add virtual/direct network resource to the project. User shared
@ -403,7 +408,7 @@ class TestNetwork(cloudstackTestCase):
self.cleanup.append(project) 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) project.id)
network_offerings = list_network_offerings( network_offerings = list_network_offerings(
self.apiclient, self.apiclient,
projectid=project.id, projectid=project.id,
@ -412,36 +417,36 @@ class TestNetwork(cloudstackTestCase):
state='Enabled' state='Enabled'
) )
self.assertEqual( self.assertEqual(
isinstance(network_offerings, list), isinstance(network_offerings, list),
True, True,
"Check for the valid network offerings" "Check for the valid network offerings"
) )
network_offering = network_offerings[0] 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) network_offering.id)
self.services["network"]["zoneid"] = self.zone.id self.services["network"]["zoneid"] = self.zone.id
network = Network.create( network = Network.create(
self.apiclient, self.apiclient,
self.services["network"], self.services["network"],
networkofferingid=network_offering.id, networkofferingid=network_offering.id,
projectid=project.id projectid=project.id
) )
self.debug("Created network with ID: %s" % network.id) self.debug("Created network with ID: %s" % network.id)
networks= Network.list( networks = Network.list(
self.apiclient, self.apiclient,
projectid=project.id, projectid=project.id,
listall=True listall=True
) )
self.assertEqual( self.assertEqual(
isinstance(networks, list), isinstance(networks, list),
True, True,
"Check for the valid network list response" "Check for the valid network list response"
) )
network_response = networks[0] network_response = networks[0]
self.debug("Deploying VM with network: %s" % network.id) self.debug("Deploying VM with network: %s" % network.id)
virtual_machine = VirtualMachine.create( virtual_machine = VirtualMachine.create(
self.apiclient, self.apiclient,
self.services["server"], self.services["server"],
@ -466,24 +471,24 @@ class TestNetwork(cloudstackTestCase):
displaytext='Offering for Shared networks' displaytext='Offering for Shared networks'
) )
self.assertEqual( self.assertEqual(
isinstance(network_offerings, list), isinstance(network_offerings, list),
True, True,
"Check for the valid network offerings" "Check for the valid network offerings"
) )
network_offering = network_offerings[0] 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) self.domain.id)
domain_network = Network.create( domain_network = Network.create(
self.apiclient, self.apiclient,
self.services["domain_network"], self.services["domain_network"],
domainid=self.domain.id, domainid=self.domain.id,
networkofferingid=network_offering.id, networkofferingid=network_offering.id,
zoneid=self.zone.id zoneid=self.zone.id
) )
self._cleanup.append(domain_network) self._cleanup.append(domain_network)
self.debug("Created network with ID: %s" % domain_network.id) self.debug("Created network with ID: %s" % domain_network.id)
virtual_machine = VirtualMachine.create( virtual_machine = VirtualMachine.create(
self.apiclient, self.apiclient,
self.services["server"], self.services["server"],
@ -586,14 +591,19 @@ class TestTemplates(cloudstackTestCase):
def test_04_public_template_use_in_project(self): def test_04_public_template_use_in_project(self):
"""Test Templates creation in projects """Test Templates creation in projects
""" """
<<<<<<< HEAD
# Validate the following # Validate the following
=======
tags = ["advanced", "basic", "sg", "eip", "advancedns"]
# Validate the following
>>>>>>> 6d17e21... This commit has following fixes:
# 1. Create a project # 1. Create a project
# 2. Verify Public templates can be used without any restriction # 2. Verify Public templates can be used without any restriction
# 3. Verify that template created in project can be used in project # 3. Verify that template created in project can be used in project
# without any restrictions # without any restrictions
self.debug("Deploying VM for with public template: %s" % self.debug("Deploying VM for with public template: %s" %
self.template.id) self.template.id)
virtual_machine_1 = VirtualMachine.create( virtual_machine_1 = VirtualMachine.create(
self.apiclient, self.apiclient,
@ -645,15 +655,20 @@ class TestTemplates(cloudstackTestCase):
def test_05_use_private_template_in_project(self): def test_05_use_private_template_in_project(self):
"""Test use of private template in a project """Test use of private template in a project
""" """
<<<<<<< HEAD
# Validate the following # Validate the following
=======
tags = ["advanced", "basic", "sg", "eip", "advancedns"]
# Validate the following
>>>>>>> 6d17e21... This commit has following fixes:
# 1. Create a project # 1. Create a project
# 2. Verify that in order to use somebodys Private template for vm # 2. Verify that in order to use somebodys Private template for vm
# creation in the project, permission to use the template has to # creation in the project, permission to use the template has to
# be granted to the Project (use API “updateTemplatePermissions” # be granted to the Project (use API “updateTemplatePermissions”
# with project id to achieve that). # 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) self.template.id)
virtual_machine_1 = VirtualMachine.create( virtual_machine_1 = VirtualMachine.create(
self.apiclient, self.apiclient,
@ -701,7 +716,7 @@ class TestTemplates(cloudstackTestCase):
True, True,
"Check Template is in ready state or not" "Check Template is in ready state or not"
) )
# Update template permissions to grant permission to project # Update template permissions to grant permission to project
self.debug( self.debug(
"Updating template permissions:%s to grant access to project: %s" % ( "Updating template permissions:%s to grant access to project: %s" % (
@ -714,7 +729,7 @@ class TestTemplates(cloudstackTestCase):
op='add', op='add',
projectids=self.project.id 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) self.template.id)
virtual_machine_2 = VirtualMachine.create( virtual_machine_2 = VirtualMachine.create(
self.apiclient, self.apiclient,
@ -864,7 +879,7 @@ class TestSnapshots(cloudstackTestCase):
True, True,
"Check Snapshot state is Running or not" "Check Snapshot state is Running or not"
) )
snapshots = Snapshot.list( snapshots = Snapshot.list(
self.apiclient, self.apiclient,
account=self.account.account.name, account=self.account.account.name,
@ -929,7 +944,7 @@ class TestPublicIpAddress(cloudstackTestCase):
serviceofferingid=cls.service_offering.id, serviceofferingid=cls.service_offering.id,
projectid=cls.project.id projectid=cls.project.id
) )
cls._cleanup = [ cls._cleanup = [
cls.project, cls.project,
cls.service_offering, cls.service_offering,
@ -964,7 +979,11 @@ class TestPublicIpAddress(cloudstackTestCase):
def test_07_associate_public_ip(self): def test_07_associate_public_ip(self):
"""Test associate public IP within the project """Test associate public IP within the project
""" """
<<<<<<< HEAD
=======
tags = ["advanced", "eip", "advancedns"]
>>>>>>> 6d17e21... This commit has following fixes:
# Validate the following # Validate the following
# 1. Create a project # 1. Create a project
# 2. Add some public Ips to the project # 2. Add some public Ips to the project
@ -972,7 +991,7 @@ class TestPublicIpAddress(cloudstackTestCase):
# inside project # inside project
networks = Network.list( networks = Network.list(
self.apiclient, self.apiclient,
projectid=self.project.id, projectid=self.project.id,
listall=True listall=True
) )
@ -996,10 +1015,10 @@ class TestPublicIpAddress(cloudstackTestCase):
projectid=self.project.id projectid=self.project.id
) )
self.cleanup.append(public_ip) self.cleanup.append(public_ip)
#Create NAT rule #Create NAT rule
self.debug( self.debug(
"Creating a NAT rule within project, VM ID: %s" % "Creating a NAT rule within project, VM ID: %s" %
self.virtual_machine.id) self.virtual_machine.id)
nat_rule = NATRule.create( nat_rule = NATRule.create(
self.apiclient, self.apiclient,
@ -1028,9 +1047,9 @@ class TestPublicIpAddress(cloudstackTestCase):
nat_rule.id, nat_rule.id,
"Check Correct Port forwarding Rule is returned" "Check Correct Port forwarding Rule is returned"
) )
#Create Load Balancer rule and assign VMs to rule #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) public_ip.ipaddress.ipaddress)
lb_rule = LoadBalancerRule.create( lb_rule = LoadBalancerRule.create(
self.apiclient, self.apiclient,
@ -1065,7 +1084,7 @@ class TestPublicIpAddress(cloudstackTestCase):
lb_rule.id, lb_rule.id,
"Check List Load Balancer Rules returns valid Rule" "Check List Load Balancer Rules returns valid Rule"
) )
#Create Firewall rule with configurations from settings file #Create Firewall rule with configurations from settings file
fw_rule = FireWallRule.create( fw_rule = FireWallRule.create(
self.apiclient, self.apiclient,
@ -1077,7 +1096,7 @@ class TestPublicIpAddress(cloudstackTestCase):
projectid=self.project.id projectid=self.project.id
) )
self.debug("Created firewall rule: %s" % fw_rule.id) self.debug("Created firewall rule: %s" % fw_rule.id)
# After Router start, FW rule should be in Active state # After Router start, FW rule should be in Active state
fw_rules = FireWallRule.list( fw_rules = FireWallRule.list(
self.apiclient, self.apiclient,
@ -1088,7 +1107,7 @@ class TestPublicIpAddress(cloudstackTestCase):
True, True,
"Check for list FW rules response return valid data" "Check for list FW rules response return valid data"
) )
self.assertEqual( self.assertEqual(
fw_rules[0].state, fw_rules[0].state,
'Active', 'Active',
@ -1105,7 +1124,7 @@ class TestPublicIpAddress(cloudstackTestCase):
str(self.services["fw_rule"]["endport"]), str(self.services["fw_rule"]["endport"]),
"Check end port of firewall rule" "Check end port of firewall rule"
) )
self.debug("Deploying VM for account: %s" % self.account.account.name) self.debug("Deploying VM for account: %s" % self.account.account.name)
virtual_machine_1 = VirtualMachine.create( virtual_machine_1 = VirtualMachine.create(
self.apiclient, self.apiclient,
@ -1116,7 +1135,7 @@ class TestPublicIpAddress(cloudstackTestCase):
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
) )
self.cleanup.append(virtual_machine_1) self.cleanup.append(virtual_machine_1)
self.debug("VM state after deploy: %s" % virtual_machine_1.state) self.debug("VM state after deploy: %s" % virtual_machine_1.state)
# Verify VM state # Verify VM state
self.assertEqual( self.assertEqual(
@ -1124,7 +1143,7 @@ class TestPublicIpAddress(cloudstackTestCase):
'Running', 'Running',
"Check VM state is Running or not" "Check VM state is Running or not"
) )
self.debug("Creating NAT rule for VM (ID: %s) outside project" % self.debug("Creating NAT rule for VM (ID: %s) outside project" %
virtual_machine_1.id) virtual_machine_1.id)
with self.assertRaises(Exception): with self.assertRaises(Exception):
@ -1134,7 +1153,7 @@ class TestPublicIpAddress(cloudstackTestCase):
self.services["natrule"], self.services["natrule"],
public_ip.ipaddress.id, public_ip.ipaddress.id,
) )
self.debug("Creating LB rule for public IP: %s outside project" % self.debug("Creating LB rule for public IP: %s outside project" %
public_ip.ipaddress.ipaddress) public_ip.ipaddress.ipaddress)
with self.assertRaises(Exception): with self.assertRaises(Exception):
@ -1160,7 +1179,7 @@ class TestPublicIpAddress(cloudstackTestCase):
class TestSecurityGroup(cloudstackTestCase): class TestSecurityGroup(cloudstackTestCase):
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
@ -1189,7 +1208,7 @@ class TestSecurityGroup(cloudstackTestCase):
# Get Zone, Domain and templates # Get Zone, Domain and templates
cls.domain = get_domain(cls.api_client, cls.services) cls.domain = get_domain(cls.api_client, cls.services)
cls.zone = get_zone(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services)
template = get_template( template = get_template(
cls.api_client, cls.api_client,
cls.zone.id, cls.zone.id,
@ -1198,7 +1217,7 @@ class TestSecurityGroup(cloudstackTestCase):
cls.services["domainid"] = cls.domain.id cls.services["domainid"] = cls.domain.id
cls.services["server"]["zoneid"] = cls.zone.id cls.services["server"]["zoneid"] = cls.zone.id
cls.services["server"]["template"] = template.id cls.services["server"]["template"] = template.id
cls.service_offering = ServiceOffering.create( cls.service_offering = ServiceOffering.create(
cls.api_client, cls.api_client,
cls.services["service_offering"] cls.services["service_offering"]
@ -1248,8 +1267,8 @@ class TestSecurityGroup(cloudstackTestCase):
# to that project. # to that project.
security_group = SecurityGroup.create( security_group = SecurityGroup.create(
self.apiclient, self.apiclient,
self.services["security_group"], self.services["security_group"],
projectid=self.project.id projectid=self.project.id
) )
self.debug("Created security group with ID: %s" % security_group.id) self.debug("Created security group with ID: %s" % security_group.id)
@ -1263,16 +1282,16 @@ class TestSecurityGroup(cloudstackTestCase):
True, True,
"Check for list security groups response" "Check for list security groups response"
) )
self.assertNotEqual( self.assertNotEqual(
len(sercurity_groups), len(sercurity_groups),
0, 0,
"Check List Security groups response" "Check List Security groups response"
) )
# Authorize Security group to SSH to VM # Authorize Security group to SSH to VM
ingress_rule = security_group.authorize( ingress_rule = security_group.authorize(
self.apiclient, self.apiclient,
self.services["security_group"], self.services["security_group"],
projectid=self.project.id projectid=self.project.id
) )
self.assertEqual( self.assertEqual(
@ -1280,9 +1299,9 @@ class TestSecurityGroup(cloudstackTestCase):
True, True,
"Check ingress rule created properly" "Check ingress rule created properly"
) )
self.debug( 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) % security_group.id)
self.virtual_machine = VirtualMachine.create( self.virtual_machine = VirtualMachine.create(
self.apiclient, self.apiclient,
@ -1296,8 +1315,8 @@ class TestSecurityGroup(cloudstackTestCase):
self.project.id self.project.id
)) ))
self.assertEqual( self.assertEqual(
self.virtual_machine.state, self.virtual_machine.state,
'Running', 'Running',
"VM state should be running after deployment" "VM state should be running after deployment"
) )
# Deploy another VM with same security group outside the project # Deploy another VM with same security group outside the project

View File

@ -26,6 +26,7 @@ from integration.lib.common import *
from marvin.remoteSSHClient import remoteSSHClient from marvin.remoteSSHClient import remoteSSHClient
import datetime import datetime
class Services: class Services:
"""Test Snapshots Services """Test Snapshots Services
""" """
@ -49,8 +50,8 @@ class Services:
"name": "Tiny Instance", "name": "Tiny Instance",
"displaytext": "Tiny Instance", "displaytext": "Tiny Instance",
"cpunumber": 1, "cpunumber": 1,
"cpuspeed": 100, # in MHz "cpuspeed": 100, # in MHz
"memory": 64, # In MBs "memory": 64, # In MBs
}, },
"disk_offering": { "disk_offering": {
"displaytext": "Small", "displaytext": "Small",
@ -107,7 +108,7 @@ class Services:
# Cent OS 5.3 (64 bit) # Cent OS 5.3 (64 bit)
"sleep": 60, "sleep": 60,
"timeout": 10, "timeout": 10,
"mode":'advanced' "mode": 'advanced'
} }
@ -141,14 +142,14 @@ class TestVmUsage(cloudstackTestCase):
) )
cls.services["account"] = cls.account.account.name cls.services["account"] = cls.account.account.name
cls.project = Project.create( cls.project = Project.create(
cls.api_client, cls.api_client,
cls.services["project"], cls.services["project"],
account=cls.account.account.name, account=cls.account.account.name,
domainid=cls.account.account.domainid domainid=cls.account.account.domainid
) )
cls.service_offering = ServiceOffering.create( cls.service_offering = ServiceOffering.create(
cls.api_client, cls.api_client,
cls.services["service_offering"] cls.services["service_offering"]
@ -206,17 +207,17 @@ class TestVmUsage(cloudstackTestCase):
self.debug("Stopping the VM: %s" % self.virtual_machine.id) self.debug("Stopping the VM: %s" % self.virtual_machine.id)
# Stop the VM # Stop the VM
self.virtual_machine.stop(self.apiclient) self.virtual_machine.stop(self.apiclient)
time.sleep(self.services["sleep"]) time.sleep(self.services["sleep"])
# Destroy the VM # Destroy the VM
self.debug("Destroying the VM: %s" % self.virtual_machine.id) self.debug("Destroying the VM: %s" % self.virtual_machine.id)
self.virtual_machine.delete(self.apiclient) self.virtual_machine.delete(self.apiclient)
# Fetch project account ID from project UUID # Fetch project account ID from project UUID
self.debug( self.debug(
"select project_account_id from projects where uuid = '%s';" \ "select project_account_id from projects where uuid = '%s';" \
% self.project.id) % self.project.id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select project_account_id from projects where uuid = '%s';" \ "select project_account_id from projects where uuid = '%s';" \
% self.project.id % self.project.id
@ -226,7 +227,7 @@ class TestVmUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -237,7 +238,7 @@ class TestVmUsage(cloudstackTestCase):
account_id = qresult[0] account_id = qresult[0]
self.debug("select type from usage_event where account_id = '%s';" \ self.debug("select type from usage_event where account_id = '%s';" \
% account_id) % account_id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select type from usage_event where account_id = '%s';" \ "select type from usage_event where account_id = '%s';" \
% account_id % account_id
@ -247,7 +248,7 @@ class TestVmUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -335,14 +336,14 @@ class TestPublicIPUsage(cloudstackTestCase):
) )
cls.services["account"] = cls.account.account.name cls.services["account"] = cls.account.account.name
cls.project = Project.create( cls.project = Project.create(
cls.api_client, cls.api_client,
cls.services["project"], cls.services["project"],
account=cls.account.account.name, account=cls.account.account.name,
domainid=cls.account.account.domainid domainid=cls.account.account.domainid
) )
cls.service_offering = ServiceOffering.create( cls.service_offering = ServiceOffering.create(
cls.api_client, cls.api_client,
cls.services["service_offering"] cls.services["service_offering"]
@ -355,7 +356,7 @@ class TestPublicIPUsage(cloudstackTestCase):
projectid=cls.project.id projectid=cls.project.id
) )
networks = Network.list( networks = Network.list(
cls.api_client, cls.api_client,
projectid=cls.project.id, projectid=cls.project.id,
listall=True listall=True
) )
@ -402,7 +403,7 @@ class TestPublicIPUsage(cloudstackTestCase):
return return
def test_01_public_ip_usage(self): 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 # Validate the following
@ -412,17 +413,17 @@ class TestPublicIPUsage(cloudstackTestCase):
# has IP.Release event for released IP for this account # has IP.Release event for released IP for this account
# 3. Delete the newly created account # 3. Delete the newly created account
self.debug("Deleting public IP: %s" % self.debug("Deleting public IP: %s" %
self.public_ip.ipaddress.ipaddress) self.public_ip.ipaddress.ipaddress)
# Release one of the IP # Release one of the IP
self.public_ip.delete(self.apiclient) self.public_ip.delete(self.apiclient)
# Fetch project account ID from project UUID # Fetch project account ID from project UUID
self.debug( self.debug(
"select project_account_id from projects where uuid = '%s';" \ "select project_account_id from projects where uuid = '%s';" \
% self.project.id) % self.project.id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select project_account_id from projects where uuid = '%s';" \ "select project_account_id from projects where uuid = '%s';" \
% self.project.id % self.project.id
@ -442,12 +443,12 @@ class TestPublicIPUsage(cloudstackTestCase):
account_id = qresult[0] account_id = qresult[0]
self.debug("select type from usage_event where account_id = '%s';" \ self.debug("select type from usage_event where account_id = '%s';" \
% account_id) % account_id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select type from usage_event where account_id = '%s';" \ "select type from usage_event where account_id = '%s';" \
% account_id % account_id
) )
self.assertEqual( self.assertEqual(
isinstance(qresultset, list), isinstance(qresultset, list),
True, True,
@ -582,8 +583,8 @@ class TestVolumeUsage(cloudstackTestCase):
listall=True listall=True
) )
self.assertEqual( self.assertEqual(
isinstance(volume_response, list), isinstance(volume_response, list),
True, True,
"Check for valid list volumes response" "Check for valid list volumes response"
) )
data_volume = volume_response[0] data_volume = volume_response[0]
@ -601,11 +602,11 @@ class TestVolumeUsage(cloudstackTestCase):
cmd.id = data_volume.id cmd.id = data_volume.id
self.apiclient.deleteVolume(cmd) self.apiclient.deleteVolume(cmd)
# Fetch project account ID from project UUID # Fetch project account ID from project UUID
self.debug( self.debug(
"select project_account_id from projects where uuid = '%s';" \ "select project_account_id from projects where uuid = '%s';" \
% self.project.id) % self.project.id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select project_account_id from projects where uuid = '%s';" \ "select project_account_id from projects where uuid = '%s';" \
% self.project.id % self.project.id
@ -615,7 +616,7 @@ class TestVolumeUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -626,12 +627,12 @@ class TestVolumeUsage(cloudstackTestCase):
account_id = qresult[0] account_id = qresult[0]
self.debug("select type from usage_event where account_id = '%s';" \ self.debug("select type from usage_event where account_id = '%s';" \
% account_id) % account_id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select type from usage_event where account_id = '%s';" \ "select type from usage_event where account_id = '%s';" \
% account_id % account_id
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -642,7 +643,7 @@ class TestVolumeUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
qresult = str(qresultset) qresult = str(qresultset)
self.debug("Query result: %s" % qresult) self.debug("Query result: %s" % qresult)
# Check VOLUME.CREATE, VOLUME.DESTROY events in cloud.usage_event table # Check VOLUME.CREATE, VOLUME.DESTROY events in cloud.usage_event table
@ -717,7 +718,7 @@ class TestTemplateUsage(cloudstackTestCase):
type='ROOT', type='ROOT',
listall=True listall=True
) )
if isinstance(list_volume, list): if isinstance(list_volume, list):
cls.volume = list_volume[0] cls.volume = list_volume[0]
else: else:
raise Exception("List Volumes failed!") raise Exception("List Volumes failed!")
@ -775,11 +776,11 @@ class TestTemplateUsage(cloudstackTestCase):
self.template.delete(self.apiclient) self.template.delete(self.apiclient)
self.debug("Deleted template with ID: %s" % self.template.id) 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( self.debug(
"select project_account_id from projects where uuid = '%s';" \ "select project_account_id from projects where uuid = '%s';" \
% self.project.id) % self.project.id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select project_account_id from projects where uuid = '%s';" \ "select project_account_id from projects where uuid = '%s';" \
% self.project.id % self.project.id
@ -789,7 +790,7 @@ class TestTemplateUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -800,7 +801,7 @@ class TestTemplateUsage(cloudstackTestCase):
account_id = qresult[0] account_id = qresult[0]
self.debug("select type from usage_event where account_id = '%s';" \ self.debug("select type from usage_event where account_id = '%s';" \
% account_id) % account_id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select type from usage_event where account_id = '%s';" \ "select type from usage_event where account_id = '%s';" \
% account_id % account_id
@ -816,10 +817,10 @@ class TestTemplateUsage(cloudstackTestCase):
0, 0,
"Check DB Query result set" "Check DB Query result set"
) )
qresult = str(qresultset) qresult = str(qresultset)
self.debug("Query result: %s" % qresult) self.debug("Query result: %s" % qresult)
# Check for TEMPLATE.CREATE, TEMPLATE.DELETE in cloud.usage_event table # Check for TEMPLATE.CREATE, TEMPLATE.DELETE in cloud.usage_event table
self.assertEqual( self.assertEqual(
qresult.count('TEMPLATE.CREATE'), qresult.count('TEMPLATE.CREATE'),
@ -846,7 +847,7 @@ class TestISOUsage(cloudstackTestCase):
cls.zone = get_zone(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services)
cls.services["server"]["zoneid"] = cls.zone.id cls.services["server"]["zoneid"] = cls.zone.id
cls.services["iso"]["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.account = Account.create(
cls.api_client, cls.api_client,
cls.services["account"], cls.services["account"],
@ -917,12 +918,12 @@ class TestISOUsage(cloudstackTestCase):
# Delete the ISO # Delete the ISO
self.debug("Deleting ISO with ID: %s" % self.iso.id) self.debug("Deleting ISO with ID: %s" % self.iso.id)
self.iso.delete(self.apiclient) self.iso.delete(self.apiclient)
# Fetch project account ID from project UUID # Fetch project account ID from project UUID
self.debug( self.debug(
"select project_account_id from projects where uuid = '%s';" \ "select project_account_id from projects where uuid = '%s';" \
% self.project.id) % self.project.id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select project_account_id from projects where uuid = '%s';" \ "select project_account_id from projects where uuid = '%s';" \
% self.project.id % self.project.id
@ -932,7 +933,7 @@ class TestISOUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -943,18 +944,18 @@ class TestISOUsage(cloudstackTestCase):
account_id = qresult[0] account_id = qresult[0]
self.debug("select type from usage_event where account_id = '%s';" \ self.debug("select type from usage_event where account_id = '%s';" \
% account_id) % account_id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select type from usage_event where account_id = '%s';" \ "select type from usage_event where account_id = '%s';" \
% account_id % account_id
) )
self.assertEqual( self.assertEqual(
isinstance(qresultset, list), isinstance(qresultset, list),
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -984,7 +985,7 @@ class TestLBRuleUsage(cloudstackTestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.api_client = super( cls.api_client = super(
TestLBRuleUsage, TestLBRuleUsage,
cls cls
).getClsTestClient().getApiClient() ).getClsTestClient().getApiClient()
cls.services = Services().services cls.services = Services().services
@ -1028,7 +1029,7 @@ class TestLBRuleUsage(cloudstackTestCase):
projectid=cls.project.id projectid=cls.project.id
) )
networks = Network.list( networks = Network.list(
cls.api_client, cls.api_client,
projectid=cls.project.id, projectid=cls.project.id,
listall=True listall=True
) )
@ -1077,7 +1078,11 @@ class TestLBRuleUsage(cloudstackTestCase):
def test_01_lb_usage(self): def test_01_lb_usage(self):
"""Test Create/Delete a LB rule and verify correct usage is recorded """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 # Validate the following
# 1. Acquire a IP for this account. lb.rule.create event is registered # 1. Acquire a IP for this account. lb.rule.create event is registered
# for this account in cloud.usage_event table # for this account in cloud.usage_event table
@ -1087,7 +1092,7 @@ class TestLBRuleUsage(cloudstackTestCase):
# 4. Delete this account. # 4. Delete this account.
self.debug( self.debug(
"Creating load balancer rule for public IP: %s" % "Creating load balancer rule for public IP: %s" %
self.public_ip_1.ipaddress.id) self.public_ip_1.ipaddress.id)
#Create Load Balancer rule and assign VMs to rule #Create Load Balancer rule and assign VMs to rule
lb_rule = LoadBalancerRule.create( lb_rule = LoadBalancerRule.create(
@ -1100,11 +1105,11 @@ class TestLBRuleUsage(cloudstackTestCase):
self.debug("Deleting LB rule with ID: %s" % lb_rule.id) self.debug("Deleting LB rule with ID: %s" % lb_rule.id)
lb_rule.delete(self.apiclient) lb_rule.delete(self.apiclient)
# Fetch project account ID from project UUID # Fetch project account ID from project UUID
self.debug( self.debug(
"select project_account_id from projects where uuid = '%s';" \ "select project_account_id from projects where uuid = '%s';" \
% self.project.id) % self.project.id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select project_account_id from projects where uuid = '%s';" \ "select project_account_id from projects where uuid = '%s';" \
% self.project.id % self.project.id
@ -1114,7 +1119,7 @@ class TestLBRuleUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -1125,7 +1130,7 @@ class TestLBRuleUsage(cloudstackTestCase):
account_id = qresult[0] account_id = qresult[0]
self.debug("select type from usage_event where account_id = '%s';" \ self.debug("select type from usage_event where account_id = '%s';" \
% account_id) % account_id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select type from usage_event where account_id = '%s';" \ "select type from usage_event where account_id = '%s';" \
% account_id % account_id
@ -1146,7 +1151,7 @@ class TestLBRuleUsage(cloudstackTestCase):
qresult = str(qresultset) qresult = str(qresultset)
self.debug("Query result: %s" % qresult) 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( self.assertEqual(
qresult.count('LB.CREATE'), qresult.count('LB.CREATE'),
1, 1,
@ -1242,7 +1247,7 @@ class TestSnapshotUsage(cloudstackTestCase):
def test_01_snapshot_usage(self): def test_01_snapshot_usage(self):
"""Test Create/Delete a manual snap shot and verify """Test Create/Delete a manual snap shot and verify
correct usage is recorded correct usage is recorded
""" """
# Validate the following # Validate the following
@ -1252,7 +1257,7 @@ class TestSnapshotUsage(cloudstackTestCase):
# generated for the destroyed Snapshot # generated for the destroyed Snapshot
# 3. Delete the account # 3. Delete the account
# Get the Root disk of VM # Get the Root disk of VM
volumes = list_volumes( volumes = list_volumes(
self.apiclient, self.apiclient,
projectid=self.project.id, projectid=self.project.id,
@ -1264,7 +1269,7 @@ class TestSnapshotUsage(cloudstackTestCase):
True, True,
"Check if list volumes return a valid data" "Check if list volumes return a valid data"
) )
volume = volumes[0] volume = volumes[0]
# Create a snapshot from the ROOTDISK # Create a snapshot from the ROOTDISK
@ -1275,11 +1280,11 @@ class TestSnapshotUsage(cloudstackTestCase):
self.debug("Deleting snapshot: %s" % snapshot.id) self.debug("Deleting snapshot: %s" % snapshot.id)
snapshot.delete(self.apiclient) snapshot.delete(self.apiclient)
# Fetch project account ID from project UUID # Fetch project account ID from project UUID
self.debug( self.debug(
"select project_account_id from projects where uuid = '%s';" \ "select project_account_id from projects where uuid = '%s';" \
% self.project.id) % self.project.id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select project_account_id from projects where uuid = '%s';" \ "select project_account_id from projects where uuid = '%s';" \
% self.project.id % self.project.id
@ -1289,7 +1294,7 @@ class TestSnapshotUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -1300,12 +1305,12 @@ class TestSnapshotUsage(cloudstackTestCase):
account_id = qresult[0] account_id = qresult[0]
self.debug("select type from usage_event where account_id = '%s';" \ self.debug("select type from usage_event where account_id = '%s';" \
% account_id) % account_id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select type from usage_event where account_id = '%s';" \ "select type from usage_event where account_id = '%s';" \
% account_id % account_id
) )
self.assertEqual( self.assertEqual(
isinstance(qresultset, list), isinstance(qresultset, list),
True, True,
@ -1386,7 +1391,7 @@ class TestNatRuleUsage(cloudstackTestCase):
projectid=cls.project.id projectid=cls.project.id
) )
networks = Network.list( networks = Network.list(
cls.api_client, cls.api_client,
projectid=cls.project.id, projectid=cls.project.id,
listall=True listall=True
) )
@ -1435,7 +1440,11 @@ class TestNatRuleUsage(cloudstackTestCase):
def test_01_nat_usage(self): def test_01_nat_usage(self):
"""Test Create/Delete a PF rule and verify correct usage is recorded """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 # Validate the following
# 1. Acquire a IP for this account # 1. Acquire a IP for this account
# 2. Create a PF rule on the IP associated with 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 # is registered for this account in cloud.usage_event table
# 4. Delete this account. # 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) self.public_ip_1.ipaddress.id)
#Create NAT rule #Create NAT rule
nat_rule = NATRule.create( nat_rule = NATRule.create(
@ -1459,11 +1468,11 @@ class TestNatRuleUsage(cloudstackTestCase):
self.debug("Deleting NAT rule: %s" % nat_rule.id) self.debug("Deleting NAT rule: %s" % nat_rule.id)
nat_rule.delete(self.apiclient) nat_rule.delete(self.apiclient)
# Fetch project account ID from project UUID # Fetch project account ID from project UUID
self.debug( self.debug(
"select project_account_id from projects where uuid = '%s';" \ "select project_account_id from projects where uuid = '%s';" \
% self.project.id) % self.project.id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select project_account_id from projects where uuid = '%s';" \ "select project_account_id from projects where uuid = '%s';" \
% self.project.id % self.project.id
@ -1473,7 +1482,7 @@ class TestNatRuleUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -1484,7 +1493,7 @@ class TestNatRuleUsage(cloudstackTestCase):
account_id = qresult[0] account_id = qresult[0]
self.debug("select type from usage_event where account_id = '%s';" \ self.debug("select type from usage_event where account_id = '%s';" \
% account_id) % account_id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select type from usage_event where account_id = '%s';" \ "select type from usage_event where account_id = '%s';" \
% account_id % account_id
@ -1569,7 +1578,7 @@ class TestVpnUsage(cloudstackTestCase):
projectid=cls.project.id projectid=cls.project.id
) )
networks = Network.list( networks = Network.list(
cls.api_client, cls.api_client,
projectid=cls.project.id, projectid=cls.project.id,
listall=True listall=True
) )
@ -1618,16 +1627,20 @@ class TestVpnUsage(cloudstackTestCase):
def test_01_vpn_usage(self): def test_01_vpn_usage(self):
"""Test Create/Delete a VPN and verify correct usage is recorded """Test Create/Delete a VPN and verify correct usage is recorded
""" """
<<<<<<< HEAD
=======
tags = ["advanced", "advancedns"]
>>>>>>> 6d17e21... This commit has following fixes:
# Validate the following # Validate the following
# 1. Enable VPN for this IP. vpn.add.user event is registered for this # 1. Enable VPN for this IP. vpn.add.user event is registered for this
# account in cloud.usage_event table # 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 # 3. Delete user for this VPN. vpn.user.delete event is registered for
# this account in cloud.usage_event table # this account in cloud.usage_event table
# 4. Delete this account. # 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) self.public_ip.ipaddress.id)
#Assign VPN to Public IP #Assign VPN to Public IP
vpn = Vpn.create( vpn = Vpn.create(
@ -1636,7 +1649,7 @@ class TestVpnUsage(cloudstackTestCase):
projectid=self.project.id projectid=self.project.id
) )
self.debug("Created VPN user for account: %s" % self.debug("Created VPN user for account: %s" %
self.account.account.name) self.account.account.name)
vpnuser = VpnUser.create( vpnuser = VpnUser.create(
@ -1654,11 +1667,11 @@ class TestVpnUsage(cloudstackTestCase):
self.debug("Deleting VPN: %s" % vpn.publicipid) self.debug("Deleting VPN: %s" % vpn.publicipid)
vpn.delete(self.apiclient) vpn.delete(self.apiclient)
# Fetch project account ID from project UUID # Fetch project account ID from project UUID
self.debug( self.debug(
"select project_account_id from projects where uuid = '%s';" \ "select project_account_id from projects where uuid = '%s';" \
% self.project.id) % self.project.id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select project_account_id from projects where uuid = '%s';" \ "select project_account_id from projects where uuid = '%s';" \
% self.project.id % self.project.id
@ -1668,7 +1681,7 @@ class TestVpnUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -1679,7 +1692,7 @@ class TestVpnUsage(cloudstackTestCase):
account_id = qresult[0] account_id = qresult[0]
self.debug("select type from usage_event where account_id = '%s';" \ self.debug("select type from usage_event where account_id = '%s';" \
% account_id) % account_id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select type from usage_event where account_id = '%s';" \ "select type from usage_event where account_id = '%s';" \
% account_id % account_id
@ -1698,8 +1711,8 @@ class TestVpnUsage(cloudstackTestCase):
qresult = str(qresultset) qresult = str(qresultset)
self.debug("Query result: %s" % qresult) self.debug("Query result: %s" % qresult)
# Check for VPN user related events # Check for VPN user related events
self.assertEqual( self.assertEqual(
qresult.count('VPN.USER.ADD'), qresult.count('VPN.USER.ADD'),
1, 1,

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,7 @@ from integration.lib.base import *
from integration.lib.common import * from integration.lib.common import *
import datetime import datetime
class Services: class Services:
"""Test Resource Limits Services """Test Resource Limits Services
""" """
@ -47,8 +48,8 @@ class Services:
"name": "Tiny Instance", "name": "Tiny Instance",
"displaytext": "Tiny Instance", "displaytext": "Tiny Instance",
"cpunumber": 1, "cpunumber": 1,
"cpuspeed": 100, # in MHz "cpuspeed": 100, # in MHz
"memory": 64, # In MBs "memory": 64, # In MBs
}, },
"disk_offering": { "disk_offering": {
"displaytext": "Small", "displaytext": "Small",
@ -81,6 +82,7 @@ class Services:
"mode": 'advanced', "mode": 'advanced',
} }
class TestResourceLimitsAccount(cloudstackTestCase): class TestResourceLimitsAccount(cloudstackTestCase):
@classmethod @classmethod
@ -153,7 +155,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
def test_01_vm_per_account(self): def test_01_vm_per_account(self):
"""Test VM limit per account """Test VM limit per account
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. Set user_vm=1 limit for account 1. # 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 # 3. Try to start 2 VMs account 2. Verify 2 SM are started properly
self.debug( self.debug(
"Updating instance resource limit for account: %s" % "Updating instance resource limit for account: %s" %
self.account_1.account.name) self.account_1.account.name)
# Set usage_vm=1 for Account 1 # Set usage_vm=1 for Account 1
update_resource_limit( update_resource_limit(
self.apiclient, self.apiclient,
0, # Instance 0, # Instance
account=self.account_1.account.name, account=self.account_1.account.name,
domainid=self.account_1.account.domainid, domainid=self.account_1.account.domainid,
max=1 max=1
) )
self.debug( self.debug(
"Deploying VM instance in account: %s" % "Deploying VM instance in account: %s" %
self.account_1.account.name) self.account_1.account.name)
virtual_machine = VirtualMachine.create( virtual_machine = VirtualMachine.create(
@ -204,7 +206,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
serviceofferingid=self.service_offering.id serviceofferingid=self.service_offering.id
) )
self.debug( self.debug(
"Deploying VM instance in account: %s" % "Deploying VM instance in account: %s" %
self.account_2.account.name) self.account_2.account.name)
# Start 2 instances for account_2 # Start 2 instances for account_2
virtual_machine_1 = VirtualMachine.create( virtual_machine_1 = VirtualMachine.create(
@ -224,7 +226,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
) )
self.debug( self.debug(
"Deploying VM instance in account: %s" % "Deploying VM instance in account: %s" %
self.account_2.account.name) self.account_2.account.name)
virtual_machine_2 = VirtualMachine.create( virtual_machine_2 = VirtualMachine.create(
self.apiclient, self.apiclient,
@ -246,7 +248,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
def test_02_publicip_per_account(self): def test_02_publicip_per_account(self):
"""Test Public IP limit per account """Test Public IP limit per account
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. Set Public_IP= 2 limit for account 1. # 1. Set Public_IP= 2 limit for account 1.
@ -256,21 +258,21 @@ class TestResourceLimitsAccount(cloudstackTestCase):
# denied to acquire more than one IP. # denied to acquire more than one IP.
# 5. Acquire 2 IP in account 2. Verify account 2 should be able to # 5. Acquire 2 IP in account 2. Verify account 2 should be able to
# Acquire IP without any warning # Acquire IP without any warning
self.debug( self.debug(
"Updating public IP resource limit for account: %s" % "Updating public IP resource limit for account: %s" %
self.account_1.account.name) self.account_1.account.name)
# Set usage_vm=1 for Account 1 # Set usage_vm=1 for Account 1
update_resource_limit( update_resource_limit(
self.apiclient, self.apiclient,
1, # Public Ip 1, # Public Ip
account=self.account_1.account.name, account=self.account_1.account.name,
domainid=self.account_1.account.domainid, domainid=self.account_1.account.domainid,
max=2 max=2
) )
self.debug( self.debug(
"Deploying VM instance in account: %s" % "Deploying VM instance in account: %s" %
self.account_1.account.name) self.account_1.account.name)
virtual_machine_1 = VirtualMachine.create( virtual_machine_1 = VirtualMachine.create(
self.apiclient, self.apiclient,
@ -289,7 +291,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
) )
self.debug( self.debug(
"Deploying VM instance in account: %s" % "Deploying VM instance in account: %s" %
self.account_2.account.name) self.account_2.account.name)
# Create VM for second account # Create VM for second account
virtual_machine_2 = VirtualMachine.create( virtual_machine_2 = VirtualMachine.create(
@ -308,7 +310,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
"Check VM state is Running or not" "Check VM state is Running or not"
) )
self.debug( self.debug(
"Associating public IP for account: %s" % "Associating public IP for account: %s" %
virtual_machine_1.account) virtual_machine_1.account)
public_ip_1 = PublicIPAddress.create( public_ip_1 = PublicIPAddress.create(
self.apiclient, self.apiclient,
@ -343,7 +345,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
) )
self.debug( self.debug(
"Associating public IP for account: %s" % "Associating public IP for account: %s" %
virtual_machine_2.account) virtual_machine_2.account)
# Assign Public IP for account 2 # Assign Public IP for account 2
public_ip_3 = PublicIPAddress.create( public_ip_3 = PublicIPAddress.create(
@ -365,7 +367,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
"Check Public IP state is allocated or not" "Check Public IP state is allocated or not"
) )
self.debug( self.debug(
"Associating public IP for account: %s" % "Associating public IP for account: %s" %
virtual_machine_2.account) virtual_machine_2.account)
public_ip_4 = PublicIPAddress.create( public_ip_4 = PublicIPAddress.create(
self.apiclient, self.apiclient,
@ -389,7 +391,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
def test_03_snapshots_per_account(self): def test_03_snapshots_per_account(self):
"""Test Snapshot limit per account """Test Snapshot limit per account
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. Set snapshot= 2 limit for account 1. # 1. Set snapshot= 2 limit for account 1.
@ -401,19 +403,19 @@ class TestResourceLimitsAccount(cloudstackTestCase):
# create snapshots without any warning # create snapshots without any warning
self.debug( self.debug(
"Updating public IP resource limit for account: %s" % "Updating public IP resource limit for account: %s" %
self.account_1.account.name) self.account_1.account.name)
# Set usage_vm=1 for Account 1 # Set usage_vm=1 for Account 1
update_resource_limit( update_resource_limit(
self.apiclient, self.apiclient,
3, # Snapshot 3, # Snapshot
account=self.account_1.account.name, account=self.account_1.account.name,
domainid=self.account_1.account.domainid, domainid=self.account_1.account.domainid,
max=1 max=1
) )
self.debug( self.debug(
"Deploying VM instance in account: %s" % "Deploying VM instance in account: %s" %
self.account_1.account.name) self.account_1.account.name)
virtual_machine_1 = VirtualMachine.create( virtual_machine_1 = VirtualMachine.create(
self.apiclient, self.apiclient,
@ -432,7 +434,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
) )
self.debug( self.debug(
"Deploying VM instance in account: %s" % "Deploying VM instance in account: %s" %
self.account_1.account.name) self.account_1.account.name)
# Create VM for second account # Create VM for second account
virtual_machine_2 = VirtualMachine.create( virtual_machine_2 = VirtualMachine.create(
@ -504,7 +506,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
"Check for list volume response return valid data" "Check for list volume response return valid data"
) )
volume = volumes[0] volume = volumes[0]
self.debug("Creating snapshot from volume: %s" % volumes[0].id) self.debug("Creating snapshot from volume: %s" % volumes[0].id)
# Create a snapshot from the ROOTDISK (Account 2) # Create a snapshot from the ROOTDISK (Account 2)
snapshot_2 = Snapshot.create(self.apiclient, snapshot_2 = Snapshot.create(self.apiclient,
@ -545,7 +547,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
def test_04_volumes_per_account(self): def test_04_volumes_per_account(self):
"""Test Volumes limit per account """Test Volumes limit per account
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. Set volumes=2 limit for account 1. # 1. Set volumes=2 limit for account 1.
@ -557,12 +559,12 @@ class TestResourceLimitsAccount(cloudstackTestCase):
# create Volume without any warning # create Volume without any warning
self.debug( self.debug(
"Updating volume resource limit for account: %s" % "Updating volume resource limit for account: %s" %
self.account_1.account.name) self.account_1.account.name)
# Set usage_vm=1 for Account 1 # Set usage_vm=1 for Account 1
update_resource_limit( update_resource_limit(
self.apiclient, self.apiclient,
2, # Volume 2, # Volume
account=self.account_1.account.name, account=self.account_1.account.name,
domainid=self.account_1.account.domainid, domainid=self.account_1.account.domainid,
max=2 max=2
@ -687,7 +689,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
def test_05_templates_per_account(self): def test_05_templates_per_account(self):
"""Test Templates limit per account """Test Templates limit per account
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. Set templates=1 limit for account 1. # 1. Set templates=1 limit for account 1.
@ -697,19 +699,19 @@ class TestResourceLimitsAccount(cloudstackTestCase):
# able to create template without any error # able to create template without any error
self.debug( self.debug(
"Updating template resource limit for account: %s" % "Updating template resource limit for account: %s" %
self.account_1.account.name) self.account_1.account.name)
# Set usage_vm=1 for Account 1 # Set usage_vm=1 for Account 1
update_resource_limit( update_resource_limit(
self.apiclient, self.apiclient,
4, # Template 4, # Template
account=self.account_1.account.name, account=self.account_1.account.name,
domainid=self.account_1.account.domainid, domainid=self.account_1.account.domainid,
max=1 max=1
) )
self.debug( self.debug(
"Updating volume resource limit for account: %s" % "Updating volume resource limit for account: %s" %
self.account_1.account.name) self.account_1.account.name)
virtual_machine_1 = VirtualMachine.create( virtual_machine_1 = VirtualMachine.create(
self.apiclient, self.apiclient,
@ -728,7 +730,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
) )
self.debug( self.debug(
"Deploying virtual machine for account: %s" % "Deploying virtual machine for account: %s" %
self.account_2.account.name) self.account_2.account.name)
# Create VM for second account # Create VM for second account
virtual_machine_2 = VirtualMachine.create( virtual_machine_2 = VirtualMachine.create(
@ -917,7 +919,7 @@ class TestResourceLimitsDomain(cloudstackTestCase):
def test_01_vm_per_domain(self): def test_01_vm_per_domain(self):
"""Test VM limit per domain """Test VM limit per domain
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. Set max VM per domain to 2 # 1. Set max VM per domain to 2
@ -926,12 +928,12 @@ class TestResourceLimitsDomain(cloudstackTestCase):
# should be raised # should be raised
self.debug( self.debug(
"Updating instance resource limits for domain: %s" % "Updating instance resource limits for domain: %s" %
self.account.account.domainid) self.account.account.domainid)
# Set usage_vm=1 for Account 1 # Set usage_vm=1 for Account 1
update_resource_limit( update_resource_limit(
self.apiclient, self.apiclient,
0, # Instance 0, # Instance
domainid=self.account.account.domainid, domainid=self.account.account.domainid,
max=2 max=2
) )
@ -983,7 +985,7 @@ class TestResourceLimitsDomain(cloudstackTestCase):
def test_01_publicip_per_domain(self): def test_01_publicip_per_domain(self):
"""Test Public IP limit per domain """Test Public IP limit per domain
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. set max no of IPs per domain to 2. # 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. # appropriate error and an alert should be generated.
self.debug( self.debug(
"Updating public IP resource limits for domain: %s" % "Updating public IP resource limits for domain: %s" %
self.account.account.domainid) self.account.account.domainid)
# Set usage_vm=1 for Account 1 # Set usage_vm=1 for Account 1
update_resource_limit( update_resource_limit(
self.apiclient, self.apiclient,
1, # Public Ip 1, # Public Ip
domainid=self.account.account.domainid, domainid=self.account.account.domainid,
max=2 max=2
) )
@ -1053,7 +1055,7 @@ class TestResourceLimitsDomain(cloudstackTestCase):
def test_03_snapshots_per_domain(self): def test_03_snapshots_per_domain(self):
"""Test Snapshot limit per domain """Test Snapshot limit per domain
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. set max no of snapshots per domain to 1. # 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. # user an appropriate error and an alert should be generated.
self.debug( self.debug(
"Updating snapshot resource limits for domain: %s" % "Updating snapshot resource limits for domain: %s" %
self.account.account.domainid) self.account.account.domainid)
# Set usage_vm=1 for Account 1 # Set usage_vm=1 for Account 1
update_resource_limit( update_resource_limit(
self.apiclient, self.apiclient,
3, # Snapshot 3, # Snapshot
domainid=self.account.account.domainid, domainid=self.account.account.domainid,
max=1 max=1
) )
@ -1136,7 +1138,7 @@ class TestResourceLimitsDomain(cloudstackTestCase):
def test_04_volumes_per_domain(self): def test_04_volumes_per_domain(self):
"""Test Volumes limit per domain """Test Volumes limit per domain
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. set max no of volume per domain to 1. # 1. set max no of volume per domain to 1.
@ -1147,12 +1149,12 @@ class TestResourceLimitsDomain(cloudstackTestCase):
# should be generated. # should be generated.
self.debug( self.debug(
"Updating volume resource limits for domain: %s" % "Updating volume resource limits for domain: %s" %
self.account.account.domainid) self.account.account.domainid)
# Set usage_vm=1 for Account 1 # Set usage_vm=1 for Account 1
update_resource_limit( update_resource_limit(
self.apiclient, self.apiclient,
2, # Volume 2, # Volume
domainid=self.account.account.domainid, domainid=self.account.account.domainid,
max=2 max=2
) )
@ -1189,9 +1191,9 @@ class TestResourceLimitsDomain(cloudstackTestCase):
def test_05_templates_per_domain(self): def test_05_templates_per_domain(self):
"""Test Templates limit per domain """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. # 1. set max no of templates per domain to 2.
# 2. Create an account in this domain # 2. Create an account in this domain
# 3. Create 2 templates in this domain. Both template should be in # 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 # Set usage_vm=1 for Account 1
update_resource_limit( update_resource_limit(
self.apiclient, self.apiclient,
2, # Volume 2, # Volume
domainid=self.account.account.domainid, domainid=self.account.account.domainid,
max=5 max=5
) )
self.debug( self.debug(
"Updating template resource limits for domain: %s" % "Updating template resource limits for domain: %s" %
self.account.account.domainid) self.account.account.domainid)
# Set usage_vm=1 for Account 1 # Set usage_vm=1 for Account 1
update_resource_limit( update_resource_limit(
self.apiclient, self.apiclient,
4, # Template 4, # Template
domainid=self.account.account.domainid, domainid=self.account.account.domainid,
max=2 max=2
) )
@ -1301,14 +1303,14 @@ class TestResources(cloudstackTestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.api_client = super( cls.api_client = super(
TestResources, TestResources,
cls cls
).getClsTestClient().getApiClient() ).getClsTestClient().getApiClient()
cls.services = Services().services cls.services = Services().services
# Get Zone, Domain and templates # Get Zone, Domain and templates
cls.zone = get_zone(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services)
cls._cleanup = [] cls._cleanup = []
return return
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
@ -1335,16 +1337,16 @@ class TestResources(cloudstackTestCase):
def test_01_zones(self): def test_01_zones(self):
"""Check the status of zones""" """Check the status of zones"""
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. List zones # 1. List zones
# 2. Check allocation state is "enabled" or not # 2. Check allocation state is "enabled" or not
zones = Zone.list( zones = Zone.list(
self.apiclient, self.apiclient,
id=self.zone.id, id=self.zone.id,
listall=True listall=True
) )
self.assertEqual( self.assertEqual(
isinstance(zones, list), isinstance(zones, list),
@ -1361,16 +1363,16 @@ class TestResources(cloudstackTestCase):
def test_02_pods(self): def test_02_pods(self):
"""Check the status of pods""" """Check the status of pods"""
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. List pods # 1. List pods
# 2. Check allocation state is "enabled" or not # 2. Check allocation state is "enabled" or not
pods = Pod.list( pods = Pod.list(
self.apiclient, self.apiclient,
zoneid=self.zone.id, zoneid=self.zone.id,
listall=True listall=True
) )
self.assertEqual( self.assertEqual(
isinstance(pods, list), isinstance(pods, list),
@ -1384,19 +1386,19 @@ class TestResources(cloudstackTestCase):
"Pods allocation state should be enabled" "Pods allocation state should be enabled"
) )
return return
def test_03_clusters(self): def test_03_clusters(self):
"""Check the status of clusters""" """Check the status of clusters"""
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. List clusters # 1. List clusters
# 2. Check allocation state is "enabled" or not # 2. Check allocation state is "enabled" or not
clusters = Cluster.list( clusters = Cluster.list(
self.apiclient, self.apiclient,
zoneid=self.zone.id, zoneid=self.zone.id,
listall=True listall=True
) )
self.assertEqual( self.assertEqual(
isinstance(clusters, list), isinstance(clusters, list),
@ -1410,20 +1412,20 @@ class TestResources(cloudstackTestCase):
"Clusters allocation state should be enabled" "Clusters allocation state should be enabled"
) )
return return
def test_04_hosts(self): def test_04_hosts(self):
"""Check the status of hosts""" """Check the status of hosts"""
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. List hosts with type=Routing # 1. List hosts with type=Routing
# 2. Check state is "Up" or not # 2. Check state is "Up" or not
hosts = Host.list( hosts = Host.list(
self.apiclient, self.apiclient,
zoneid=self.zone.id, zoneid=self.zone.id,
type='Routing', type='Routing',
listall=True listall=True
) )
self.assertEqual( self.assertEqual(
isinstance(hosts, list), isinstance(hosts, list),
@ -1437,19 +1439,19 @@ class TestResources(cloudstackTestCase):
"Host should be in Up state and running" "Host should be in Up state and running"
) )
return return
def test_05_storage_pools(self): def test_05_storage_pools(self):
"""Check the status of Storage pools""" """Check the status of Storage pools"""
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. List storage pools for the zone # 1. List storage pools for the zone
# 2. Check state is "enabled" or not # 2. Check state is "enabled" or not
storage_pools = StoragePool.list( storage_pools = StoragePool.list(
self.apiclient, self.apiclient,
zoneid=self.zone.id, zoneid=self.zone.id,
listall=True listall=True
) )
self.assertEqual( self.assertEqual(
isinstance(storage_pools, list), isinstance(storage_pools, list),
@ -1463,20 +1465,20 @@ class TestResources(cloudstackTestCase):
"storage pool should be in Up state and running" "storage pool should be in Up state and running"
) )
return return
def test_06_secondary_storage(self): def test_06_secondary_storage(self):
"""Check the status of secondary storage""" """Check the status of secondary storage"""
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. List secondary storage # 1. List secondary storage
# 2. Check state is "Up" or not # 2. Check state is "Up" or not
sec_storages = Host.list( sec_storages = Host.list(
self.apiclient, self.apiclient,
zoneid=self.zone.id, zoneid=self.zone.id,
type='SecondaryStorage', type='SecondaryStorage',
listall=True listall=True
) )
self.assertEqual( self.assertEqual(
isinstance(sec_storages, list), isinstance(sec_storages, list),

View File

@ -82,7 +82,7 @@ class Services:
"publicport": 2222, "publicport": 2222,
"protocol": 'TCP', "protocol": 'TCP',
}, },
"fw_rule":{ "fw_rule": {
"startport": 1, "startport": 1,
"endport": 6000, "endport": 6000,
"cidr": '55.55.0.0/11', "cidr": '55.55.0.0/11',
@ -90,7 +90,7 @@ class Services:
}, },
"ostypeid": '5776c0d2-f331-42db-ba3a-29f1f8319bc9', "ostypeid": '5776c0d2-f331-42db-ba3a-29f1f8319bc9',
# Used for Get_Template : CentOS 5.3 (64 bit) # 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 # e. LB
# f. VPN # f. VPN
# g. userdata # 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) # a. listRouters account=user, domainid=1 (router state=Running)
# b. listNetworks account=user domainid=1 (network state=Implemented) # b. listNetworks account=user domainid=1 (network state=Implemented)
# c. listVirtualMachines account=user domainid=1 (VM state=Running) # c. listVirtualMachines account=user domainid=1 (VM state=Running)
@ -318,7 +318,7 @@ class TestRouterServices(cloudstackTestCase):
""" """
tags = ["advanced"] tags = ["advanced"]
# Validate the following # 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) # a.listRouters account=user, domainid=1 (router state=Running)
# b.listNetworks account=user domainid=1 (network state=Implemented) # b.listNetworks account=user domainid=1 (network state=Implemented)
# c.listVirtualMachines account=user domainid=1 (VM states=Running) # 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) 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 # 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) time.sleep(total_wait * 2)
routers = list_routers( routers = list_routers(
@ -580,7 +580,6 @@ class TestRouterServices(cloudstackTestCase):
return return
class TestRouterStopCreatePF(cloudstackTestCase): class TestRouterStopCreatePF(cloudstackTestCase):
@classmethod @classmethod
@ -657,10 +656,10 @@ class TestRouterStopCreatePF(cloudstackTestCase):
# 2. stopRouter for this account # 2. stopRouter for this account
# 3. wait for listRouters to report Router as 'Stopped' # 3. wait for listRouters to report Router as 'Stopped'
# 4. listPublicIpAddresses account=user, domainid=1 - pick ipaddressid # 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. # a. for port 22 (ssh) for user VM deployed in step 1.
# b. public port 222 , private port 22 # 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 # 7. wait for listRouters to show router as Running
# Get router details associated for that account # Get router details associated for that account
@ -720,7 +719,7 @@ class TestRouterStopCreatePF(cloudstackTestCase):
) )
public_ip = public_ips[0] public_ip = public_ips[0]
# Open up firewall port for SSH # Open up firewall port for SSH
fw_rule = FireWallRule.create( fw_rule = FireWallRule.create(
self.apiclient, self.apiclient,
ipaddressid=public_ip.id, ipaddressid=public_ip.id,
@ -791,6 +790,7 @@ class TestRouterStopCreatePF(cloudstackTestCase):
) )
return return
class TestRouterStopCreateLB(cloudstackTestCase): class TestRouterStopCreateLB(cloudstackTestCase):
@classmethod @classmethod
@ -923,8 +923,8 @@ class TestRouterStopCreateLB(cloudstackTestCase):
"Check for list public IPs response return valid data" "Check for list public IPs response return valid data"
) )
public_ip = public_ips[0] public_ip = public_ips[0]
# Open up firewall port for SSH # Open up firewall port for SSH
fw_rule = FireWallRule.create( fw_rule = FireWallRule.create(
self.apiclient, self.apiclient,
ipaddressid=public_ip.id, ipaddressid=public_ip.id,
@ -1076,7 +1076,7 @@ class TestRouterStopCreateFW(cloudstackTestCase):
# (optional backend) # (optional backend)
# 3. verify on router using iptables -t nat -nvx if rules are applied # 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( routers = list_routers(
self.apiclient, self.apiclient,
account=self.account.account.name, account=self.account.account.name,
@ -1223,4 +1223,3 @@ class TestRouterStopCreateFW(cloudstackTestCase):
"Check public IP address" "Check public IP address"
) )
return return

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,7 @@ from integration.lib.base import *
from integration.lib.common import * from integration.lib.common import *
from marvin.remoteSSHClient import remoteSSHClient from marvin.remoteSSHClient import remoteSSHClient
class Services: class Services:
"""Test Snapshots Services """Test Snapshots Services
""" """
@ -44,8 +45,8 @@ class Services:
"name": "Tiny Instance", "name": "Tiny Instance",
"displaytext": "Tiny Instance", "displaytext": "Tiny Instance",
"cpunumber": 1, "cpunumber": 1,
"cpuspeed": 200, # in MHz "cpuspeed": 200, # in MHz
"memory": 256, # In MBs "memory": 256, # In MBs
}, },
"disk_offering": { "disk_offering": {
"displaytext": "Small Disk", "displaytext": "Small Disk",
@ -71,10 +72,10 @@ class Services:
"recurring_snapshot": { "recurring_snapshot": {
"intervaltype": 'HOURLY', "intervaltype": 'HOURLY',
# Frequency of snapshots # Frequency of snapshots
"maxsnaps": 1, # Should be min 2 "maxsnaps": 1, # Should be min 2
"schedule": 1, "schedule": 1,
"timezone": 'US/Arizona', "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": { "templates": {
"displaytext": 'Template', "displaytext": 'Template',
@ -84,7 +85,7 @@ class Services:
}, },
"diskdevice": "/dev/xvda", "diskdevice": "/dev/xvda",
"diskname": "TestDiskServ", "diskname": "TestDiskServ",
"size": 1, # GBs "size": 1, # GBs
"mount_dir": "/mnt/tmp", "mount_dir": "/mnt/tmp",
"sub_dir": "test", "sub_dir": "test",
@ -96,7 +97,7 @@ class Services:
# Cent OS 5.3 (64 bit) # Cent OS 5.3 (64 bit)
"sleep": 60, "sleep": 60,
"timeout": 10, "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): def test_01_createVM_snapshotTemplate(self):
"""Test create VM, Snapshot and Template """Test create VM, Snapshot and Template
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. Deploy VM using default template, small service offering # 1. Deploy VM using default template, small service offering
# and small data disk offering. # and small data disk offering.
@ -191,7 +192,7 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase):
serviceofferingid=self.service_offering.id serviceofferingid=self.service_offering.id
) )
self.debug("Created VM with ID: %s" % self.virtual_machine.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( volumes = list_volumes(
self.apiclient, self.apiclient,
virtualmachineid=self.virtual_machine.id, virtualmachineid=self.virtual_machine.id,
@ -332,7 +333,7 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase):
export_path = '/'.join(parse_url[3:]) export_path = '/'.join(parse_url[3:])
# Export path: export/test # Export path: export/test
# Sleep to ensure that snapshot is reflected in sec storage # Sleep to ensure that snapshot is reflected in sec storage
time.sleep(self.services["sleep"]) time.sleep(self.services["sleep"])
try: try:
@ -344,7 +345,7 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase):
self.services["mgmt_server"]["password"], self.services["mgmt_server"]["password"],
) )
cmds = [ cmds = [
"mkdir -p %s" % self.services["mount_dir"], "mkdir -p %s" % self.services["mount_dir"],
"mount %s/%s %s" % ( "mount %s/%s %s" % (
sec_storage_ip, sec_storage_ip,
@ -361,7 +362,7 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase):
self.debug("command: %s" % c) self.debug("command: %s" % c)
result = ssh_client.execute(c) result = ssh_client.execute(c)
self.debug("Result: %s" % result) self.debug("Result: %s" % result)
except Exception as e: except Exception as e:
self.fail("SSH failed for Management server: %s" % self.fail("SSH failed for Management server: %s" %
self.services["mgmt_server"]["ipaddress"]) self.services["mgmt_server"]["ipaddress"])
@ -379,7 +380,7 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase):
except Exception as e: except Exception as e:
self.fail("SSH failed for Management server: %s" % self.fail("SSH failed for Management server: %s" %
self.services["mgmt_server"]["ipaddress"]) self.services["mgmt_server"]["ipaddress"])
res = str(uuids) res = str(uuids)
self.assertEqual( self.assertEqual(
res.count(snapshot_uuid), res.count(snapshot_uuid),
@ -430,7 +431,7 @@ class TestAccountSnapshotClean(cloudstackTestCase):
domainid=cls.account.account.domainid, domainid=cls.account.account.domainid,
serviceofferingid=cls.service_offering.id serviceofferingid=cls.service_offering.id
) )
# Get the Root disk of VM # Get the Root disk of VM
volumes = list_volumes( volumes = list_volumes(
cls.api_client, cls.api_client,
virtualmachineid=cls.virtual_machine.id, virtualmachineid=cls.virtual_machine.id,
@ -473,7 +474,7 @@ class TestAccountSnapshotClean(cloudstackTestCase):
def test_02_accountSnapshotClean(self): def test_02_accountSnapshotClean(self):
"""Test snapshot cleanup after account deletion """Test snapshot cleanup after account deletion
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. listAccounts API should list out the newly created account # 1. listAccounts API should list out the newly created account
# 2. listVirtualMachines() command should return the deployed VM. # 2. listVirtualMachines() command should return the deployed VM.
@ -518,7 +519,7 @@ class TestAccountSnapshotClean(cloudstackTestCase):
for virtual_machine in virtual_machines: for virtual_machine in virtual_machines:
self.debug("VM ID: %s, VM state: %s" % ( self.debug("VM ID: %s, VM state: %s" % (
virtual_machine.id, virtual_machine.id,
virtual_machine.state virtual_machine.state
)) ))
self.assertEqual( self.assertEqual(
virtual_machine.state, virtual_machine.state,
@ -591,7 +592,7 @@ class TestAccountSnapshotClean(cloudstackTestCase):
export_path = '/'.join(parse_url[3:]) export_path = '/'.join(parse_url[3:])
# Export path: export/test # Export path: export/test
# Sleep to ensure that snapshot is reflected in sec storage # Sleep to ensure that snapshot is reflected in sec storage
time.sleep(self.services["sleep"]) time.sleep(self.services["sleep"])
try: try:
@ -621,7 +622,7 @@ class TestAccountSnapshotClean(cloudstackTestCase):
self.debug("command: %s" % c) self.debug("command: %s" % c)
result = ssh_client.execute(c) result = ssh_client.execute(c)
self.debug("Result: %s" % result) self.debug("Result: %s" % result)
uuids.append(result) uuids.append(result)
# Unmount the Sec Storage # Unmount the Sec Storage
@ -633,14 +634,14 @@ class TestAccountSnapshotClean(cloudstackTestCase):
except Exception: except Exception:
self.fail("SSH failed for management server: %s" % self.fail("SSH failed for management server: %s" %
self.services["mgmt_server"]["ipaddress"]) self.services["mgmt_server"]["ipaddress"])
res = str(uuids) res = str(uuids)
self.assertEqual( self.assertEqual(
res.count(snapshot_uuid), res.count(snapshot_uuid),
1, 1,
"Check snapshot UUID in secondary storage and database" "Check snapshot UUID in secondary storage and database"
) )
self.debug("Deleting account: %s" % self.account.account.name) self.debug("Deleting account: %s" % self.account.account.name)
# Delete account # Delete account
self.account.delete(self.apiclient) self.account.delete(self.apiclient)
@ -655,7 +656,7 @@ class TestAccountSnapshotClean(cloudstackTestCase):
"Check list response returns a valid list" "Check list response returns a valid list"
) )
self.debug("account.cleanup.interval: %s" % interval[0].value) self.debug("account.cleanup.interval: %s" % interval[0].value)
# Wait for account cleanup interval # Wait for account cleanup interval
time.sleep(int(interval[0].value) * 2) time.sleep(int(interval[0].value) * 2)
@ -663,14 +664,14 @@ class TestAccountSnapshotClean(cloudstackTestCase):
self.apiclient, self.apiclient,
id=self.account.account.id 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: for host in hosts:
# hosts[0].name = "nfs://192.168.100.21/export/test" # hosts[0].name = "nfs://192.168.100.21/export/test"
parse_url = (host.name).split('/') parse_url = (host.name).split('/')
@ -684,7 +685,7 @@ class TestAccountSnapshotClean(cloudstackTestCase):
# Export path: export/test # Export path: export/test
try: try:
cmds = [ cmds = [
"mount %s/%s %s" % ( "mount %s/%s %s" % (
sec_storage_ip, sec_storage_ip,
export_path, export_path,
@ -701,7 +702,7 @@ class TestAccountSnapshotClean(cloudstackTestCase):
self.debug("command: %s" % c) self.debug("command: %s" % c)
result = ssh_client.execute(c) result = ssh_client.execute(c)
self.debug("Result: %s" % result) self.debug("Result: %s" % result)
uuids.append(result) uuids.append(result)
# Unmount the Sec Storage # Unmount the Sec Storage
cmds = [ cmds = [
@ -715,7 +716,7 @@ class TestAccountSnapshotClean(cloudstackTestCase):
except Exception: except Exception:
self.fail("SSH failed for management server: %s" % self.fail("SSH failed for management server: %s" %
self.services["mgmt_server"]["ipaddress"]) self.services["mgmt_server"]["ipaddress"])
res = str(uuids) res = str(uuids)
self.assertNotEqual( self.assertNotEqual(
res.count(snapshot_uuid), res.count(snapshot_uuid),
@ -804,7 +805,7 @@ class TestSnapshotDetachedDisk(cloudstackTestCase):
def test_03_snapshot_detachedDisk(self): def test_03_snapshot_detachedDisk(self):
"""Test snapshot from detached disk """Test snapshot from detached disk
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. login in VM and write some data on data disk(use fdisk to # 1. login in VM and write some data on data disk(use fdisk to
# partition datadisk,fdisk /dev/sdb, and make filesystem using # partition datadisk,fdisk /dev/sdb, and make filesystem using
@ -863,7 +864,7 @@ class TestSnapshotDetachedDisk(cloudstackTestCase):
self.services["sub_lvl_dir2"], self.services["sub_lvl_dir2"],
self.services["random_data"] self.services["random_data"]
), ),
"sync", "sync",
] ]
for c in cmds: for c in cmds:
self.debug(ssh_client.execute(c)) self.debug(ssh_client.execute(c))
@ -908,7 +909,7 @@ class TestSnapshotDetachedDisk(cloudstackTestCase):
except Exception as e: except Exception as e:
self.fail("SSH failed for VM with IP: %s" % self.fail("SSH failed for VM with IP: %s" %
self.virtual_machine.ipaddress) self.virtual_machine.ipaddress)
# Fetch values from database # Fetch values from database
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select backup_snap_id, account_id, volume_id from snapshots where uuid = '%s';" \ "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 = '/'.join(parse_url[3:])
# Export path: export/test # Export path: export/test
# Sleep to ensure that snapshot is reflected in sec storage # Sleep to ensure that snapshot is reflected in sec storage
time.sleep(self.services["sleep"]) time.sleep(self.services["sleep"])
try: try:
@ -983,7 +984,7 @@ class TestSnapshotDetachedDisk(cloudstackTestCase):
for c in cmds: for c in cmds:
result = ssh_client.execute(c) result = ssh_client.execute(c)
uuids.append(result) uuids.append(result)
# Unmount the Sec Storage # Unmount the Sec Storage
cmds = [ cmds = [
@ -994,7 +995,7 @@ class TestSnapshotDetachedDisk(cloudstackTestCase):
except Exception as e: except Exception as e:
self.fail("SSH failed for management server: %s" % self.fail("SSH failed for management server: %s" %
self.services["mgmt_server"]["ipaddress"]) self.services["mgmt_server"]["ipaddress"])
res = str(uuids) res = str(uuids)
self.assertEqual( self.assertEqual(
res.count(snapshot_uuid), res.count(snapshot_uuid),
@ -1076,15 +1077,15 @@ class TestSnapshotLimit(cloudstackTestCase):
def test_04_snapshot_limit(self): def test_04_snapshot_limit(self):
"""Test snapshot limit in snapshot policies """Test snapshot limit in snapshot policies
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. Perform hourly recurring snapshot on the root disk of VM and keep # 1. Perform hourly recurring snapshot on the root disk of VM and keep
# the maxsnapshots as 1 # the maxsnapshots as 1
# 2. listSnapshots should list the snapshot that was created # 2. listSnapshots should list the snapshot that was created
# snapshot folder in secondary storage should contain only one # snapshot folder in secondary storage should contain only one
# snapshot image(/secondary/snapshots/$accountid/$volumeid/) # snapshot image(/secondary/snapshots/$accountid/$volumeid/)
# Get the Root disk of VM # Get the Root disk of VM
volumes = list_volumes( volumes = list_volumes(
self.apiclient, self.apiclient,
virtualmachineid=self.virtual_machine.id, virtualmachineid=self.virtual_machine.id,
@ -1116,7 +1117,7 @@ class TestSnapshotLimit(cloudstackTestCase):
True, True,
"Check list response returns a valid list" "Check list response returns a valid list"
) )
self.assertNotEqual( self.assertNotEqual(
snapshot_policy, snapshot_policy,
None, None,
@ -1148,7 +1149,7 @@ class TestSnapshotLimit(cloudstackTestCase):
snapshottype='RECURRING', snapshottype='RECURRING',
listall=True listall=True
) )
self.assertEqual( self.assertEqual(
isinstance(snapshots, list), isinstance(snapshots, list),
True, True,
@ -1159,7 +1160,7 @@ class TestSnapshotLimit(cloudstackTestCase):
self.services["recurring_snapshot"]["maxsnaps"], self.services["recurring_snapshot"]["maxsnaps"],
"Check maximum number of recurring snapshots retained" "Check maximum number of recurring snapshots retained"
) )
snapshot = snapshots[0] snapshot = snapshots[0]
# Sleep to ensure that snapshot is reflected in sec storage # Sleep to ensure that snapshot is reflected in sec storage
time.sleep(self.services["sleep"]) time.sleep(self.services["sleep"])
@ -1328,13 +1329,13 @@ class TestSnapshotEvents(cloudstackTestCase):
def test_05_snapshot_events(self): def test_05_snapshot_events(self):
"""Test snapshot events """Test snapshot events
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. Perform snapshot on the root disk of this VM and check the events/alerts. # 1. Perform snapshot on the root disk of this VM and check the events/alerts.
# 2. delete the snapshots and check the events/alerts # 2. delete the snapshots and check the events/alerts
# 3. listEvents() shows created/deleted snapshot events # 3. listEvents() shows created/deleted snapshot events
# Get the Root disk of VM # Get the Root disk of VM
volumes = list_volumes( volumes = list_volumes(
self.apiclient, self.apiclient,
virtualmachineid=self.virtual_machine.id, virtualmachineid=self.virtual_machine.id,

View File

@ -49,8 +49,8 @@ class Services:
"name": "Tiny Instance", "name": "Tiny Instance",
"displaytext": "Tiny Instance", "displaytext": "Tiny Instance",
"cpunumber": 1, "cpunumber": 1,
"cpuspeed": 100, # in MHz "cpuspeed": 100, # in MHz
"memory": 64, # In MBs "memory": 64, # In MBs
}, },
"disk_offering": { "disk_offering": {
"displaytext": "Small", "displaytext": "Small",
@ -71,15 +71,15 @@ class Services:
"diskname": "Test Volume", "diskname": "Test Volume",
}, },
"templates": { "templates": {
# Configs for different Template formats # Configs for different Template formats
# For Eg. raw image, zip etc # For Eg. raw image, zip etc
0:{ 0: {
"displaytext": "Public Template", "displaytext": "Public Template",
"name": "Public template", "name": "Public template",
"ostypeid": '5776c0d2-f331-42db-ba3a-29f1f8319bc9', "ostypeid": '5776c0d2-f331-42db-ba3a-29f1f8319bc9',
"url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2", "url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2",
"hypervisor": 'XenServer', "hypervisor": 'XenServer',
"format" : 'VHD', "format": 'VHD',
"isfeatured": True, "isfeatured": True,
"ispublic": True, "ispublic": True,
"isextractable": True, "isextractable": True,
@ -92,11 +92,11 @@ class Services:
"templatefilter": 'self', "templatefilter": 'self',
}, },
"templatefilter": 'self', "templatefilter": 'self',
"destzoneid": 2, # For Copy template (Destination zone) "destzoneid": 2, # For Copy template (Destination zone)
"ostypeid": '5776c0d2-f331-42db-ba3a-29f1f8319bc9', "ostypeid": '5776c0d2-f331-42db-ba3a-29f1f8319bc9',
"sleep": 60, "sleep": 60,
"timeout": 10, "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): def test_01_create_template(self):
"""Test create public & private template """Test create public & private template
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following: # Validate the following:
# 1. Upload a templates in raw img format. Create a Vm instances from # 1. Upload a templates in raw img format. Create a Vm instances from
# raw img template. # raw img template.
@ -212,7 +212,7 @@ class TestCreateTemplate(cloudstackTestCase):
break break
elif timeout == 0: elif timeout == 0:
raise Exception("List template failed!") raise Exception("List template failed!")
time.sleep(5) time.sleep(5)
timeout = timeout - 1 timeout = timeout - 1
#Verify template response to check whether template added successfully #Verify template response to check whether template added successfully
@ -221,13 +221,13 @@ class TestCreateTemplate(cloudstackTestCase):
True, True,
"Check for list template response return valid data" "Check for list template response return valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(list_template_response), len(list_template_response),
0, 0,
"Check template available in List Templates" "Check template available in List Templates"
) )
template_response = list_template_response[0] template_response = list_template_response[0]
self.assertEqual( self.assertEqual(
template_response.isready, template_response.isready,
@ -314,10 +314,10 @@ class TestTemplates(cloudstackTestCase):
#Stop virtual machine #Stop virtual machine
cls.virtual_machine.stop(cls.api_client) cls.virtual_machine.stop(cls.api_client)
timeout = cls.services["timeout"] timeout = cls.services["timeout"]
#Wait before server has be successfully stopped #Wait before server has be successfully stopped
time.sleep(cls.services["sleep"]) time.sleep(cls.services["sleep"])
while True: while True:
list_volume = list_volumes( list_volume = list_volumes(
cls.api_client, cls.api_client,
@ -329,10 +329,10 @@ class TestTemplates(cloudstackTestCase):
break break
elif timeout == 0: elif timeout == 0:
raise Exception("List volumes failed.") raise Exception("List volumes failed.")
time.sleep(5) time.sleep(5)
timeout = timeout -1 timeout = timeout - 1
cls.volume = list_volume[0] cls.volume = list_volume[0]
#Create template from volume #Create template from volume
@ -378,7 +378,7 @@ class TestTemplates(cloudstackTestCase):
def test_01_create_template_volume(self): def test_01_create_template_volume(self):
"""Test Create template from volume """Test Create template from volume
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following: # Validate the following:
# 1. Deploy new VM using the template created from Volume # 1. Deploy new VM using the template created from Volume
@ -392,7 +392,7 @@ class TestTemplates(cloudstackTestCase):
domainid=self.account.account.domainid, domainid=self.account.account.domainid,
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
) )
self.debug("creating an instance with template ID: %s" % self.template.id) self.debug("creating an instance with template ID: %s" % self.template.id)
self.cleanup.append(virtual_machine) self.cleanup.append(virtual_machine)
vm_response = list_virtual_machines( vm_response = list_virtual_machines(
@ -417,12 +417,12 @@ class TestTemplates(cloudstackTestCase):
def test_02_copy_template(self): def test_02_copy_template(self):
"""Test for copy template from one zone to another""" """Test for copy template from one zone to another"""
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. copy template should be successful and # 1. copy template should be successful and
# secondary storage should contain new copied template. # secondary storage should contain new copied template.
self.debug( self.debug(
"Copying template from zone: %s to %s" % ( "Copying template from zone: %s to %s" % (
self.template.id, self.template.id,
@ -447,7 +447,7 @@ class TestTemplates(cloudstackTestCase):
True, True,
"Check for list template response return valid list" "Check for list template response return valid list"
) )
self.assertNotEqual( self.assertNotEqual(
len(list_template_response), len(list_template_response),
0, 0,
@ -476,7 +476,7 @@ class TestTemplates(cloudstackTestCase):
def test_03_delete_template(self): def test_03_delete_template(self):
"""Test Delete template """Test Delete template
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following: # Validate the following:
# 1. Create a template and verify it is shown in list templates response # 1. Create a template and verify it is shown in list templates response
@ -495,7 +495,7 @@ class TestTemplates(cloudstackTestCase):
True, True,
"Check for list template response return valid list" "Check for list template response return valid list"
) )
self.assertNotEqual( self.assertNotEqual(
len(list_template_response), len(list_template_response),
0, 0,
@ -508,12 +508,12 @@ class TestTemplates(cloudstackTestCase):
self.template.id, self.template.id,
"Check display text of updated template" "Check display text of updated template"
) )
self.debug("Deleting template: %s" % self.template) self.debug("Deleting template: %s" % self.template)
# Delete the template # Delete the template
self.template.delete(self.apiclient) self.template.delete(self.apiclient)
self.debug("Delete template: %s successful" % self.template) self.debug("Delete template: %s successful" % self.template)
list_template_response = list_templates( list_template_response = list_templates(
self.apiclient, self.apiclient,
templatefilter=\ templatefilter=\
@ -531,7 +531,7 @@ class TestTemplates(cloudstackTestCase):
def test_04_template_from_snapshot(self): def test_04_template_from_snapshot(self):
"""Create Template from snapshot """Create Template from snapshot
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 2. Snapshot the Root disk # 2. Snapshot the Root disk
@ -546,7 +546,7 @@ class TestTemplates(cloudstackTestCase):
listall=True listall=True
) )
volume = volumes[0] volume = volumes[0]
self.debug("Creating a snapshot from volume: %s" % volume.id) self.debug("Creating a snapshot from volume: %s" % volume.id)
#Create a snapshot of volume #Create a snapshot of volume
snapshot = Snapshot.create( snapshot = Snapshot.create(

View File

@ -26,6 +26,7 @@ from integration.lib.common import *
from marvin.remoteSSHClient import remoteSSHClient from marvin.remoteSSHClient import remoteSSHClient
import datetime import datetime
class Services: class Services:
"""Test Snapshots Services """Test Snapshots Services
""" """
@ -103,7 +104,7 @@ class Services:
# Cent OS 5.3 (64 bit) # Cent OS 5.3 (64 bit)
"sleep": 60, "sleep": 60,
"timeout": 10, "timeout": 10,
"mode":'advanced' "mode": 'advanced'
} }
@ -192,16 +193,16 @@ class TestVmUsage(cloudstackTestCase):
self.debug("Stopping the VM: %s" % self.virtual_machine.id) self.debug("Stopping the VM: %s" % self.virtual_machine.id)
# Stop the VM # Stop the VM
self.virtual_machine.stop(self.apiclient) self.virtual_machine.stop(self.apiclient)
time.sleep(self.services["sleep"]) time.sleep(self.services["sleep"])
# Destroy the VM # Destroy the VM
self.debug("Destroying the VM: %s" % self.virtual_machine.id) self.debug("Destroying the VM: %s" % self.virtual_machine.id)
self.virtual_machine.delete(self.apiclient) 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.debug("select id from account where uuid = '%s';" \
% self.account.account.id) % self.account.account.id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select id from account where uuid = '%s';" \ "select id from account where uuid = '%s';" \
% self.account.account.id % self.account.account.id
@ -211,7 +212,7 @@ class TestVmUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -222,7 +223,7 @@ class TestVmUsage(cloudstackTestCase):
account_id = qresult[0] account_id = qresult[0]
self.debug("select type from usage_event where account_id = '%s';" \ self.debug("select type from usage_event where account_id = '%s';" \
% account_id) % account_id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select type from usage_event where account_id = '%s';" \ "select type from usage_event where account_id = '%s';" \
% account_id % account_id
@ -232,7 +233,7 @@ class TestVmUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -368,7 +369,7 @@ class TestPublicIPUsage(cloudstackTestCase):
return return
def test_01_public_ip_usage(self): 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 # Validate the following
@ -378,16 +379,16 @@ class TestPublicIPUsage(cloudstackTestCase):
# has IP.Release event for released IP for this account # has IP.Release event for released IP for this account
# 3. Delete the newly created account # 3. Delete the newly created account
self.debug("Deleting public IP: %s" % self.debug("Deleting public IP: %s" %
self.public_ip.ipaddress.ipaddress) self.public_ip.ipaddress.ipaddress)
# Release one of the IP # Release one of the IP
self.public_ip.delete(self.apiclient) 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.debug("select id from account where uuid = '%s';" \
% self.account.account.id) % self.account.account.id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select id from account where uuid = '%s';" \ "select id from account where uuid = '%s';" \
% self.account.account.id % self.account.account.id
@ -407,12 +408,12 @@ class TestPublicIPUsage(cloudstackTestCase):
account_id = qresult[0] account_id = qresult[0]
self.debug("select type from usage_event where account_id = '%s';" \ self.debug("select type from usage_event where account_id = '%s';" \
% account_id) % account_id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select type from usage_event where account_id = '%s';" \ "select type from usage_event where account_id = '%s';" \
% account_id % account_id
) )
self.assertEqual( self.assertEqual(
isinstance(qresultset, list), isinstance(qresultset, list),
True, True,
@ -537,8 +538,8 @@ class TestVolumeUsage(cloudstackTestCase):
listall=True listall=True
) )
self.assertEqual( self.assertEqual(
isinstance(volume_response, list), isinstance(volume_response, list),
True, True,
"Check for valid list volumes response" "Check for valid list volumes response"
) )
data_volume = volume_response[0] data_volume = volume_response[0]
@ -556,10 +557,10 @@ class TestVolumeUsage(cloudstackTestCase):
cmd.id = data_volume.id cmd.id = data_volume.id
self.apiclient.deleteVolume(cmd) 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.debug("select id from account where uuid = '%s';" \
% self.account.account.id) % self.account.account.id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select id from account where uuid = '%s';" \ "select id from account where uuid = '%s';" \
% self.account.account.id % self.account.account.id
@ -569,7 +570,7 @@ class TestVolumeUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -580,12 +581,12 @@ class TestVolumeUsage(cloudstackTestCase):
account_id = qresult[0] account_id = qresult[0]
self.debug("select type from usage_event where account_id = '%s';" \ self.debug("select type from usage_event where account_id = '%s';" \
% account_id) % account_id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select type from usage_event where account_id = '%s';" \ "select type from usage_event where account_id = '%s';" \
% account_id % account_id
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -596,7 +597,7 @@ class TestVolumeUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
qresult = str(qresultset) qresult = str(qresultset)
self.debug("Query result: %s" % qresult) self.debug("Query result: %s" % qresult)
# Check VOLUME.CREATE, VOLUME.DESTROY events in cloud.usage_event table # Check VOLUME.CREATE, VOLUME.DESTROY events in cloud.usage_event table
@ -663,7 +664,7 @@ class TestTemplateUsage(cloudstackTestCase):
type='ROOT', type='ROOT',
listall=True listall=True
) )
if isinstance(list_volume, list): if isinstance(list_volume, list):
cls.volume = list_volume[0] cls.volume = list_volume[0]
else: else:
raise Exception("List Volumes failed!") raise Exception("List Volumes failed!")
@ -719,10 +720,10 @@ class TestTemplateUsage(cloudstackTestCase):
self.template.delete(self.apiclient) self.template.delete(self.apiclient)
self.debug("Deleted template with ID: %s" % self.template.id) 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.debug("select id from account where uuid = '%s';" \
% self.account.account.id) % self.account.account.id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select id from account where uuid = '%s';" \ "select id from account where uuid = '%s';" \
% self.account.account.id % self.account.account.id
@ -732,7 +733,7 @@ class TestTemplateUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -743,7 +744,7 @@ class TestTemplateUsage(cloudstackTestCase):
account_id = qresult[0] account_id = qresult[0]
self.debug("select type from usage_event where account_id = '%s';" \ self.debug("select type from usage_event where account_id = '%s';" \
% account_id) % account_id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select type from usage_event where account_id = '%s';" \ "select type from usage_event where account_id = '%s';" \
% account_id % account_id
@ -759,10 +760,10 @@ class TestTemplateUsage(cloudstackTestCase):
0, 0,
"Check DB Query result set" "Check DB Query result set"
) )
qresult = str(qresultset) qresult = str(qresultset)
self.debug("Query result: %s" % qresult) self.debug("Query result: %s" % qresult)
# Check for TEMPLATE.CREATE, TEMPLATE.DELETE in cloud.usage_event table # Check for TEMPLATE.CREATE, TEMPLATE.DELETE in cloud.usage_event table
self.assertEqual( self.assertEqual(
qresult.count('TEMPLATE.CREATE'), qresult.count('TEMPLATE.CREATE'),
@ -789,7 +790,7 @@ class TestISOUsage(cloudstackTestCase):
cls.zone = get_zone(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services)
cls.services["server"]["zoneid"] = cls.zone.id cls.services["server"]["zoneid"] = cls.zone.id
cls.services["iso"]["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.account = Account.create(
cls.api_client, cls.api_client,
cls.services["account"], cls.services["account"],
@ -853,11 +854,11 @@ class TestISOUsage(cloudstackTestCase):
# Delete the ISO # Delete the ISO
self.debug("Deleting ISO with ID: %s" % self.iso.id) self.debug("Deleting ISO with ID: %s" % self.iso.id)
self.iso.delete(self.apiclient) 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.debug("select id from account where uuid = '%s';" \
% self.account.account.id) % self.account.account.id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select id from account where uuid = '%s';" \ "select id from account where uuid = '%s';" \
% self.account.account.id % self.account.account.id
@ -867,7 +868,7 @@ class TestISOUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -878,18 +879,18 @@ class TestISOUsage(cloudstackTestCase):
account_id = qresult[0] account_id = qresult[0]
self.debug("select type from usage_event where account_id = '%s';" \ self.debug("select type from usage_event where account_id = '%s';" \
% account_id) % account_id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select type from usage_event where account_id = '%s';" \ "select type from usage_event where account_id = '%s';" \
% account_id % account_id
) )
self.assertEqual( self.assertEqual(
isinstance(qresultset, list), isinstance(qresultset, list),
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -1002,7 +1003,7 @@ class TestLBRuleUsage(cloudstackTestCase):
# 4. Delete this account. # 4. Delete this account.
self.debug( self.debug(
"Creating load balancer rule for public IP: %s" % "Creating load balancer rule for public IP: %s" %
self.public_ip_1.ipaddress.id) self.public_ip_1.ipaddress.id)
#Create Load Balancer rule and assign VMs to rule #Create Load Balancer rule and assign VMs to rule
lb_rule = LoadBalancerRule.create( lb_rule = LoadBalancerRule.create(
@ -1015,10 +1016,10 @@ class TestLBRuleUsage(cloudstackTestCase):
self.debug("Deleting LB rule with ID: %s" % lb_rule.id) self.debug("Deleting LB rule with ID: %s" % lb_rule.id)
lb_rule.delete(self.apiclient) 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.debug("select id from account where uuid = '%s';" \
% self.account.account.id) % self.account.account.id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select id from account where uuid = '%s';" \ "select id from account where uuid = '%s';" \
% self.account.account.id % self.account.account.id
@ -1028,7 +1029,7 @@ class TestLBRuleUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -1039,7 +1040,7 @@ class TestLBRuleUsage(cloudstackTestCase):
account_id = qresult[0] account_id = qresult[0]
self.debug("select type from usage_event where account_id = '%s';" \ self.debug("select type from usage_event where account_id = '%s';" \
% account_id) % account_id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select type from usage_event where account_id = '%s';" \ "select type from usage_event where account_id = '%s';" \
% account_id % account_id
@ -1060,7 +1061,7 @@ class TestLBRuleUsage(cloudstackTestCase):
qresult = str(qresultset) qresult = str(qresultset)
self.debug("Query result: %s" % qresult) 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( self.assertEqual(
qresult.count('LB.CREATE'), qresult.count('LB.CREATE'),
1, 1,
@ -1146,7 +1147,7 @@ class TestSnapshotUsage(cloudstackTestCase):
def test_01_snapshot_usage(self): def test_01_snapshot_usage(self):
"""Test Create/Delete a manual snap shot and verify """Test Create/Delete a manual snap shot and verify
correct usage is recorded correct usage is recorded
""" """
# Validate the following # Validate the following
@ -1156,7 +1157,7 @@ class TestSnapshotUsage(cloudstackTestCase):
# generated for the destroyed Snapshot # generated for the destroyed Snapshot
# 3. Delete the account # 3. Delete the account
# Get the Root disk of VM # Get the Root disk of VM
volumes = list_volumes( volumes = list_volumes(
self.apiclient, self.apiclient,
virtualmachineid=self.virtual_machine.id, virtualmachineid=self.virtual_machine.id,
@ -1168,7 +1169,7 @@ class TestSnapshotUsage(cloudstackTestCase):
True, True,
"Check if list volumes return a valid data" "Check if list volumes return a valid data"
) )
volume = volumes[0] volume = volumes[0]
# Create a snapshot from the ROOTDISK # Create a snapshot from the ROOTDISK
@ -1179,10 +1180,10 @@ class TestSnapshotUsage(cloudstackTestCase):
self.debug("Deleting snapshot: %s" % snapshot.id) self.debug("Deleting snapshot: %s" % snapshot.id)
snapshot.delete(self.apiclient) 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.debug("select id from account where uuid = '%s';" \
% self.account.account.id) % self.account.account.id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select id from account where uuid = '%s';" \ "select id from account where uuid = '%s';" \
% self.account.account.id % self.account.account.id
@ -1192,7 +1193,7 @@ class TestSnapshotUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -1203,12 +1204,12 @@ class TestSnapshotUsage(cloudstackTestCase):
account_id = qresult[0] account_id = qresult[0]
self.debug("select type from usage_event where account_id = '%s';" \ self.debug("select type from usage_event where account_id = '%s';" \
% account_id) % account_id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select type from usage_event where account_id = '%s';" \ "select type from usage_event where account_id = '%s';" \
% account_id % account_id
) )
self.assertEqual( self.assertEqual(
isinstance(qresultset, list), isinstance(qresultset, list),
True, True,
@ -1318,7 +1319,11 @@ class TestNatRuleUsage(cloudstackTestCase):
def test_01_nat_usage(self): def test_01_nat_usage(self):
"""Test Create/Delete a PF rule and verify correct usage is recorded """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 # Validate the following
# 1. Acquire a IP for this account # 1. Acquire a IP for this account
# 2. Create a PF rule on the IP associated with 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 # is registered for this account in cloud.usage_event table
# 4. Delete this account. # 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) self.public_ip_1.ipaddress.id)
#Create NAT rule #Create NAT rule
nat_rule = NATRule.create( nat_rule = NATRule.create(
@ -1342,10 +1347,10 @@ class TestNatRuleUsage(cloudstackTestCase):
self.debug("Deleting NAT rule: %s" % nat_rule.id) self.debug("Deleting NAT rule: %s" % nat_rule.id)
nat_rule.delete(self.apiclient) 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.debug("select id from account where uuid = '%s';" \
% self.account.account.id) % self.account.account.id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select id from account where uuid = '%s';" \ "select id from account where uuid = '%s';" \
% self.account.account.id % self.account.account.id
@ -1355,7 +1360,7 @@ class TestNatRuleUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -1366,7 +1371,7 @@ class TestNatRuleUsage(cloudstackTestCase):
account_id = qresult[0] account_id = qresult[0]
self.debug("select type from usage_event where account_id = '%s';" \ self.debug("select type from usage_event where account_id = '%s';" \
% account_id) % account_id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select type from usage_event where account_id = '%s';" \ "select type from usage_event where account_id = '%s';" \
% account_id % account_id
@ -1484,12 +1489,12 @@ class TestVpnUsage(cloudstackTestCase):
# Validate the following # Validate the following
# 1. Enable VPN for this IP. vpn.add.user event is registered for this # 1. Enable VPN for this IP. vpn.add.user event is registered for this
# account in cloud.usage_event table # 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 # 3. Delete user for this VPN. vpn.user.delete event is registered for
# this account in cloud.usage_event table # this account in cloud.usage_event table
# 4. Delete this account. # 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) self.public_ip.ipaddress.id)
#Assign VPN to Public IP #Assign VPN to Public IP
vpn = Vpn.create( vpn = Vpn.create(
@ -1499,7 +1504,7 @@ class TestVpnUsage(cloudstackTestCase):
domainid=self.account.account.domainid 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) self.account.account.name)
vpnuser = VpnUser.create( vpnuser = VpnUser.create(
@ -1518,10 +1523,10 @@ class TestVpnUsage(cloudstackTestCase):
self.debug("Deleting VPN: %s" % vpn.publicipid) self.debug("Deleting VPN: %s" % vpn.publicipid)
vpn.delete(self.apiclient) 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.debug("select id from account where uuid = '%s';" \
% self.account.account.id) % self.account.account.id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select id from account where uuid = '%s';" \ "select id from account where uuid = '%s';" \
% self.account.account.id % self.account.account.id
@ -1531,7 +1536,7 @@ class TestVpnUsage(cloudstackTestCase):
True, True,
"Check DB query result set for valid data" "Check DB query result set for valid data"
) )
self.assertNotEqual( self.assertNotEqual(
len(qresultset), len(qresultset),
0, 0,
@ -1542,7 +1547,7 @@ class TestVpnUsage(cloudstackTestCase):
account_id = qresult[0] account_id = qresult[0]
self.debug("select type from usage_event where account_id = '%s';" \ self.debug("select type from usage_event where account_id = '%s';" \
% account_id) % account_id)
qresultset = self.dbclient.execute( qresultset = self.dbclient.execute(
"select type from usage_event where account_id = '%s';" \ "select type from usage_event where account_id = '%s';" \
% account_id % account_id
@ -1561,8 +1566,8 @@ class TestVpnUsage(cloudstackTestCase):
qresult = str(qresultset) qresult = str(qresultset)
self.debug("Query result: %s" % qresult) self.debug("Query result: %s" % qresult)
# Check for VPN user related events # Check for VPN user related events
self.assertEqual( self.assertEqual(
qresult.count('VPN.USER.ADD'), qresult.count('VPN.USER.ADD'),
1, 1,

View File

@ -50,8 +50,8 @@ class Services:
"name": "Tiny Instance", "name": "Tiny Instance",
"displaytext": "Tiny Instance", "displaytext": "Tiny Instance",
"cpunumber": 1, "cpunumber": 1,
"cpuspeed": 100, # in MHz "cpuspeed": 100, # in MHz
"memory": 64, # In MBs "memory": 64, # In MBs
}, },
"disk_offering": { "disk_offering": {
"displaytext": "Small", "displaytext": "Small",
@ -143,7 +143,7 @@ class TestAttachVolume(cloudstackTestCase):
def test_01_volume_attach(self): def test_01_volume_attach(self):
"""Test Attach volumes (max capacity) """Test Attach volumes (max capacity)
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. Deploy a vm and create 5 data disk # 1. Deploy a vm and create 5 data disk
# 2. Attach all the created Volume to the vm. # 2. Attach all the created Volume to the vm.
@ -163,7 +163,7 @@ class TestAttachVolume(cloudstackTestCase):
) )
self.debug("Created volume: %s for account: %s" % ( self.debug("Created volume: %s for account: %s" % (
volume.id, volume.id,
self.account.account.name self.account.account.name
)) ))
# Check List Volume response for newly created volume # Check List Volume response for newly created volume
list_volume_response = list_volumes( list_volume_response = list_volumes(
@ -182,7 +182,7 @@ class TestAttachVolume(cloudstackTestCase):
) )
self.debug("Attach volume: %s to VM: %s" % ( self.debug("Attach volume: %s to VM: %s" % (
volume.id, volume.id,
self.virtual_machine.id self.virtual_machine.id
)) ))
# Check all volumes attached to same VM # Check all volumes attached to same VM
list_volume_response = list_volumes( list_volume_response = list_volumes(
@ -196,7 +196,7 @@ class TestAttachVolume(cloudstackTestCase):
True, True,
"Check list volumes response for valid list" "Check list volumes response for valid list"
) )
self.assertNotEqual( self.assertNotEqual(
list_volume_response, list_volume_response,
None, None,
@ -246,7 +246,7 @@ class TestAttachVolume(cloudstackTestCase):
True, True,
"Check list VM response for valid list" "Check list VM response for valid list"
) )
#Verify VM response to check whether VM deployment was successful #Verify VM response to check whether VM deployment was successful
self.assertNotEqual( self.assertNotEqual(
len(vm_response), len(vm_response),
@ -276,7 +276,7 @@ class TestAttachVolume(cloudstackTestCase):
True, True,
"Check list VM response for valid list" "Check list VM response for valid list"
) )
#Verify VM response to check whether VM deployment was successful #Verify VM response to check whether VM deployment was successful
self.assertNotEqual( self.assertNotEqual(
len(vm_response), len(vm_response),
@ -295,7 +295,7 @@ class TestAttachVolume(cloudstackTestCase):
def test_02_volume_attach_max(self): def test_02_volume_attach_max(self):
"""Test attach volumes (more than max) to an instance """Test attach volumes (more than max) to an instance
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. Attach one more data volume to VM (Already 5 attached) # 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" % ( self.debug("Created volume: %s for account: %s" % (
volume.id, volume.id,
self.account.account.name self.account.account.name
)) ))
# Check List Volume response for newly created volume # Check List Volume response for newly created volume
list_volume_response = list_volumes( list_volume_response = list_volumes(
@ -324,7 +324,7 @@ class TestAttachVolume(cloudstackTestCase):
True, True,
"Check list volumes response for valid list" "Check list volumes response for valid list"
) )
self.assertNotEqual( self.assertNotEqual(
list_volume_response, list_volume_response,
None, None,
@ -334,7 +334,7 @@ class TestAttachVolume(cloudstackTestCase):
with self.assertRaises(Exception): with self.assertRaises(Exception):
self.debug("Trying to Attach volume: %s to VM: %s" % ( self.debug("Trying to Attach volume: %s to VM: %s" % (
volume.id, volume.id,
self.virtual_machine.id self.virtual_machine.id
)) ))
self.virtual_machine.attach_volume( self.virtual_machine.attach_volume(
self.apiclient, self.apiclient,
@ -426,7 +426,7 @@ class TestAttachDetachVolume(cloudstackTestCase):
def test_01_volume_attach_detach(self): def test_01_volume_attach_detach(self):
"""Test Volume attach/detach to VM (5 data volumes) """Test Volume attach/detach to VM (5 data volumes)
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. Deploy a vm and create 5 data disk # 1. Deploy a vm and create 5 data disk
@ -449,7 +449,7 @@ class TestAttachDetachVolume(cloudstackTestCase):
) )
self.debug("Created volume: %s for account: %s" % ( self.debug("Created volume: %s for account: %s" % (
volume.id, volume.id,
self.account.account.name self.account.account.name
)) ))
self.cleanup.append(volume) self.cleanup.append(volume)
volumes.append(volume) volumes.append(volume)
@ -464,7 +464,7 @@ class TestAttachDetachVolume(cloudstackTestCase):
True, True,
"Check list volumes response for valid list" "Check list volumes response for valid list"
) )
self.assertNotEqual( self.assertNotEqual(
list_volume_response, list_volume_response,
None, None,
@ -472,7 +472,7 @@ class TestAttachDetachVolume(cloudstackTestCase):
) )
self.debug("Attach volume: %s to VM: %s" % ( self.debug("Attach volume: %s to VM: %s" % (
volume.id, volume.id,
self.virtual_machine.id self.virtual_machine.id
)) ))
# Attach volume to VM # Attach volume to VM
self.virtual_machine.attach_volume( self.virtual_machine.attach_volume(
@ -492,7 +492,7 @@ class TestAttachDetachVolume(cloudstackTestCase):
True, True,
"Check list volumes response for valid list" "Check list volumes response for valid list"
) )
self.assertNotEqual( self.assertNotEqual(
list_volume_response, list_volume_response,
None, None,
@ -508,7 +508,7 @@ class TestAttachDetachVolume(cloudstackTestCase):
for volume in volumes: for volume in volumes:
self.debug("Detach volume: %s to VM: %s" % ( self.debug("Detach volume: %s to VM: %s" % (
volume.id, volume.id,
self.virtual_machine.id self.virtual_machine.id
)) ))
self.virtual_machine.detach_volume( self.virtual_machine.detach_volume(
self.apiclient, self.apiclient,
@ -530,7 +530,7 @@ class TestAttachDetachVolume(cloudstackTestCase):
True, True,
"Check list VM response for valid list" "Check list VM response for valid list"
) )
self.assertNotEqual( self.assertNotEqual(
len(vm_response), len(vm_response),
0, 0,
@ -542,7 +542,7 @@ class TestAttachDetachVolume(cloudstackTestCase):
'Running', 'Running',
"Check the state of VM" "Check the state of VM"
) )
# Stop VM # Stop VM
self.debug("Stopping the VM: %s" % self.virtual_machine.id) self.debug("Stopping the VM: %s" % self.virtual_machine.id)
self.virtual_machine.stop(self.apiclient) self.virtual_machine.stop(self.apiclient)
@ -674,7 +674,7 @@ class TestAttachVolumeISO(cloudstackTestCase):
def test_01_volume_iso_attach(self): def test_01_volume_iso_attach(self):
"""Test Volumes and ISO attach """Test Volumes and ISO attach
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. Create and attach 5 data volumes to VM # 1. Create and attach 5 data volumes to VM
@ -693,7 +693,7 @@ class TestAttachVolumeISO(cloudstackTestCase):
) )
self.debug("Created volume: %s for account: %s" % ( self.debug("Created volume: %s for account: %s" % (
volume.id, volume.id,
self.account.account.name self.account.account.name
)) ))
# Check List Volume response for newly created volume # Check List Volume response for newly created volume
list_volume_response = list_volumes( list_volume_response = list_volumes(
@ -746,7 +746,7 @@ class TestAttachVolumeISO(cloudstackTestCase):
domainid=self.account.account.domainid, domainid=self.account.account.domainid,
) )
self.debug("Created ISO with ID: %s for account: %s" % ( self.debug("Created ISO with ID: %s for account: %s" % (
iso.id, iso.id,
self.account.account.name self.account.account.name
)) ))
@ -778,7 +778,7 @@ class TestAttachVolumeISO(cloudstackTestCase):
True, True,
"Check list VM response for valid list" "Check list VM response for valid list"
) )
self.assertNotEqual( self.assertNotEqual(
len(vm_response), len(vm_response),
0, 0,
@ -870,7 +870,7 @@ class TestVolumes(cloudstackTestCase):
def test_01_attach_volume(self): def test_01_attach_volume(self):
"""Attach a created Volume to a Running VM """Attach a created Volume to a Running VM
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. Create a data volume. # 1. Create a data volume.
# 2. List Volumes should not have vmname and virtualmachineid fields in # 2. List Volumes should not have vmname and virtualmachineid fields in
@ -954,7 +954,7 @@ class TestVolumes(cloudstackTestCase):
def test_02_detach_volume(self): def test_02_detach_volume(self):
"""Detach a Volume attached to a VM """Detach a Volume attached to a VM
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. Data disk should be detached from instance # 1. Data disk should be detached from instance
@ -979,7 +979,7 @@ class TestVolumes(cloudstackTestCase):
True, True,
"Check list volumes response for valid list" "Check list volumes response for valid list"
) )
self.assertNotEqual( self.assertNotEqual(
list_volume_response, list_volume_response,
None, None,
@ -1002,7 +1002,7 @@ class TestVolumes(cloudstackTestCase):
def test_03_delete_detached_volume(self): def test_03_delete_detached_volume(self):
"""Delete a Volume unattached to an VM """Delete a Volume unattached to an VM
""" """
tags = ["advanced","advancedns"] tags = ["advanced", "advancedns"]
# Validate the following # Validate the following
# 1. volume should be deleted successfully and listVolume should not # 1. volume should be deleted successfully and listVolume should not
# contain the deleted volume details. # contain the deleted volume details.