Merge "Fix SRIOV and DPDK tests"

This commit is contained in:
Jenkins 2017-04-12 11:40:50 +00:00 committed by Gerrit Code Review
commit 17fb97d464
9 changed files with 86 additions and 53 deletions

View File

@ -4,9 +4,6 @@ RUN apt-get update -qq && \
apt-get install -q -y \ apt-get install -q -y \
python-dev \ python-dev \
libvirt-dev \ libvirt-dev \
# xvfb \
# iceweasel \
# libav-tools \
&& \ && \
apt-get clean && \ apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
@ -15,9 +12,7 @@ WORKDIR /opt/app
COPY . /opt/app/ COPY . /opt/app/
ENV OSLO_PACKAGE_VERSION=1.8 RUN pip install . -r requirements.txt
RUN pip install -e . -r requirements.txt
ENV OS_USERNAME=admin ENV OS_USERNAME=admin
ENV OS_PASSWORD=workshop ENV OS_PASSWORD=workshop

View File

@ -1,4 +1,5 @@
git+https://github.com/Mirantis/stepler.git#egg=stepler[libvirt] # git+https://github.com/Mirantis/stepler.git#egg=stepler[libvirt]
git+https://review.gerrithub.io/Mirantis/stepler#egg=stepler[libvirt]
git+https://github.com/morganfainberg/positional.git git+https://github.com/morganfainberg/positional.git
git+https://github.com/gdyuldin/contrail-python-api@R3.0 git+https://github.com/gdyuldin/contrail-python-api@R3.0
dpath dpath

View File

@ -37,8 +37,10 @@ class Predicates(skip.Predicates):
@_store_call @_store_call
def sriov_enabled(self): def sriov_enabled(self):
"""Define whether sriov enabled.""" """Define whether sriov enabled."""
agent_steps = self._get_fixture('agent_steps') os_faults_steps = self._get_fixture('os_faults_steps')
sriov_device_mappings = sriov.get_sriov_device_mapping(agent_steps) computes = self._get_fixture('computes')
sriov_device_mappings = sriov.get_sriov_devices(os_faults_steps,
computes)
return len(sriov_device_mappings) > 0 return len(sriov_device_mappings) > 0
@property @property

View File

@ -10,27 +10,29 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from vapor import settings from stepler import config as stepler_config
from vapor.helpers import nodes_steps
def get_sriov_device_mapping(agent_steps): def get_sriov_devices(os_faults_steps, computes):
"""Return computes with sriov neutron agents and them device mapping. """Return computes with sriov neutron agents and them ifaces data.
Example output: Example output:
{'node-4.test.domain.local': {"physnet2": ["ens11f1"]}} {'node-4.test.domain.local': {"ens11f1": {"sriov_numvfs": 7}}}
""" """
agents = agent_steps.get_agents(binary=settings.NEUTRON_SRIOV_NIC_AGENT, cmd = "grep -v 0 /sys/class/net/*/device/sriov_numvfs"
check=False) result = os_faults_steps.execute_cmd(computes, cmd, check=False)
mapping = {} mapping = {}
for agent in agents: for node_result in result:
mapping[agent['host']] = agent['configurations']['device_mappings'] node = nodes_steps.get_node_by_result(node_result, os_faults_steps)
if node_result.status == stepler_config.STATUS_OK:
node_data = {}
for line in node_result.payload['stdout_lines']:
path, sriov_numvfs = line.split(':')
sriov_numvfs = int(sriov_numvfs)
iface = path.split('/')[4]
node_data[iface] = {'sriov_numvfs': sriov_numvfs}
mapping[node.fqdn] = node_data
return mapping return mapping
def get_sriov_numvfs(os_faults_steps, node, iface):
"""Return numvfs value from node for iface."""
fqdn = os_faults_steps.get_fqdn_by_host_name(node)
node = os_faults_steps.get_node(fqdns=[fqdn])
cmd = 'cat /sys/class/net/{}/device/sriov_numvfs'.format(iface)
result = os_faults_steps.execute_cmd(node, cmd)
return int(result[0].payload['stdout'])

View File

@ -57,10 +57,12 @@ def get_interface_table(os_faults_steps, nodes):
pairs = {key: value} pairs = {key: value}
else: else:
pairs = line.split() pairs = line.split()
if ':' not in pairs[0]: start = next(i for i, pair in enumerate(pairs)
pairs = [ if ':' in pair)
u'{}_{}'.format(pairs[0], p) for p in pairs[1:] prefix = u'_'.join(pairs[:start])
] pairs = [
u'{}_{}'.format(prefix, p) for p in pairs[start:]
]
pairs = dict(x.split(':', 1) for x in pairs) pairs = dict(x.split(':', 1) for x in pairs)
iface.update(pairs) iface.update(pairs)
if iface: if iface:

View File

