Browse Source

Fix some MCP-related issues

Change-Id: I9e670a03ca6169edfdb81a04b86ca7d0d1c6569b
Georgy Dyuldin 2 years ago
parent
commit
68dc1ebb45

+ 1
- 1
plugin_test/vapor/pytest.ini View File

@@ -5,4 +5,4 @@ markers =
5 5
     performance_test: mark test as Performance.
6 6
 
7 7
 #addopts = -vv --color=yes --junit-xml=report.xml
8
-addopts = -vv --color=yes -ra -p stepler.third_party.destructive_dispatcher -p stepler.third_party.idempotent_id
8
+addopts = -vv --color=yes -ra -p stepler.third_party.destructive_dispatcher -p stepler.third_party.idempotent_id -p stepler.third_party.default_project

+ 13
- 3
plugin_test/vapor/vapor/fixtures/contrail.py View File

@@ -89,7 +89,8 @@ def contrail_api_endpoint(os_faults_steps):
89 89
 def contrail_vrouter_agent_endpoint(contrail_services_http_introspect_ports):
90 90
     """Return contrail agent endpoint."""
91 91
     service_name = 'contrail-vrouter-agent'
92
-    ip = contrail_services_http_introspect_ports[service_name]['ips'][0]
92
+    ip = contrail_services_http_introspect_ports[service_name]['nodes'][0][
93
+        'ip']
93 94
     port = contrail_services_http_introspect_ports[service_name]['port']
94 95
     return {'ip': ip, 'port': port}
95 96
 
@@ -128,7 +129,10 @@ def contrail_services_http_introspect_ports(os_faults_steps, contrail_nodes):
128 129
             filename = os.path.basename(path)
129 130
             service_name = os.path.splitext(filename)[0]
130 131
             if service_name in results:
131
-                results[service_name]['ips'].append(node_ip)
132
+                results[service_name]['nodes'].append({
133
+                    'ip': node_ip,
134
+                    'fqdn': node.get_fqdns()[0]
135
+                })
132 136
                 continue
133 137
             if service_name not in default_ports:
134 138
                 continue
@@ -148,7 +152,13 @@ def contrail_services_http_introspect_ports(os_faults_steps, contrail_nodes):
148 152
             except configparser.NoSectionError:
149 153
                 pass
150 154
             if port:
151
-                results[service_name] = {'port': port, 'ips': [node_ip]}
155
+                results[service_name] = {
156
+                    'port': port,
157
+                    'nodes': [{
158
+                        'ip': node_ip,
159
+                        'fqdn': node.get_fqdns()[0]
160
+                    }],
161
+                }
152 162
     return results
153 163
 
154 164
 

+ 11
- 1
plugin_test/vapor/vapor/fixtures/different_tenants_resources.py View File

@@ -16,6 +16,8 @@ import six
16 16
 import stepler.config as stepler_config
17 17
 from stepler.third_party import utils
18 18
 
19
+from vapor.helpers import project
20
+
19 21
 if six.PY2:
20 22
     import contextlib2 as contextlib
21 23
 else:
@@ -121,6 +123,7 @@ class ResourceManager(object):
121 123
             'server': server,
122 124
             'port': port,
123 125
             'floating_ip': floating_ip,
126
+            'security_group': security_group,
124 127
         })
125 128
 
126 129
 
