CLOUDSTACK-6657: Adding condition for checking error code 530 across test cases

Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>
This commit is contained in:
Gaurav Aradhye 2014-05-15 23:19:06 -04:00 committed by SrikanteswaraRao Talluri
parent 2c54e5e2c5
commit 2e9cc58af6
16 changed files with 155 additions and 102 deletions

View File

@ -18,7 +18,6 @@
""" """
#Import Local Modules #Import Local Modules
from marvin.cloudstackTestCase import cloudstackTestCase from marvin.cloudstackTestCase import cloudstackTestCase
#from marvin.cloudstackAPI import *
from marvin.lib.utils import (random_gen, from marvin.lib.utils import (random_gen,
cleanup_resources) cleanup_resources)
from marvin.lib.base import (Domain, from marvin.lib.base import (Domain,
@ -41,7 +40,7 @@ from marvin.lib.common import (get_domain,
get_builtin_template_info, get_builtin_template_info,
wait_for_cleanup) wait_for_cleanup)
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from marvin.cloudstackException import CloudstackAPIException from marvin.codes import ERROR_CODE_530
import time import time
class Services: class Services:
@ -1672,21 +1671,25 @@ class TestDomainForceRemove(cloudstackTestCase):
" to cleanup any remaining resouces") " to cleanup any remaining resouces")
# Sleep 3*account.gc to ensure that all resources are deleted # Sleep 3*account.gc to ensure that all resources are deleted
wait_for_cleanup(self.apiclient, ["account.cleanup.interval"]*3) wait_for_cleanup(self.apiclient, ["account.cleanup.interval"]*3)
with self.assertRaises(CloudstackAPIException): response = Domain.list(
Domain.list(
self.apiclient, self.apiclient,
id=domain.id, id=domain.id,
listall=True listall=True
) )
self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
self.debug("Checking if the resources in domain are deleted") self.debug("Checking if the resources in domain are deleted")
with self.assertRaises(CloudstackAPIException): response = Account.list(
Account.list(
self.apiclient, self.apiclient,
name=self.account_1.name, name=self.account_1.name,
domainid=self.account_1.domainid, domainid=self.account_1.domainid,
listall=True listall=True
) )
self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
return return
@attr(tags=["domains", "advanced", "advancedns", "simulator", "selfservice"]) @attr(tags=["domains", "advanced", "advancedns", "simulator", "selfservice"])
@ -1831,6 +1834,8 @@ class TestDomainForceRemove(cloudstackTestCase):
) )
self.debug("Deleting domain without force option") self.debug("Deleting domain without force option")
with self.assertRaises(Exception): response = domain.delete(self.apiclient, cleanup=False)
domain.delete(self.apiclient, cleanup=False) self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
return return

View File

@ -58,7 +58,7 @@ from marvin.cloudstackAPI import (addNicToVirtualMachine,
removeNicFromVirtualMachine, removeNicFromVirtualMachine,
updateDefaultNicForVirtualMachine) updateDefaultNicForVirtualMachine)
from marvin.codes import PASS from marvin.codes import PASS, ERROR_CODE_530
import random import random
import time import time
@ -466,8 +466,10 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
self.cleanup.append(vpc) self.cleanup.append(vpc)
self.cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.debug("Trying to add VPC to vm belonging to isolated network, this should fail") self.debug("Trying to add VPC to vm belonging to isolated network, this should fail")
with self.assertRaises(Exception): response = self.virtual_machine.add_nic(self.apiclient, vpc.id)
self.virtual_machine.add_nic(self.apiclient, vpc.id) self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
self.debug("Starting virtual machine") self.debug("Starting virtual machine")
self.virtual_machine.start(self.apiclient) self.virtual_machine.start(self.apiclient)
self.debug("Disabling vpc offering: %s" % vpc_off.id) self.debug("Disabling vpc offering: %s" % vpc_off.id)
@ -825,9 +827,10 @@ class TestRemoveNetworkFromVirtualMachine(cloudstackTestCase):
self.assertEqual(len(vm_list[0].nic), 1, "There should only be default nic present in the vm") self.assertEqual(len(vm_list[0].nic), 1, "There should only be default nic present in the vm")
self.debug("Trying to remove the default nic of vm : %s, this should fail" % self.debug("Trying to remove the default nic of vm : %s, this should fail" %
self.virtual_machine.id) self.virtual_machine.id)
with self.assertRaises(Exception): response = self.virtual_machine.remove_nic(self.apiclient, vm_list[0].nic[0].id)
self.virtual_machine.remove_nic(self.apiclient, vm_list[0].nic[0].id) self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
self.debug("Removing default nic of vm failed") have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
return return
@attr(tags = ["advanced"]) @attr(tags = ["advanced"])

