Skip to content

Commit e526afc

Browse files
Balazs Gibizermriedem
authored andcommitted
Extract pf$N literals as constants from func test
As a follow up for I4ed0381ec3bbcc9c72a7d5c0e232ac7b44241205 this patch extract constants from the functional tests Change-Id: Id1e895efe0ff9246a5c3ecd057371ad1d77d85db blueprint: support-move-ops-with-qos-ports
1 parent a412d72 commit e526afc

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

nova/tests/functional/test_servers.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5491,6 +5491,9 @@ class PortResourceRequestBasedSchedulingTestBase(
54915491
CUSTOM_PHYSNET1 = 'CUSTOM_PHYSNET1'
54925492
CUSTOM_PHYSNET2 = 'CUSTOM_PHYSNET2'
54935493
CUSTOM_PHYSNET3 = 'CUSTOM_PHYSNET3'
5494+
PF1 = 'pf1'
5495+
PF2 = 'pf2'
5496+
PF3 = 'pf3'
54945497

54955498
def setUp(self):
54965499
# enable PciPassthroughFilter to support SRIOV before the base class
@@ -5652,7 +5655,8 @@ def _create_sriov_networking_rp_tree(self, hostname, compute_rp_uuid):
56525655
dev_rp_name_prefix = ("%s:NIC Switch agent:" % hostname)
56535656

56545657
sriov_pf1_rp_uuid = getattr(uuids, sriov_agent_rp_uuid + 'PF1')
5655-
self.sriov_dev_rp_per_host[compute_rp_uuid]['pf1'] = sriov_pf1_rp_uuid
5658+
self.sriov_dev_rp_per_host[
5659+
compute_rp_uuid][self.PF1] = sriov_pf1_rp_uuid
56565660

56575661
inventories = {
56585662
orc.NET_BW_IGR_KILOBIT_PER_SEC: {"total": 100000},
@@ -5664,7 +5668,8 @@ def _create_sriov_networking_rp_tree(self, hostname, compute_rp_uuid):
56645668
device_rp_name=dev_rp_name_prefix + "%s-ens1" % hostname)
56655669

56665670
sriov_pf2_rp_uuid = getattr(uuids, sriov_agent_rp_uuid + 'PF2')
5667-
self.sriov_dev_rp_per_host[compute_rp_uuid]['pf2'] = sriov_pf2_rp_uuid
5671+
self.sriov_dev_rp_per_host[
5672+
compute_rp_uuid][self.PF2] = sriov_pf2_rp_uuid
56685673
inventories = {
56695674
orc.NET_BW_IGR_KILOBIT_PER_SEC: {"total": 100000},
56705675
orc.NET_BW_EGR_KILOBIT_PER_SEC: {"total": 100000},
@@ -5676,7 +5681,8 @@ def _create_sriov_networking_rp_tree(self, hostname, compute_rp_uuid):
56765681
device_rp_name=dev_rp_name_prefix + "%s-ens2" % hostname)
56775682

56785683
sriov_pf3_rp_uuid = getattr(uuids, sriov_agent_rp_uuid + 'PF3')
5679-
self.sriov_dev_rp_per_host[compute_rp_uuid]['pf3'] = sriov_pf3_rp_uuid
5684+
self.sriov_dev_rp_per_host[
5685+
compute_rp_uuid][self.PF3] = sriov_pf3_rp_uuid
56805686
inventories = {}
56815687
traits = [self.CUSTOM_VNIC_TYPE_DIRECT, self.CUSTOM_PHYSNET2]
56825688
self._create_pf_device_rp(
@@ -5982,7 +5988,7 @@ def test_one_ovs_one_sriov_port(self):
59825988
self.ovs_bridge_rp_per_host[self.compute1_rp_uuid]]['resources']
59835989
sriov_allocations = allocations[
59845990
self.sriov_dev_rp_per_host[
5985-
self.compute1_rp_uuid]['pf2']]['resources']
5991+
self.compute1_rp_uuid][self.PF2]]['resources']
59865992

59875993
self.assertPortMatchesAllocation(ovs_port, ovs_allocations)
59885994
self.assertPortMatchesAllocation(sriov_port, sriov_allocations)
@@ -5995,7 +6001,7 @@ def test_one_ovs_one_sriov_port(self):
59956001
ovs_binding['allocation'])
59966002
sriov_binding = sriov_port['binding:profile']
59976003
self.assertEqual(
5998-
self.sriov_dev_rp_per_host[self.compute1_rp_uuid]['pf2'],
6004+
self.sriov_dev_rp_per_host[self.compute1_rp_uuid][self.PF2],
59996005
sriov_binding['allocation'])
60006006

