Removing invalid test for accounts

Signed-off-by: Prasanna Santhanam <tsp@apache.org>
(cherry picked from commit f83187585e48b530ef7247dfd836c866cb3e1c32)
This commit is contained in:
Prasanna Santhanam 2013-07-28 17:00:30 +05:30
parent 03150fd6ee
commit 76c90efa40

View File

@ -227,275 +227,6 @@ class TestAccounts(cloudstackTestCase):
return
class TestRemoveUserFromAccount(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls.api_client = super(
TestRemoveUserFromAccount,
cls
).getClsTestClient().getApiClient()
cls.services = Services().services
# Get Zone, Domain and templates
cls.zone = get_zone(cls.api_client, cls.services)
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.services["ostype"]
)
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
cls.service_offering = ServiceOffering.create(
cls.api_client,
cls.services["service_offering"]
)
# Create an account
cls.account = Account.create(
cls.api_client,
cls.services["account"]
)
cls._cleanup = [
cls.service_offering,
]
return
@classmethod
def tearDownClass(cls):
try:
#Cleanup resources used
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def setUp(self):
self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection()
self.cleanup = []
return
def tearDown(self):
try:
#Clean up, terminate the created instance, users etc
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@attr(tags=["advanced", "basic", "eip", "advancedns", "sg"])
def test_01_user_remove_VM_running(self):
"""Test Remove one user from the account
"""
# Validate the following
# 1. Create an account with 2 users.
# 2. Start 2 VMs; one for each user of the account
# 3. Remove one user from the account. Verify that account still exists.
# 4. Verify that VM started by the removed user are still running
# Create an User associated with account and VMs
user_1 = User.create(
self.apiclient,
self.services["user"],
account=self.account.name,
domainid=self.account.domainid
)
self.debug("Created user: %s" % user_1.id)
user_2 = User.create(
self.apiclient,
self.services["user"],
account=self.account.name,
domainid=self.account.domainid
)
self.debug("Created user: %s" % user_2.id)
self.cleanup.append(user_2)
vm_1 = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering.id
)
self.debug("Deployed VM in account: %s, ID: %s" % (
self.account.name,
vm_1.id
))
self.cleanup.append(vm_1)
vm_2 = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering.id
)
self.debug("Deployed VM in account: %s, ID: %s" % (
self.account.name,
vm_2.id
))
self.cleanup.append(vm_2)
# Remove one of the user
self.debug("Deleting user: %s" % user_1.id)
user_1.delete(self.apiclient)
# Account should exist after deleting user
accounts_response = list_accounts(
self.apiclient,
id=self.account.id
)
self.assertEqual(
isinstance(accounts_response, list),
True,
"Check for valid list accounts response"
)
self.assertNotEqual(
len(accounts_response),
0,
"Check List Account response"
)
vm_response = list_virtual_machines(
self.apiclient,
account=self.account.name,
domainid=self.account.domainid
)
self.assertEqual(
isinstance(vm_response, list),
True,
"Check for valid list VM response"
)
self.assertNotEqual(
len(vm_response),
0,
"Check List VM response"
)
# VMs associated with that account should be running
for vm in vm_response:
self.assertEqual(
vm.state,
'Running',
"Check state of VMs associated with account"
)
return
@attr(tags=["advanced", "basic", "eip", "advancedns", "sg"])
def test_02_remove_all_users(self):
"""Test Remove both users from the account
"""
# Validate the following
# 1. Remove both the users from the account.
# 2. Verify account is removed
# 3. Verify all VMs associated with that account got removed
# Create an User associated with account and VMs
user_1 = User.create(
self.apiclient,
self.services["user"],
account=self.account.name,
domainid=self.account.domainid
)
self.debug("Created user: %s" % user_1.id)
user_2 = User.create(
self.apiclient,
self.services["user"],
account=self.account.name,
domainid=self.account.domainid
)
self.debug("Created user: %s" % user_2.id)
vm_1 = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering.id
)
self.debug("Deployed VM in account: %s, ID: %s" % (
self.account.name,
vm_1.id
))
vm_2 = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering.id
)
self.debug("Deployed VM in account: %s, ID: %s" % (
self.account.name,
vm_2.id
))
# Get users associated with an account
# (Total 3: 2 - Created & 1 default generated while account creation)
users = list_users(
self.apiclient,
account=self.account.name,
domainid=self.account.domainid
)
self.assertEqual(
isinstance(users, list),
True,
"Check for valid list users response"
)
for user in users:
self.debug("Deleting user: %s" % user.id)
cmd = deleteUser.deleteUserCmd()
cmd.id = user.id
self.apiclient.deleteUser(cmd)
interval = list_configurations(
self.apiclient,
name='account.cleanup.interval'
)
self.assertEqual(
isinstance(interval, list),
True,
"Check for valid list configurations response"
)
self.debug("account.cleanup.interval: %s" % interval[0].value)
# Sleep to ensure that all resources are deleted
time.sleep(int(interval[0].value))
# Account is removed after last user is deleted
account_response = list_accounts(
self.apiclient,
id=self.account.id
)
self.assertEqual(
account_response,
None,
"Check List VM response"
)
# All VMs associated with account are removed.
vm_response = list_virtual_machines(
self.apiclient,
account=self.account.name,
domainid=self.account.domainid
)
self.assertEqual(
vm_response,
None,
"Check List VM response"
)
# DomR associated with account is deleted
with self.assertRaises(Exception):
list_routers(
self.apiclient,
account=self.account.name,
domainid=self.account.domainid
)
return
class TestNonRootAdminsPrivileges(cloudstackTestCase):
@classmethod