@ -190,3 +190,6 @@ SERVER_ATTR_HYPERVISOR_HOSTNAME = 'OS-EXT-SRV-ATTR:hypervisor_hostname'
NEUTRON_SRIOV_NIC_AGENT = "neutron-sriov-nic-agent" NEUTRON_SRIOV_NIC_AGENT = "neutron-sriov-nic-agent"
DPDK_NEC_BIND_PATH = '/opt/contrail/bin/dpdk_nic_bind.py' DPDK_NEC_BIND_PATH = '/opt/contrail/bin/dpdk_nic_bind.py'
# SR-IOV
SRIOV_PHYSNET = 'physnet1'

View File

@ -13,7 +13,7 @@
import time import time
import attrdict import attrdict
from hamcrest import assert_that, equal_to, greater_than # noqa: H301 from hamcrest import assert_that, equal_to # noqa: H301
from pycontrail import types from pycontrail import types
import pytest import pytest
from stepler import config as stepler_config from stepler import config as stepler_config

View File

@ -12,6 +12,7 @@
from hamcrest import (assert_that, has_entries, has_item, only_contains, from hamcrest import (assert_that, has_entries, has_item, only_contains,
is_not, empty, greater_than, has_length) is_not, empty, greater_than, has_length)
import pytest
from vapor.helpers import contrail_status from vapor.helpers import contrail_status
from vapor.helpers import dpdk from vapor.helpers import dpdk
@ -66,6 +67,9 @@ def test_contrail_vrouter_dpdk_cpu_usage(os_faults_steps, computes):
assert_that(usage, greater_than(50)) assert_that(usage, greater_than(50))
@pytest.mark.parametrize(
'flavor', [dict(metadata={"hw:mem_page_size": "small"})], indirect=True)
@pytest.mark.usefixtures('flavor')
def test_vrouter_create_interface(request, os_faults_steps, computes): def test_vrouter_create_interface(request, os_faults_steps, computes):
"""Verify if vRouter creates interface after creation of a virtual machine. """Verify if vRouter creates interface after creation of a virtual machine.
@ -78,7 +82,8 @@ def test_vrouter_create_interface(request, os_faults_steps, computes):
before_ifaces = vrouter_steps.get_interface_table(os_faults_steps, before_ifaces = vrouter_steps.get_interface_table(os_faults_steps,
computes) computes)
server = request.getfixturevalue('server') server = request.getfixturevalue('server')
compute_fqdn = getattr(server, settings.SERVER_ATTR_HYPERVISOR_HOSTNAME) compute = getattr(server, settings.SERVER_ATTR_HYPERVISOR_HOSTNAME)
compute_fqdn = os_faults_steps.get_fqdn_by_host_name(compute)
after_ifaces = vrouter_steps.get_interface_table(os_faults_steps, computes) after_ifaces = vrouter_steps.get_interface_table(os_faults_steps, computes)
assert_that(after_ifaces[compute_fqdn], assert_that(after_ifaces[compute_fqdn],
has_length(greater_than(len(before_ifaces[compute_fqdn])))) has_length(greater_than(len(before_ifaces[compute_fqdn]))))

View File

