Browse Source

Merge "Fix SRIOV and DPDK tests"

Jenkins 2 years ago
parent
commit
17fb97d464

+ 1
- 6
plugin_test/vapor/Dockerfile View File

@@ -4,9 +4,6 @@ RUN  apt-get update -qq &&  \
4 4
 apt-get install -q -y \
5 5
     python-dev \
6 6
     libvirt-dev \
7
-    # xvfb \
8
-    # iceweasel \
9
-    # libav-tools \
10 7
     && \
11 8
 apt-get clean  && \
12 9
 rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
@@ -15,9 +12,7 @@ WORKDIR /opt/app
15 12
 
16 13
 COPY . /opt/app/
17 14
 
18
-ENV OSLO_PACKAGE_VERSION=1.8
19
-
20
-RUN pip install -e . -r requirements.txt
15
+RUN pip install . -r requirements.txt
21 16
 
22 17
 ENV OS_USERNAME=admin
23 18
 ENV OS_PASSWORD=workshop

+ 2
- 1
plugin_test/vapor/requirements.txt View File

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

+ 4
- 2
plugin_test/vapor/vapor/fixtures/skip.py View File

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

+ 19
- 17
plugin_test/vapor/vapor/helpers/sriov.py View File

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

+ 6
- 4
plugin_test/vapor/vapor/helpers/vrouter_steps.py View File

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

+ 3
- 0
plugin_test/vapor/vapor/settings.py View File

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

+ 1
- 1
plugin_test/vapor/vapor/tests/common/test_security_group.py View File

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

+ 6
- 1
plugin_test/vapor/vapor/tests/test_dpdk.py View File

@@ -12,6 +12,7 @@
12 12
 
13 13
 from hamcrest import (assert_that, has_entries, has_item, only_contains,
14 14
                       is_not, empty, greater_than, has_length)
15
+import pytest
15 16
 
16 17
 from vapor.helpers import contrail_status
17 18
 from vapor.helpers import dpdk
@@ -66,6 +67,9 @@ def test_contrail_vrouter_dpdk_cpu_usage(os_faults_steps, computes):
66 67
         assert_that(usage, greater_than(50))
67 68
 
68 69
 
70
+@pytest.mark.parametrize(
71
+    'flavor', [dict(metadata={"hw:mem_page_size": "small"})], indirect=True)
72
+@pytest.mark.usefixtures('flavor')
69 73
 def test_vrouter_create_interface(request, os_faults_steps, computes):
70 74
     """Verify if vRouter creates interface after creation of a virtual machine.
71 75
 
@@ -78,7 +82,8 @@ def test_vrouter_create_interface(request, os_faults_steps, computes):
78 82
     before_ifaces = vrouter_steps.get_interface_table(os_faults_steps,
79 83
                                                       computes)
80 84
     server = request.getfixturevalue('server')
81
-    compute_fqdn = getattr(server, settings.SERVER_ATTR_HYPERVISOR_HOSTNAME)
85
+    compute = getattr(server, settings.SERVER_ATTR_HYPERVISOR_HOSTNAME)
86
+    compute_fqdn = os_faults_steps.get_fqdn_by_host_name(compute)
82 87
     after_ifaces = vrouter_steps.get_interface_table(os_faults_steps, computes)
83 88
     assert_that(after_ifaces[compute_fqdn],
84 89
                 has_length(greater_than(len(before_ifaces[compute_fqdn]))))

+ 44
- 21
plugin_test/vapor/vapor/tests/test_sriov.py View File

@@ -16,13 +16,16 @@ from stepler import config as stepler_config
16 16
 from stepler.third_party import utils
17 17
 
18 18
 from vapor.helpers import sriov
19
+from vapor import settings
19 20
 
20 21
 pytestmark = pytest.mark.requires('sriov_enabled')
21 22
 
22 23
 
23 24
 def test_virtual_function_exhaustion_and_reuse(
24
-        cirros_image, flavor, network, subnet, create_network, create_subnet,
25
-        create_port, agent_steps, os_faults_steps, server_steps):
25
+        ubuntu_xenial_image, flavor, network, subnet, net_subnet_router,
26
+        neutron_security_group, floating_ip, keypair, create_network,
27
+        create_subnet, create_port, os_faults_steps, computes,
28
+        floating_ip_steps, server_steps, nova_availability_zone_hosts):
26 29
     """Verify Nova can schedule VM to all the VF of a PF.
27 30
 
28 31
     Steps:
