Fix tab/space issues

Several test failures occurred due to tab issues

Signed-off-by: Prasanna Santhanam <tsp@apache.org>
This commit is contained in:
Prasanna Santhanam 2013-06-30 13:20:27 +05:30
parent 2a51c3e2c9
commit c7315975d2
8 changed files with 409 additions and 482 deletions

View File

@ -304,15 +304,14 @@ class TestListAffinityGroups(cloudstackTestCase):
def tearDown(self): def tearDown(self):
try: try:
cls.api_client = super(TestListAffinityGroups, cls).getClsTestClient().getApiClient() self.api_client = super(TestListAffinityGroups, self).getClsTestClient().getApiClient()
#Clean up, terminate the created templates #Clean up, terminate the created templates
cleanup_resources(cls.api_client, cls.cleanup) cleanup_resources(self.api_client, self.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)
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: try:
cls.api_client = super(TestListAffinityGroups, cls).getClsTestClient().getApiClient() cls.api_client = super(TestListAffinityGroups, cls).getClsTestClient().getApiClient()
#Clean up, terminate the created templates #Clean up, terminate the created templates
@ -327,10 +326,6 @@ class TestListAffinityGroups(cloudstackTestCase):
api_client = self.api_client api_client = self.api_client
if aff_grp == None: if aff_grp == None:
self.services["host_anti_affinity_0"] self.services["host_anti_affinity_0"]
#if acc == None:
# acc = self.account.name
#if domainid == None:
# domainid = self.domain.id
try: try:
self.aff_grp.append(AffinityGroup.create(api_client, self.aff_grp.append(AffinityGroup.create(api_client,
@ -339,34 +334,25 @@ class TestListAffinityGroups(cloudstackTestCase):
raise Exception("Error: Creation of Affinity Group failed : %s" %e) raise Exception("Error: Creation of Affinity Group failed : %s" %e)
def create_vm_in_aff_grps(self, ag_list): def create_vm_in_aff_grps(self, ag_list):
#try:
self.debug('Creating VM in AffinityGroup=%s' % ag_list[0]) self.debug('Creating VM in AffinityGroup=%s' % ag_list[0])
vm = VirtualMachine.create( vm = VirtualMachine.create(
self.api_client, self.api_client,
self.services["virtual_machine"], self.services["virtual_machine"],
templateid=self.template.id, templateid=self.template.id,
#accountid=self.account.name,
#domainid=self.account.domainid,
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
affinitygroupnames=ag_list affinitygroupnames=ag_list
) )
self.debug('Created VM=%s in Affinity Group=%s' % self.debug('Created VM=%s in Affinity Group=%s' %
(vm.id, ag_list[0])) (vm.id, ag_list[0]))
#except Exception:
#self.debug('Unable to create VM in a Affinity Group=%s'
# % ag_list[0])
list_vm = list_virtual_machines(self.api_client, id=vm.id) list_vm = list_virtual_machines(self.api_client, id=vm.id)
self.assertEqual(isinstance(list_vm, list), True, self.assertEqual(isinstance(list_vm, list), True,
"Check list response returns a valid list") "Check list response returns a valid list")
self.assertNotEqual(len(list_vm),0, self.assertNotEqual(len(list_vm),0,
"Check VM available in List Virtual Machines") "Check VM available in List Virtual Machines")
vm_response = list_vm[0] vm_response = list_vm[0]
self.assertEqual(vm_response.state, 'Running', self.assertEqual(vm_response.state, 'Running',
msg="VM is not in Running state") msg="VM is not in Running state")
return vm, vm_response.hostid return vm, vm_response.hostid
def test_01_list_aff_grps_for_vm(self): def test_01_list_aff_grps_for_vm(self):
@ -543,11 +529,6 @@ class TestDeleteAffinityGroups(cloudstackTestCase):
api_client = self.api_client api_client = self.api_client
if aff_grp == None: if aff_grp == None:
self.services["host_anti_affinity_0"] self.services["host_anti_affinity_0"]
#if acc == None:
# acc = self.account.name
#if domainid == None:
# domainid = self.domain.id
try: try:
self.aff_grp.append(AffinityGroup.create(api_client, self.aff_grp.append(AffinityGroup.create(api_client,
aff_grp, acc, domainid)) aff_grp, acc, domainid))
@ -555,22 +536,16 @@ class TestDeleteAffinityGroups(cloudstackTestCase):
raise Exception("Error: Creation of Affinity Group failed : %s" %e) raise Exception("Error: Creation of Affinity Group failed : %s" %e)
def create_vm_in_aff_grps(self, ag_list): def create_vm_in_aff_grps(self, ag_list):
#try:
self.debug('Creating VM in AffinityGroup=%s' % ag_list[0]) self.debug('Creating VM in AffinityGroup=%s' % ag_list[0])
vm = VirtualMachine.create( vm = VirtualMachine.create(
self.api_client, self.api_client,
self.services["virtual_machine"], self.services["virtual_machine"],
templateid=self.template.id, templateid=self.template.id,
#accountid=self.account.name,
#domainid=self.account.domainid,
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
affinitygroupnames=ag_list affinitygroupnames=ag_list
) )
self.debug('Created VM=%s in Affinity Group=%s' % self.debug('Created VM=%s in Affinity Group=%s' %
(vm.id, ag_list[0])) (vm.id, ag_list[0]))
#except Exception:
#self.debug('Unable to create VM in a Affinity Group=%s'
# % ag_list[0])
list_vm = list_virtual_machines(self.api_client, id=vm.id) list_vm = list_virtual_machines(self.api_client, id=vm.id)
@ -817,11 +792,6 @@ class TestUpdateVMAffinityGroups(cloudstackTestCase):
api_client = self.api_client api_client = self.api_client
if aff_grp == None: if aff_grp == None:
self.services["host_anti_affinity_0"] self.services["host_anti_affinity_0"]
#if acc == None:
# acc = self.account.name
#if domainid == None:
# domainid = self.domain.id
try: try:
self.aff_grp.append(AffinityGroup.create(api_client, self.aff_grp.append(AffinityGroup.create(api_client,
aff_grp, acc, domainid)) aff_grp, acc, domainid))
@ -829,22 +799,16 @@ class TestUpdateVMAffinityGroups(cloudstackTestCase):
raise Exception("Error: Creation of Affinity Group failed : %s" %e) raise Exception("Error: Creation of Affinity Group failed : %s" %e)
def create_vm_in_aff_grps(self, ag_list): def create_vm_in_aff_grps(self, ag_list):
#try:
self.debug('Creating VM in AffinityGroup=%s' % ag_list[0]) self.debug('Creating VM in AffinityGroup=%s' % ag_list[0])
vm = VirtualMachine.create( vm = VirtualMachine.create(
self.api_client, self.api_client,
self.services["virtual_machine"], self.services["virtual_machine"],
templateid=self.template.id, templateid=self.template.id,
#accountid=self.account.name,
#domainid=self.account.domainid,
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
affinitygroupnames=ag_list affinitygroupnames=ag_list
) )
self.debug('Created VM=%s in Affinity Group=%s' % self.debug('Created VM=%s in Affinity Group=%s' %
(vm.id, ag_list[0])) (vm.id, ag_list[0]))
#except Exception:
#self.debug('Unable to create VM in a Affinity Group=%s'
# % ag_list[0])
list_vm = list_virtual_machines(self.api_client, id=vm.id) list_vm = list_virtual_machines(self.api_client, id=vm.id)
@ -996,7 +960,7 @@ class TestUpdateVMAffinityGroups(cloudstackTestCase):
vm1.start(self.api_client) vm1.start(self.api_client)
list_aff_grps = AffinityGroup.list(self.api_client, list_aff_grps = AffinityGroup.list(self.api_client,
virtualmachineid=vm.id) virtualmachineid=vm1.id)
self.assertEqual(list_aff_grps, [], "The affinity groups list is not empyty") self.assertEqual(list_aff_grps, [], "The affinity groups list is not empyty")
vm1.delete(self.api_client) vm1.delete(self.api_client)
@ -1096,10 +1060,6 @@ class TestDeployVMAffinityGroups(cloudstackTestCase):
api_client = self.api_client api_client = self.api_client
if aff_grp == None: if aff_grp == None:
self.services["host_anti_affinity_0"] self.services["host_anti_affinity_0"]
#if acc == None:
# acc = self.account.name
#if domainid == None:
# domainid = self.domain.id
try: try:
self.aff_grp.append(AffinityGroup.create(api_client, self.aff_grp.append(AffinityGroup.create(api_client,
@ -1116,8 +1076,6 @@ class TestDeployVMAffinityGroups(cloudstackTestCase):
api_client, api_client,
self.services["virtual_machine"], self.services["virtual_machine"],
templateid=self.template.id, templateid=self.template.id,
#accountid=self.account.name,
#domainid=self.account.domainid,
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
affinitygroupnames=ag_list, affinitygroupnames=ag_list,
affinitygroupids=ag_ids affinitygroupids=ag_ids
@ -1143,7 +1101,6 @@ class TestDeployVMAffinityGroups(cloudstackTestCase):
""" """
Deploy VM without affinity group Deploy VM without affinity group
""" """
vm1, hostid1 = self.create_vm_in_aff_grps() vm1, hostid1 = self.create_vm_in_aff_grps()
vm1.delete(self.api_client) vm1.delete(self.api_client)
@ -1441,10 +1398,6 @@ class TestAffinityGroupsAdminUser(cloudstackTestCase):
api_client = self.api_client api_client = self.api_client
if aff_grp == None: if aff_grp == None:
self.services["host_anti_affinity_0"] self.services["host_anti_affinity_0"]
#if acc == None:
# acc = self.account.name
#if domainid == None:
# domainid = self.domain.id
try: try:
self.aff_grp.append(AffinityGroup.create(api_client, self.aff_grp.append(AffinityGroup.create(api_client,
@ -1461,8 +1414,6 @@ class TestAffinityGroupsAdminUser(cloudstackTestCase):
api_client, api_client,
self.services["virtual_machine"], self.services["virtual_machine"],
templateid=self.template.id, templateid=self.template.id,
#accountid=self.account.name,
#domainid=self.account.domainid,
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
affinitygroupnames=ag_list, affinitygroupnames=ag_list,
affinitygroupids=ag_ids affinitygroupids=ag_ids

View File

@ -740,7 +740,7 @@ class TestNetScalerDedicated(cloudstackTestCase):
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
networkids=[str(self.network.id)] networkids=[str(self.network.id)]
) )
self.debug("Deply instacne in dedicated Network offering mode failed") self.debug("Deply instance in dedicated Network offering mode failed")
return return

View File

@ -748,18 +748,6 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
account=cls.account.name, account=cls.account.name,
domainid=cls.account.domainid domainid=cls.account.domainid
) )
# cls.assertEqual(
# isinstance(public_ips, list),
# True,
# "List public Ip for network should list the Ip addr"
# )
# cls.assertEqual(
# public_ips[0].ipaddress,
# public_ip_2.ipaddress.ipaddress,
# "List public Ip for network should list the Ip addr"
# )
#
public_ip_3 = PublicIPAddress.create( public_ip_3 = PublicIPAddress.create(
cls.apiclient, cls.apiclient,
accountid=cls.account.name, accountid=cls.account.name,
@ -1031,7 +1019,6 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
self.validate_vpc_offering(self.vpc_off) self.validate_vpc_offering(self.vpc_off)
self.validate_vpc_network(self.vpc) self.validate_vpc_network(self.vpc)
#self.validate_network_rules()
self.assertEqual( self.assertEqual(
isinstance(self.gateways, list), isinstance(self.gateways, list),
True, True,
@ -1354,4 +1341,3 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
"is %s" % (router.serviceofferingid, service_offering.id) "is %s" % (router.serviceofferingid, service_offering.id)
) )
return return

View File

@ -837,13 +837,11 @@ class TestLoadBalancingRule(cloudstackTestCase):
)) ))
self.try_ssh(src_nat_ip_addr, hostnames) self.try_ssh(src_nat_ip_addr, hostnames)
self.assertIn( self.assertIn(
self.vm_1.name, self.vm_1.name,
hostnames, hostnames,
"Check if ssh succeeded for server1" "Check if ssh succeeded for server1"
) )
except Exception as e: except Exception as e:
self.fail("%s: SSH failed for VM with IP Address: %s" % self.fail("%s: SSH failed for VM with IP Address: %s" %
(e, src_nat_ip_addr.ipaddress)) (e, src_nat_ip_addr.ipaddress))
@ -988,15 +986,12 @@ class TestLoadBalancingRule(cloudstackTestCase):
hostnames[:] = [] hostnames[:] = []
self.try_ssh(self.non_src_nat_ip, hostnames) self.try_ssh(self.non_src_nat_ip, hostnames)
self.assertIn( self.assertIn(
self.vm_1.name, self.vm_1.name,
hostnames, hostnames,
"Check if ssh succeeded for server1" "Check if ssh succeeded for server1"
) )
self.debug("Hostnames after removing VM2: %s" % str(hostnames)) self.debug("Hostnames after removing VM2: %s" % str(hostnames))
except Exception as e: except Exception as e:
self.fail("%s: SSH failed for VM with IP Address: %s" % self.fail("%s: SSH failed for VM with IP Address: %s" %
(e, self.non_src_nat_ip.ipaddress.ipaddress)) (e, self.non_src_nat_ip.ipaddress.ipaddress))
@ -1017,7 +1012,6 @@ class TestLoadBalancingRule(cloudstackTestCase):
ssh_1.execute("hostname")[0] ssh_1.execute("hostname")[0]
return return
class TestRebootRouter(cloudstackTestCase): class TestRebootRouter(cloudstackTestCase):
def setUp(self): def setUp(self):
@ -1354,8 +1348,6 @@ class TestAssignRemoveLB(cloudstackTestCase):
hostnames, hostnames,
"Check if ssh succeeded for server2" "Check if ssh succeeded for server2"
) )
#Removing VM and assigning another VM to LB rule #Removing VM and assigning another VM to LB rule
lb_rule.remove(self.apiclient, [self.vm_2]) lb_rule.remove(self.apiclient, [self.vm_2])
@ -1375,7 +1367,6 @@ class TestAssignRemoveLB(cloudstackTestCase):
hostnames, hostnames,
"Check if ssh succeeded for server1" "Check if ssh succeeded for server1"
) )
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.non_src_nat_ip.ipaddress) self.non_src_nat_ip.ipaddress)
@ -1384,13 +1375,11 @@ class TestAssignRemoveLB(cloudstackTestCase):
# Making hostnames list empty # Making hostnames list empty
hostnames[:] = [] hostnames[:] = []
self.try_ssh(self.non_src_nat_ip, hostnames) self.try_ssh(self.non_src_nat_ip, hostnames)
self.try_ssh(self.non_src_nat_ip, hostnames) self.try_ssh(self.non_src_nat_ip, hostnames)
self.try_ssh(self.non_src_nat_ip, hostnames) self.try_ssh(self.non_src_nat_ip, hostnames)
self.try_ssh(self.non_src_nat_ip, hostnames) self.try_ssh(self.non_src_nat_ip, hostnames)
self.try_ssh(self.non_src_nat_ip, hostnames) self.try_ssh(self.non_src_nat_ip, hostnames)
self.debug("Hostnames: %s" % str(hostnames)) self.debug("Hostnames: %s" % str(hostnames))
self.assertIn( self.assertIn(
self.vm_1.name, self.vm_1.name,

View File

@ -70,8 +70,8 @@ class Services:
}, },
"test_dir": "/tmp", "test_dir": "/tmp",
"random_data": "random.data", "random_data": "random.data",
"snapshot_name":"TestSnapshot", "snapshot_name": "TestSnapshot",
"snapshot_displaytext":"Test", "snapshot_displaytext": "Test",
"ostype": "CentOS 5.3 (64-bit)", "ostype": "CentOS 5.3 (64-bit)",
"sleep": 60, "sleep": 60,
"timeout": 10, "timeout": 10,
@ -79,6 +79,7 @@ class Services:
} }
class TestVmSnapshot(cloudstackTestCase): class TestVmSnapshot(cloudstackTestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.api_client = super(TestVmSnapshot, cls).getClsTestClient().getApiClient() cls.api_client = super(TestVmSnapshot, cls).getClsTestClient().getApiClient()
@ -220,7 +221,7 @@ class TestVmSnapshot(cloudstackTestCase):
time.sleep(self.services["sleep"]) time.sleep(self.services["sleep"])
list_snapshot_response = VmSnapshot.list(self.apiclient,vmid=self.virtual_machine.id,listall=True) list_snapshot_response = VmSnapshot.list(self.apiclient, vmid=self.virtual_machine.id, listall=True)
self.assertEqual( self.assertEqual(
isinstance(list_snapshot_response, list), isinstance(list_snapshot_response, list),
@ -239,7 +240,7 @@ class TestVmSnapshot(cloudstackTestCase):
"Check the snapshot of vm is ready!" "Check the snapshot of vm is ready!"
) )
VmSnapshot.revertToSnapshot(self.apiclient,list_snapshot_response[0].id) VmSnapshot.revertToSnapshot(self.apiclient, list_snapshot_response[0].id)
list_vm_response = list_virtual_machines( list_vm_response = list_virtual_machines(
self.apiclient, self.apiclient,
@ -285,7 +286,7 @@ class TestVmSnapshot(cloudstackTestCase):
"""Test to delete vm snapshots """Test to delete vm snapshots
""" """
list_snapshot_response = VmSnapshot.list(self.apiclient,vmid=self.virtual_machine.id,listall=True) list_snapshot_response = VmSnapshot.list(self.apiclient, vmid=self.virtual_machine.id, listall=True)
self.assertEqual( self.assertEqual(
isinstance(list_snapshot_response, list), isinstance(list_snapshot_response, list),
@ -297,11 +298,11 @@ class TestVmSnapshot(cloudstackTestCase):
None, None,
"Check if snapshot exists in ListSnapshot" "Check if snapshot exists in ListSnapshot"
) )
VmSnapshot.deleteVMSnapshot(self.apiclient,list_snapshot_response[0].id) VmSnapshot.deleteVMSnapshot(self.apiclient, list_snapshot_response[0].id)
time.sleep(self.services["sleep"]*3) time.sleep(self.services["sleep"] * 3)
list_snapshot_response = VmSnapshot.list(self.apiclient,vmid=self.virtual_machine.id,listall=True) list_snapshot_response = VmSnapshot.list(self.apiclient, vmid=self.virtual_machine.id, listall=True)
self.assertEqual( self.assertEqual(
list_snapshot_response, list_snapshot_response,