def test_03_multiplecore_delete_instance(self): """Test Deploy VM with multiple core CPU & verify the usage""" # Validate the following # 1. Deploy VM with multiple core CPU & verify the usage # 2. Destroy VM & verify update resource count of Root Admin Account # 3. Resource count should list properly. account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].cputotal expected_resource_count = int(self.services["service_offering"]["cpunumber"]) self.assertEqual(resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Destroying instance: %s" % self.vm.name) try: self.vm.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].cputotal self.assertEqual(resource_count, 0 , "Resource count for %s should be 0" % get_resource_type(resource_id=8))#CPU return
def test_03_multiplecore_delete_instance(self): """Test Deploy VM with multiple core CPU & verify the usage""" # Validate the following # 1. Deploy VM with multiple core CPU & verify the usage # 2. Destroy VM & verify update resource count of Root Admin Account # 3. Resource count should list properly. account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].cputotal expected_resource_count = int( self.services["service_offering"]["cpunumber"]) self.assertEqual( resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Destroying instance: %s" % self.vm.name) try: self.vm.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].cputotal self.assertEqual(resource_count, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=8)) #CPU return
def test_02_migrate_vm(self): """Test Deploy VM with specified RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM & Deploy VM in the created domain # 2. List Resource count for the root admin Memory usage # 3. Migrate vm to another host, resource count should list properly. #Resetting memory count in service offering self.services["service_offering"]["memory"] = 2048 self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = { self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2 } for domain, admin in users.items(): self.account = admin self.domain = domain self.debug("Creating an instance with service offering: %s" % self.service_offering.name) api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].memorytotal expected_resource_count = int( self.services["service_offering"]["memory"]) self.assertEqual( resource_count, expected_resource_count, "Resource count should match with the expected resource count") host = find_suitable_host(self.apiclient, vm) self.debug("Migrating instance: %s to host: %s" % (vm.name, host.name)) try: vm.migrate(self.apiclient, host.id) except Exception as e: self.fail("Failed to migrate instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count_after_migrate = account_list[0].memorytotal self.assertTrue( resource_count_after_migrate == resource_count, "Resource count should be same after migrating the instance") return
def test_02_migrate_vm(self): """Test Deploy VM with specified RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM & Deploy VM in the created domain # 2. List Resource count for the root admin Memory usage # 3. Migrate vm to another host, resource count should list properly. #Resetting memory count in service offering self.services["service_offering"]["memory"] = 2048 self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = { self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2 } for domain, admin in users.items(): self.account = admin self.domain = domain self.debug("Creating an instance with service offering: %s" % self.service_offering.name) api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].memorytotal expected_resource_count = int(self.services["service_offering"]["memory"]) self.assertEqual(resource_count, expected_resource_count, "Resource count should match with the expected resource count") host = findSuitableHostForMigration(self.apiclient, vm.id) if host is None: self.skipTest(ERROR_NO_HOST_FOR_MIGRATION) self.debug("Migrating instance: %s to host: %s" % (vm.name, host.name)) try: vm.migrate(self.apiclient, host.id) except Exception as e: self.fail("Failed to migrate instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_migrate = account_list[0].memorytotal self.assertTrue(resource_count_after_migrate == resource_count, "Resource count should be same after migrating the instance") return
def test_02_multiple_core_vm_migrate_instance(self): """Test Deploy VM with 4 core CPU & verify the usage""" # Validate the following # 1. Create two domains and set specific resource (cpu) limit for them # 2. Create compute offering with 4 core CPU & deploy vm # 3. Update Resource count for the domains # 4. Migrate instance to new host and check resource count # 5. Resource count should list properly. self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = {self.domain: self.admin, self.child_domain: self.child_do_admin } for domain, admin in users.items(): self.account = admin self.domain = domain api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].cputotal expected_resource_count = int(self.services["service_offering"]["cpunumber"]) self.assertEqual(resource_count, expected_resource_count, "Initial resource count should match with the expected resource count") host = findSuitableHostForMigration(self.apiclient, vm.id) if host is None: self.skipTest(ERROR_NO_HOST_FOR_MIGRATION) self.debug("Migrating instance: %s to host: %s" % (vm.name, host.name)) try: vm.migrate(self.apiclient, host.id) except Exception as e: self.fail("Failed to migrate instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_migrate = account_list[0].cputotal self.assertEqual(resource_count, resource_count_after_migrate, "Resource count should be same as before, after migrating the instance") return
def test_03_delete_vm(self): """Test Deploy VM with 5 GB RAM & verify the usage""" # Validate the following # 1. Create compute offering with 5 GB RAM & Deploy VM in the created domain # 2. List Resource count for the root admin Memory usage # 3. Delete vm, resource count should list as 0 after delete operation. self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = { self.domain: self.admin, self.child_domain: self.child_do_admin } for domain, admin in users.items(): self.account = admin self.domain = domain self.debug("Creating an instance with service offering: %s" % self.service_offering.name) api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].memorytotal expected_resource_count = int( self.services["service_offering"]["memory"]) self.assertEqual( resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Destroying instance: %s" % vm.name) try: vm.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) # Wait for expunge interval to cleanup Memory wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"]) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count_after_delete = account_list[0].memorytotal self.assertEqual(resource_count_after_delete, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=9)) #RAM return
def test_03_multiple_core_vm_delete_instance(self): """Test Deploy VM with 4 core CPU & verify the usage""" # Validate the following # 1. Create two domains and set specific resource (cpu) limit for them # 2. Create compute offering with 4 core CPU & deploy vm # 3. Update Resource count for the domains # 4. delete instance and check resource count # 5. Resource count should list properly. self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = { self.domain: self.admin, self.child_domain: self.child_do_admin } for domain, admin in users.items(): self.account = admin self.domain = domain api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].cputotal expected_resource_count = int( self.services["service_offering"]["cpunumber"]) self.assertEqual( resource_count, expected_resource_count, "Initial resource count should with the expected resource count" ) self.debug("Destroying instance: %s" % vm.name) try: vm.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count_after_delete = account_list[0].cputotal self.assertEqual(resource_count_after_delete, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=8)) #CPU return
def test_03_delete_vm(self): """Test Deploy VM with specified RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM & Deploy VM in the created domain # 2. List Resource count for the root admin Memory usage # 3. Delete vm, resource count should list as 0 after delete operation. # Resetting the memory count of service offering self.services["service_offering"]["memory"] = 2048 self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = { self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2 } for domain, admin in users.items(): self.account = admin self.domain = domain self.debug("Creating an instance with service offering: %s" % self.service_offering.name) api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].memorytotal expected_resource_count = int(self.services["service_offering"]["memory"]) self.assertEqual(resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Destroying instance: %s" % vm.name) try: vm.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) # Wait for expunge interval to cleanup Memory wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"]) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_delete = account_list[0].memorytotal self.assertEqual(resource_count_after_delete, 0 , "Resource count for %s should be 0" % get_resource_type(resource_id=9))#RAM return
def test_04_deploy_multiple_vm(self): """Test Deploy multiple VM with specified RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM # 2. Deploy multiple VMs with this service offering # 3. List Resource count for the root admin Memory usage # 4. Memory usage should list properly account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].memorytotal expected_resource_count = int(self.services["service_offering"]["memory"]) self.assertEqual(resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Creating two instances with service offering: %s" % self.service_offering.name) vm_1 = self.createInstance(service_off=self.service_offering) self.createInstance(service_off=self.service_offering) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_new = account_list[0].memorytotal expected_resource_count = int(self.services["service_offering"]["memory"]) * 3 #Total 3 VMs self.assertEqual(resource_count_new, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Destroying instance: %s" % vm_1.name) try: vm_1.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_delete = account_list[0].memorytotal expected_resource_count -= int(self.services["service_offering"]["memory"]) self.assertEqual(resource_count_after_delete, expected_resource_count, "Resource count should match with the expected resource count") return
def test_03_delete_instance(self): """Test Deploy VM with specified RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM in child domains of root domain & Deploy VM # 2. List Resource count for the Memory usage # 3. Delete instance # 4. Resource count should list as 0 self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = { self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2 } for domain, admin in users.items(): self.account = admin self.domain = domain api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].memorytotal expected_resource_count = int( self.services["service_offering"]["memory"]) self.assertEqual( resource_count, expected_resource_count, "Initial resource count should match with the expected resource count" ) self.debug("Destroying instance: %s" % vm.name) try: vm.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].memorytotal self.assertEqual(resource_count, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=9)) #RAM return
def test_04_deploy_multiple_vm(self): """Test Deploy multiple VM with specified RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM # 2. Deploy multiple VMs with this service offering # 3. List Resource count for the root admin Memory usage # 4. Memory usage should list properly account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].memorytotal expected_resource_count = int( self.services["service_offering"]["memory"]) self.assertEqual( resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Creating two instances with service offering: %s" % self.service_offering.name) vm_1 = self.createInstance(service_off=self.service_offering) self.createInstance(service_off=self.service_offering) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_new = account_list[0].memorytotal expected_resource_count = int( self.services["service_offering"]["memory"]) * 3 #Total 3 VMs self.assertEqual( resource_count_new, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Destroying instance: %s" % vm_1.name) try: vm_1.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_after_delete = account_list[0].memorytotal expected_resource_count -= int( self.services["service_offering"]["memory"]) self.assertEqual( resource_count_after_delete, expected_resource_count, "Resource count should match with the expected resource count") return
def test_02_migrate_instance(self): """Test Deploy VM with 4 core CPU & verify the usage""" # Validate the following # 1. Create compute offering with 4 core CPU & Deploy VM # 2. List Resource count # 3. Migrate instance to another host # 4. Resource count should list properly. self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = {self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2 } for domain, admin in users.items(): self.account = admin self.domain = domain api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].cputotal expected_resource_count = int(self.services["service_offering"]["cpunumber"]) self.assertEqual(resource_count, expected_resource_count, "Initial resource count should with the expected resource count") host = find_suitable_host(self.apiclient, vm) self.debug("Migrating instance: %s to host: %s" % (vm.name, host.name)) try: vm.migrate(self.apiclient, host.id) except Exception as e: self.fail("Failed to migrate instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_migrate = account_list[0].cputotal self.assertEqual(resource_count, resource_count_after_migrate, "Resource count should be same after starting the instance") return
def test_02_migrate_instance(self): """Test Deploy VM with 4 core CPU & verify the usage""" # Validate the following # 1. Create compute offering with 4 core CPU & Deploy VM # 2. List Resource count # 3. Migrate instance to another host # 4. Resource count should list properly. self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = { self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2 } for domain, admin in users.items(): self.account = admin self.domain = domain api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].cputotal expected_resource_count = int( self.services["service_offering"]["cpunumber"]) self.assertEqual( resource_count, expected_resource_count, "Initial resource count should with the expected resource count") host = find_suitable_host(self.apiclient, vm) self.debug("Migrating instance: %s to host: %s" % (vm.name, host.name)) try: vm.migrate(self.apiclient, host.id) except Exception as e: self.fail("Failed to migrate instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_after_migrate = account_list[0].cputotal self.assertEqual( resource_count, resource_count_after_migrate, "Resource count should be same after starting the instance") return
def test_03_multiple_core_vm_delete_instance(self): """Test Deploy VM with 4 core CPU & verify the usage""" # Validate the following # 1. Create two domains and set specific resource (cpu) limit for them # 2. Create compute offering with 4 core CPU & deploy vm # 3. Update Resource count for the domains # 4. delete instance and check resource count # 5. Resource count should list properly. self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = {self.domain: self.admin, self.child_domain: self.child_do_admin } for domain, admin in users.items(): self.account = admin self.domain = domain api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].cputotal expected_resource_count = int(self.services["service_offering"]["cpunumber"]) self.assertEqual(resource_count, expected_resource_count, "Initial resource count should with the expected resource count") self.debug("Destroying instance: %s" % vm.name) try: vm.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_delete = account_list[0].cputotal self.assertEqual(resource_count_after_delete, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=8))#CPU return
def test_03_delete_instance(self): """Test Deploy VM with 4 core CPU & verify the usage""" # Validate the following # 1. Create compute offering with 4 core CPU & Deploy VM # 2. List Resource count for the CPU usage # 3. Delete instance # 4. Resource count should list as 0 self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = { self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2 } for domain, admin in users.items(): self.account = admin self.domain = domain api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm = self.createInstance( service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].cputotal expected_resource_count = int( self.services["service_offering"]["cpunumber"]) self.assertEqual( resource_count, expected_resource_count, "Initial resource count should match with the expected resource count" ) self.debug("Destroying instance: %s" % vm.name) try: vm.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].cputotal self.assertEqual(resource_count, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=8)) #CPU return
def test_01_multiplecore_start_stop_instance(self): """Test Deploy VM with multiple core CPU & verify the usage""" # Validate the following # 1. Deploy VM with multiple core CPU & verify the usage # 2. Stop VM & verify the update resource count of Root Admin Account # 3. Start VM & verify the update resource count of Root Admin Account # 4. Resource count should list properly. account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].cputotal expected_resource_count = int(self.services["service_offering"]["cpunumber"]) self.assertEqual(resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Stopping instance: %s" % self.vm.name) try: self.vm.stop(self.apiclient) except Exception as e: self.fail("Failed to stop instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_stop = account_list[0].cputotal self.assertEqual(resource_count, resource_count_after_stop, "Resource count should be same after stopping the instance") self.debug("Starting instance: %s" % self.vm.name) try: self.vm.start(self.apiclient) except Exception as e: self.fail("Failed to start instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_start = account_list[0].cputotal self.assertEqual(resource_count, resource_count_after_start, "Resource count should be same after stopping the instance") return
def test_01_multiplecore_start_stop_instance(self): """Test Deploy VM with multiple core CPU & verify the usage""" # Validate the following # 1. Deploy VM with multiple core CPU & verify the usage # 2. Stop VM & verify the update resource count of Root Admin Account # 3. Start VM & verify the update resource count of Root Admin Account # 4. Resource count should list properly. account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].cputotal expected_resource_count = int( self.services["service_offering"]["cpunumber"]) self.assertEqual( resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Stopping instance: %s" % self.vm.name) try: self.vm.stop(self.apiclient) except Exception as e: self.fail("Failed to stop instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_after_stop = account_list[0].cputotal self.assertEqual( resource_count, resource_count_after_stop, "Resource count should be same after stopping the instance") self.debug("Starting instance: %s" % self.vm.name) try: self.vm.start(self.apiclient) except Exception as e: self.fail("Failed to start instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_after_start = account_list[0].cputotal self.assertEqual( resource_count, resource_count_after_start, "Resource count should be same after stopping the instance") return
def test_01_stop_start_instance(self): """Test Deploy VM with specified RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM & Deploy VM as root admin # 2 .List Resource count for the root admin Memory usage # 3. Stop and start instance, resource count should list properly. account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].memorytotal expected_resource_count = int(self.services["service_offering"]["memory"]) self.assertEqual(resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Stopping instance: %s" % self.vm.name) try: self.vm.stop(self.apiclient) except Exception as e: self.fail("Failed to stop instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_stop = account_list[0].memorytotal self.assertEqual(resource_count, resource_count_after_stop, "Resource count should be same after stopping the instance") self.debug("Starting instance: %s" % self.vm.name) try: self.vm.start(self.apiclient) except Exception as e: self.fail("Failed to start instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_start = account_list[0].memorytotal self.assertEqual(resource_count, resource_count_after_start, "Resource count should be same after stopping the instance") return
def test_01_stop_start_instance(self): """Test Deploy VM with specified RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM & Deploy VM as root admin # 2 .List Resource count for the root admin Memory usage # 3. Stop and start instance, resource count should list properly. account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].memorytotal expected_resource_count = int( self.services["service_offering"]["memory"]) self.assertEqual( resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Stopping instance: %s" % self.vm.name) try: self.vm.stop(self.apiclient) except Exception as e: self.fail("Failed to stop instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_after_stop = account_list[0].memorytotal self.assertEqual( resource_count, resource_count_after_stop, "Resource count should be same after stopping the instance") self.debug("Starting instance: %s" % self.vm.name) try: self.vm.start(self.apiclient) except Exception as e: self.fail("Failed to start instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_after_start = account_list[0].memorytotal self.assertEqual( resource_count, resource_count_after_start, "Resource count should be same after stopping the instance") return
def test_04_deploy_multiple_vm_with_multiple_cpus(self): """Test Deploy multiple VM with 4 core CPU & verify the usage""" # Validate the following # 1. Create compute offering with 4 core CPU # 2. Deploy multiple VMs with this service offering # 3. List Resource count for the root admin CPU usage # 4. CPU usage should list properly # 5. Destroy one VM among multiple VM's and verify the resource count # 6. Migrate VM from & verify resource updates # 7. List resource count for Root Admin # 8. Failed to deploy VM and verify the resource usage self.debug("Creating service offering with 4 CPU cores") self.service_offering = ServiceOffering.create( self.apiclient, self.services["service_offering"]) # Adding to cleanup list after execution self.cleanup.append(self.service_offering) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm_1 = self.createInstance(service_off=self.service_offering) vm_2 = self.createInstance(service_off=self.service_offering) self.createInstance(service_off=self.service_offering) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].cputotal expected_resource_count = int( self.services["service_offering"]["cpunumber"]) * 4 #Total 4 Vms self.assertTrue(resource_count == expected_resource_count, "Resource count does not match the expected vavlue") return
def test_04_deploy_multiple_vm_with_multiple_cpus(self): """Test Deploy multiple VM with 4 core CPU & verify the usage""" # Validate the following # 1. Create compute offering with 4 core CPU # 2. Deploy multiple VMs with this service offering # 3. List Resource count for the root admin CPU usage # 4. CPU usage should list properly # 5. Destroy one VM among multiple VM's and verify the resource count # 6. Migrate VM from & verify resource updates # 7. List resource count for Root Admin # 8. Failed to deploy VM and verify the resource usage self.debug("Creating service offering with 4 CPU cores") self.service_offering = ServiceOffering.create( self.apiclient, self.services["service_offering"]) # Adding to cleanup list after execution self.cleanup.append(self.service_offering) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm_1 = self.createInstance(service_off=self.service_offering) vm_2 = self.createInstance(service_off=self.service_offering) self.createInstance(service_off=self.service_offering) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].cputotal expected_resource_count = int( self.services["service_offering"]["cpunumber"]) * 4 #Total 4 Vms self.assertTrue(resource_count == expected_resource_count, "Resource count does not match the expected vavlue") return
def test_04_deploy_multiple_vm(self): """Test Deploy multiple VM with specified RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM # 2. Deploy multiple VMs with this service offering # 3. List Resource count for the root admin Memory usage # 4. Memory usage should list properly # Resetting the memory count of service offering self.services["service_offering"]["memory"] = 2048 self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = { self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2 } for domain, admin in users.items(): self.account = admin self.domain = domain self.debug("Creating an instance with service offering: %s" % self.service_offering.name) api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) vm_1 = self.createInstance(service_off=self.service_offering, api_client=api_client) vm_2 = self.createInstance(service_off=self.service_offering, api_client=api_client) vm_3 = self.createInstance(service_off=self.service_offering, api_client=api_client) self.debug( "Deploying instance - Memory capacity is fully utilized") with self.assertRaises(Exception): self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].memorytotal expected_resource_count = int( self.services["service_offering"]["memory"]) * 3 #Total 3 VMs self.assertEqual( resource_count, expected_resource_count, "Resource count should match with the expected resource count") vm_2.delete(self.apiclient) vm_3.delete(self.apiclient) return
def test_02_multiplecore_migrate_instance(self): """Test Deploy VM with multiple core CPU & verify the usage""" # Validate the following # 1. Deploy VM with multiple core CPU & verify the usage # 2. Migrate VM & verify updated resource count of Root Admin Account # 3. Resource count should list properly. account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].cputotal expected_resource_count = int(self.services["service_offering"]["cpunumber"]) self.assertEqual(resource_count, expected_resource_count, "Resource count should match with the expected resource count") host = findSuitableHostForMigration(self.apiclient, self.vm.id) if host is None: self.skipTest(ERROR_NO_HOST_FOR_MIGRATION) self.debug("Migrating instance: %s to host: %s" % (self.vm.name, host.name)) try: self.vm.migrate(self.apiclient, host.id) except Exception as e: self.fail("Failed to migrate instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_migrate = account_list[0].cputotal self.assertEqual(resource_count, resource_count_after_migrate, "Resource count should be same after migrating the instance") return
def test_02_migrate_instance(self): """Test Deploy VM with specified RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM & Deploy VM as root admin # 2. List Resource count for the root admin Memory usage # 3. Migrate vm, resource count should list properly. account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].memorytotal expected_resource_count = int(self.services["service_offering"]["memory"]) self.assertEqual(resource_count, expected_resource_count, "Resource count should match with the expected resource count") host = findSuitableHostForMigration(self.apiclient, self.vm.id) if host is None: self.skipTest(ERROR_NO_HOST_FOR_MIGRATION) self.debug("Migrating instance: %s to host: %s" % (self.vm.name, host.name)) try: self.vm.migrate(self.apiclient, host.id) except Exception as e: self.fail("Failed to migrate instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_migrate = account_list[0].memorytotal self.assertEqual(resource_count, resource_count_after_migrate, "Resource count should be same after stopping the instance") return
def test_03_delete_instance(self): """Test Deploy VM with specified GB RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM & Deploy VM as root admin # 2. List Resource count for the root admin Memory usage # 3. Delete instance, resource count should be 0 after delete operation. account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].memorytotal expected_resource_count = int( self.services["service_offering"]["memory"]) self.assertEqual( resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Destroying instance: %s" % self.vm.name) try: self.vm.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) # Wait for expunge interval to cleanup Memory wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"]) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_after_delete = account_list[0].memorytotal self.assertEqual(resource_count_after_delete, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=9)) #RAM return
def test_04_deploy_multiple_vm(self): """Test Deploy multiple VM with specified RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM # 2. Deploy multiple VMs with this service offering # 3. List Resource count for the root admin Memory usage # 4. Memory usage should list properly # Resetting the memory count of service offering self.services["service_offering"]["memory"] = 2048 self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = { self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2 } for domain, admin in users.items(): self.account = admin self.domain = domain self.debug("Creating an instance with service offering: %s" % self.service_offering.name) api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) vm_1 = self.createInstance(service_off=self.service_offering, api_client=api_client) vm_2 = self.createInstance(service_off=self.service_offering, api_client=api_client) vm_3 = self.createInstance(service_off=self.service_offering, api_client=api_client) self.debug("Deploying instance - Memory capacity is fully utilized") with self.assertRaises(Exception): self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].memorytotal expected_resource_count = int(self.services["service_offering"]["memory"]) * 3 #Total 3 VMs self.assertEqual(resource_count, expected_resource_count, "Resource count should match with the expected resource count") vm_2.delete(self.apiclient) vm_3.delete(self.apiclient) return
def test_02_migrate_instance(self): """Test Deploy VM with specified RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM & Deploy VM as root admin # 2. List Resource count for the root admin Memory usage # 3. Migrate vm, resource count should list properly. account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].memorytotal expected_resource_count = int( self.services["service_offering"]["memory"]) self.assertEqual( resource_count, expected_resource_count, "Resource count should match with the expected resource count") host = find_suitable_host(self.apiclient, self.vm) self.debug("Migrating instance: %s to host: %s" % (self.vm.name, host.name)) try: self.vm.migrate(self.apiclient, host.id) except Exception as e: self.fail("Failed to migrate instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_after_migrate = account_list[0].memorytotal self.assertEqual( resource_count, resource_count_after_migrate, "Resource count should be same after stopping the instance") return
def test_02_multiplecore_migrate_instance(self): """Test Deploy VM with multiple core CPU & verify the usage""" # Validate the following # 1. Deploy VM with multiple core CPU & verify the usage # 2. Migrate VM & verify updated resource count of Root Admin Account # 3. Resource count should list properly. account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].cputotal expected_resource_count = int( self.services["service_offering"]["cpunumber"]) self.assertEqual( resource_count, expected_resource_count, "Resource count should match with the expected resource count") host = find_suitable_host(self.apiclient, self.vm) self.debug("Migrating instance: %s to host: %s" % (self.vm.name, host.name)) try: self.vm.migrate(self.apiclient, host.id) except Exception as e: self.fail("Failed to migrate instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_after_migrate = account_list[0].cputotal self.assertEqual( resource_count, resource_count_after_migrate, "Resource count should be same after migrating the instance") return
def test_03_delete_instance(self): """Test Deploy VM with specified GB RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM & Deploy VM as root admin # 2. List Resource count for the root admin Memory usage # 3. Delete instance, resource count should be 0 after delete operation. account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].memorytotal expected_resource_count = int(self.services["service_offering"]["memory"]) self.assertEqual(resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Destroying instance: %s" % self.vm.name) try: self.vm.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) # Wait for expunge interval to cleanup Memory wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"]) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_delete = account_list[0].memorytotal self.assertEqual(resource_count_after_delete, 0 , "Resource count for %s should be 0" % get_resource_type(resource_id=9))#RAM return
def test_01_multiple_child_domains(self): """Test CPU limits with multiple child domains""" # Validate the following # 1. Create Domain1 with 10 core CPU and 2 child domains with 4 core # each.Assign 2 cores for Domain1 admin1 & Domain1 User1 .Assign 2 # cores for Domain2 admin1 & Domain2 User1 # 2. Deploy VM's by Domain1 admin1/user1/ Domain2 user1/Admin1 account # and verify the resource updates # 3. Deploy VM by admin account after reaching max parent domain limit # 4. Deploy VM with child account after reaching max child domain limit # 5. Destroy user/admin account VM's and verify the child & Parent # domain resource updates self.debug("Creating service offering with 2 CPU cores") self.services["service_offering"]["cpunumber"] = 2 self.service_offering = ServiceOffering.create( self.apiclient, self.services["service_offering"] ) # Adding to cleanup list after execution self.cleanup.append(self.service_offering) self.debug("Setting up account and domain hierarchy") self.setupAccounts() api_client_cadmin_1 = self.testClient.createUserApiClient( UserName=self.cadmin_1.name, DomainName=self.cadmin_1.domain) api_client_cadmin_2 = self.testClient.createUserApiClient( UserName=self.cadmin_2.name, DomainName=self.cadmin_2.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm_1 = self.createInstance(account=self.cadmin_1, service_off=self.service_offering, api_client=api_client_cadmin_1) vm_2 = self.createInstance(account=self.cadmin_2, service_off=self.service_offering, api_client=api_client_cadmin_2) self.debug("Checking resource count for account: %s" % self.cadmin_1.name) account_list = Account.list(self.apiclient, id=self.cadmin_1.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_cadmin_1 = account_list[0].cputotal self.debug(resource_count_cadmin_1) self.debug("Checking resource count for account: %s" % self.cadmin_2.name) account_list = Account.list(self.apiclient, id=self.cadmin_2.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_cadmin_2 = account_list[0].cputotal self.debug(resource_count_cadmin_2) self.debug( "Creating instance when CPU limit is fully used in child domain 1") with self.assertRaises(Exception): self.createInstance(account=self.cadmin_1, service_off=self.service_offering, api_client=api_client_cadmin_1) self.debug( "Creating instance when CPU limit is fully used in child domain 2") with self.assertRaises(Exception): self.createInstance(account=self.cadmin_2, service_off=self.service_offering, api_client=api_client_cadmin_2) self.debug("Destroying instances: %s, %s" % (vm_1.name, vm_2.name)) try: vm_1.delete(self.apiclient) vm_2.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) self.debug("Checking resource count for account: %s" % self.cadmin_1.name) account_list = Account.list(self.apiclient, id=self.cadmin_1.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_cadmin_1 = account_list[0].cputotal self.debug(resource_count_cadmin_1) self.assertEqual(resource_count_cadmin_1, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=8))#CPU self.debug("Checking resource count for account: %s" % self.cadmin_2.name) account_list = Account.list(self.apiclient, id=self.cadmin_2.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_cadmin_2 = account_list[0].cputotal self.debug(resource_count_cadmin_2) self.assertEqual(resource_count_cadmin_2, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=8))#CPU return
def test_04_deploy_multiple_vm_with_multiple_core(self): """Test Deploy multiple VM with 4 core CPU & verify the usage""" # Validate the following # 1. Create compute offering with 4 core CPU # 2. Deploy multiple VMs within domain with this service offering # 3. Update Resource count for the domain # 4. CPU usage should list properly self.debug("Creating service offering with 4 CPU cores") self.service_offering = ServiceOffering.create( self.apiclient, self.services["service_offering"] ) # Adding to cleanup list after execution self.cleanup.append(self.service_offering) self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = {self.domain: self.admin, self.child_domain: self.child_do_admin } for domain, admin in users.items(): self.account = admin self.domain = domain api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm_1 = self.createInstance(service_off=self.service_offering, api_client=api_client) vm_2 = self.createInstance(service_off=self.service_offering, api_client=api_client) self.createInstance(service_off=self.service_offering, api_client=api_client) self.createInstance(service_off=self.service_offering, api_client=api_client) self.debug("Deploying instance - CPU capacity is fully utilized") with self.assertRaises(Exception): self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].cputotal expected_resource_count = int(self.services["service_offering"]["cpunumber"]) * 4 #Total 4 VMs self.assertEqual(resource_count, expected_resource_count, "Initial resource count should be 4") self.debug("Destroying instance: %s" % vm_1.name) try: vm_1.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_delete = account_list[0].cputotal expected_resource_count -= int(self.services["service_offering"]["cpunumber"]) self.assertEqual(resource_count_after_delete, expected_resource_count, "Resource count should match with the expected count") host = findSuitableHostForMigration(self.apiclient, vm_2.id) if host is None: self.skipTest(ERROR_NO_HOST_FOR_MIGRATION) self.debug("Migrating instance: %s to host: %s" % (vm_2.name, host.name)) try: vm_2.migrate(self.apiclient, host.id) except Exception as e: self.fail("Failed to migrate instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_migrate = account_list[0].cputotal self.assertEqual(resource_count_after_migrate, resource_count_after_delete, "Resource count should not change after migrating the instance") return
def test_01_change_service_offering(self): """Test Deploy VM with specified RAM & verify the usage""" # Validate the following # 1. Create compute offering with specified RAM & Deploy VM in the created domain # 2. List Resource count for the root admin Memory usage # 3. Upgrade and downgrade service offering # 4. Resource count should list properly for the domain self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = { self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2 } for domain, admin in users.items(): self.account = admin self.domain = domain #Resetting memory count in service offering self.services["service_offering"]["memory"] = 2048 self.debug("Creating an instance with service offering: %s" % self.service_offering.name) api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].memorytotal expected_resource_count = int( self.services["service_offering"]["memory"]) self.assertEqual( resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Stopping instance: %s" % vm.name) try: vm.stop(self.apiclient) except Exception as e: self.fail("Failed to stop instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count_after_stop = account_list[0].memorytotal self.assertEqual( resource_count_after_stop, expected_resource_count, "Resource count should be same after stopping the instance") self.debug("Creating service offering with 5 GB RAM") self.services["service_offering"]["memory"] = 5120 self.service_offering_5gb = ServiceOffering.create( self.apiclient, self.services["service_offering"]) # Adding to cleanup list after execution self.cleanup.append(self.service_offering_5gb) self.debug( "Upgrade service offering of instance %s from %s to %s" % (vm.name, self.service_offering.name, self.service_offering_5gb.name)) try: vm.change_service_offering( self.apiclient, serviceOfferingId=self.service_offering_5gb.id) except Exception as e: self.fail("Failed to change service offering of vm %s - %s" % (vm.name, e)) update_resource_count(self.apiclient, domainid=self.domain.id, rtype=9) #RAM account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count_after_upgrade = account_list[0].memorytotal self.debug(resource_count_after_upgrade) self.assertTrue( resource_count_after_upgrade > resource_count_after_stop, "Resource count should be more than before, after upgrading service offering" ) self.debug( "Down grade service offering of instance %s from %s to %s" % (vm.name, self.service_offering_5gb.name, self.service_offering.name)) try: vm.change_service_offering( self.apiclient, serviceOfferingId=self.service_offering.id) except Exception as e: self.fail("Failed to change service offering of vm %s - %s" % (vm.name, e)) update_resource_count(self.apiclient, domainid=self.domain.id, rtype=9) #RAM account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count_after_downgrade = account_list[0].memorytotal self.debug(resource_count_after_downgrade) self.assertTrue( resource_count_after_downgrade < resource_count_after_upgrade, "Resource count should be less than before, after downgrading service offering" ) self.debug("Starting instance: %s" % vm.name) try: vm.start(self.apiclient) except Exception as e: self.fail("Failed to start instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count_after_start = account_list[0].memorytotal self.assertTrue( resource_count_after_start == resource_count_after_downgrade, "Resource count should be same after starting the instance") return
def test_01_stop_start_instance(self): """Test Deploy VM with 4 core CPU & verify the usage""" # Validate the following # 1. Create compute offering with 4 core CPU & Deploy VM # 2. List Resource count CPU usage # 3. Stop and Start instance, check resource count. # 4. Resource count should list properly. self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = {self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2 } for domain, admin in users.items(): self.account = admin self.domain = domain api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].cputotal expected_resource_count = int(self.services["service_offering"]["cpunumber"]) self.assertEqual(resource_count, expected_resource_count, "Initial resource count should match with the expected resource count") self.debug("Stopping instance: %s" % vm.name) try: vm.stop(self.apiclient) except Exception as e: self.fail("Failed to stop instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_stop = account_list[0].cputotal self.assertEqual(resource_count, resource_count_after_stop, "Resource count should be same after stopping the instance") self.debug("Starting instance: %s" % vm.name) try: vm.start(self.apiclient) except Exception as e: self.fail("Failed to start instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_start = account_list[0].cputotal self.assertEqual(resource_count_after_stop, resource_count_after_start, "Resource count should be same after starting the instance") return
def test_04_deploy_multiple_vm(self): """Test Deploy multiple VM with 2 GB memory & verify the usage""" #keep the configuration value - max.account.memory = 8192 (maximum 4 instances per account with 2 GB RAM) # Validate the following # 1. Create compute offering with 2 GB RAM # 2. Deploy multiple VMs with this service offering in child domains of root domain # 3. List Resource count for the root admin Memory usage # 4. Memory usage should list properly self.debug("Creating service offering with 2 GB RAM") self.service_offering = ServiceOffering.create( self.apiclient, self.services["service_offering"] ) # Adding to cleanup list after execution self.cleanup.append(self.service_offering) self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = {self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2 } for domain, admin in users.items(): self.account = admin self.domain = domain memory_account_gc = Resources.list(self.apiclient, resourcetype = 9, #Memory account = self.account.name, domainid = self.domain.id ) if memory_account_gc[0].max != 8192: self.skipTest("This test case requires configuration value max.account.memory to be 8192") api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm_1 = self.createInstance(service_off=self.service_offering, api_client=api_client) vm_2 = self.createInstance(service_off=self.service_offering, api_client=api_client) self.createInstance(service_off=self.service_offering, api_client=api_client) self.createInstance(service_off=self.service_offering, api_client=api_client) self.debug("Deploying instance - memory capacity is fully utilized") with self.assertRaises(Exception): self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].memorytotal expected_resource_count = int(self.services["service_offering"]["memory"]) * 4 #Total 4 vms self.assertEqual(resource_count, expected_resource_count, "Initial resource count should with the expected resource count") self.debug("Destroying instance: %s" % vm_1.name) try: vm_1.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_delete = account_list[0].memorytotal expected_resource_count -= int(self.services["service_offering"]["memory"]) self.assertEqual(resource_count_after_delete, expected_resource_count, "Resource count should match with the expected resource count") host = findSuitableHostForMigration(self.apiclient, vm_2.id) if host is None: self.skipTest(ERROR_NO_HOST_FOR_MIGRATION) self.debug("Migrating instance: %s to host: %s" % (vm_2.name, host.name)) try: vm_2.migrate(self.apiclient, host.id) except Exception as e: self.fail("Failed to migrate instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_migrate = account_list[0].memorytotal self.debug(resource_count_after_migrate) self.assertEqual(resource_count_after_delete, resource_count_after_migrate, "Resource count should be same after migrating the instance") return
def test_04_deploy_multiple_vm_with_multiple_cpus(self): """Test Deploy multiple VM with 4 core CPU & verify the usage""" #keep the configuration value - max.account.cpus number = 16 # Validate the following # 1. Create compute offering with 4 core CPU # 2. Deploy multiple VMs with this service offering # 3. List Resource count for the root admin CPU usage # 4. CPU usage should list properly self.debug("Creating service offering with 4 CPU cores") self.service_offering = ServiceOffering.create( self.apiclient, self.services["service_offering"] ) # Adding to cleanup list after execution self.cleanup.append(self.service_offering) self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = {self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2 } for domain, admin in users.items(): self.account = admin self.domain = domain cpu_account_gc = Resources.list(self.apiclient, resourcetype = 8, #CPU account = self.account.name, domainid = self.domain.id ) if cpu_account_gc[0].max != 16: self.skipTest("This test case requires configuration value max.account.cpus to be 16") api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm_1 = self.createInstance(service_off=self.service_offering, api_client=api_client) vm_2 = self.createInstance(service_off=self.service_offering, api_client=api_client) self.createInstance(service_off=self.service_offering, api_client=api_client) self.createInstance(service_off=self.service_offering, api_client=api_client) self.debug("Deploying instance - CPU capacity is fully utilized") with self.assertRaises(Exception): self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].cputotal expected_resource_count = int(self.services["service_offering"]["cpunumber"]) * 4 #Total 4 vms self.assertEqual(resource_count, expected_resource_count, "Initial resource count should with the expected resource count") self.debug("Destroying instance: %s" % vm_1.name) try: vm_1.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_delete = account_list[0].cputotal expected_resource_count -= int(self.services["service_offering"]["cpunumber"]) self.assertEqual(resource_count_after_delete, expected_resource_count, "Resource count should be less than before after deleting the instance") host = find_suitable_host(self.apiclient, vm_2) self.debug("Migrating instance: %s to host: %s" % (vm_2.name, host.name)) try: vm_2.migrate(self.apiclient, host.id) except Exception as e: self.fail("Failed to migrate instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_migrate = account_list[0].cputotal self.debug(resource_count_after_migrate) self.assertEqual(resource_count_after_delete, resource_count_after_migrate, "Resource count should be same after migrating the instance")
def test_04_deploy_multiple_vm_with_multiple_cpus(self): """Test Deploy multiple VM with 4 core CPU & verify the usage""" #keep the configuration value - max.account.cpus number = 16 # Validate the following # 1. Create compute offering with 4 core CPU # 2. Deploy multiple VMs with this service offering # 3. List Resource count for the root admin CPU usage # 4. CPU usage should list properly self.debug("Creating service offering with 4 CPU cores") self.service_offering = ServiceOffering.create( self.apiclient, self.services["service_offering"]) # Adding to cleanup list after execution self.cleanup.append(self.service_offering) self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = { self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2 } for domain, admin in users.items(): self.account = admin self.domain = domain cpu_account_gc = Resources.list( self.apiclient, resourcetype=8, #CPU account=self.account.name, domainid=self.domain.id) if cpu_account_gc[0].max != 16: self.skipTest( "This test case requires configuration value max.account.cpus to be 16" ) api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm_1 = self.createInstance(service_off=self.service_offering, api_client=api_client) vm_2 = self.createInstance(service_off=self.service_offering, api_client=api_client) self.createInstance(service_off=self.service_offering, api_client=api_client) self.createInstance(service_off=self.service_offering, api_client=api_client) self.debug("Deploying instance - CPU capacity is fully utilized") with self.assertRaises(Exception): self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].cputotal expected_resource_count = int(self.services["service_offering"] ["cpunumber"]) * 4 #Total 4 vms self.assertEqual( resource_count, expected_resource_count, "Initial resource count should with the expected resource count" ) self.debug("Destroying instance: %s" % vm_1.name) try: vm_1.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count_after_delete = account_list[0].cputotal expected_resource_count -= int( self.services["service_offering"]["cpunumber"]) self.assertEqual( resource_count_after_delete, expected_resource_count, "Resource count should be less than before after deleting the instance" ) host = find_suitable_host(self.apiclient, vm_2) self.debug("Migrating instance: %s to host: %s" % (vm_2.name, host.name)) try: vm_2.migrate(self.apiclient, host.id) except Exception as e: self.fail("Failed to migrate instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count_after_migrate = account_list[0].cputotal self.debug(resource_count_after_migrate) self.assertEqual( resource_count_after_delete, resource_count_after_migrate, "Resource count should be same after migrating the instance")
def test_01_change_service_offering(self): """Test Deploy VM with 5 GB RAM & verify the usage""" # Validate the following # 1. Create compute offering with 5 GB RAM & Deploy VM in the created domain # 2. List Resource count for the root admin Memory usage # 3. Upgrade and downgrade service offering # 4. Resource count should list properly for the domain self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = { self.domain: self.admin, self.child_domain: self.child_do_admin } for domain, admin in users.items(): self.account = admin self.domain = domain self.debug("Creating an instance with service offering: %s" % self.service_offering.name) api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count = account_list[0].memorytotal expected_resource_count = int(self.services["service_offering"]["memory"]) self.assertEqual(resource_count, expected_resource_count, "Resource count should match with the expected resource count") self.debug("Stopping instance: %s" % vm.name) try: vm.stop(self.apiclient) except Exception as e: self.fail("Failed to stop instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_stop = account_list[0].memorytotal self.asserEqual(resource_count_after_stop, expected_resource_count, "Resource count should be same after stopping the instance") self.debug("Creating service offering with 7 GB RAM") self.services["service_offering"]["memory"] = 7168 self.service_offering_7gb = ServiceOffering.create( self.apiclient, self.services["service_offering"] ) # Adding to cleanup list after execution self.cleanup.append(self.service_offering_7gb) self.debug( "Upgrade service offering of instance %s from %s to %s" % (vm.name, self.service_offering.name, self.service_offering_7gb.name)) try: vm.change_service_offering(self.apiclient, serviceOfferingId=self.service_offering_7gb.id) except Exception as e: self.fail("Failed to change service offering of vm %s - %s" % (vm.name, e)) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_upgrade = account_list[0].memorytotal self.debug(resource_count_after_upgrade) self.assertTrue(resource_count_after_upgrade > resource_count_after_stop, "Resource count should be more than before, after upgrading service offering") self.debug( "Down grade service offering of instance %s from %s to %s" % (vm.name, self.service_offering_7gb.name, self.service_offering.name)) try: vm.change_service_offering(self.apiclient, serviceOfferingId=self.service_offering.id) except Exception as e: self.fail("Failed to change service offering of vm %s - %s" % (vm.name, e)) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_downgrade = account_list[0].memorytotal self.assertTrue(resource_count_after_downgrade < resource_count_after_upgrade, "Resource count should be less than before, after downgrading service offering") self.debug("Starting instance: %s" % vm.name) try: vm.start(self.apiclient) except Exception as e: self.fail("Failed to start instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response" ) resource_count_after_start = account_list[0].memorytotal self.assertTrue(resource_count_after_start == resource_count_after_downgrade, "Resource count should be same after starting the instance") return
def test_01_stop_start_instance(self): """Test Deploy VM with 4 core CPU & verify the usage""" # Validate the following # 1. Create compute offering with 4 core CPU & Deploy VM # 2. List Resource count CPU usage # 3. Stop and Start instance, check resource count. # 4. Resource count should list properly. self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = { self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2 } for domain, admin in users.items(): self.account = admin self.domain = domain api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm = self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].cputotal expected_resource_count = int( self.services["service_offering"]["cpunumber"]) self.assertEqual( resource_count, expected_resource_count, "Initial resource count should match with the expected resource count" ) self.debug("Stopping instance: %s" % vm.name) try: vm.stop(self.apiclient) except Exception as e: self.fail("Failed to stop instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_after_stop = account_list[0].cputotal self.assertEqual( resource_count, resource_count_after_stop, "Resource count should be same after stopping the instance") self.debug("Starting instance: %s" % vm.name) try: vm.start(self.apiclient) except Exception as e: self.fail("Failed to start instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_after_start = account_list[0].cputotal self.assertEqual( resource_count_after_stop, resource_count_after_start, "Resource count should be same after starting the instance") return
def test_04_deploy_multiple_vm_with_multiple_core(self): """Test Deploy multiple VM with 4 core CPU & verify the usage""" # Validate the following # 1. Create compute offering with 4 core CPU # 2. Deploy multiple VMs within domain with this service offering # 3. Update Resource count for the domain # 4. CPU usage should list properly self.debug("Creating service offering with 4 CPU cores") self.service_offering = ServiceOffering.create( self.apiclient, self.services["service_offering"]) # Adding to cleanup list after execution self.cleanup.append(self.service_offering) self.debug("Setting up account and domain hierarchy") self.setupAccounts() users = { self.domain: self.admin, self.child_domain: self.child_do_admin } for domain, admin in users.items(): self.account = admin self.domain = domain api_client = self.testClient.createUserApiClient( UserName=self.account.name, DomainName=self.account.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm_1 = self.createInstance(service_off=self.service_offering, api_client=api_client) vm_2 = self.createInstance(service_off=self.service_offering, api_client=api_client) self.createInstance(service_off=self.service_offering, api_client=api_client) self.createInstance(service_off=self.service_offering, api_client=api_client) self.debug("Deploying instance - CPU capacity is fully utilized") with self.assertRaises(Exception): self.createInstance(service_off=self.service_offering, api_client=api_client) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count = account_list[0].cputotal expected_resource_count = int(self.services["service_offering"] ["cpunumber"]) * 4 #Total 4 VMs self.assertEqual(resource_count, expected_resource_count, "Initial resource count should be 4") self.debug("Destroying instance: %s" % vm_1.name) try: vm_1.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count_after_delete = account_list[0].cputotal expected_resource_count -= int( self.services["service_offering"]["cpunumber"]) self.assertEqual( resource_count_after_delete, expected_resource_count, "Resource count should match with the expected count") host = find_suitable_host(self.apiclient, vm_2) self.debug("Migrating instance: %s to host: %s" % (vm_2.name, host.name)) try: vm_2.migrate(self.apiclient, host.id) except Exception as e: self.fail("Failed to migrate instance: %s" % e) account_list = Account.list(self.apiclient, id=self.account.id) self.assertIsInstance( account_list, list, "List Accounts should return a valid response") resource_count_after_migrate = account_list[0].cputotal self.assertEqual( resource_count_after_migrate, resource_count_after_delete, "Resource count should not change after migrating the instance" ) return
def test_01_multiple_child_domains(self): """Test CPU limits with multiple child domains""" # Validate the following # 1. Create Domain1 with 10 core CPU and 2 child domains with 4 core # each.Assign 2 cores for Domain1 admin1 & Domain1 User1 .Assign 2 # cores for Domain2 admin1 & Domain2 User1 # 2. Deploy VM's by Domain1 admin1/user1/ Domain2 user1/Admin1 account # and verify the resource updates # 3. Deploy VM by admin account after reaching max parent domain limit # 4. Deploy VM with child account after reaching max child domain limit # 5. Destroy user/admin account VM's and verify the child & Parent # domain resource updates self.debug("Creating service offering with 2 CPU cores") self.services["service_offering"]["cpunumber"] = 2 self.service_offering = ServiceOffering.create( self.apiclient, self.services["service_offering"]) # Adding to cleanup list after execution self.cleanup.append(self.service_offering) self.debug("Setting up account and domain hierarchy") self.setupAccounts() api_client_cadmin_1 = self.testClient.createUserApiClient( UserName=self.cadmin_1.name, DomainName=self.cadmin_1.domain) api_client_cadmin_2 = self.testClient.createUserApiClient( UserName=self.cadmin_2.name, DomainName=self.cadmin_2.domain) self.debug("Creating an instance with service offering: %s" % self.service_offering.name) vm_1 = self.createInstance(account=self.cadmin_1, service_off=self.service_offering, api_client=api_client_cadmin_1) vm_2 = self.createInstance(account=self.cadmin_2, service_off=self.service_offering, api_client=api_client_cadmin_2) self.debug("Checking resource count for account: %s" % self.cadmin_1.name) account_list = Account.list(self.apiclient, id=self.cadmin_1.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_cadmin_1 = account_list[0].cputotal self.debug(resource_count_cadmin_1) self.debug("Checking resource count for account: %s" % self.cadmin_2.name) account_list = Account.list(self.apiclient, id=self.cadmin_2.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_cadmin_2 = account_list[0].cputotal self.debug(resource_count_cadmin_2) self.debug( "Creating instance when CPU limit is fully used in child domain 1") with self.assertRaises(Exception): self.createInstance(account=self.cadmin_1, service_off=self.service_offering, api_client=api_client_cadmin_1) self.debug( "Creating instance when CPU limit is fully used in child domain 2") with self.assertRaises(Exception): self.createInstance(account=self.cadmin_2, service_off=self.service_offering, api_client=api_client_cadmin_2) self.debug("Destroying instances: %s, %s" % (vm_1.name, vm_2.name)) try: vm_1.delete(self.apiclient) vm_2.delete(self.apiclient) except Exception as e: self.fail("Failed to delete instance: %s" % e) self.debug("Checking resource count for account: %s" % self.cadmin_1.name) account_list = Account.list(self.apiclient, id=self.cadmin_1.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_cadmin_1 = account_list[0].cputotal self.debug(resource_count_cadmin_1) self.assertEqual(resource_count_cadmin_1, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=8)) #CPU self.debug("Checking resource count for account: %s" % self.cadmin_2.name) account_list = Account.list(self.apiclient, id=self.cadmin_2.id) self.assertIsInstance(account_list, list, "List Accounts should return a valid response") resource_count_cadmin_2 = account_list[0].cputotal self.debug(resource_count_cadmin_2) self.assertEqual(resource_count_cadmin_2, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=8)) #CPU return