@@ -32,7 +35,9 @@ def test_virtual_function_exhaustion_and_reuse(
32 35
         #. Create 1 port for management network and 1 port for SRIOV network
33 36
         #. Boot server with created 2 ports, check that is reaches ACTIVE
34 37
             status
35
-        #. Repeat last 2 steps `total_vfs` times
38
+        #. Create 1 port for SRIOV network
39
+        #. Repeat last 2 steps `total_vfs` - 1 times
40
+        #. Check ping from 1st server to all another
36 41
         #. Create 1 port for management network and 1 port for SRIOV network
37 42
         #. Create another one server with created 2 ports
38 43
         #. Check that server reaches ERROR status
@@ -42,35 +47,56 @@ def test_virtual_function_exhaustion_and_reuse(
42 47
         #. Create another one server with created 2 ports, check that is
43 48
             reaches ACTIVE status
44 49
     """
45
-    sriov_device_mappings = sriov.get_sriov_device_mapping(agent_steps)
46
-    compute_name, device_mapping = next(six.iteritems(sriov_device_mappings))
47
-    sriov_physnet = next(six.iterkeys(device_mapping))
48
-    sriov_iface = device_mapping[sriov_physnet][0]
49
-    numvfs = sriov.get_sriov_numvfs(os_faults_steps, compute_name, sriov_iface)
50
+    sriov_devices = sriov.get_sriov_devices(os_faults_steps, computes)
51
+    compute_name, ifaces = next(six.iteritems(sriov_devices))
52
+    sriov_iface = next(six.iterkeys(ifaces))
53
+    numvfs = ifaces[sriov_iface]['sriov_numvfs']
54
+
55
+    # Find availability zone compute host
56
+    compute_host = next(
57
+        host for host in nova_availability_zone_hosts
58
+        if compute_name.startswith(host))
50 59
 
51 60
     # Create SRIOV net and subnet
52 61
     kwargs = {
53 62
         'provider:network_type': 'vlan',
54
-        'provider:physical_network': sriov_physnet,
63
+        'provider:physical_network': settings.SRIOV_PHYSNET,
55 64
         'provider:segmentation_id': 200
56 65
     }
57 66
     sriov_net_name, = utils.generate_ids()
58 67
     sriov_net = create_network(sriov_net_name, **kwargs)
59
-    create_subnet(sriov_net_name + '__subnet', sriov_net, cidr="55.1.1.0/24")
68
+    create_subnet(
69
+        sriov_net_name + '__subnet', sriov_net, cidr="10.200.54.0/24")
60 70
 
61 71
     # Create servers
62 72
     servers = []
63
-    sriov_port_kwargs = {'binding:vnic_type': 'direct'}
73
+    sriov_port_kwargs = {
74
+        'binding:vnic_type': 'direct',
75
+        'security_groups': [neutron_security_group['id']]
76
+    }
64 77
     server_create_args = dict(
65
-        image=cirros_image,
78
+        image=ubuntu_xenial_image,
66 79
         flavor=flavor,
67
-        availability_zone='nova:{}'.format(compute_name))
68
-    for _ in range(numvfs):
69
-        mgmt_port = create_port(network)
80
+        availability_zone='nova:{}'.format(compute_host),
81
+        keypair=keypair,
82
+        username=stepler_config.UBUNTU_USERNAME)
83
+    for i in range(numvfs):
70 84
         sriov_port = create_port(sriov_net, **sriov_port_kwargs)
85
+        ports = [sriov_port]
86
+        if i == 0:
87
+            mgmt_port = create_port(
88
+                network, security_groups=[neutron_security_group['id']])
89
+            ports.insert(0, mgmt_port)
71 90
         server = server_steps.create_servers(
72
-            ports=[mgmt_port, sriov_port], **server_create_args)[0]
91
+            ports=ports, **server_create_args)[0]
73 92
         servers.append(server)
93
+        if i == 0:
94
+            floating_ip_steps.attach_floating_ip(floating_ip, mgmt_port)
95
+
96
+    # Check ping between servers
97
+    ping_plan = {servers[0]: servers[1:]}
98
+    server_steps.check_ping_by_plan(
99
+        ping_plan, timeout=stepler_config.PING_BETWEEN_SERVERS_TIMEOUT)
74 100
 
75 101
     # Try to create one more server
76 102
     mgmt_port = create_port(network)
@@ -79,8 +105,7 @@ def test_virtual_function_exhaustion_and_reuse(
79 105
     error_server = server_steps.create_servers(
80 106
         ports=[mgmt_port, sriov_port], check=False, **server_create_args)[0]
81 107
     server_steps.check_server_status(
82
-        error_server,
83
-        [stepler_config.STATUS_ERROR],
108
+        error_server, [stepler_config.STATUS_ERROR],
84 109
         transit_statuses=[stepler_config.STATUS_BUILD],
85 110
         timeout=stepler_config.SERVER_ACTIVE_TIMEOUT)
86 111
 
@@ -91,8 +116,6 @@ def test_virtual_function_exhaustion_and_reuse(
91 116
     server_steps.delete_servers(servers[:1])
92 117
 
93 118
     # Create another server
94
-    mgmt_port = create_port(network)
95 119
     sriov_port = create_port(sriov_net, **sriov_port_kwargs)
96 120
 
97
-    server_steps.create_servers(
98
-        ports=[mgmt_port, sriov_port], **server_create_args)[0]
121
+    server_steps.create_servers(ports=[sriov_port], **server_create_args)[0]

Loading…
Cancel
Save