View File

@ -29,6 +29,7 @@ from marvin.lib.common import (get_zone,
get_template, get_template,
list_virtual_machines, list_virtual_machines,
wait_for_cleanup) wait_for_cleanup)
from marvin.codes import ERROR_CODE_530
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
class Services: class Services:
@ -1086,9 +1087,10 @@ class TestUpdateVMAffinityGroups(cloudstackTestCase):
vm1, hostid1 = self.create_vm_in_aff_grps([self.aff_grp[0].name], account_name=self.account.name, domain_id=self.domain.id) vm1, hostid1 = self.create_vm_in_aff_grps([self.aff_grp[0].name], account_name=self.account.name, domain_id=self.domain.id)
aff_grps = [self.aff_grp[0], self.aff_grp[1]] aff_grps = [self.aff_grp[0], self.aff_grp[1]]
with self.assertRaises(Exception): response = vm1.update_affinity_group(self.api_client, affinitygroupnames=[])
vm1.update_affinity_group(self.api_client, affinitygroupnames=[]) self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
vm1.delete(self.api_client) vm1.delete(self.api_client)
#Wait for expunge interval to cleanup VM #Wait for expunge interval to cleanup VM
wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"]) wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])

View File

@ -38,6 +38,7 @@ from marvin.lib.common import (get_domain,
list_snapshots, list_snapshots,
list_virtual_machines) list_virtual_machines)
from marvin.lib.utils import cleanup_resources from marvin.lib.utils import cleanup_resources
from marvin.codes import ERROR_CODE_530
def log_test_exceptions(func): def log_test_exceptions(func):
def test_wrap_exception_log(self, *args, **kwargs): def test_wrap_exception_log(self, *args, **kwargs):
@ -369,7 +370,14 @@ class TestVMOwnership(cloudstackTestCase):
# 1. deploy VM in sub subdomain1 # 1. deploy VM in sub subdomain1
# 3. assignVirtualMachine to subdomain2 # 3. assignVirtualMachine to subdomain2
self.create_vm(self.sdomain_account_user1['account'], self.sdomain_account_user1['domain'],isRunning=True) self.create_vm(self.sdomain_account_user1['account'], self.sdomain_account_user1['domain'],isRunning=True)
self.assertRaises(Exception, self.virtual_machine.assign_virtual_machine, self.apiclient, self.sdomain_account_user2['account'].name ,self.sdomain_account_user2['domain'].id) response = self.virtual_machine.assign_virtual_machine(
self.apiclient,
self.sdomain_account_user2['account'].name,
self.sdomain_account_user2['domain'].id)
self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
return
@attr(tags = ["advanced"]) @attr(tags = ["advanced"])
@log_test_exceptions @log_test_exceptions
@ -380,7 +388,14 @@ class TestVMOwnership(cloudstackTestCase):
# 1. deploy VM in sub subdomain1 with PF rule set. # 1. deploy VM in sub subdomain1 with PF rule set.
# 3. assignVirtualMachine to subdomain2 # 3. assignVirtualMachine to subdomain2
self.create_vm(self.sdomain_account_user1['account'], self.sdomain_account_user1['domain'],pfrule=True) self.create_vm(self.sdomain_account_user1['account'], self.sdomain_account_user1['domain'],pfrule=True)
self.assertRaises(Exception, self.virtual_machine.assign_virtual_machine, self.apiclient, self.sdomain_account_user2['account'].name ,self.sdomain_account_user2['domain'].id) response = self.virtual_machine.assign_virtual_machine(
self.apiclient,
self.sdomain_account_user2['account'].name,
self.sdomain_account_user2['domain'].id)
self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
return
@attr(tags = ["advanced"]) @attr(tags = ["advanced"])
@log_test_exceptions @log_test_exceptions

View File

