Skip to content

Commit f831875

Browse files
author
Prasanna Santhanam
committed
Removing invalid test for accounts
Signed-off-by: Prasanna Santhanam <tsp@apache.org>
1 parent e3a35e4 commit f831875

1 file changed

Lines changed: 0 additions & 269 deletions

File tree

‎test/integration/component/test_accounts.py‎

Lines changed: 0 additions & 269 deletions
Original file line numberDiff line numberDiff line change
@@ -227,275 +227,6 @@ def test_01_create_account(self):
227227
return
228228

229229

230-
class TestRemoveUserFromAccount(cloudstackTestCase):
231-
232-
@classmethod
233-
def setUpClass(cls):
234-
cls.api_client = super(
235-
TestRemoveUserFromAccount,
236-
cls
237-
).getClsTestClient().getApiClient()
238-
cls.services = Services().services
239-
# Get Zone, Domain and templates
240-
cls.zone = get_zone(cls.api_client, cls.services)
241-
cls.services['mode'] = cls.zone.networktype
242-
cls.template = get_template(
243-
cls.api_client,
244-
cls.zone.id,
245-
cls.services["ostype"]
246-
)
247-
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
248-
cls.services["virtual_machine"]["template"] = cls.template.id
249-
250-
cls.service_offering = ServiceOffering.create(
251-
cls.api_client,
252-
cls.services["service_offering"]
253-
)
254-
# Create an account
255-
cls.account = Account.create(
256-
cls.api_client,
257-
cls.services["account"]
258-
)
259-
260-
cls._cleanup = [
261-
cls.service_offering,
262-
]
263-
return
264-
265-
@classmethod
266-
def tearDownClass(cls):
267-
try:
268-
#Cleanup resources used
269-
cleanup_resources(cls.api_client, cls._cleanup)
270-
except Exception as e:
271-
raise Exception("Warning: Exception during cleanup : %s" % e)
272-
return
273-
274-
def setUp(self):
275-
self.apiclient = self.testClient.getApiClient()
276-
self.dbclient = self.testClient.getDbConnection()
277-
self.cleanup = []
278-
return
279-
280-
def tearDown(self):
281-
try:
282-
#Clean up, terminate the created instance, users etc
283-
cleanup_resources(self.apiclient, self.cleanup)
284-
except Exception as e:
285-
raise Exception("Warning: Exception during cleanup : %s" % e)
286-
return
287-
288-
@attr(tags=["advanced", "basic", "eip", "advancedns", "sg"])
289-
def test_01_user_remove_VM_running(self):
290-
"""Test Remove one user from the account
291-
"""
292-
293-
# Validate the following
294-
# 1. Create an account with 2 users.
295-
# 2. Start 2 VMs; one for each user of the account
296-
# 3. Remove one user from the account. Verify that account still exists.
297-
# 4. Verify that VM started by the removed user are still running
298-
299-
# Create an User associated with account and VMs
300-
user_1 = User.create(
301-
self.apiclient,
302-
self.services["user"],
303-
account=self.account.name,
304-
domainid=self.account.domainid
305-
)
306-
self.debug("Created user: %s" % user_1.id)
307-
user_2 = User.create(
308-
self.apiclient,
309-
self.services["user"],
310-
account=self.account.name,
311-
domainid=self.account.domainid
312-
)
313-
self.debug("Created user: %s" % user_2.id)
314-
self.cleanup.append(user_2)
315-
316-
vm_1 = VirtualMachine.create(
317-
self.apiclient,
318-
self.services["virtual_machine"],
319-
accountid=self.account.name,
320-
domainid=self.account.domainid,
321-
serviceofferingid=self.service_offering.id
322-
)
323-
self.debug("Deployed VM in account: %s, ID: %s" % (
324-
self.account.name,
325-
vm_1.id
326-
))
327-
self.cleanup.append(vm_1)
328-
329-
vm_2 = VirtualMachine.create(
330-
self.apiclient,
331-
self.services["virtual_machine"],
332-
accountid=self.account.name,
333-
domainid=self.account.domainid,
334-
serviceofferingid=self.service_offering.id
335-
)
336-
self.debug("Deployed VM in account: %s, ID: %s" % (
337-
self.account.name,
338-
vm_2.id
339-
))
340-
self.cleanup.append(vm_2)
341-
342-
# Remove one of the user
343-
self.debug("Deleting user: %s" % user_1.id)
344-
user_1.delete(self.apiclient)
345-
346-
# Account should exist after deleting user
347-
accounts_response = list_accounts(
348-
self.apiclient,
349-
id=self.account.id
350-
)
351-
self.assertEqual(
352-
isinstance(accounts_response, list),
353-
True,
354-
"Check for valid list accounts response"
355-
)
356-
357-
self.assertNotEqual(
358-
len(accounts_response),
359-
0,
360-
"Check List Account response"
361-
)
362-
vm_response = list_virtual_machines(
363-
self.apiclient,
364-
account=self.account.name,
365-
domainid=self.account.domainid
366-
)
367-
self.assertEqual(
368-
isinstance(vm_response, list),
369-
True,
370-
"Check for valid list VM response"
371-
)
372-
373-
self.assertNotEqual(
374-
len(vm_response),
375-
0,
376-
"Check List VM response"
377-
)
378-
379-
# VMs associated with that account should be running
380-
for vm in vm_response:
381-
self.assertEqual(
382-
vm.state,
383-
'Running',
384-
"Check state of VMs associated with account"
385-
)
386-
return
387-
388-
@attr(tags=["advanced", "basic", "eip", "advancedns", "sg"])
389-
def test_02_remove_all_users(self):
390-
"""Test Remove both users from the account
391-
"""
392-
393-
# Validate the following
394-
# 1. Remove both the users from the account.
395-
# 2. Verify account is removed
396-
# 3. Verify all VMs associated with that account got removed
397-
398-
# Create an User associated with account and VMs
399-
user_1 = User.create(
400-
self.apiclient,
401-
self.services["user"],
402-
account=self.account.name,
403-
domainid=self.account.domainid
404-
)
405-
self.debug("Created user: %s" % user_1.id)
406-
user_2 = User.create(
407-
self.apiclient,
408-
self.services["user"],
409-
account=self.account.name,
410-
domainid=self.account.domainid
411-
)
412-
self.debug("Created user: %s" % user_2.id)
413-
vm_1 = VirtualMachine.create(
414-
self.apiclient,
415-
self.services["virtual_machine"],
416-
accountid=self.account.name,
417-
domainid=self.account.domainid,
418-
serviceofferingid=self.service_offering.id
419-
)
420-
self.debug("Deployed VM in account: %s, ID: %s" % (
421-
self.account.name,
422-
vm_1.id
423-
))
424-
vm_2 = VirtualMachine.create(
425-
self.apiclient,
426-
self.services["virtual_machine"],
427-
accountid=self.account.name,
428-
domainid=self.account.domainid,
429-
serviceofferingid=self.service_offering.id
430-
)
431-
self.debug("Deployed VM in account: %s, ID: %s" % (
432-
self.account.name,
433-
vm_2.id
434-
))
435-
# Get users associated with an account
436-
# (Total 3: 2 - Created & 1 default generated while account creation)
437-
users = list_users(
438-
self.apiclient,
439-
account=self.account.name,
440-
domainid=self.account.domainid
441-
)
442-
self.assertEqual(
443-
isinstance(users, list),
444-
True,
445-
"Check for valid list users response"
446-
)
447-
for user in users:
448-
449-
self.debug("Deleting user: %s" % user.id)
450-
cmd = deleteUser.deleteUserCmd()
451-
cmd.id = user.id
452-
self.apiclient.deleteUser(cmd)
453-
454-
interval = list_configurations(
455-
self.apiclient,
456-
name='account.cleanup.interval'
457-
)
458-
self.assertEqual(
459-
isinstance(interval, list),
460-
True,
461-
"Check for valid list configurations response"
462-
)
463-
self.debug("account.cleanup.interval: %s" % interval[0].value)
464-
465-
# Sleep to ensure that all resources are deleted
466-
time.sleep(int(interval[0].value))
467-
468-
# Account is removed after last user is deleted
469-
account_response = list_accounts(
470-
self.apiclient,
471-
id=self.account.id
472-
)
473-
self.assertEqual(
474-
account_response,
475-
None,
476-
"Check List VM response"
477-
)
478-
# All VMs associated with account are removed.
479-
vm_response = list_virtual_machines(
480-
self.apiclient,
481-
account=self.account.name,
482-
domainid=self.account.domainid
483-
)
484-
self.assertEqual(
485-
vm_response,
486-
None,
487-
"Check List VM response"
488-
)
489-
# DomR associated with account is deleted
490-
with self.assertRaises(Exception):
491-
list_routers(
492-
self.apiclient,
493-
account=self.account.name,
494-
domainid=self.account.domainid
495-
)
496-
return
497-
498-
499230
class TestNonRootAdminsPrivileges(cloudstackTestCase):
500231

501232
@classmethod

0 commit comments

Comments
 (0)