@@ -144,7 +147,8 @@ def different_tenants_resources(
144 147
         cirros_image, sorted_hypervisors, get_network_steps, get_subnet_steps,
145 148
         get_server_steps, port_steps, get_floating_ip_steps, public_flavor,
146 149
         public_network, get_neutron_security_group_steps,
147
-        get_neutron_security_group_rule_steps, nova_availability_zone_hosts):
150
+        get_neutron_security_group_rule_steps, nova_availability_zone_hosts,
151
+        get_current_project, contrail_api_client):
148 152
     """Fixture to create network, subnet and server on each of 2 projects.
149 153
 
150 154
     Created subnets has same CIDR.
@@ -185,11 +189,17 @@ def different_tenants_resources(
185 189
         project_resources = mrg.create(subnet_cidr, ips[0], cirros_image,
186 190
                                        public_flavor, host)
187 191
 
192
+        contrail_project = project.get_contrail_project(get_current_project(),
193
+                                                        contrail_api_client)
194
+        project_resources.contrail_project = contrail_project
188 195
         projects_resources.append(project_resources)
189 196
 
190 197
         with credentials.change(project_2):
191 198
 
192 199
             project_resources = mrg.create(subnet_cidr, ips[1], cirros_image,
193 200
                                            public_flavor, host)
201
+            contrail_project = project.get_contrail_project(
202
+                get_current_project(), contrail_api_client)
203
+            project_resources.contrail_project = contrail_project
194 204
             projects_resources.append(project_resources)
195 205
             yield projects_resources

+ 27
- 11
plugin_test/vapor/vapor/fixtures/policies.py View File

@@ -10,8 +10,8 @@ def contrail_policies_cleanup(contrail_api_client):
10 10
 
11 11
     def _get_policies_uuids():
12 12
         return {
13
-            net['uuid']
14
-            for net in contrail_api_client.network_policys_list()[
13
+            policy['uuid']
14
+            for policy in contrail_api_client.network_policys_list()[
15 15
                 'network-policys']
16 16
         }
17 17
 
@@ -24,15 +24,31 @@ def contrail_policies_cleanup(contrail_api_client):
24 24
 
25 25
 
26 26
 @pytest.fixture
27
-def contrail_network_policy(contrail_api_client, contrail_current_project):
28
-    policy_name, = utils.generate_ids()
29
-    policy = types.NetworkPolicy(
30
-        policy_name, parent_obj=contrail_current_project)
31
-    contrail_api_client.network_policy_create(policy)
27
+def create_network_policy(contrail_api_client, contrail_current_project):
28
+    """Fixture to create network policy."""
32 29
 
33
-    yield policy
30
+    policies = []
34 31
 
35
-    try:
32
+    def _create_network_policy(name=None, parent=None):
33
+        name = name or next(utils.generate_ids())
34
+        parent = parent or contrail_current_project
35
+        policy = types.NetworkPolicy(name, parent_obj=parent)
36
+        contrail_api_client.network_policy_create(policy)
37
+
38
+        policies.append(policy)
39
+
40
+        return policy
41
+
42
+    yield _create_network_policy
43
+
44
+    for policy in policies:
45
+        try:
46
+            policy = contrail_api_client.network_policy_read(id=policy.uuid)
47
+        except exceptions.NoIdError:
48
+            continue
36 49
         contrail_api_client.network_policy_delete(id=policy.uuid)
37
-    except exceptions.NoIdError:
38
-        pass
50
+
51
+
52
+@pytest.fixture
53
+def contrail_network_policy(create_network_policy):
54
+    return create_network_policy()

+ 6
- 0
plugin_test/vapor/vapor/fixtures/subnets.py View File

@@ -10,6 +10,7 @@
10 10
 # License for the specific language governing permissions and limitations
11 11
 # under the License.
12 12
 
13
+from pycontrail import exceptions
13 14
 import pycontrail.types as types
14 15
 import pytest
15 16
 
@@ -74,6 +75,11 @@ def contrail_create_subnet(contrail_api_client, contrail_default_ipam):
74 75
     yield _contrail_create_subnet
75 76
 
76 77
     for network, ipam in networks:
78
+        try:
79
+            network = contrail_api_client.virtual_network_read(id=network.uuid)
80
+            ipam = contrail_api_client.network_ipam_read(id=ipam.uuid)
81
+        except exceptions.NoIdError:
82
+            continue
77 83
         network.del_network_ipam(ipam)
78 84
         contrail_api_client.virtual_network_update(network)
79 85
 

+ 2
- 1
plugin_test/vapor/vapor/helpers/contrail_status.py View File

@@ -8,6 +8,7 @@ from stepler.third_party import waiter
8 8
 
9 9
 from vapor.helpers import asserts
10 10
 from vapor.helpers import nodes_steps
11
+from vapor import settings
11 12
 
12 13
 
13 14
 STATUS_ACTIVE = 'active'
@@ -84,7 +85,7 @@ def check_services_statuses(os_faults_steps):
84 85
 
85 86
             statuses = set(statuses)
86 87
             active = {x for x in statuses if x.status == STATUS_ACTIVE}
87
-            if service in ('contrail-svc-monitor', 'contrail-schema'):
88
+            if service in settings.ACTIVE_BACKUP_SERVICES:
88 89
                 backup = {x for x in statuses if x.status == STATUS_BACKUP}
89 90
                 broken = statuses - active - backup
90 91
                 collector.check(active,

+ 3
- 2
plugin_test/vapor/vapor/helpers/policy.py View File

@@ -13,13 +13,14 @@
13 13
 import pycontrail.types as types
14 14
 
15 15
 
16
-def make_policy_entry(protocol, src_ports_range, dst_ports_range):
16
+def make_policy_entry(protocol, src_ports_range, dst_ports_range,
17
+                      action='pass'):
17 18
     address = types.AddressType(virtual_network='any')
18 19
     src_port = types.PortType(
19 20
         start_port=src_ports_range[0], end_port=src_ports_range[1])
20 21
     dst_port = types.PortType(
21 22
         start_port=dst_ports_range[0], end_port=dst_ports_range[1])
22
-    action = types.ActionListType(simple_action='pass')
23
+    action = types.ActionListType(simple_action=action)
23 24
     rule = types.PolicyRuleType(
24 25
         protocol=protocol,
25 26
         direction='<>',

+ 19
- 0
plugin_test/vapor/vapor/helpers/project.py View File

@@ -0,0 +1,19 @@
1
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
2
+# not use this file except in compliance with the License. You may obtain
3
+# a copy of the License at
4
+
5
+#     http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+# Unless required by applicable law or agreed to in writing, software
8
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+# License for the specific language governing permissions and limitations
11
+# under the License.
12
+
13
+import uuid
14
+
15
+
16
+def get_contrail_project(os_project, contrail_api_client):
17
+    """Return contrail project by keystone project."""
18
+    project_id = str(uuid.UUID(os_project.id))
19
+    return contrail_api_client.project_read(id=project_id)

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

@@ -159,6 +159,8 @@ CONTRAIL_ANALYTIC_PROCESSES = {
159 159
     ],
160 160
 }
161 161
 
162
+ACTIVE_BACKUP_SERVICES = ('contrail-svc-monitor', 'contrail-schema')
163
+
162 164
 HEAT_TEMPLATES_PATH = os.path.join(BASE_DIR, 'heat')
163 165
 
164 166
 VROUTER_HEADLESS_MODE_CMD = r"grep -iP '^headless_mode\s*=\s*true' /etc/contrail/contrail-vrouter-agent.conf"  # noqa

+ 112
- 73
plugin_test/vapor/vapor/tests/common/test_base.py View File

@@ -24,7 +24,7 @@ import pytest
24 24
 
25 25
 from vapor.helpers import agent_steps
26 26
 from vapor.helpers import asserts
27
-from vapor.helpers import contrail_status, policy, connectivity
27
+from vapor.helpers import contrail_status, connectivity
28 28
 from vapor import settings
29 29
 from vapor.settings import logger
30 30
 
@@ -90,8 +90,8 @@ def test_delete_vm_with_associated_vn(contrail_network, contrail_subnet,
90 90
 
91 91
 def test_two_nets_same_name(contrail_api_client, contrail_network,
92 92
                             contrail_subnet):
93
-    """Description: Test to validate that with the same subnet and
94
-        name provided, two different VNs cannot be created.
93
+    """Description: check creating 2 VNs with same name and parent.
94
+
95 95
     Test steps:
96 96
         1. Create a VN.
97 97
         2. Create a second VN with the same name and subnet as the first VN.
@@ -99,7 +99,9 @@ def test_two_nets_same_name(contrail_api_client, contrail_network,
99 99
     Pass criteria:
100 100
         There is a single VN created.
101 101
     """