@ -258,8 +258,10 @@ class TestIpReservation(cloudstackTestCase):
except Exception as e: except Exception as e:
self.fail("VM creation failed: %s" % e) self.fail("VM creation failed: %s" % e)
with self.assertRaises(Exception): response = isolated_network.update(self.apiclient, guestvmcidr=guest_vm_cidr)
isolated_network.update(self.apiclient, guestvmcidr=guest_vm_cidr) self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
return return
@attr(tags=["advanced"]) @attr(tags=["advanced"])
@ -288,8 +290,10 @@ class TestIpReservation(cloudstackTestCase):
except Exception as e: except Exception as e:
self.fail("VM creation failed: %s" % e) self.fail("VM creation failed: %s" % e)
with self.assertRaises(Exception): response = isolated_network.update(self.apiclient, guestvmcidr=guest_vm_cidr)
isolated_network.update(self.apiclient, guestvmcidr=guest_vm_cidr) self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
return return
@data(NAT_RULE, STATIC_NAT_RULE) @data(NAT_RULE, STATIC_NAT_RULE)
@ -1072,11 +1076,18 @@ class TestFailureScnarios(cloudstackTestCase):
# #
# validation # validation
# should throw exception as network is not in implemented state as no vm is created # should throw exception as network is not in implemented state as no vm is created
try: networkOffering = self.isolated_network_offering
update_response = Network.update(self.isolated_network, self.apiclient, id=isolated_network.id, guestvmcidr="10.1.1.0/26") resultSet = createIsolatedNetwork(self, networkOffering.id)
self.fail("Network Update of guest VM CIDR is successful withot any VM deployed in network") if resultSet[0] == FAIL:
except Exception as e: self.fail("Failed to create isolated network")
self.debug("Network Update of guest VM CIDR should fail as there is no VM deployed in network") else:
isolated_network = resultSet[1]
response = isolated_network.update(self.apiclient, guestvmcidr="10.1.1.0/26")
self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
return
@attr(tags=["advanced", "selfservice"]) @attr(tags=["advanced", "selfservice"])
def test_vm_create_after_reservation(self): def test_vm_create_after_reservation(self):

View File

@ -27,7 +27,7 @@
#Import local modules #Import local modules
from marvin.cloudstackTestCase import (cloudstackTestCase,unittest) from marvin.cloudstackTestCase import (cloudstackTestCase)
from marvin.lib.base import (Account, from marvin.lib.base import (Account,
ServiceOffering, ServiceOffering,
PhysicalNetwork, PhysicalNetwork,
@ -40,6 +40,7 @@ from marvin.lib.common import (get_zone,
setNonContiguousVlanIds) setNonContiguousVlanIds)
from marvin.lib.utils import (cleanup_resources, from marvin.lib.utils import (cleanup_resources,
xsplit) xsplit)
from marvin.codes import ERROR_CODE_530
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
@ -317,12 +318,11 @@ class TestNonContiguousVLANRanges(cloudstackTestCase):
self.debug("Deployed instance in account: %s" % account.name) self.debug("Deployed instance in account: %s" % account.name)
self.debug("Trying to remove vlan range : %s , This should fail" % self.vlan["partial_range"][0]) self.debug("Trying to remove vlan range : %s , This should fail" % self.vlan["partial_range"][0])
with self.assertRaises(Exception) as e: response = self.physicalnetwork.update(self.apiClient, id = self.physicalnetworkid, vlan = self.vlan["partial_range"][0])
self.physicalnetwork.update(self.apiClient, id = self.physicalnetworkid, vlan = self.vlan["partial_range"][0]) self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
self.debug("operation failed with exception: %s" % e.exception) %s" % (ERROR_CODE_530, str(response)))
account.delete(self.apiclient) account.delete(self.apiclient)
except Exception as e: except Exception as e:
self.fail("Exception in test case: %s" % e) self.fail("Exception in test case: %s" % e)

View File

@ -17,15 +17,13 @@
""" P1 tests for Project """ P1 tests for Project
""" """
#Import Local Modules #Import Local Modules
import marvin
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import * from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import * from marvin.cloudstackAPI import *
from marvin.lib.utils import * from marvin.lib.utils import *
from marvin.lib.base import * from marvin.lib.base import *
from marvin.lib.common import * from marvin.lib.common import *
from marvin.sshClient import SshClient from marvin.codes import ERROR_CODE_530
import datetime
class Services: class Services:
@ -430,13 +428,14 @@ class TestCrossDomainAccountAdd(cloudstackTestCase):
self.user.domainid, self.user.domainid,
project.id project.id
)) ))
with self.assertRaises(Exception): # Add user to the project from different domain
# Add user to the project from different domain response = project.addAccount(
project.addAccount(
self.apiclient, self.apiclient,
self.user.name self.user.name
) )
self.debug("User add to project failed!") self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
return return
@ -542,10 +541,10 @@ class TestDeleteAccountWithProject(cloudstackTestCase):
"Check project name from list response" "Check project name from list response"
) )
# Deleting account who is owner of the project # Deleting account who is owner of the project
with self.assertRaises(Exception): response = self.account.delete(self.apiclient)
self.account.delete(self.apiclient) self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
self.debug("Deleting account %s failed!" % have failed with error code %s, instead got response \
self.account.name) %s" % (ERROR_CODE_530, str(response)))
return return