@ -16,13 +16,16 @@ from stepler import config as stepler_config
from stepler.third_party import utils from stepler.third_party import utils
from vapor.helpers import sriov from vapor.helpers import sriov
from vapor import settings
pytestmark = pytest.mark.requires('sriov_enabled') pytestmark = pytest.mark.requires('sriov_enabled')
def test_virtual_function_exhaustion_and_reuse( def test_virtual_function_exhaustion_and_reuse(
cirros_image, flavor, network, subnet, create_network, create_subnet, ubuntu_xenial_image, flavor, network, subnet, net_subnet_router,
create_port, agent_steps, os_faults_steps, server_steps): neutron_security_group, floating_ip, keypair, create_network,
create_subnet, create_port, os_faults_steps, computes,
floating_ip_steps, server_steps, nova_availability_zone_hosts):
"""Verify Nova can schedule VM to all the VF of a PF. """Verify Nova can schedule VM to all the VF of a PF.
Steps: Steps:
@ -32,7 +35,9 @@ def test_virtual_function_exhaustion_and_reuse(
#. Create 1 port for management network and 1 port for SRIOV network #. Create 1 port for management network and 1 port for SRIOV network
#. Boot server with created 2 ports, check that is reaches ACTIVE #. Boot server with created 2 ports, check that is reaches ACTIVE
status status
#. Repeat last 2 steps `total_vfs` times #. Create 1 port for SRIOV network
#. Repeat last 2 steps `total_vfs` - 1 times
#. Check ping from 1st server to all another
#. Create 1 port for management network and 1 port for SRIOV network #. Create 1 port for management network and 1 port for SRIOV network
#. Create another one server with created 2 ports #. Create another one server with created 2 ports
#. Check that server reaches ERROR status #. Check that server reaches ERROR status
@ -42,35 +47,56 @@ def test_virtual_function_exhaustion_and_reuse(
#. Create another one server with created 2 ports, check that is #. Create another one server with created 2 ports, check that is
reaches ACTIVE status reaches ACTIVE status
""" """
sriov_device_mappings = sriov.get_sriov_device_mapping(agent_steps) sriov_devices = sriov.get_sriov_devices(os_faults_steps, computes)
compute_name, device_mapping = next(six.iteritems(sriov_device_mappings)) compute_name, ifaces = next(six.iteritems(sriov_devices))
sriov_physnet = next(six.iterkeys(device_mapping)) sriov_iface = next(six.iterkeys(ifaces))
sriov_iface = device_mapping[sriov_physnet][0] numvfs = ifaces[sriov_iface]['sriov_numvfs']
numvfs = sriov.get_sriov_numvfs(os_faults_steps, compute_name, sriov_iface)
# Find availability zone compute host
compute_host = next(
host for host in nova_availability_zone_hosts
if compute_name.startswith(host))
# Create SRIOV net and subnet # Create SRIOV net and subnet
kwargs = { kwargs = {
'provider:network_type': 'vlan', 'provider:network_type': 'vlan',
'provider:physical_network': sriov_physnet, 'provider:physical_network': settings.SRIOV_PHYSNET,
'provider:segmentation_id': 200 'provider:segmentation_id': 200
} }
sriov_net_name, = utils.generate_ids() sriov_net_name, = utils.generate_ids()
sriov_net = create_network(sriov_net_name, **kwargs) sriov_net = create_network(sriov_net_name, **kwargs)
create_subnet(sriov_net_name + '__subnet', sriov_net, cidr="55.1.1.0/24") create_subnet(
sriov_net_name + '__subnet', sriov_net, cidr="10.200.54.0/24")
# Create servers # Create servers
servers = [] servers = []
sriov_port_kwargs = {'binding:vnic_type': 'direct'} sriov_port_kwargs = {
'binding:vnic_type': 'direct',
'security_groups': [neutron_security_group['id']]
}
server_create_args = dict( server_create_args = dict(
image=cirros_image, image=ubuntu_xenial_image,
flavor=flavor, flavor=flavor,
availability_zone='nova:{}'.format(compute_name)) availability_zone='nova:{}'.format(compute_host),
for _ in range(numvfs): keypair=keypair,
mgmt_port = create_port(network) username=stepler_config.UBUNTU_USERNAME)
for i in range(numvfs):
sriov_port = create_port(sriov_net, **sriov_port_kwargs) sriov_port = create_port(sriov_net, **sriov_port_kwargs)
ports = [sriov_port]
if i == 0:
mgmt_port = create_port(
network, security_groups=[neutron_security_group['id']])
ports.insert(0, mgmt_port)
server = server_steps.create_servers( server = server_steps.create_servers(
ports=[mgmt_port, sriov_port], **server_create_args)[0] ports=ports, **server_create_args)[0]
servers.append(server) servers.append(server)
if i == 0:
floating_ip_steps.attach_floating_ip(floating_ip, mgmt_port)
# Check ping between servers
ping_plan = {servers[0]: servers[1:]}
server_steps.check_ping_by_plan(
ping_plan, timeout=stepler_config.PING_BETWEEN_SERVERS_TIMEOUT)
# Try to create one more server # Try to create one more server
mgmt_port = create_port(network) mgmt_port = create_port(network)
@ -79,8 +105,7 @@ def test_virtual_function_exhaustion_and_reuse(
error_server = server_steps.create_servers( error_server = server_steps.create_servers(
ports=[mgmt_port, sriov_port], check=False, **server_create_args)[0] ports=[mgmt_port, sriov_port], check=False, **server_create_args)[0]
server_steps.check_server_status( server_steps.check_server_status(
error_server, error_server, [stepler_config.STATUS_ERROR],
[stepler_config.STATUS_ERROR],
transit_statuses=[stepler_config.STATUS_BUILD], transit_statuses=[stepler_config.STATUS_BUILD],
timeout=stepler_config.SERVER_ACTIVE_TIMEOUT) timeout=stepler_config.SERVER_ACTIVE_TIMEOUT)
@ -91,8 +116,6 @@ def test_virtual_function_exhaustion_and_reuse(
server_steps.delete_servers(servers[:1]) server_steps.delete_servers(servers[:1])
# Create another server # Create another server
mgmt_port = create_port(network)
sriov_port = create_port(sriov_net, **sriov_port_kwargs) sriov_port = create_port(sriov_net, **sriov_port_kwargs)
server_steps.create_servers( server_steps.create_servers(ports=[sriov_port], **server_create_args)[0]
ports=[mgmt_port, sriov_port], **server_create_args)[0]