60016007
def test_interface_detach_with_port_with_bandwidth_request(self):
@@ -6182,7 +6188,7 @@ def test_two_sriov_ports_one_with_request_two_available_pfs(self):
61826188

61836189
sriov_allocations = allocations[
61846190
self.sriov_dev_rp_per_host[
6185-
self.compute1_rp_uuid]['pf2']]['resources']
6191+
self.compute1_rp_uuid][self.PF2]]['resources']
61866192
self.assertPortMatchesAllocation(
61876193
sriov_port_with_res_req, sriov_allocations)
61886194

@@ -6191,7 +6197,7 @@ def test_two_sriov_ports_one_with_request_two_available_pfs(self):
61916197
# request
61926198
sriov_with_req_binding = sriov_port_with_res_req['binding:profile']
61936199
self.assertEqual(
6194-
self.sriov_dev_rp_per_host[self.compute1_rp_uuid]['pf2'],
6200+
self.sriov_dev_rp_per_host[self.compute1_rp_uuid][self.PF2],
61956201
sriov_with_req_binding['allocation'])
61966202
# and the port without resource request does not have allocation
61976203
sriov_binding = sriov_port['binding:profile']
@@ -6278,7 +6284,7 @@ def test_sriov_macvtap_port_with_resource_request(self):
62786284
allocations, self.compute1_rp_uuid, self.flavor)
62796285

62806286
sriov_allocations = allocations[self.sriov_dev_rp_per_host[
6281-
self.compute1_rp_uuid]['pf2']]['resources']
6287+
self.compute1_rp_uuid][self.PF2]]['resources']
62826288
self.assertPortMatchesAllocation(
62836289
port, sriov_allocations)
62846290

@@ -6287,7 +6293,7 @@ def test_sriov_macvtap_port_with_resource_request(self):
62876293
# request
62886294
port_binding = port['binding:profile']
62896295
self.assertEqual(
6290-
self.sriov_dev_rp_per_host[self.compute1_rp_uuid]['pf2'],
6296+
self.sriov_dev_rp_per_host[self.compute1_rp_uuid][self.PF2],
62916297
port_binding['allocation'])
62926298

62936299
# We expect that the selected PCI device matches with the RP from
@@ -6365,7 +6371,7 @@ def _check_allocation(
63656371
self.ovs_bridge_rp_per_host[compute_rp_uuid]]['resources']
63666372
self.assertPortMatchesAllocation(qos_port, ovs_allocations)
63676373
sriov_allocations = allocations[
6368-
self.sriov_dev_rp_per_host[compute_rp_uuid]['pf2']]['resources']
6374+
self.sriov_dev_rp_per_host[compute_rp_uuid][self.PF2]]['resources']
63696375
self.assertPortMatchesAllocation(qos_sriov_port, sriov_allocations)
63706376

63716377
# We expect that only the RP uuid of the networking RP having the port
@@ -6375,7 +6381,7 @@ def _check_allocation(
63756381
self.assertEqual(self.ovs_bridge_rp_per_host[compute_rp_uuid],
63766382
qos_binding_profile['allocation'])
63776383
qos_sriov_binding_profile = updated_qos_sriov_port['binding:profile']
6378-
self.assertEqual(self.sriov_dev_rp_per_host[compute_rp_uuid]['pf2'],
6384+
self.assertEqual(self.sriov_dev_rp_per_host[compute_rp_uuid][self.PF2],
63796385
qos_sriov_binding_profile['allocation'])
63806386

63816387
# And we expect not to have any allocation set in the port binding for
@@ -6399,7 +6405,7 @@ def _check_allocation(
63996405
self.assertPortMatchesAllocation(qos_port, ovs_allocations)
64006406
sriov_allocations = migration_allocations[
64016407
self.sriov_dev_rp_per_host[
6402-
source_compute_rp_uuid]['pf2']]['resources']
6408+
source_compute_rp_uuid][self.PF2]]['resources']
64036409
self.assertPortMatchesAllocation(qos_sriov_port, sriov_allocations)
64046410

64056411
def _create_server_with_ports(self, *ports):

0 commit comments

Comments
 (0)