View File

@ -36,6 +36,7 @@ from marvin.lib.common import (get_domain,
get_zone, get_zone,
get_template, get_template,
get_pod) get_pod)
from marvin.codes import ERROR_CODE_530
#Import System modules #Import System modules
import time import time
@ -341,16 +342,17 @@ class TestAttachVolume(cloudstackTestCase):
True, True,
"Check list volumes response for valid list" "Check list volumes response for valid list"
) )
# Attach volume to VM self.debug("Trying to Attach volume: %s to VM: %s" % (
with self.assertRaises(Exception):
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( response = self.virtual_machine.attach_volume(
self.apiclient, self.apiclient,
volume volume
) )
self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
return return
class TestAttachDetachVolume(cloudstackTestCase): class TestAttachDetachVolume(cloudstackTestCase):

View File

@ -25,6 +25,7 @@ from marvin.cloudstackAPI import *
from marvin.lib.utils import * from marvin.lib.utils import *
from marvin.lib.base import * from marvin.lib.base import *
from marvin.lib.common import * from marvin.lib.common import *
from marvin.codes import ERROR_CODE_530
class Services: class Services:
@ -699,8 +700,10 @@ class TestVPC(cloudstackTestCase):
self.debug("Created network with ID: %s" % network_2.id) self.debug("Created network with ID: %s" % network_2.id)
self.debug("Deleting the VPC with no network") self.debug("Deleting the VPC with no network")
with self.assertRaises(Exception): response = vpc.delete(self.apiclient)
vpc.delete(self.apiclient) self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
self.debug("Delete VPC failed as there are still networks in VPC") self.debug("Delete VPC failed as there are still networks in VPC")
self.debug("Deleting the networks in the VPC") self.debug("Deleting the networks in the VPC")

View File

@ -44,7 +44,7 @@ from marvin.lib.common import (get_zone,
# For more info on ddt refer to http://ddt.readthedocs.org/en/latest/api.html#module-ddt # For more info on ddt refer to http://ddt.readthedocs.org/en/latest/api.html#module-ddt
from ddt import ddt, data from ddt import ddt, data
import time import time
from marvin.codes import PASS from marvin.codes import PASS, ERROR_CODE_530
class Services: class Services:
"""Test VPC network services """Test VPC network services
@ -2107,12 +2107,14 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
self.fail("Failed to stop VMs, %s" % e) self.fail("Failed to stop VMs, %s" % e)
self.debug("Upgrading network offering to support PF services") self.debug("Upgrading network offering to support PF services")
with self.assertRaises(Exception): response = network_1.update(
network_1.update(
self.apiclient, self.apiclient,
networkofferingid=nw_off_vr.id, networkofferingid=nw_off_vr.id,
changecidr=True changecidr=True
) )
self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
return return
class TestVPCNetworkGc(cloudstackTestCase): class TestVPCNetworkGc(cloudstackTestCase):

View File

@ -39,6 +39,7 @@ from marvin.lib.common import (get_domain,
get_template, get_template,
list_routers) list_routers)
from marvin.lib.utils import cleanup_resources from marvin.lib.utils import cleanup_resources
from marvin.codes import ERROR_CODE_530
import socket import socket
import time import time
@ -640,8 +641,10 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
lb_rule = self.create_LB_Rule(public_ip_1, network_1, [vm_1, vm_2], self.services["lbrule_http"]) lb_rule = self.create_LB_Rule(public_ip_1, network_1, [vm_1, vm_2], self.services["lbrule_http"])
# In a VPC, the load balancing service is supported only on a single tier. # In a VPC, the load balancing service is supported only on a single tier.
# http://cloudstack.apache.org/docs/en-US/Apache_CloudStack/4.0.2/html/Installation_Guide/configure-vpc.html # http://cloudstack.apache.org/docs/en-US/Apache_CloudStack/4.0.2/html/Installation_Guide/configure-vpc.html
with self.assertRaises(Exception): response = lb_rule.assign(self.apiclient, [vm_3])
lb_rule.assign(self.apiclient, [vm_3]) self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False)
return return

