3232 cleanup_resources ,
3333 wait_for_cleanup ,
3434 find_suitable_host ,
35- get_resource_type
35+ get_resource_type ,
36+ update_resource_count
3637 )
3738
3839class Services :
@@ -219,12 +220,16 @@ def test_01_change_service_offering(self):
219220
220221 self .debug ("Setting up account and domain hierarchy" )
221222 self .setupAccounts ()
222- users = { self .domain : self .admin ,
223- self .child_domain : self .child_do_admin
223+ users = { self .child_domain_1 : self .child_do_admin_1 ,
224+ self .child_domain_2 : self .child_do_admin_2
224225 }
225226 for domain , admin in users .items ():
226227 self .account = admin
227228 self .domain = domain
229+
230+ #Resetting memory count in service offering
231+ self .services ["service_offering" ]["memory" ] = 5120
232+
228233 self .debug ("Creating an instance with service offering: %s" %
229234 self .service_offering .name )
230235
@@ -258,7 +263,7 @@ def test_01_change_service_offering(self):
258263 )
259264 resource_count_after_stop = account_list [0 ].memorytotal
260265
261- self .asserEqual (resource_count_after_stop , expected_resource_count ,
266+ self .assertEqual (resource_count_after_stop , expected_resource_count ,
262267 "Resource count should be same after stopping the instance" )
263268
264269 self .debug ("Creating service offering with 7 GB RAM" )
@@ -283,6 +288,8 @@ def test_01_change_service_offering(self):
283288 self .fail ("Failed to change service offering of vm %s - %s" %
284289 (vm .name , e ))
285290
291+ update_resource_count (self .apiclient , domainid = self .domain .id , rtype = 9 ) #RAM
292+
286293 account_list = Account .list (self .apiclient , id = self .account .id )
287294 self .assertIsInstance (account_list ,
288295 list ,
@@ -308,13 +315,18 @@ def test_01_change_service_offering(self):
308315 self .fail ("Failed to change service offering of vm %s - %s" %
309316 (vm .name , e ))
310317
318+ update_resource_count (self .apiclient , domainid = self .domain .id , rtype = 9 ) #RAM
319+
311320 account_list = Account .list (self .apiclient , id = self .account .id )
312321 self .assertIsInstance (account_list ,
313322 list ,
314323 "List Accounts should return a valid response"
315324 )
325+
316326 resource_count_after_downgrade = account_list [0 ].memorytotal
317327
328+ self .debug (resource_count_after_downgrade )
329+
318330 self .assertTrue (resource_count_after_downgrade < resource_count_after_upgrade ,
319331 "Resource count should be less than before, after downgrading service offering" )
320332
@@ -344,10 +356,13 @@ def test_02_migrate_vm(self):
344356 # 2. List Resource count for the root admin Memory usage
345357 # 3. Migrate vm to another host, resource count should list properly.
346358
359+ #Resetting memory count in service offering
360+ self .services ["service_offering" ]["memory" ] = 5120
361+
347362 self .debug ("Setting up account and domain hierarchy" )
348363 self .setupAccounts ()
349- users = { self .domain : self .admin ,
350- self .child_domain : self .child_do_admin
364+ users = { self .child_domain_1 : self .child_do_admin_1 ,
365+ self .child_domain_2 : self .child_do_admin_2
351366 }
352367 for domain , admin in users .items ():
353368 self .account = admin
@@ -400,10 +415,13 @@ def test_03_delete_vm(self):
400415 # 2. List Resource count for the root admin Memory usage
401416 # 3. Delete vm, resource count should list as 0 after delete operation.
402417
418+ # Resetting the memory count of service offering
419+ self .services ["service_offering" ]["memory" ] = 5120
420+
403421 self .debug ("Setting up account and domain hierarchy" )
404422 self .setupAccounts ()
405- users = { self .domain : self .admin ,
406- self .child_domain : self .child_do_admin
423+ users = { self .child_domain_1 : self .child_do_admin_1 ,
424+ self .child_domain_2 : self .child_do_admin_2
407425 }
408426 for domain , admin in users .items ():
409427 self .account = admin
@@ -457,10 +475,13 @@ def test_04_deploy_multiple_vm(self):
457475 # 3. List Resource count for the root admin Memory usage
458476 # 4. Memory usage should list properly
459477
478+ # Resetting the memory count of service offering
479+ self .services ["service_offering" ]["memory" ] = 5120
480+
460481 self .debug ("Setting up account and domain hierarchy" )
461482 self .setupAccounts ()
462- users = { self .domain : self .admin ,
463- self .child_domain : self .child_do_admin
483+ users = { self .child_domain_1 : self .child_do_admin_1 ,
484+ self .child_domain_2 : self .child_do_admin_2
464485 }
465486 for domain , admin in users .items ():
466487 self .account = admin
@@ -496,7 +517,6 @@ def test_04_deploy_multiple_vm(self):
496517 vm_3 .delete (self .apiclient )
497518 return
498519
499-
500520class TestMultipleChildDomainsMemory (cloudstackTestCase ):
501521
502522 @classmethod
@@ -507,7 +527,7 @@ def setUpClass(cls):
507527 # Get Zone, Domain and templates
508528 cls .domain = get_domain (cls .api_client , cls .services )
509529 cls .zone = get_zone (cls .api_client , cls .services )
510- cls .services ["mode" ] = cls .zone .networktype
530+ cls .services ["mode" ] = cls .zone .networktype
511531
512532 cls .template = get_template (
513533 cls .api_client ,
@@ -548,8 +568,8 @@ def createInstance(self, account, service_off, networks=None, api_client=None):
548568 self .debug ("Deploying an instance in account: %s" %
549569 account .name )
550570
551- if api_client is None :
552- api_client = self .apiclient
571+ if api_client is None :
572+ api_client = self .apiclient
553573
554574 try :
555575 vm = VirtualMachine .create (
@@ -644,12 +664,12 @@ def setupAccounts(self):
644664 account = self .cadmin_2 .name ,
645665 domainid = self .cadmin_2 .domainid )
646666
647- # Cleanup the resources created at end of test
667+ # Cleanup the resources created at end of test
648668 self .cleanup .append (self .cadmin_1 )
649669 self .cleanup .append (self .cadmin_2 )
650670 self .cleanup .append (self .cdomain_1 )
651- self .cleanup .append (self .cdomain_2 )
652- self .cleanup .append (self .parentd_admin )
671+ self .cleanup .append (self .cdomain_2 )
672+ self .cleanup .append (self .parentd_admin )
653673 self .cleanup .append (self .parent_domain )
654674
655675 users = {
@@ -687,11 +707,11 @@ def test_01_multiple_child_domains(self):
687707 self .debug ("Setting up account and domain hierarchy" )
688708 self .setupAccounts ()
689709
690- api_client_cadmin_1 = self .testClient .createUserApiClient (
710+ api_client_cadmin_1 = self .testClient .createUserApiClient (
691711 UserName = self .cadmin_1 .name ,
692712 DomainName = self .cadmin_1 .domain )
693713
694- api_client_cadmin_2 = self .testClient .createUserApiClient (
714+ api_client_cadmin_2 = self .testClient .createUserApiClient (
695715 UserName = self .cadmin_2 .name ,
696716 DomainName = self .cadmin_2 .domain )
697717
0 commit comments