Browse Source

Add test_network_in_agent_with_server_add_delete

Change-Id: Ia4ba683edc3e2b85bbc8686caabc1ca81ded6ddd
Georgy Dyuldin 2 years ago
parent
commit
9b8c9d27ad

+ 29
- 0
plugin_test/vapor/vapor/helpers/agent_steps.py View File

@@ -0,0 +1,29 @@
1
+"""Assertion helpers."""
2
+
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+import xml.etree.ElementTree as ET
16
+
17
+
18
+def get_vna_vn(session, ip, port, network_fq_name):
19
+    """Return a dict with network parameter on agent or None."""
20
+    response = session.get(
21
+        'http://{ip}:{port}/Snh_VnListReq?name={name}'.format(
22
+            ip=ip, port=port, name=network_fq_name))
23
+    response.raise_for_status()
24
+    tree = ET.fromstring(response.content)
25
+    networks = tree.findall('.//list/VnSandeshData')
26
+
27
+    for network in networks:
28
+        if network.find('name').text in network_fq_name:
29
+            return {el.tag: el.text for el in network}

+ 40
- 0
plugin_test/vapor/vapor/tests/common/test_base.py View File

@@ -22,6 +22,7 @@ from pycontrail import exceptions
22 22
 import pycontrail.types as contrail_types
23 23
 import pytest
24 24
 
25
+from vapor.helpers import agent_steps
25 26
 from vapor.helpers import asserts
26 27
 from vapor.helpers import contrail_status
27 28
 from vapor import settings
@@ -442,3 +443,42 @@ def test_create_multiple_servers_on_many_networks(
442 443
     for network in networks:
443 444
         server_steps.create_servers(
444 445
             count=4, flavor=flavor, image=cirros_image, networks=[network])
446
+
447
+
448
+def test_network_in_agent_with_server_add_delete(
449
+        contrail_api_client, session, contrail_services_http_introspect_ports,
450
+        network, server, server_steps):
451
+    """Validate network's existence and removal in agent.
452
+
453
+    Steps:
454
+        #. Create network, subnet
455
+        #. Launch server on it
456
+        #. Check that network is present on one of vrouter agent
457
+        #. Delete server
458
+        #. Check that network is not present on any of vrouter agent
459
+    """
460
+    contrail_network = contrail_api_client.virtual_network_read(
461
+        id=network['id'])
462
+    network_fq_name = contrail_network.get_fq_name_str()
463
+
464
+    nodes = contrail_services_http_introspect_ports['contrail-vrouter-agent']
465
+    port = nodes['port']
466
+    agent_networks = []
467
+    for ip in nodes['ips']:
468
+        agent_network = agent_steps.get_vna_vn(session, ip, port,
469
+                                               network_fq_name)
470
+        if agent_network:
471
+            agent_networks.append(agent_network)
472
+
473
+    assert_that(agent_networks, is_not(empty()))
474
+
475
+    server_steps.delete_servers([server])
476
+
477
+    agent_networks = []
478
+    for ip in nodes['ips']:
479
+        agent_network = agent_steps.get_vna_vn(session, ip, port,
480
+                                               network_fq_name)
481
+        if agent_network:
482
+            agent_networks.append(agent_network)
483
+
484
+    assert_that(agent_networks, empty())

Loading…
Cancel
Save