View File

@ -19,7 +19,7 @@
""" """
#Import Local Modules #Import Local Modules
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest from marvin.cloudstackTestCase import cloudstackTestCase
from marvin.lib.base import (VirtualMachine, from marvin.lib.base import (VirtualMachine,
NetworkOffering, NetworkOffering,
VpcOffering, VpcOffering,
@ -43,6 +43,7 @@ from marvin.lib.common import (get_domain,
get_free_vlan) get_free_vlan)
from marvin.lib.utils import cleanup_resources from marvin.lib.utils import cleanup_resources
from marvin.codes import ERROR_CODE_530
from marvin.cloudstackAPI import rebootRouter from marvin.cloudstackAPI import rebootRouter
@ -1622,8 +1623,10 @@ class TestVMDeployVPC(cloudstackTestCase):
"Vm state should be running for each VM deployed" "Vm state should be running for each VM deployed"
) )
self.debug("Trying to delete network: %s" % network_1.name) self.debug("Trying to delete network: %s" % network_1.name)
with self.assertRaises(Exception): response = network_1.delete(self.apiclient)
network_1.delete(self.apiclient) self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
self.debug("Delete netwpork failed as there are running instances") self.debug("Delete netwpork failed as there are running instances")
self.debug("Destroying all the instances in network1: %s" % self.debug("Destroying all the instances in network1: %s" %
@ -2161,8 +2164,10 @@ class TestVMDeployVPC(cloudstackTestCase):
) )
self.debug("Trying to delete network: %s" % network_1.name) self.debug("Trying to delete network: %s" % network_1.name)
with self.assertRaises(Exception): response = network_1.delete(self.apiclient)
network_1.delete(self.apiclient) self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
self.debug("Delete network failed as there are running instances") self.debug("Delete network failed as there are running instances")
self.debug("Destroying all the instances in network1: %s" % self.debug("Destroying all the instances in network1: %s" %

View File

@ -27,6 +27,7 @@ from marvin.lib.utils import *
from marvin.lib.base import * from marvin.lib.base import *
from marvin.lib.common import * from marvin.lib.common import *
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from marvin.codes import ERROR_CODE_530
#Import System modules #Import System modules
import time import time
@ -389,12 +390,14 @@ class TestPortForwarding(cloudstackTestCase):
try: try:
nat_rule.delete(self.apiclient) nat_rule.delete(self.apiclient)
list_nat_rule_response = list_nat_rules(
self.apiclient,
id=nat_rule.id
)
except CloudstackAPIException: except CloudstackAPIException:
self.fail("Nat Rule Deletion or Listing Failed") self.fail("Nat Rule deletion failed: %s" % e)
response = list_nat_rules(self.apiclient,
id=nat_rule.id)
self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
# Check if the Public SSH port is inaccessible # Check if the Public SSH port is inaccessible
with self.assertRaises(Exception): with self.assertRaises(Exception):

View File

@ -15,14 +15,17 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
""" NIC tests for VM """ """ NIC tests for VM """
import marvin from marvin.codes import ERROR_CODE_530
from marvin.codes import FAILED from marvin.cloudstackTestCase import cloudstackTestCase
from marvin.cloudstackTestCase import * from marvin.lib.base import(Account,
from marvin.cloudstackAPI import * ServiceOffering,
from marvin.sshClient import SshClient Network,
from marvin.lib.utils import * VirtualMachine,
from marvin.lib.base import * NetworkOffering)
from marvin.lib.common import * from marvin.lib.common import (get_zone,
get_domain,
get_template,
list_virtual_machines)
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
import signal import signal
@ -186,7 +189,7 @@ class TestNic(cloudstackTestCase):
existing_nic_id = vm_response.nic[0].id existing_nic_id = vm_response.nic[0].id
# 1. add a nic # 1. add a nic
add_response = self.virtual_machine.add_nic(self.apiclient, self.test_network2.id) self.virtual_machine.add_nic(self.apiclient, self.test_network2.id)
time.sleep(5) time.sleep(5)
# now go get the vm list? # now go get the vm list?
@ -231,13 +234,11 @@ class TestNic(cloudstackTestCase):
"Verify second adapter is set to default" "Verify second adapter is set to default"
) )
sawException = False response = self.virtual_machine.remove_nic(self.apiclient, new_nic_id)
try: self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
self.virtual_machine.remove_nic(self.apiclient, new_nic_id) have failed with error code %s, instead got response \
except Exception as ex: %s" % (ERROR_CODE_530, str(response)))
sawException = True
self.assertEqual(sawException, True, "Make sure we cannot delete the default NIC")
self.virtual_machine.update_default_nic(self.apiclient, existing_nic_id) self.virtual_machine.update_default_nic(self.apiclient, existing_nic_id)
time.sleep(5) time.sleep(5)
self.virtual_machine.remove_nic(self.apiclient, new_nic_id) self.virtual_machine.remove_nic(self.apiclient, new_nic_id)

