From 9b23e1be07a8d686a403ba8939ec5ac79d4ebc74 Mon Sep 17 00:00:00 2001 From: Lajos Katona Date: Wed, 5 Sep 2018 14:04:17 +0200 Subject: [PATCH] sriov-agent: fullstack test resource info report Change-Id: Ibbe656707276d6c3c68b051e6d66d6d388dbfd18 Partial-Bug: #1578989 See-Also: https://review.openstack.org/502306 (nova spec) See-Also: https://review.openstack.org/508149 (neutron spec) --- neutron/tests/fullstack/resources/config.py | 27 +++++++++++++++++++ .../tests/fullstack/resources/environment.py | 22 +++++++++++++++ neutron/tests/fullstack/resources/process.py | 26 ++++++++++++++++++ .../fullstack/test_agent_bandwidth_report.py | 15 ++++++++--- 4 files changed, 87 insertions(+), 3 deletions(-) diff --git a/neutron/tests/fullstack/resources/config.py b/neutron/tests/fullstack/resources/config.py index 5f6046ad59f..365bd202ae5 100644 --- a/neutron/tests/fullstack/resources/config.py +++ b/neutron/tests/fullstack/resources/config.py @@ -246,6 +246,33 @@ class OVSConfigFixture(ConfigFixture): return self.config.ovs.tunnel_bridge +class SRIOVConfigFixture(ConfigFixture): + def __init__(self, env_desc, host_desc, temp_dir, local_ip): + super(SRIOVConfigFixture, self).__init__( + env_desc, host_desc, temp_dir, + base_filename='sriov_agent.ini') + + device1 = utils.get_rand_device_name(prefix='ens5') + device2 = utils.get_rand_device_name(prefix='ens6') + phys_dev_mapping = '%s:%s,%s:%s' % (PHYSICAL_NETWORK_NAME, device1, + PHYSICAL_NETWORK_NAME, device2) + rp_bandwidths = '%s:%s:%s,%s:%s:%s' % (device1, + MINIMUM_BANDWIDTH_EGRESS_KBPS, + MINIMUM_BANDWIDTH_INGRESS_KBPS, + device2, + MINIMUM_BANDWIDTH_EGRESS_KBPS, + MINIMUM_BANDWIDTH_INGRESS_KBPS) + self.config.update({ + 'sriov_nic': { + 'physical_device_mappings': phys_dev_mapping, + 'resource_provider_bandwidths': rp_bandwidths, + } + }) + + def _setUp(self): + super(SRIOVConfigFixture, self)._setUp() + + class LinuxBridgeConfigFixture(ConfigFixture): def __init__(self, env_desc, host_desc, temp_dir, local_ip, diff --git a/neutron/tests/fullstack/resources/environment.py b/neutron/tests/fullstack/resources/environment.py index 7e311736dd8..ec3074ccfb8 100644 --- a/neutron/tests/fullstack/resources/environment.py +++ b/neutron/tests/fullstack/resources/environment.py @@ -116,6 +116,8 @@ class Host(fixtures.Fixture): if self.host_desc.l2_agent_type == constants.AGENT_TYPE_OVS: self.setup_host_with_ovs_agent() + elif self.host_desc.l2_agent_type == constants.AGENT_TYPE_NIC_SWITCH: + self.setup_host_with_sriov_agent() elif self.host_desc.l2_agent_type == constants.AGENT_TYPE_LINUXBRIDGE: self.setup_host_with_linuxbridge_agent() if self.host_desc.l3_agent: @@ -175,6 +177,16 @@ class Host(fixtures.Fixture): self.neutron_config.temp_dir, self.ovs_agent.agent_cfg_fixture.get_br_int_name())) + def setup_host_with_sriov_agent(self): + agent_cfg_fixture = config.SRIOVConfigFixture( + self.env_desc, self.host_desc, self.neutron_config.temp_dir, + self.local_ip) + self.useFixture(agent_cfg_fixture) + self.sriov_agent = self.useFixture( + process.SRIOVAgentFixture( + self.env_desc, self.host_desc, + self.test_name, self.neutron_config, agent_cfg_fixture)) + def setup_host_with_linuxbridge_agent(self): # First we need to provide connectivity for agent to prepare proper # bridge mappings in agent's config: @@ -299,6 +311,14 @@ class Host(fixtures.Fixture): def ovs_agent(self, agent): self.agents['ovs'] = agent + @property + def sriov_agent(self): + return self.agents['sriov'] + + @sriov_agent.setter + def sriov_agent(self, agent): + self.agents['sriov'] = agent + @property def linuxbridge_agent(self): return self.agents['linuxbridge'] @@ -313,6 +333,8 @@ class Host(fixtures.Fixture): return self.linuxbridge_agent elif self.host_desc.l2_agent_type == constants.AGENT_TYPE_OVS: return self.ovs_agent + elif self.host_desc.l2_agent_type == constants.AGENT_TYPE_NIC_SWITCH: + return self.sriov_agent class Environment(fixtures.Fixture): diff --git a/neutron/tests/fullstack/resources/process.py b/neutron/tests/fullstack/resources/process.py index 214a2feeed9..26d635a57e9 100644 --- a/neutron/tests/fullstack/resources/process.py +++ b/neutron/tests/fullstack/resources/process.py @@ -210,6 +210,32 @@ class OVSAgentFixture(ServiceFixture): kill_signal=signal.SIGTERM)) +class SRIOVAgentFixture(ServiceFixture): + + NEUTRON_SRIOV_AGENT = "neutron-sriov-nic-agent" + + def __init__(self, env_desc, host_desc, + test_name, neutron_cfg_fixture, agent_cfg_fixture): + super(SRIOVAgentFixture, self).__init__() + self.env_desc = env_desc + self.host_desc = host_desc + self.test_name = test_name + self.neutron_cfg_fixture = neutron_cfg_fixture + self.neutron_config = self.neutron_cfg_fixture.config + self.agent_cfg_fixture = agent_cfg_fixture + self.agent_config = agent_cfg_fixture.config + + def _setUp(self): + config_filenames = [self.neutron_cfg_fixture.filename, + self.agent_cfg_fixture.filename] + self.process_fixture = self.useFixture(ProcessFixture( + test_name=self.test_name, + process_name=self.NEUTRON_SRIOV_AGENT, + exec_name=self.NEUTRON_SRIOV_AGENT, + config_filenames=config_filenames, + kill_signal=signal.SIGTERM)) + + class LinuxBridgeAgentFixture(ServiceFixture): NEUTRON_LINUXBRIDGE_AGENT = "neutron-linuxbridge-agent" diff --git a/neutron/tests/fullstack/test_agent_bandwidth_report.py b/neutron/tests/fullstack/test_agent_bandwidth_report.py index de202a3cf85..26b85ffd5d1 100644 --- a/neutron/tests/fullstack/test_agent_bandwidth_report.py +++ b/neutron/tests/fullstack/test_agent_bandwidth_report.py @@ -27,7 +27,9 @@ class TestAgentBandwidthReport(base.BaseFullStackTestCase): scenarios = [ (constants.AGENT_TYPE_OVS, - {'l2_agent_type': constants.AGENT_TYPE_OVS}) + {'l2_agent_type': constants.AGENT_TYPE_OVS}), + (constants.AGENT_TYPE_NIC_SWITCH, + {'l2_agent_type': constants.AGENT_TYPE_NIC_SWITCH}) ] def setUp(self): @@ -51,6 +53,8 @@ class TestAgentBandwidthReport(base.BaseFullStackTestCase): agent_configurations = agents['agents'][0]['configurations'] if 'bridge_mappings' in agent_configurations: mapping_key = 'bridge_mappings' + elif 'device_mappings' in agent_configurations: + mapping_key = 'device_mappings' else: self.fail('No mapping information is found in agent ' 'configurations') @@ -60,8 +64,13 @@ class TestAgentBandwidthReport(base.BaseFullStackTestCase): self.assertIn(c_const.RP_BANDWIDTHS, agent_configurations) self.assertIn(c_const.RP_INVENTORY_DEFAULTS, agent_configurations) - self.assertIn(bridge_or_devices, - agent_configurations[c_const.RP_BANDWIDTHS]) + if mapping_key == 'bridge_mappings': + self.assertIn(bridge_or_devices, + agent_configurations[c_const.RP_BANDWIDTHS]) + else: + for device in bridge_or_devices: + self.assertIn(device, agent_configurations[ + c_const.RP_BANDWIDTHS]) for device in agent_configurations[c_const.RP_BANDWIDTHS]: self.assertEqual(