Merge "sriov-agent: fullstack test resource info report"

This commit is contained in:
Zuul 2018-11-06 22:38:40 +00:00 committed by Gerrit Code Review
commit 6531cf9833
4 changed files with 87 additions and 3 deletions

View File

@ -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,

View File

@ -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):

View File

@ -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"

View File

@ -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(