@@ -61,13 +61,7 @@ class PlacementPCIReportingTests(test_pci_sriov_servers._PCIServersTestBase):
61
61
62
62
def setUp (self ):
63
63
super ().setUp ()
64
- patcher = mock .patch (
65
- "nova.compute.pci_placement_translator."
66
- "_is_placement_tracking_enabled" ,
67
- return_value = True
68
- )
69
- self .addCleanup (patcher .stop )
70
- self .mock_pci_report_in_placement = patcher .start ()
64
+ self .flags (group = "pci" , report_in_placement = True )
71
65
72
66
# These tests should not depend on the host's sysfs
73
67
self .useFixture (
@@ -718,7 +712,7 @@ def _create_one_compute_with_a_pf_consumed_by_an_instance(self):
718
712
]
719
713
)
720
714
self .flags (group = 'pci' , device_spec = device_spec )
721
- self .mock_pci_report_in_placement . return_value = True
715
+ self .flags ( group = "pci" , report_in_placement = True )
722
716
self .start_compute (hostname = "compute1" , pci_info = pci_info )
723
717
724
718
self .assertPCIDeviceCounts ("compute1" , total = 1 , free = 1 )
@@ -893,7 +887,7 @@ def test_reporting_disabled_nothing_is_reported(self):
893
887
# Disable placement reporting so even if there are PCI devices on the
894
888
# hypervisor matching the [pci]device_spec config they are not reported
895
889
# to Placement
896
- self .mock_pci_report_in_placement . return_value = False
890
+ self .flags ( group = "pci" , report_in_placement = False )
897
891
self .start_compute (hostname = "compute1" , pci_info = pci_info )
898
892
899
893
self .assert_placement_pci_view (
@@ -931,7 +925,7 @@ def test_reporting_cannot_be_disable_once_it_is_enabled(self):
931
925
932
926
# Try to disable placement reporting. The compute will refuse to start
933
927
# as there are already PCI device RPs in placement.
934
- self .mock_pci_report_in_placement . return_value = False
928
+ self .flags ( group = "pci" , report_in_placement = False )
935
929
ex = self .assertRaises (
936
930
exception .PlacementPciException ,
937
931
self .restart_compute_service ,
@@ -988,7 +982,7 @@ def test_heal_single_pci_allocation(self):
988
982
self .flags (group = 'pci' , device_spec = device_spec )
989
983
990
984
# Start a compute *without* PCI tracking in placement
991
- self .mock_pci_report_in_placement . return_value = False
985
+ self .flags ( group = "pci" , report_in_placement = False )
992
986
self .start_compute (hostname = "compute1" , pci_info = pci_info )
993
987
self .assertPCIDeviceCounts ("compute1" , total = 1 , free = 1 )
994
988
@@ -999,7 +993,7 @@ def test_heal_single_pci_allocation(self):
999
993
self .assertPCIDeviceCounts ("compute1" , total = 1 , free = 0 )
1000
994
1001
995
# Restart the compute but now with PCI tracking enabled
1002
- self .mock_pci_report_in_placement . return_value = True
996
+ self .flags ( group = "pci" , report_in_placement = True )
1003
997
self .restart_compute_service ("compute1" )
1004
998
# Assert that the PCI allocation is healed in placement
1005
999
self .assertPCIDeviceCounts ("compute1" , total = 1 , free = 0 )
@@ -1057,7 +1051,7 @@ def test_heal_multiple_allocations(self):
1057
1051
self .flags (group = 'pci' , device_spec = device_spec )
1058
1052
1059
1053
# Start a compute *without* PCI tracking in placement
1060
- self .mock_pci_report_in_placement . return_value = False
1054
+ self .flags ( group = "pci" , report_in_placement = False )
1061
1055
self .start_compute (hostname = "compute1" , pci_info = pci_info )
1062
1056
# 2 PCI + 1 PF + 4 VFs
1063
1057
self .assertPCIDeviceCounts ("compute1" , total = 7 , free = 7 )
@@ -1082,7 +1076,7 @@ def test_heal_multiple_allocations(self):
1082
1076
self .assertPCIDeviceCounts ("compute1" , total = 7 , free = 1 )
1083
1077
1084
1078
# Restart the compute but now with PCI tracking enabled
1085
- self .mock_pci_report_in_placement . return_value = True
1079
+ self .flags ( group = "pci" , report_in_placement = True )
1086
1080
self .restart_compute_service ("compute1" )
1087
1081
# Assert that the PCI allocation is healed in placement
1088
1082
self .assertPCIDeviceCounts ("compute1" , total = 7 , free = 1 )
@@ -1157,7 +1151,7 @@ def test_heal_partial_allocations(self):
1157
1151
self .flags (group = 'pci' , device_spec = device_spec )
1158
1152
1159
1153
# Start a compute with PCI tracking in placement
1160
- self .mock_pci_report_in_placement . return_value = True
1154
+ self .flags ( group = "pci" , report_in_placement = True )
1161
1155
self .start_compute (hostname = "compute1" , pci_info = pci_info )
1162
1156
# 2 PCI + 1 PF + 4 VFs
1163
1157
self .assertPCIDeviceCounts ("compute1" , total = 7 , free = 7 )
@@ -1234,7 +1228,7 @@ def test_heal_partial_allocations_during_resize_downsize(self):
1234
1228
self .flags (group = 'pci' , device_spec = compute1_device_spec )
1235
1229
1236
1230
# Start a compute with PCI tracking in placement
1237
- self .mock_pci_report_in_placement . return_value = True
1231
+ self .flags ( group = "pci" , report_in_placement = True )
1238
1232
self .start_compute (hostname = "compute1" , pci_info = compute1_pci_info )
1239
1233
self .assertPCIDeviceCounts ("compute1" , total = 2 , free = 2 )
1240
1234
compute1_expected_placement_view = {
@@ -1395,7 +1389,7 @@ def test_heal_partial_allocations_during_resize_change_dev_type(self):
1395
1389
self .flags (group = 'pci' , device_spec = compute1_device_spec )
1396
1390
1397
1391
# Start a compute with PCI tracking in placement
1398
- self .mock_pci_report_in_placement . return_value = True
1392
+ self .flags ( group = "pci" , report_in_placement = True )
1399
1393
self .start_compute (hostname = "compute1" , pci_info = compute1_pci_info )
1400
1394
self .assertPCIDeviceCounts ("compute1" , total = 1 , free = 1 )
1401
1395
compute1_expected_placement_view = {
@@ -1458,7 +1452,7 @@ def test_heal_partial_allocations_during_resize_change_dev_type(self):
1458
1452
self .flags (group = 'pci' , device_spec = compute2_device_spec )
1459
1453
1460
1454
# Start a compute with PCI tracking in placement
1461
- self .mock_pci_report_in_placement . return_value = True
1455
+ self .flags ( group = "pci" , report_in_placement = True )
1462
1456
self .start_compute (hostname = "compute2" , pci_info = compute2_pci_info )
1463
1457
self .assertPCIDeviceCounts ("compute2" , total = 3 , free = 3 )
1464
1458
compute2_expected_placement_view = {
@@ -1533,7 +1527,7 @@ def test_heal_allocation_during_same_host_resize(self):
1533
1527
)
1534
1528
self .flags (group = 'pci' , device_spec = compute1_device_spec )
1535
1529
# Start a compute with PCI tracking in placement
1536
- self .mock_pci_report_in_placement . return_value = True
1530
+ self .flags ( group = "pci" , report_in_placement = True )
1537
1531
self .start_compute (hostname = "compute1" , pci_info = compute1_pci_info )
1538
1532
self .assertPCIDeviceCounts ("compute1" , total = 3 , free = 3 )
1539
1533
compute1_expected_placement_view = {
0 commit comments