From d2e3ea940731c0cf8161aff36935e0b1209f9378 Mon Sep 17 00:00:00 2001 From: Georgy Dyuldin Date: Fri, 14 Apr 2017 18:09:00 +0300 Subject: [PATCH] Fix some tests failures on baremetal contrail lab Change-Id: Ifb03b2828fe2ee3d725477684cb69060e541d4be --- plugin_test/vapor/vapor/fixtures/skip.py | 13 +++++++ plugin_test/vapor/vapor/helpers/dpdk.py | 2 +- plugin_test/vapor/vapor/settings.py | 6 ++- .../vapor/vapor/tests/common/test_base.py | 38 +++++++++++-------- .../vapor/tests/common/test_security_group.py | 1 + .../vapor/tests/common/test_sg_policy.py | 5 ++- plugin_test/vapor/vapor/tests/test_dpdk.py | 5 +-- plugin_test/vapor/vapor/tests/test_system.py | 1 + 8 files changed, 48 insertions(+), 23 deletions(-) diff --git a/plugin_test/vapor/vapor/fixtures/skip.py b/plugin_test/vapor/vapor/fixtures/skip.py index 8fd50ff3d..0d5327811 100644 --- a/plugin_test/vapor/vapor/fixtures/skip.py +++ b/plugin_test/vapor/vapor/fixtures/skip.py @@ -14,6 +14,7 @@ import pytest import six from stepler.fixtures import skip +from vapor.helpers import dpdk from vapor.helpers import sriov from vapor import settings @@ -43,6 +44,18 @@ class Predicates(skip.Predicates): computes) 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 @_store_call def contrail_control_nodes_count(self): diff --git a/plugin_test/vapor/vapor/helpers/dpdk.py b/plugin_test/vapor/vapor/helpers/dpdk.py index 4fd13ea1e..1cf73dfbc 100644 --- a/plugin_test/vapor/vapor/helpers/dpdk.py +++ b/plugin_test/vapor/vapor/helpers/dpdk.py @@ -21,7 +21,7 @@ from vapor import settings def get_devices(os_faults_steps, nodes): 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 = {} for node_result in result: node = nodes_steps.get_node_by_result(node_result, os_faults_steps) diff --git a/plugin_test/vapor/vapor/settings.py b/plugin_test/vapor/vapor/settings.py index 2fcf1aae6..e7666820e 100644 --- a/plugin_test/vapor/vapor/settings.py +++ b/plugin_test/vapor/vapor/settings.py @@ -192,10 +192,10 @@ SERVER_ATTR_HYPERVISOR_HOSTNAME = 'OS-EXT-SRV-ATTR:hypervisor_hostname' 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 -SRIOV_PHYSNET = 'physnet1' +SRIOV_PHYSNET = os.environ.get('SRIOV_PHYSNET', 'physnet1') # Security groups INGRESS = 'ingress' @@ -217,3 +217,5 @@ SECURITY_GROUP_PING_RULES = [ SECURITY_GROUP_SSH_PING_RULES = (stepler_config.SECURITY_GROUP_SSH_RULES + SECURITY_GROUP_PING_RULES) + +DPDK_ENABLED_GROUP = u'Network devices using DPDK-compatible driver' diff --git a/plugin_test/vapor/vapor/tests/common/test_base.py b/plugin_test/vapor/vapor/tests/common/test_base.py index 5fde6cf28..eb95ccfb2 100644 --- a/plugin_test/vapor/vapor/tests/common/test_base.py +++ b/plugin_test/vapor/vapor/tests/common/test_base.py @@ -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, - tiny_flavor, cirros_image, - server_steps, network_steps, - contrail_api_client): + flavor, cirros_image, server_steps, + network_steps, contrail_api_client): """Description: Test to validate that VN cannot be deleted if there is a VM associated with it. Test steps: @@ -69,13 +68,20 @@ def test_delete_vm_with_associated_vn(contrail_network, contrail_subnet, The attempt to delete VN should fail. """ server_steps.create_servers( - image=cirros_image, flavor=tiny_flavor, - nics=[{'net-id': contrail_network.uuid}]) + image=cirros_image, + flavor=flavor, + nics=[{ + 'net-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. - assert_that(calling(network_steps.delete).with_args(net), - raises(neutron_exceptions.NetworkInUseClient)) + assert_that( + calling(neutron_client.delete_network).with_args( + contrail_network.uuid), + raises(neutron_exceptions.NetworkInUseClient)) # Check that network is still there # 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))) # via neutron API - assert_that(network_steps.get_network_by_name(net['name']), - is_not(empty())) + assert_that( + network_steps.get_network_by_name(net['name']), is_not(empty())) 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)')) -def test_file_transfer_with_scp( - ubuntu_image, keypair, flavor, create_floating_ip, public_network, - network, subnet, security_group, server_steps, port_steps): +def test_file_transfer_with_scp(ubuntu_xenial_image, keypair, flavor, + create_floating_ip, public_network, network, + subnet, security_group, port_steps, + server_steps): """Validate File Transfer using scp between VMs. Steps: @@ -262,7 +269,9 @@ def test_file_transfer_with_scp( "chmod 600 {path}", "echo {done_marker}", ]).format( - content=key_content, path=key_path, user=username, + content=key_content, + path=key_path, + user=username, done_marker=stepler_config.USERDATA_DONE_MARKER) ssh_opts = ('-o UserKnownHostsFile=/dev/null ' @@ -271,7 +280,7 @@ def test_file_transfer_with_scp( # Boot servers servers = server_steps.create_servers( count=2, - image=ubuntu_image, + image=ubuntu_xenial_image, flavor=flavor, networks=[network], 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) -@pytest.mark.parametrize('flavor', [dict(ram=128, disk=1)], indirect=True) def test_create_multiple_servers_on_many_networks( cirros_image, flavor, create_network, create_subnet, server_steps): """Validate creation of multiple VN with multiple subnet and VMs in it. diff --git a/plugin_test/vapor/vapor/tests/common/test_security_group.py b/plugin_test/vapor/vapor/tests/common/test_security_group.py index c5def65f8..88595e858 100644 --- a/plugin_test/vapor/vapor/tests/common/test_security_group.py +++ b/plugin_test/vapor/vapor/tests/common/test_security_group.py @@ -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)) +@pytest.mark.requires('not dpdk_enabled') @pytest.mark.parametrize( 'contrail_2_servers_different_networks', [dict(ubuntu=True)], indirect=True, diff --git a/plugin_test/vapor/vapor/tests/common/test_sg_policy.py b/plugin_test/vapor/vapor/tests/common/test_sg_policy.py index f643cb422..ecc242818 100644 --- a/plugin_test/vapor/vapor/tests/common/test_sg_policy.py +++ b/plugin_test/vapor/vapor/tests/common/test_sg_policy.py @@ -223,8 +223,9 @@ def test_security_group_and_allow_all_policy( ids=['tcp_all', 'tcp_port']) def test_allow_all_security_group_and_policies( contrail_network_policy, security_group, - neutron_security_group_rule_steps, connectivity_test_resources, - server_steps, contrail_api_client, policy_entries, checks): + neutron_security_group_rule_steps, server_steps, + connectivity_test_resources, contrail_api_client, policy_entries, + checks): """Verify traffic restrictions by policy with security group. Steps: diff --git a/plugin_test/vapor/vapor/tests/test_dpdk.py b/plugin_test/vapor/vapor/tests/test_dpdk.py index 14e2b5823..fc9591741 100644 --- a/plugin_test/vapor/vapor/tests/test_dpdk.py +++ b/plugin_test/vapor/vapor/tests/test_dpdk.py @@ -38,8 +38,7 @@ def test_bound_network_interfaces(os_faults_steps, computes): devices = dpdk.get_devices(os_faults_steps, computes) assert_that(devices.values(), only_contains( - has_entries('Network devices using DPDK-compatible driver', - is_not(empty())))) + has_entries(settings.DPDK_ENABLED_GROUP, is_not(empty())))) 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( - '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') def test_vrouter_create_interface(request, os_faults_steps, computes): """Verify if vRouter creates interface after creation of a virtual machine. diff --git a/plugin_test/vapor/vapor/tests/test_system.py b/plugin_test/vapor/vapor/tests/test_system.py index 46f73c7fc..40e2a2422 100644 --- a/plugin_test/vapor/vapor/tests/test_system.py +++ b/plugin_test/vapor/vapor/tests/test_system.py @@ -29,6 +29,7 @@ from vapor.helpers import policy from vapor import settings +@pytest.mark.requires('not dpdk_enabled') def test_no_connectivity_between_vms_in_different_tenants( request, contrail_api_client, os_faults_steps): """Check no connectivity between VMs in different tenants.