From 07dcd6ffb1ccec519093911077466938d1a796fd Mon Sep 17 00:00:00 2001 From: Rayees Namathponnan Date: Thu, 1 Aug 2013 17:26:27 -0700 Subject: [PATCH] Automation: fixed cleanup issue with test_vpn_user. Reviewed-by: Sheng Yang Signed-off-by: Sheng Yang --- test/integration/component/test_vpn_users.py | 53 +++++++++++--------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/test/integration/component/test_vpn_users.py b/test/integration/component/test_vpn_users.py index fe020d0f555..e327624cdad 100644 --- a/test/integration/component/test_vpn_users.py +++ b/test/integration/component/test_vpn_users.py @@ -19,6 +19,7 @@ """ # Import Local Modules from nose.plugins.attrib import attr +from marvin.cloudstackException import cloudstackAPIException from marvin.cloudstackTestCase import cloudstackTestCase from marvin.integration.lib.base import ( Account, @@ -127,32 +128,36 @@ class TestVPNUsers(cloudstackTestCase): return def setUp(self): - self.apiclient = self.testClient.getApiClient() - self.dbclient = self.testClient.getDbConnection() - self.account = Account.create( - self.apiclient, - self.services["account"], - domainid=self.domain.id - ) - self.virtual_machine = VirtualMachine.create( + try: + self.apiclient = self.testClient.getApiClient() + self.dbclient = self.testClient.getDbConnection() + self.account = Account.create( self.apiclient, - self.services["virtual_machine"], - templateid=self.template.id, - accountid=self.account.name, - domainid=self.account.domainid, - serviceofferingid=self.service_offering.id + self.services["account"], + domainid=self.domain.id ) - self.public_ip = PublicIPAddress.create( - self.apiclient, - self.virtual_machine.account, - self.virtual_machine.zoneid, - self.virtual_machine.domainid, - self.services["virtual_machine"] - ) - self.cleanup = [ - self.account, - ] - return + self.cleanup = [ + self.account, + ] + self.virtual_machine = VirtualMachine.create( + self.apiclient, + self.services["virtual_machine"], + templateid=self.template.id, + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id + ) + self.public_ip = PublicIPAddress.create( + self.apiclient, + self.virtual_machine.account, + self.virtual_machine.zoneid, + self.virtual_machine.domainid, + self.services["virtual_machine"] + ) + return + except cloudstackAPIException as e: + self.tearDown() + raise e def tearDown(self): try: