Fix some tests failures on baremetal contrail lab

Change-Id: Ifb03b2828fe2ee3d725477684cb69060e541d4be
This commit is contained in:
Georgy Dyuldin 2017-04-14 18:09:00 +03:00
parent 35c6eef7b8
commit d2e3ea9407
8 changed files with 48 additions and 23 deletions

View File

@ -14,6 +14,7 @@ import pytest
import six import six
from stepler.fixtures import skip from stepler.fixtures import skip
from vapor.helpers import dpdk
from vapor.helpers import sriov from vapor.helpers import sriov
from vapor import settings from vapor import settings
@ -43,6 +44,18 @@ class Predicates(skip.Predicates):
computes) computes)
return len(sriov_device_mappings) > 0 return len(sriov_device_mappings) > 0
@property
@_store_call
def dpdk_enabled(self):
"""Define whether dpdk enabled at least on one node."""
os_faults_steps = self._get_fixture('os_faults_steps')
computes = self._get_fixture('computes')
dpdk_devices = dpdk.get_devices(os_faults_steps, computes)
for devices_groups in dpdk_devices.values():
if len(devices_groups[settings.DPDK_ENABLED_GROUP]) > 0:
return True
return False
@property @property
@_store_call @_store_call
def contrail_control_nodes_count(self): def contrail_control_nodes_count(self):

View File

@ -21,7 +21,7 @@ from vapor import settings
def get_devices(os_faults_steps, nodes): def get_devices(os_faults_steps, nodes):
result = os_faults_steps.execute_cmd( result = os_faults_steps.execute_cmd(
nodes, '{} --status'.format(settings.DPDK_NEC_BIND_PATH), check=False) nodes, '{} --status'.format(settings.DPDK_NEC_BIND_CMD), check=False)
node_statuses = {} node_statuses = {}
for node_result in result: for node_result in result:
node = nodes_steps.get_node_by_result(node_result, os_faults_steps) node = nodes_steps.get_node_by_result(node_result, os_faults_steps)

View File