102
-    net = contrail_types.VirtualNetwork(contrail_network.name)
102
+    project = contrail_api_client.project_read(id=contrail_network.parent_uuid)
103
+    net = contrail_types.VirtualNetwork(
104
+        contrail_network.name, parent_obj=project)
103 105
     assert_that(
104 106
         calling(contrail_api_client.virtual_network_create).with_args(net),
105 107
         raises(exceptions.RefsExistError))
@@ -110,6 +112,7 @@ def test_metadata_service(security_group, port_steps,
110 112
                           create_floating_ip, tiny_flavor, cirros_image,
111 113
                           server_steps):
112 114
     """Description: Test to validate metadata service
115
+
113 116
     Test steps:
114 117
         1. Create a VN.
115 118
         2. Launch a VM in this VN.
@@ -118,7 +121,7 @@ def test_metadata_service(security_group, port_steps,
118 121
     Pass criteria:
119 122
         The output of the metadata script should be seen in the VM.
120 123
     """
121
-    output_filename = 'output.txt'
124
+    output_filename, = utils.generate_ids('output')
122 125
     userdata = (
123 126
         u'#!/bin/sh\n'
124 127
         u'echo "TestMetadataService.'
@@ -227,7 +230,8 @@ def test_create_server_on_exhausted_subnet(cirros_image, flavor, network,
227 230
 
228 231
     assert_that(
229 232
         calling(server_steps.create_servers).with_args(**create_server_args),
230
-        raises(AssertionError, 'No valid host was found'))
233
+        raises(AssertionError, '(No valid host was found)|'
234
+                               '(Exceeded maximum number of retries)'))
231 235
 
232 236
 
233 237
 def test_file_transfer_with_scp(
@@ -254,10 +258,12 @@ def test_file_transfer_with_scp(
254 258
     userdata = '\n'.join([
255 259
         "#!/bin/bash -v",
256 260
         "echo '{content}' > {path}",
257
-        "chown {user} {path}",
261
+        "chown {user}:{user} {path}",
258 262
         "chmod 600 {path}",
263
+        "echo {done_marker}",
259 264
     ]).format(
260
-        content=key_content, path=key_path, user=username)
265
+        content=key_content, path=key_path, user=username,
266
+        done_marker=stepler_config.USERDATA_DONE_MARKER)
261 267
 
262 268
     ssh_opts = ('-o UserKnownHostsFile=/dev/null '
263 269
                 '-o StrictHostKeyChecking=no')
@@ -282,6 +288,12 @@ def test_file_transfer_with_scp(
282 288
         floating_ip = create_floating_ip(public_network, port=port)
283 289
         floating_ips.append(floating_ip)
284 290
 
291
+    # Wait userdata to be done
292
+    server_steps.check_server_log_contains_record(
293
+        servers[0],
294
+        stepler_config.USERDATA_DONE_MARKER,
295
+        timeout=stepler_config.USERDATA_EXECUTING_TIMEOUT)
296
+
285 297
     ip = server_steps.get_fixed_ip(servers[1])
286 298
     with asserts.AssertsCollector() as collector:
287 299
         for size in sizes:
@@ -383,24 +395,30 @@ def test_create_server_on_network_without_subnet(
383 395
         raises(nova_exceptions.BadRequest, 'requires a subnet'))
384 396
 
385 397
 
386
-def test_vm_multi_intf_in_same_vn_chk_ping(network,
387
-                                           subnet,
388
-                                           cirros_image,
389
-                                           flavor,
390
-                                           security_group,
391
-                                           server_steps,
392
-                                           port_steps,
393
-                                           create_floating_ip,
394
-                                           public_network):
398
+def test_vm_multi_intf_in_same_vn_chk_ping(
399
+        network,
400
+        cirros_image,
401
+        flavor,
402
+        security_group,
403
+        server,
404
+        server_steps,
405
+        port_steps,
406
+        create_floating_ip,
407
+        public_network):
395 408
     """Test to validate that a multiple interfaces of the same VM can be
396 409
     associated to the same VN and ping is successful.
397 410
     """
398
-    userdata = (
399
-        u'#!/bin/sh\n'
400
-        u"/sbin/ifconfig -a\n"
401
-        u"/sbin/cirros-dhcpc up eth1\n")
411
+    server_port = port_steps.get_ports(
412
+        device_owner=stepler_config.PORT_DEVICE_OWNER_SERVER,
413
+        device_id=server.id)[0]
402 414
 
403
-    server = server_steps.create_servers(
415
+    floating_ip = create_floating_ip(public_network, port=server_port)
416
+
417
+    userdata = (u'#!/bin/sh\n'
418
+                u"/sbin/ifconfig -a\n"
419
+                u"/sbin/cirros-dhcpc up eth1\n")
420
+
421
+    server2 = server_steps.create_servers(
404 422
         userdata=userdata,
405 423
         image=cirros_image,
406 424
         flavor=flavor,
@@ -409,19 +427,12 @@ def test_vm_multi_intf_in_same_vn_chk_ping(network,
409 427
         username=stepler_config.CIRROS_USERNAME,
410 428
         password=stepler_config.CIRROS_PASSWORD)[0]
411 429
 
412
-    server_ports = port_steps.get_ports(
413
-        device_owner=stepler_config.PORT_DEVICE_OWNER_SERVER,
414
-        device_id=server.id)
415
-
416
-    server_port = server_ports[0]
417
-    floating_ip = create_floating_ip(public_network, port=server_port)
418
-    server_steps.check_server_ip(server,
419
-                                 floating_ip['floating_ip_address'],
420
-                                 timeout=settings.FLOATING_IP_BIND_TIMEOUT)
421
-
422
-    server_steps.check_ping_between_servers_via_floating(
423
-        [server, server],
424
-        ip_types=(stepler_config.FIXED_IP,))
430
+    with server_steps.get_server_ssh(
431
+            server, floating_ip['floating_ip_address']) as server_ssh:
432
+        for ip in server_steps.get_ips(
433
+                server2, ip_type=stepler_config.FIXED_IP).keys():
434
+            server_steps.check_ping_for_ip(
435
+                ip, server_ssh, timeout=stepler_config.PING_CALL_TIMEOUT)
425 436
 
426 437
 
427 438
 @pytest.mark.parametrize('flavor', [dict(ram=128, disk=1)], indirect=True)
@@ -462,11 +473,12 @@ def test_network_in_agent_with_server_add_delete(
462 473
         id=network['id'])
463 474
     network_fq_name = contrail_network.get_fq_name_str()
464 475
 
465
-    nodes = contrail_services_http_introspect_ports['contrail-vrouter-agent']
466
-    port = nodes['port']
476
+    service_data = contrail_services_http_introspect_ports[
477
+        'contrail-vrouter-agent']
478
+    port = service_data['port']
467 479
     agent_networks = []
468
-    for ip in nodes['ips']:
469
-        agent_network = agent_steps.get_vna_vn(session, ip, port,
480
+    for node in service_data['nodes']:
481
+        agent_network = agent_steps.get_vna_vn(session, node['ip'], port,
470 482
                                                network_fq_name)
471 483
         if agent_network:
472 484
             agent_networks.append(agent_network)
@@ -476,8 +488,8 @@ def test_network_in_agent_with_server_add_delete(
476 488
     server_steps.delete_servers([server])
477 489
 
478 490
     agent_networks = []
479
-    for ip in nodes['ips']:
480
-        agent_network = agent_steps.get_vna_vn(session, ip, port,
491
+    for node in service_data['nodes']:
492
+        agent_network = agent_steps.get_vna_vn(session, node['ip'], port,
481 493
                                                network_fq_name)
482 494
         if agent_network:
483 495
             agent_networks.append(agent_network)
@@ -485,12 +497,10 @@ def test_network_in_agent_with_server_add_delete(
485 497
     assert_that(agent_networks, empty())
486 498
 
487 499
 
488
-def test_policy_between_vns_diff_proj(different_tenants_resources,
489
-                                      server_steps,
490
-                                      contrail_api_client,
491
-                                      create_contrail_security_group):
492
-    """Test to validate that policy to deny and pass under different
493
-    projects should behave accordingly.
500
+def test_policy_between_vns_diff_proj(
501
+        different_tenants_resources, server_steps, contrail_api_client,
502
+        create_network_policy, set_network_policy):
503
+    """Check policy to deny and pass under different projects.
494 504
 
495 505
     Test steps:
496 506
         1. Create 2 different projects.
@@ -500,41 +510,70 @@ def test_policy_between_vns_diff_proj(different_tenants_resources,
500 510
     """
501 511
     project1, project2 = different_tenants_resources
502 512
 
503
-    client = project1.server
504
-    client_floating_ip = project1.floating_ip
505
-    server_floating_ip = project2.floating_ip
506
-
507
-    prj1_conrail_sg = contrail_api_client.security_group_read(
508
-        id=project1.security_group.id)
509
-    prj2_conrail_sg = contrail_api_client.security_group_read(
510
-        id=project2.security_group.id)
511
-
512
-    client_sg_entries = prj1_conrail_sg.security_group_entries
513
-    server_sg_entries = prj2_conrail_sg.security_group_entries
514
-
515
-    # Add allow policy
516
-    client_sg_entries.add_policy_rule(policy.POLICY_RULE_ALLOW_EGRESS_ICMP)
517
-    client_sg_entries.add_policy_rule(policy.POLICY_RULE_ALLOW_INGRESS_ICMP)
518
-    prj1_conrail_sg.security_group_entries = client_sg_entries
519
-    contrail_api_client.security_group_update(prj1_conrail_sg)
513
+    project1_policy = create_network_policy(parent=project1.contrail_project)
514
+    project2_policy = create_network_policy(parent=project2.contrail_project)
515
+
516
+    project1_network = contrail_api_client.virtual_network_read(
517
+        id=project1.network['id'])
518
+    project2_network = contrail_api_client.virtual_network_read(
519
+        id=project2.network['id'])
520
+    set_network_policy(project1_network, project1_policy)
521
+    set_network_policy(project2_network, project2_policy)
522
+
523
+    # Create allow ICMP policy entries
524
+    src_address = contrail_types.AddressType(
525
+        virtual_network=project1_network.get_fq_name_str())
526
+    dst_address = contrail_types.AddressType(
527
+        virtual_network=project2_network.get_fq_name_str())
528
+    port = contrail_types.PortType(start_port=-1, end_port=-1)
529
+    pass_action = contrail_types.ActionListType(simple_action='pass')
530
+    allow_rule = contrail_types.PolicyRuleType(
531
+        protocol='icmp',
532
+        direction='<>',
533
+        src_addresses=[src_address],
534
+        src_ports=[port],
535
+        dst_addresses=[dst_address],
536
+        dst_ports=[port],
537
+        action_list=pass_action)
538
+    allow_icmp_policy_entries = contrail_types.PolicyEntriesType(
539
+        policy_rule=[allow_rule])
540
+
541
+    # Create deny ICMP policy entries
542
+    deny_action = contrail_types.ActionListType(simple_action='deny')
543
+    deny_rule = contrail_types.PolicyRuleType(
544
+        protocol='icmp',
545
+        direction='<>',
546
+        src_addresses=[src_address],
547
+        src_ports=[port],
548
+        dst_addresses=[dst_address],
549
+        dst_ports=[port],
550
+        action_list=deny_action)
551
+    deny_icmp_policy_entries = contrail_types.PolicyEntriesType(
552
+        policy_rule=[deny_rule])
553
+
554
+    project1_policy.network_policy_entries = allow_icmp_policy_entries
555
+    contrail_api_client.network_policy_update(project1_policy)
556
+
557
+    project2_policy.network_policy_entries = deny_icmp_policy_entries
558
+    contrail_api_client.network_policy_update(project2_policy)
559
+
560
+    project2_server_fixed_ip = project2.server_steps.get_fixed_ip(
561
+        project2.server)
520 562
 
521 563
     with server_steps.get_server_ssh(
522
-            client,
523
-            ip=client_floating_ip['floating_ip_address']) as server_ssh:
564
+            project1.server,
565
+            ip=project1.floating_ip['floating_ip_address']) as server_ssh:
524 566
         connectivity.check_icmp_connection_status(
525
-            server_floating_ip['floating_ip_address'],
567
+            project2_server_fixed_ip,
526 568
             server_ssh,
527 569
             must_available=False,
528 570
             timeout=settings.SECURITY_GROUP_APPLY_TIMEOUT)
529 571
 
530
-        server_sg_entries.add_policy_rule(policy.POLICY_RULE_ALLOW_EGRESS_ICMP)
531
-        server_sg_entries.add_policy_rule(
532
-            policy.POLICY_RULE_ALLOW_INGRESS_ICMP)
533
-        prj2_conrail_sg.security_group_entries = server_sg_entries
534
-        contrail_api_client.security_group_update(prj2_conrail_sg)
572
+        project2_policy.network_policy_entries = allow_icmp_policy_entries
573
+        contrail_api_client.network_policy_update(project2_policy)
535 574
 
536 575
         connectivity.check_icmp_connection_status(
537
-            server_floating_ip['floating_ip_address'],
576
+            project2_server_fixed_ip,
538 577
             server_ssh,
539 578
             timeout=settings.SECURITY_GROUP_APPLY_TIMEOUT)
540 579
 

+ 33
- 6
plugin_test/vapor/vapor/tests/test_analytics.py View File

@@ -1,3 +1,17 @@
1
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
2
+# not use this file except in compliance with the License. You may obtain
3
+# a copy of the License at
4
+
5
+#     http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+# Unless required by applicable law or agreed to in writing, software
8
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+# License for the specific language governing permissions and limitations
11
+# under the License.
12
+
13
+import collections
14
+
1 15
 import dpath.util
2 16
 import jmespath
3 17
 from hamcrest import (assert_that, is_, empty, has_key, all_of, has_length,
@@ -8,6 +22,7 @@ from six.moves import filter
8 22
 from vapor.helpers import analytic_steps
9 23
 from vapor.helpers import asserts
10 24
 from vapor.helpers.asserts import superset_of
25
+from vapor.helpers import contrail_status
11 26
 from vapor import settings
12 27
 
13 28
 
@@ -27,15 +42,27 @@ def test_db_purge(client_contrail_analytics):
27 42
 
28 43
 
29 44
 def test_collector_generator_connections_through_uves(
30
-        session, client_contrail_analytics,
45
+        session, client_contrail_analytics, os_faults_steps,
31 46
         contrail_services_http_introspect_ports):
32 47
     """Check collector generator connections through UVES."""
33 48
     with asserts.AssertsCollector() as collector:
34
-        for _, nodes in contrail_services_http_introspect_ports.items():
35
-            port = nodes['port']
36
-            for ip in nodes['ips']:
37
-                status = analytic_steps.get_collector_connectivity(session, ip,
38
-                                                                   port)
49
+        expected_backup_services = collections.defaultdict(set)
50
+        for node, services in contrail_status.get_services_statuses(
51
+                os_faults_steps).items():
52
+            for service in services:
53
+                if (service['service'] in settings.ACTIVE_BACKUP_SERVICES and
54
+                        service['status'] == 'backup'):
55
+                    expected_backup_services[service['service']].add(node)
56
+
57
+        for service, data in contrail_services_http_introspect_ports.items():
58
+            port = data['port']
59
+            for node in data['nodes']:
60
+                # Skip services with backup status
61
+                if node['fqdn'] in expected_backup_services[service]:
62
+                    continue
63
+
64
+                status = analytic_steps.get_collector_connectivity(
65
+                    session, node['ip'], port)
39 66
                 collector.check(status['status'], is_('Established'))
40 67
 
41 68
         for name in client_contrail_analytics.get_uves_generators():

+ 30
- 0
plugin_test/vapor/vapor/tests/test_destructive.py View File

@@ -13,10 +13,12 @@
13 13
 from hamcrest import assert_that, is_not
14 14
 import pytest
15 15
 from stepler import config as stepler_config
16
+from stepler.third_party import waiter
16 17
 
17 18
 from vapor import settings
18 19
 from vapor.helpers.asserts import intersects_with
19 20
 from vapor.helpers import analytic_steps
21
+from vapor.helpers import contrail_status
20 22
 
21 23
 pytestmark = pytest.mark.destructive
22 24
 
@@ -230,3 +232,31 @@ def test_agent_cleanup_with_control_node_stop(
230 232
     for server in servers:
231 233
         server_steps.check_ping_to_server_floating(
232 234
             server, timeout=stepler_config.PING_CALL_TIMEOUT)
235
+
236
+
237
+@pytest.mark.requires('contrail_control_nodes_count >= 2')
238
+def test_contrail_services_status_after_restart_master_node(os_faults_steps):
239
+    """Verify contrail services status after master node restart.
240
+
241
+    Steps:
242
+        #. Restart node with contrail-schema (active)
243
+        #. Wait some time
244
+        #. Check that contrail services statuses is correct
245
+    """
246
+    services_statuses = contrail_status.get_services_statuses(os_faults_steps)
247
+    master_node_fqdn = None
248
+    for fqdn, services in services_statuses.items():
249
+        for service in services:
250
+            if (service['service'] == 'contrail-schema' and
251
+                    service['status'] == contrail_status.STATUS_ACTIVE):
252
+                master_node_fqdn = fqdn
253
+                break
254
+    assert master_node_fqdn is not None, "Can't find master node"
255
+    master_node = os_faults_steps.get_node(fqdns=[master_node_fqdn])
256
+    os_faults_steps.reset_nodes(master_node)
257
+
258
+    waiter.wait(
259
+        contrail_status.check_services_statuses,
260
+        args=(os_faults_steps),
261
+        expected_exceptions=AssertionError,
262
+        timeout=settings.CONTRAIL_NODE_RESET_TIMEOUT)

+ 2
- 0
plugin_test/vapor/vapor/tests/test_failover.py View File

@@ -5,6 +5,8 @@ from stepler import config as stepler_config
5 5
 
6 6
 from vapor import settings
7 7
 
8
+pytestmark = pytest.mark.destructive
9
+
8 10
 
9 11
 def restart_nodes(os_faults_steps, nodes):
10 12
     for node in nodes:

+ 3
- 2
plugin_test/vapor/vapor/tests/test_ipam.py View File

@@ -66,14 +66,15 @@ def test_ipam_virtual_dns(
66 66
     """
67 67
     # Create DNS records
68 68
     ip = '1.2.3.4'
69
-    name = 'test.example.com'
69
+    name = 'vapor.' + contrail_dns.virtual_DNS_data.domain_name
70 70
     add_dns_record(contrail_dns, r_name=name, r_data=ip)
71 71
 
72 72
     # Add DNS to IPAM
73
+    contrail_ipam.set_virtual_DNS(contrail_dns)
73 74
     contrail_ipam.network_ipam_mgmt = types.IpamType(
74 75
         ipam_dns_method='virtual-dns-server',
75 76
         ipam_dns_server=types.IpamDnsAddressType(
76
-            virtual_dns_server_name=':'.join(contrail_dns.fq_name)))
77
+            virtual_dns_server_name=contrail_dns.get_fq_name_str()))
77 78
     contrail_api_client.network_ipam_update(contrail_ipam)
78 79
 
79 80
     # Create subnet

+ 0
- 29
plugin_test/vapor/vapor/tests/test_smoke.py View File

@@ -16,7 +16,6 @@ import jmespath
16 16
 import pycontrail.types as types
17 17
 import pytest
18 18
 from stepler.third_party import utils
19
-from stepler.third_party import waiter
20 19
 
21 20
 from vapor.helpers import contrail_status
22 21
 from vapor.helpers import asserts
@@ -176,31 +175,3 @@ def test_contrail_alarms_is_empty(client_contrail_analytics):
176 175
 def test_zookeeper_status(znodes_list):
177 176
     expected_znodes_list = settings.ZOOKEEPER_NODES
178 177
     assert_that(znodes_list, contains_inanyorder(*expected_znodes_list))
179
-
180
-
181
-@pytest.mark.requires('contrail_control_nodes_count >= 2')
182
-def test_contrail_services_status_after_restart_master_node(os_faults_steps):
183
-    """Verify contrail services status after master node restart.
184
-
185
-    Steps:
186
-        #. Restart node with contrail-schema (active)
187
-        #. Wait some time
188
-        #. Check that contrail services statuses is correct
189
-    """
190
-    services_statuses = contrail_status.get_services_statuses(os_faults_steps)
191
-    master_node_fqdn = None
192
-    for fqdn, services in services_statuses.items():
193
-        for service in services:
194
-            if (service['service'] == 'contrail-schema' and
195
-                    service['status'] == contrail_status.STATUS_ACTIVE):
196
-                master_node_fqdn = fqdn
197
-                break
198
-    assert master_node_fqdn is not None, "Can't find master node"
199
-    master_node = os_faults_steps.get_node(fqdns=[master_node_fqdn])
200
-    os_faults_steps.reset_nodes(master_node)
201
-
202
-    waiter.wait(
203
-        contrail_status.check_services_statuses,
204
-        args=(os_faults_steps),
205
-        expected_exceptions=AssertionError,
206
-        timeout=settings.CONTRAIL_NODE_RESET_TIMEOUT)

+ 3
- 2
plugin_test/vapor/vapor/tests/test_system.py View File

@@ -319,7 +319,8 @@ def test_admin_user_can_get_user_token_info(current_project, token_steps,
319 319
 
320 320
 
321 321
 def test_connectivity_from_server_without_floating(
322
-        cirros_image, flavor, net_subnet_router, security_group, server_steps):
322
+        cirros_image, flavor, net_subnet_router, neutron_security_group,
323
+        server_steps):
323 324
     """Check connectivity via external Contrail network without floating IP.
324 325
 
325 326
     Steps:
@@ -342,7 +343,7 @@ def test_connectivity_from_server_without_floating(
342 343
         image=cirros_image,
343 344
         flavor=flavor,
344 345
         networks=[network],
345
-        security_groups=[security_group],
346
+        security_groups=[neutron_security_group],
346 347
         userdata=userdata)[0]
347 348
     server_steps.check_server_log_contains_record(
348 349
         server, done, timeout=stepler_config.USERDATA_EXECUTING_TIMEOUT)

+ 10
- 2
plugin_test/vapor/vapor/tests/test_vrouter.py View File

@@ -23,6 +23,7 @@ from vapor.helpers import vrouter_steps
23 23
 @pytest.mark.requires('computes_count >= 2')
24 24
 def test_router_table_cleanup(cirros_image, flavor, network, subnet,
25 25
                               current_project, server_steps,
26
+                              nova_availability_zone_hosts,
26 27
                               sorted_hypervisors, port_steps, os_faults_steps,
27 28
                               contrail_api_client, iface_route_table_create):
28 29
     """Check that added routes are cleaned up after servers to be deleted."""
@@ -40,11 +41,18 @@ def test_router_table_cleanup(cirros_image, flavor, network, subnet,
40 41
     route_table_before = vrouter_steps.get_route_table(os_faults_steps,
41 42
                                                        computes)
42 43
 
44
+    host1 = next(
45
+        host for host in nova_availability_zone_hosts
46
+        if hypervisor1.hypervisor_hostname.startswith(host))
43 47
     server1 = server_steps.create_servers(
44
-        availability_zone='nova:' + hypervisor1.hypervisor_hostname,
48
+        availability_zone='nova:' + host1,
45 49
         **server_create_args)[0]
50
+
51
+    host2 = next(
52
+        host for host in nova_availability_zone_hosts
53
+        if hypervisor2.hypervisor_hostname.startswith(host))
46 54
     server2 = server_steps.create_servers(
47
-        availability_zone='nova:' + hypervisor2.hypervisor_hostname,
55
+        availability_zone='nova:' + host2,
48 56
         **server_create_args)[0]
49 57
     port = port_steps.get_port(
50 58
         device_owner=stepler_config.PORT_DEVICE_OWNER_SERVER,

Loading…
Cancel
Save