@@ -2496,9 +2496,10 @@ def test_migrate_to_unified_limits_unexpected_error(self, mock_sdk):
2496
2496
mock_sdk .return_value .create_limit .side_effect = (
2497
2497
test .TestingException ('oops!' ))
2498
2498
2499
- # Create a couple of project limits.
2499
+ # Create a few project limits.
2500
2500
objects .Quotas .create_limit (self .ctxt , uuids .project , 'ram' , 8192 )
2501
2501
objects .Quotas .create_limit (self .ctxt , uuids .project , 'instances' , 25 )
2502
+ objects .Quotas .create_limit (self .ctxt , uuids .project , 'cores' , 22 )
2502
2503
2503
2504
return_code = self .cli .migrate_to_unified_limits (
2504
2505
project_id = uuids .project , verbose = True )
@@ -2511,10 +2512,16 @@ def test_migrate_to_unified_limits_unexpected_error(self, mock_sdk):
2511
2512
# cores, ram, metadata_items, injected_files,
2512
2513
# injected_file_content_bytes, injected_file_path_length, key_pairs,
2513
2514
# server_groups, and server_group_members.
2515
+ #
2516
+ # And there is 1 default limit value automatically generated for PCPU
2517
+ # based on 'cores'.
2514
2518
self .assertEqual (
2515
- 10 , mock_sdk .return_value .create_registered_limit .call_count )
2519
+ 11 , mock_sdk .return_value .create_registered_limit .call_count )
2516
2520
2517
- self .assertEqual (2 , mock_sdk .return_value .create_limit .call_count )
2521
+ # We expect that we attempted to create 4 project limits:
2522
+ # class:MEMORY_MB, servers, and class:VCPU = 3 + special case
2523
+ # class:PCPU = 4.
2524
+ self .assertEqual (4 , mock_sdk .return_value .create_limit .call_count )
2518
2525
2519
2526
def test_migrate_to_unified_limits_already_exists (self ):
2520
2527
# Create a couple of unified limits to already exist.
@@ -2531,15 +2538,18 @@ def test_migrate_to_unified_limits_already_exists(self):
2531
2538
self .cli .migrate_to_unified_limits (
2532
2539
project_id = uuids .project , verbose = True )
2533
2540
2534
- # There are 10 default limit values in the config options, so because a
2535
- # limit for 'servers' already exists, we should have only created 9.
2541
+ # There are 10 default limit values in the config options +
2542
+ # 1 special case for PCPU which will be added based on VCPU = 11.
2543
+ # Because a limit for 'servers' already exists, we should have only
2544
+ # created 10.
2536
2545
mock_sdk = self .ul_api .mock_sdk_adapter
2537
2546
self .assertEqual (
2538
- 9 , mock_sdk .create_registered_limit .call_count )
2547
+ 10 , mock_sdk .create_registered_limit .call_count )
2539
2548
2540
2549
# There already exists a project limit for 'class:VCPU', so we should
2541
- # have created only 1 project limit.
2542
- self .assertEqual (1 , mock_sdk .create_limit .call_count )
2550
+ # have created only 2 project limits. One for 'servers' and one for
2551
+ # special case 'class:PCPU' generated from VCPU.
2552
+ self .assertEqual (2 , mock_sdk .create_limit .call_count )
2543
2553
2544
2554
def test_migrate_to_unified_limits (self ):
2545
2555
# Set some defaults using the config options.
@@ -2587,10 +2597,14 @@ def test_migrate_to_unified_limits(self):
2587
2597
self .cli .migrate_to_unified_limits (
2588
2598
project_id = uuids .project , verbose = True )
2589
2599
2590
- # There should be 10 registered (default) limits now.
2600
+ # There are 10 default limit values in the config options +
2601
+ # 1 special case for PCPU which will be added based on VCPU = 11.
2602
+ #
2603
+ # There should be 11 registered (default) limits now.
2591
2604
expected_registered_limits = {
2592
2605
'servers' : 5 ,
2593
2606
'class:VCPU' : 10 ,
2607
+ 'class:PCPU' : 10 ,
2594
2608
'class:MEMORY_MB' : 4096 ,
2595
2609
'server_metadata_items' : 64 ,
2596
2610
'server_injected_files' : 3 ,
@@ -2602,7 +2616,7 @@ def test_migrate_to_unified_limits(self):
2602
2616
}
2603
2617
2604
2618
registered_limits = self .ul_api .registered_limits ()
2605
- self .assertEqual (10 , len (registered_limits ))
2619
+ self .assertEqual (11 , len (registered_limits ))
2606
2620
for rl in registered_limits :
2607
2621
self .assertEqual (
2608
2622
expected_registered_limits [rl .resource_name ], rl .default_limit )
@@ -2634,7 +2648,7 @@ def test_migrate_to_unified_limits(self):
2634
2648
2635
2649
region_registered_limits = self .ul_api .registered_limits (
2636
2650
region_id = uuids .region )
2637
- self .assertEqual (10 , len (region_registered_limits ))
2651
+ self .assertEqual (11 , len (region_registered_limits ))
2638
2652
for rl in region_registered_limits :
2639
2653
self .assertEqual (
2640
2654
expected_registered_limits [rl .resource_name ], rl .default_limit )
0 commit comments