View File

@ -17,16 +17,18 @@
""" BVT tests for Primary Storage """ BVT tests for Primary Storage
""" """
#Import Local Modules #Import Local Modules
import marvin from marvin.cloudstackTestCase import cloudstackTestCase
from marvin.cloudstackTestCase import * #from marvin.cloudstackAPI import *
from marvin.cloudstackAPI import * from marvin.lib.utils import cleanup_resources
from marvin.lib.utils import * from marvin.lib.base import StoragePool
from marvin.lib.base import * from marvin.lib.common import (get_zone,
from marvin.lib.common import * get_pod,
list_clusters,
list_hosts,
list_storage_pools)
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
#Import System modules #Import System modules
import time
_multiprocess_shared_ = True _multiprocess_shared_ = True
class TestPrimaryStorageServices(cloudstackTestCase): class TestPrimaryStorageServices(cloudstackTestCase):

View File

@ -18,11 +18,9 @@
""" """
#Import Local Modules #Import Local Modules
from marvin.cloudstackTestCase import cloudstackTestCase from marvin.cloudstackTestCase import cloudstackTestCase
#from marvin.cloudstackException import *
from marvin.cloudstackAPI import (deleteVolume, from marvin.cloudstackAPI import (deleteVolume,
extractVolume, extractVolume,
resizeVolume) resizeVolume)
#from marvin.sshClient import SshClient
from marvin.lib.utils import (cleanup_resources, from marvin.lib.utils import (cleanup_resources,
format_volume_to_ext3) format_volume_to_ext3)
from marvin.lib.base import (ServiceOffering, from marvin.lib.base import (ServiceOffering,
@ -35,7 +33,7 @@ from marvin.lib.common import (get_domain,
get_zone, get_zone,
get_template) get_template)
from marvin.lib.utils import checkVolumeSize from marvin.lib.utils import checkVolumeSize
from marvin.codes import SUCCESS, FAILED from marvin.codes import SUCCESS, FAILED, ERROR_CODE_530
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
#Import System modules #Import System modules
import os import os
@ -395,8 +393,11 @@ class TestVolumes(cloudstackTestCase):
cmd.zoneid = self.services["zoneid"] cmd.zoneid = self.services["zoneid"]
# A proper exception should be raised; # A proper exception should be raised;
# downloading attach VM is not allowed # downloading attach VM is not allowed
with self.assertRaises(Exception): response = self.apiClient.extractVolume(cmd)
self.apiClient.extractVolume(cmd) self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
have failed with error code %s, instead got response \
%s" % (ERROR_CODE_530, str(response)))
return
@attr(tags = ["advanced", "advancedns", "smoke", "basic", "selfservice"]) @attr(tags = ["advanced", "advancedns", "smoke", "basic", "selfservice"])
def test_04_delete_attached_volume(self): def test_04_delete_attached_volume(self):
@ -548,15 +549,11 @@ class TestVolumes(cloudstackTestCase):
cmd.id = rootvolume.id cmd.id = rootvolume.id
cmd.diskofferingid = self.services['diskofferingid'] cmd.diskofferingid = self.services['diskofferingid']
success = False success = False
try:
self.apiClient.resizeVolume(cmd) response = self.apiClient.resizeVolume(cmd)
except Exception as ex: self.assertEqual(response.errorcode, ERROR_CODE_530, "Job should \
if "Can only resize Data volumes" in str(ex): have failed with error code %s, instead got response \
success = True %s" % (ERROR_CODE_530, str(response)))
self.assertEqual(
success,
True,
"ResizeVolume - verify root disks cannot be resized by disk offering id")
# Ok, now let's try and resize a volume that is not custom. # Ok, now let's try and resize a volume that is not custom.
cmd.id = self.volume.id cmd.id = self.volume.id