@@ -5384,6 +5384,13 @@ def setUp(self):
5384
5384
macvtap = self .neutron .port_macvtap_with_resource_request
5385
5385
self .neutron ._ports [macvtap ['id' ]] = copy .deepcopy (macvtap )
5386
5386
5387
+ def assertComputeAllocationMatchesFlavor (
5388
+ self , allocations , compute_rp_uuid , flavor ):
5389
+ compute_allocations = allocations [compute_rp_uuid ]['resources' ]
5390
+ self .assertEqual (
5391
+ self ._resources_from_flavor (flavor ),
5392
+ compute_allocations )
5393
+
5387
5394
def _create_server (self , flavor , networks ):
5388
5395
server_req = self ._build_minimal_create_server_request (
5389
5396
self .api , 'bandwidth-aware-server' ,
@@ -5804,12 +5811,11 @@ def test_boot_server_with_two_ports_one_having_resource_request(self):
5804
5811
# compute rp and one set for the networking resources on the ovs bridge
5805
5812
# rp due to the qos_port resource request
5806
5813
self .assertEqual (2 , len (allocations ))
5807
- compute_allocations = allocations [self .compute1_rp_uuid ]['resources' ]
5814
+
5815
+ self .assertComputeAllocationMatchesFlavor (
5816
+ allocations , self .compute1_rp_uuid , self .flavor )
5808
5817
network_allocations = allocations [
5809
5818
self .ovs_bridge_rp_per_host [self .compute1_rp_uuid ]]['resources' ]
5810
-
5811
- self .assertEqual (self ._resources_from_flavor (self .flavor ),
5812
- compute_allocations )
5813
5819
self .assertPortMatchesAllocation (qos_port , network_allocations )
5814
5820
5815
5821
# We expect that only the RP uuid of the networking RP having the port
@@ -5851,15 +5857,13 @@ def test_one_ovs_one_sriov_port(self):
5851
5857
# compute rp and one set for the networking resources on the ovs bridge
5852
5858
# rp and on the sriov PF rp.
5853
5859
self .assertEqual (3 , len (allocations ))
5854
- compute_allocations = allocations [self .compute1_rp_uuid ]['resources' ]
5860
+
5861
+ self .assertComputeAllocationMatchesFlavor (
5862
+ allocations , self .compute1_rp_uuid , self .flavor_with_group_policy )
5863
+
5855
5864
ovs_allocations = allocations [
5856
5865
self .ovs_bridge_rp_per_host [self .compute1_rp_uuid ]]['resources' ]
5857
5866
sriov_allocations = allocations [self .sriov_pf2_rp_uuid ]['resources' ]
5858
-
5859
- self .assertEqual (
5860
- self ._resources_from_flavor (self .flavor_with_group_policy ),
5861
- compute_allocations )
5862
-
5863
5867
self .assertPortMatchesAllocation (ovs_port , ovs_allocations )
5864
5868
self .assertPortMatchesAllocation (sriov_port , sriov_allocations )
5865
5869
@@ -5888,12 +5892,12 @@ def test_interface_detach_with_port_with_bandwidth_request(self):
5888
5892
# compute rp and one set for the networking resources on the ovs bridge
5889
5893
# rp due to the port resource request
5890
5894
self .assertEqual (2 , len (allocations ))
5891
- compute_allocations = allocations [self .compute1_rp_uuid ]['resources' ]
5895
+
5896
+ self .assertComputeAllocationMatchesFlavor (
5897
+ allocations , self .compute1_rp_uuid , self .flavor )
5898
+
5892
5899
network_allocations = allocations [
5893
5900
self .ovs_bridge_rp_per_host [self .compute1_rp_uuid ]]['resources' ]
5894
-
5895
- self .assertEqual (self ._resources_from_flavor (self .flavor ),
5896
- compute_allocations )
5897
5901
self .assertPortMatchesAllocation (port , network_allocations )
5898
5902
5899
5903
# We expect that only the RP uuid of the networking RP having the port
@@ -5918,9 +5922,9 @@ def test_interface_detach_with_port_with_bandwidth_request(self):
5918
5922
5919
5923
# We expect that the port related resource allocations are removed
5920
5924
self .assertEqual (1 , len (allocations ))
5921
- compute_allocations = allocations [ self . compute1_rp_uuid ][ 'resources' ]
5922
- self .assertEqual ( self . _resources_from_flavor ( self . flavor ),
5923
- compute_allocations )
5925
+
5926
+ self .assertComputeAllocationMatchesFlavor (
5927
+ allocations , self . compute1_rp_uuid , self . flavor )
5924
5928
5925
5929
# We expect that the allocation is removed from the port too
5926
5930
binding_profile = updated_port ['binding:profile' ]
@@ -6051,10 +6055,9 @@ def test_two_sriov_ports_one_with_request_two_available_pfs(self):
6051
6055
# compute rp and one set for the networking resources on the sriov PF2
6052
6056
# rp.
6053
6057
self .assertEqual (2 , len (allocations ))
6054
- compute_allocations = allocations [self .compute1_rp_uuid ]['resources' ]
6055
- self .assertEqual (
6056
- self ._resources_from_flavor (self .flavor_with_group_policy ),
6057
- compute_allocations )
6058
+
6059
+ self .assertComputeAllocationMatchesFlavor (
6060
+ allocations , self .compute1_rp_uuid , self .flavor_with_group_policy )
6058
6061
6059
6062
sriov_allocations = allocations [self .sriov_pf2_rp_uuid ]['resources' ]
6060
6063
self .assertPortMatchesAllocation (
@@ -6073,11 +6076,15 @@ def test_two_sriov_ports_one_with_request_two_available_pfs(self):
6073
6076
# We expect that the selected PCI device matches with the RP from
6074
6077
# where the bandwidth is allocated from. The bandwidth is allocated
6075
6078
# from 0000:02:00 (PF2) so the PCI device should be a VF of that PF
6076
- self .assertEqual ('0000:02:00.1' , sriov_with_req_binding ['pci_slot' ])
6079
+ self .assertEqual (
6080
+ fake .FakeDriverWithPciResources .PCI_ADDR_PF2_VF1 ,
6081
+ sriov_with_req_binding ['pci_slot' ])
6077
6082
# But also the port that has no resource request still gets a pci slot
6078
6083
# allocated. The 0000:02:00 has no more VF available but 0000:03:00 has
6079
6084
# one VF available and that PF is also on physnet2
6080
- self .assertEqual ('0000:03:00.1' , sriov_binding ['pci_slot' ])
6085
+ self .assertEqual (
6086
+ fake .FakeDriverWithPciResources .PCI_ADDR_PF3_VF1 ,
6087
+ sriov_binding ['pci_slot' ])
6081
6088
6082
6089
def test_one_sriov_port_no_vf_and_bandwidth_available_on_the_same_pf (self ):
6083
6090
"""Verify that if there is no PF that both provides bandwidth and VFs
@@ -6095,7 +6102,9 @@ def test_one_sriov_port_no_vf_and_bandwidth_available_on_the_same_pf(self):
6095
6102
sriov_binding = sriov_port ['binding:profile' ]
6096
6103
6097
6104
# We expect that this consume the last available VF from the PF2
6098
- self .assertEqual ('0000:02:00.1' , sriov_binding ['pci_slot' ])
6105
+ self .assertEqual (
6106
+ fake .FakeDriverWithPciResources .PCI_ADDR_PF2_VF1 ,
6107
+ sriov_binding ['pci_slot' ])
6099
6108
6100
6109
# Now boot a second server with a port that has resource request
6101
6110
# At this point PF2 has available bandwidth but no available VF
@@ -6141,10 +6150,8 @@ def test_sriov_macvtap_port_with_resource_request(self):
6141
6150
# rp.
6142
6151
self .assertEqual (2 , len (allocations ))
6143
6152
6144
- compute_allocations = allocations [self .compute1_rp_uuid ]['resources' ]
6145
- self .assertEqual (
6146
- self ._resources_from_flavor (self .flavor ),
6147
- compute_allocations )
6153
+ self .assertComputeAllocationMatchesFlavor (
6154
+ allocations , self .compute1_rp_uuid , self .flavor )
6148
6155
6149
6156
sriov_allocations = allocations [self .sriov_pf2_rp_uuid ]['resources' ]
6150
6157
self .assertPortMatchesAllocation (
@@ -6160,7 +6167,9 @@ def test_sriov_macvtap_port_with_resource_request(self):
6160
6167
# We expect that the selected PCI device matches with the RP from
6161
6168
# where the bandwidth is allocated from. The bandwidth is allocated
6162
6169
# from 0000:02:00 (PF2) so the PCI device should be a VF of that PF
6163
- self .assertEqual ('0000:02:00.1' , port_binding ['pci_slot' ])
6170
+ self .assertEqual (
6171
+ fake .FakeDriverWithPciResources .PCI_ADDR_PF2_VF1 ,
6172
+ port_binding ['pci_slot' ])
6164
6173
6165
6174
6166
6175
class PortResourceRequestReSchedulingTest (
@@ -6207,12 +6216,12 @@ def test_boot_reschedule_success(self):
6207
6216
# compute rp and one set for the networking resources on the ovs bridge
6208
6217
# rp
6209
6218
self .assertEqual (2 , len (allocations ))
6210
- compute_allocations = allocations [dest_compute_rp_uuid ]['resources' ]
6219
+
6220
+ self .assertComputeAllocationMatchesFlavor (
6221
+ allocations , dest_compute_rp_uuid , self .flavor )
6222
+
6211
6223
network_allocations = allocations [
6212
6224
self .ovs_bridge_rp_per_host [dest_compute_rp_uuid ]]['resources' ]
6213
-
6214
- self .assertEqual (self ._resources_from_flavor (self .flavor ),
6215
- compute_allocations )
6216
6225
self .assertPortMatchesAllocation (port , network_allocations )
6217
6226
6218
6227
# assert that the allocations against the host where the spawn
0 commit comments