@ -192,10 +192,10 @@ 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_CMD = 'curl https://raw.githubusercontent.com/Juniper/contrail-dpdk/master/tools/dpdk_nic_bind.py 2>/dev/null | python -' # noqa
# SR-IOV # SR-IOV
SRIOV_PHYSNET = 'physnet1' SRIOV_PHYSNET = os.environ.get('SRIOV_PHYSNET', 'physnet1')
# Security groups # Security groups
INGRESS = 'ingress' INGRESS = 'ingress'
@ -217,3 +217,5 @@ SECURITY_GROUP_PING_RULES = [
SECURITY_GROUP_SSH_PING_RULES = (stepler_config.SECURITY_GROUP_SSH_RULES + SECURITY_GROUP_SSH_PING_RULES = (stepler_config.SECURITY_GROUP_SSH_RULES +
SECURITY_GROUP_PING_RULES) SECURITY_GROUP_PING_RULES)
DPDK_ENABLED_GROUP = u'Network devices using DPDK-compatible driver'

View File

@ -56,9 +56,8 @@ def test_create_vm_bulk(net_subnet_router, tiny_flavor,
def test_delete_vm_with_associated_vn(contrail_network, contrail_subnet, def test_delete_vm_with_associated_vn(contrail_network, contrail_subnet,
tiny_flavor, cirros_image, flavor, cirros_image, server_steps,
server_steps, network_steps, network_steps, contrail_api_client):
contrail_api_client):
"""Description: Test to validate that VN cannot be deleted if """Description: Test to validate that VN cannot be deleted if
there is a VM associated with it. there is a VM associated with it.
Test steps: Test steps:
@ -69,13 +68,20 @@ def test_delete_vm_with_associated_vn(contrail_network, contrail_subnet,
The attempt to delete VN should fail. The attempt to delete VN should fail.
""" """
server_steps.create_servers( server_steps.create_servers(
image=cirros_image, flavor=tiny_flavor, image=cirros_image,
nics=[{'net-id': contrail_network.uuid}]) flavor=flavor,
nics=[{
'net-id': contrail_network.uuid
}])
net = network_steps.get_network(id=contrail_network.uuid) net = network_steps.get_network(id=contrail_network.uuid)
neutron_client = network_steps._client._rest_client
# Check that we can't delete this net. # Check that we can't delete this net.
assert_that(calling(network_steps.delete).with_args(net), assert_that(
raises(neutron_exceptions.NetworkInUseClient)) calling(neutron_client.delete_network).with_args(
contrail_network.uuid),
raises(neutron_exceptions.NetworkInUseClient))
# Check that network is still there # Check that network is still there
# via contrail API # via contrail API
@ -84,8 +90,8 @@ def test_delete_vm_with_associated_vn(contrail_network, contrail_subnet,
has_item(has_entry('uuid', contrail_network.uuid))) has_item(has_entry('uuid', contrail_network.uuid)))
# via neutron API # via neutron API
assert_that(network_steps.get_network_by_name(net['name']), assert_that(
is_not(empty())) network_steps.get_network_by_name(net['name']), is_not(empty()))
def test_two_nets_same_name(contrail_api_client, contrail_network, def test_two_nets_same_name(contrail_api_client, contrail_network,
@ -234,9 +240,10 @@ def test_create_server_on_exhausted_subnet(cirros_image, flavor, network,
'(Exceeded maximum number of retries)')) '(Exceeded maximum number of retries)'))
def test_file_transfer_with_scp( def test_file_transfer_with_scp(ubuntu_xenial_image, keypair, flavor,
ubuntu_image, keypair, flavor, create_floating_ip, public_network, create_floating_ip, public_network, network,
network, subnet, security_group, server_steps, port_steps): subnet, security_group, port_steps,
server_steps):
"""Validate File Transfer using scp between VMs. """Validate File Transfer using scp between VMs.
Steps: Steps:
@ -262,7 +269,9 @@ def test_file_transfer_with_scp(
"chmod 600 {path}", "chmod 600 {path}",
"echo {done_marker}", "echo {done_marker}",
]).format( ]).format(
content=key_content, path=key_path, user=username, content=key_content,
path=key_path,
user=username,
done_marker=stepler_config.USERDATA_DONE_MARKER) done_marker=stepler_config.USERDATA_DONE_MARKER)
ssh_opts = ('-o UserKnownHostsFile=/dev/null ' ssh_opts = ('-o UserKnownHostsFile=/dev/null '
@ -271,7 +280,7 @@ def test_file_transfer_with_scp(
# Boot servers # Boot servers
servers = server_steps.create_servers( servers = server_steps.create_servers(
count=2, count=2,
image=ubuntu_image, image=ubuntu_xenial_image,
flavor=flavor, flavor=flavor,
networks=[network], networks=[network],
security_groups=[security_group], security_groups=[security_group],
@ -435,7 +444,6 @@ def test_vm_multi_intf_in_same_vn_chk_ping(
ip, server_ssh, timeout=stepler_config.PING_CALL_TIMEOUT) ip, server_ssh, timeout=stepler_config.PING_CALL_TIMEOUT)
@pytest.mark.parametrize('flavor', [dict(ram=128, disk=1)], indirect=True)
def test_create_multiple_servers_on_many_networks( def test_create_multiple_servers_on_many_networks(
cirros_image, flavor, create_network, create_subnet, server_steps): cirros_image, flavor, create_network, create_subnet, server_steps):
"""Validate creation of multiple VN with multiple subnet and VMs in it. """Validate creation of multiple VN with multiple subnet and VMs in it.

View File

@ -304,6 +304,7 @@ def test_security_group_rules_uuid_in_contrail_and_neutron(contrail_api_client,
assert_that(contrail_rules_uuids, equal_to(neutron_rules_uuids)) assert_that(contrail_rules_uuids, equal_to(neutron_rules_uuids))
@pytest.mark.requires('not dpdk_enabled')
@pytest.mark.parametrize( @pytest.mark.parametrize(
'contrail_2_servers_different_networks', [dict(ubuntu=True)], 'contrail_2_servers_different_networks', [dict(ubuntu=True)],
indirect=True, indirect=True,

View File

@ -223,8 +223,9 @@ def test_security_group_and_allow_all_policy(
ids=['tcp_all', 'tcp_port']) ids=['tcp_all', 'tcp_port'])
def test_allow_all_security_group_and_policies( def test_allow_all_security_group_and_policies(
contrail_network_policy, security_group, contrail_network_policy, security_group,
neutron_security_group_rule_steps, connectivity_test_resources, neutron_security_group_rule_steps, server_steps,
server_steps, contrail_api_client, policy_entries, checks): connectivity_test_resources, contrail_api_client, policy_entries,
checks):
"""Verify traffic restrictions by policy with security group. """Verify traffic restrictions by policy with security group.
Steps: Steps:

View File

@ -38,8 +38,7 @@ def test_bound_network_interfaces(os_faults_steps, computes):
devices = dpdk.get_devices(os_faults_steps, computes) devices = dpdk.get_devices(os_faults_steps, computes)
assert_that(devices.values(), assert_that(devices.values(),
only_contains( only_contains(
has_entries('Network devices using DPDK-compatible driver', has_entries(settings.DPDK_ENABLED_GROUP, is_not(empty()))))
is_not(empty()))))
def test_huge_pages_usage(os_faults_steps, computes): def test_huge_pages_usage(os_faults_steps, computes):
@ -71,7 +70,7 @@ def test_contrail_vrouter_dpdk_cpu_usage(os_faults_steps, computes):
@pytest.mark.parametrize( @pytest.mark.parametrize(
'flavor', [dict(metadata={"hw:mem_page_size": "small"})], indirect=True) 'flavor', [dict(ram=1024, metadata={"hw:mem_page_size": "large"})], indirect=True)
@pytest.mark.usefixtures('flavor') @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.

View File

@ -29,6 +29,7 @@ from vapor.helpers import policy
from vapor import settings from vapor import settings
@pytest.mark.requires('not dpdk_enabled')
def test_no_connectivity_between_vms_in_different_tenants( def test_no_connectivity_between_vms_in_different_tenants(
request, contrail_api_client, os_faults_steps): request, contrail_api_client, os_faults_steps):
"""Check no connectivity between VMs in different tenants. """Check no connectivity between VMs in different tenants.