@@ -2443,9 +2443,10 @@ def test_migrate_to_unified_limits_unexpected_error(self, mock_sdk):
2443
2443
mock_sdk .return_value .create_limit .side_effect = (
2444
2444
test .TestingException ('oops!' ))
2445
2445
2446
- # Create a couple of project limits.
2446
+ # Create a few project limits.
2447
2447
objects .Quotas .create_limit (self .ctxt , uuids .project , 'ram' , 8192 )
2448
2448
objects .Quotas .create_limit (self .ctxt , uuids .project , 'instances' , 25 )
2449
+ objects .Quotas .create_limit (self .ctxt , uuids .project , 'cores' , 22 )
2449
2450
2450
2451
return_code = self .cli .migrate_to_unified_limits (
2451
2452
project_id = uuids .project , verbose = True )
@@ -2458,10 +2459,16 @@ def test_migrate_to_unified_limits_unexpected_error(self, mock_sdk):
2458
2459
# cores, ram, metadata_items, injected_files,
2459
2460
# injected_file_content_bytes, injected_file_path_length, key_pairs,
2460
2461
# server_groups, and server_group_members.
2462
+ #
2463
+ # And there is 1 default limit value automatically generated for PCPU
2464
+ # based on 'cores'.
2461
2465
self .assertEqual (
2462
- 10 , mock_sdk .return_value .create_registered_limit .call_count )
2466
+ 11 , mock_sdk .return_value .create_registered_limit .call_count )
2463
2467
2464
- self .assertEqual (2 , mock_sdk .return_value .create_limit .call_count )
2468
+ # We expect that we attempted to create 4 project limits:
2469
+ # class:MEMORY_MB, servers, and class:VCPU = 3 + special case
2470
+ # class:PCPU = 4.
2471
+ self .assertEqual (4 , mock_sdk .return_value .create_limit .call_count )
2465
2472
2466
2473
def test_migrate_to_unified_limits_already_exists (self ):
2467
2474
# Create a couple of unified limits to already exist.
@@ -2478,15 +2485,18 @@ def test_migrate_to_unified_limits_already_exists(self):
2478
2485
self .cli .migrate_to_unified_limits (
2479
2486
project_id = uuids .project , verbose = True )
2480
2487
2481
- # There are 10 default limit values in the config options, so because a
2482
- # limit for 'servers' already exists, we should have only created 9.
2488
+ # There are 10 default limit values in the config options +
2489
+ # 1 special case for PCPU which will be added based on VCPU = 11.
2490
+ # Because a limit for 'servers' already exists, we should have only
2491
+ # created 10.
2483
2492
mock_sdk = self .ul_api .mock_sdk_adapter
2484
2493
self .assertEqual (
2485
- 9 , mock_sdk .create_registered_limit .call_count )
2494
+ 10 , mock_sdk .create_registered_limit .call_count )
2486
2495
2487
2496
# There already exists a project limit for 'class:VCPU', so we should
2488
- # have created only 1 project limit.
2489
- self .assertEqual (1 , mock_sdk .create_limit .call_count )
2497
+ # have created only 2 project limits. One for 'servers' and one for
2498
+ # special case 'class:PCPU' generated from VCPU.
2499
+ self .assertEqual (2 , mock_sdk .create_limit .call_count )
2490
2500
2491
2501
def test_migrate_to_unified_limits (self ):
2492
2502
# Set some defaults using the config options.
@@ -2534,10 +2544,14 @@ def test_migrate_to_unified_limits(self):
2534
2544
self .cli .migrate_to_unified_limits (
2535
2545
project_id = uuids .project , verbose = True )
2536
2546
2537
- # There should be 10 registered (default) limits now.
2547
+ # There are 10 default limit values in the config options +
2548
+ # 1 special case for PCPU which will be added based on VCPU = 11.
2549
+ #
2550
+ # There should be 11 registered (default) limits now.
2538
2551
expected_registered_limits = {
2539
2552
'servers' : 5 ,
2540
2553
'class:VCPU' : 10 ,
2554
+ 'class:PCPU' : 10 ,
2541
2555
'class:MEMORY_MB' : 4096 ,
2542
2556
'server_metadata_items' : 64 ,
2543
2557
'server_injected_files' : 3 ,
@@ -2549,7 +2563,7 @@ def test_migrate_to_unified_limits(self):
2549
2563
}
2550
2564
2551
2565
registered_limits = self .ul_api .registered_limits ()
2552
- self .assertEqual (10 , len (registered_limits ))
2566
+ self .assertEqual (11 , len (registered_limits ))
2553
2567
for rl in registered_limits :
2554
2568
self .assertEqual (
2555
2569
expected_registered_limits [rl .resource_name ], rl .default_limit )
@@ -2581,7 +2595,7 @@ def test_migrate_to_unified_limits(self):
2581
2595
2582
2596
region_registered_limits = self .ul_api .registered_limits (
2583
2597
region_id = uuids .region )
2584
- self .assertEqual (10 , len (region_registered_limits ))
2598
+ self .assertEqual (11 , len (region_registered_limits ))
2585
2599
for rl in region_registered_limits :
2586
2600
self .assertEqual (
2587
2601
expected_registered_limits [rl .resource_name ], rl .default_limit )
0 commit comments