blob: 2ba8f13e88f4f2ef98c9f2f7e55db0a739985497 [file] [log] [blame]
Kevin Bentona305d592016-09-19 04:26:10 -07001# All Rights Reserved.
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
Federico Ressi06ef8542018-10-25 15:23:52 +020015import collections
16
17from neutron_lib import constants
Slawek Kaplonskic12b50c2020-11-09 11:58:46 +010018from neutron_lib.utils import test
Kevin Benton07c90562017-02-27 01:53:16 -080019from oslo_log import log as logging
Chandan Kumarc125fd12017-11-15 19:41:01 +053020from tempest.common import utils as tutils
Itzik Brownbac51dc2016-10-31 12:25:04 +000021from tempest.lib.common.utils import data_utils
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000022from tempest.lib import decorators
Genadi Chereshnyae91b69c2017-07-16 09:51:58 +030023import testtools
Kevin Bentona305d592016-09-19 04:26:10 -070024
Federico Ressi06ef8542018-10-25 15:23:52 +020025from neutron_tempest_plugin.common import ip
Chandan Kumar667d3d32017-09-22 12:24:06 +053026from neutron_tempest_plugin.common import ssh
27from neutron_tempest_plugin.common import utils
28from neutron_tempest_plugin import config
29from neutron_tempest_plugin.scenario import base
Federico Ressi06ef8542018-10-25 15:23:52 +020030
Kevin Bentona305d592016-09-19 04:26:10 -070031
Kevin Benton07c90562017-02-27 01:53:16 -080032LOG = logging.getLogger(__name__)
Kevin Bentona305d592016-09-19 04:26:10 -070033CONF = config.CONF
Kevin Bentona305d592016-09-19 04:26:10 -070034
Federico Ressi06ef8542018-10-25 15:23:52 +020035
36ServerWithTrunkPort = collections.namedtuple(
37 'ServerWithTrunkPort',
38 ['port', 'subport', 'trunk', 'floating_ip', 'server',
39 'ssh_client'])
Jakub Libosvar6d397d32016-12-30 10:57:52 -050040
41
Kevin Bentona305d592016-09-19 04:26:10 -070042class TrunkTest(base.BaseTempestTestCase):
Alex Katzbaf14a52020-03-05 11:31:19 +020043 credentials = ['primary', 'admin']
Kevin Bentona305d592016-09-19 04:26:10 -070044 force_tenant_isolation = False
45
46 @classmethod
Chandan Kumarc125fd12017-11-15 19:41:01 +053047 @tutils.requires_ext(extension="trunk", service="network")
Kevin Bentona305d592016-09-19 04:26:10 -070048 def resource_setup(cls):
49 super(TrunkTest, cls).resource_setup()
50 # setup basic topology for servers we can log into
Federico Ressi06ef8542018-10-25 15:23:52 +020051 cls.rand_name = data_utils.rand_name(
52 cls.__name__.rsplit('.', 1)[-1])
53 cls.network = cls.create_network(name=cls.rand_name)
54 cls.subnet = cls.create_subnet(network=cls.network,
55 name=cls.rand_name)
Huifeng Le1c9f40b2018-11-07 01:14:21 +080056 cls.router = cls.create_router_by_client()
57 cls.create_router_interface(cls.router['id'], cls.subnet['id'])
Federico Ressi06ef8542018-10-25 15:23:52 +020058 cls.keypair = cls.create_keypair(name=cls.rand_name)
Kevin Bentona305d592016-09-19 04:26:10 -070059
Federico Ressi06ef8542018-10-25 15:23:52 +020060 def setUp(self):
61 super(TrunkTest, self).setUp()
62 self.security_group = self.create_security_group(name=self.rand_name)
63 self.create_loginable_secgroup_rule(self.security_group['id'])
Kevin Bentona305d592016-09-19 04:26:10 -070064
Federico Ressi06ef8542018-10-25 15:23:52 +020065 def _create_server_with_network(self, network, use_advanced_image=False):
66 port = self._create_server_port(network=network)
67 floating_ip = self.create_floatingip(port=port)
68 ssh_client = self._create_ssh_client(
69 floating_ip=floating_ip, use_advanced_image=use_advanced_image)
70 server = self._create_server(port=port,
71 use_advanced_image=use_advanced_image)
72 return ServerWithTrunkPort(port=port, subport=None, trunk=None,
73 floating_ip=floating_ip, server=server,
74 ssh_client=ssh_client)
75
76 def _create_server_with_trunk_port(self, subport_network=None,
77 segmentation_id=None,
78 use_advanced_image=False):
79 port = self._create_server_port()
80 floating_ip = self.create_floatingip(port=port)
81 ssh_client = self._create_ssh_client(
82 floating_ip=floating_ip, use_advanced_image=use_advanced_image)
83
84 subport = None
85 subports = None
86 if subport_network:
87 subport = self._create_server_port(
88 network=subport_network, mac_address=port['mac_address'])
89 subports = [{'port_id': subport['id'],
90 'segmentation_type': 'vlan',
91 'segmentation_id': segmentation_id}]
92 trunk = self.create_trunk(port=port, subports=subports)
93
94 server = self._create_server(port=port,
95 use_advanced_image=use_advanced_image)
96 return ServerWithTrunkPort(port=port, subport=subport, trunk=trunk,
97 floating_ip=floating_ip, server=server,
98 ssh_client=ssh_client)
99
Yarboa11b68922021-01-07 13:03:35 +0200100 def _create_advanced_servers_with_trunk_port(self, num_servers=1,
101 subport_network=None,
102 segmentation_id=None,
103 vlan_subnet=None,
104 use_advanced_image=False):
105 server_list = []
106 for _ in range(0, num_servers):
107 vm = self._create_server_with_trunk_port(
108 subport_network,
109 segmentation_id,
110 use_advanced_image)
111 server_list.append(vm)
112 self._configure_vlan_subport(
113 vm=vm,
114 vlan_tag=segmentation_id,
115 vlan_subnet=vlan_subnet)
116
Yarboa11b68922021-01-07 13:03:35 +0200117 return server_list
118
119 def _check_servers_remote_connectivity(self, vms=None,
120 should_succeed=True):
121 self.check_remote_connectivity(
122 vms[0].ssh_client,
123 vms[1].subport['fixed_ips'][0]['ip_address'],
124 should_succeed=should_succeed)
125
Federico Ressi06ef8542018-10-25 15:23:52 +0200126 def _create_server_port(self, network=None, **params):
127 network = network or self.network
128 return self.create_port(network=network, name=self.rand_name,
129 security_groups=[self.security_group['id']],
130 **params)
131
132 def _create_server(self, port, use_advanced_image=False, **params):
Slawek Kaplonskida17f002018-10-11 18:35:23 +0200133 if use_advanced_image:
134 flavor_ref = CONF.neutron_plugin_options.advanced_image_flavor_ref
135 image_ref = CONF.neutron_plugin_options.advanced_image_ref
Federico Ressi06ef8542018-10-25 15:23:52 +0200136 else:
137 flavor_ref = CONF.compute.flavor_ref
138 image_ref = CONF.compute.image_ref
139 return self.create_server(flavor_ref=flavor_ref,
140 image_ref=image_ref,
141 key_name=self.keypair['name'],
142 networks=[{'port': port['id']}],
143 **params)['server']
Jakub Libosvar6d397d32016-12-30 10:57:52 -0500144
Federico Ressi06ef8542018-10-25 15:23:52 +0200145 def _show_port(self, port, update=False):
146 observed = self.client.show_port(port['id'])['port']
147 if update:
148 port.update(observed)
149 return observed
Kevin Bentona305d592016-09-19 04:26:10 -0700150
Federico Ressi06ef8542018-10-25 15:23:52 +0200151 def _show_trunk(self, trunk, update=False):
152 observed = self.client.show_trunk(trunk['id'])['trunk']
153 if update:
154 trunk.update(observed)
155 return observed
Kevin Bentona305d592016-09-19 04:26:10 -0700156
Federico Ressi06ef8542018-10-25 15:23:52 +0200157 def _is_trunk_status(self, trunk, status, update=False):
158 return self._show_trunk(trunk, update)['status'] == status
Kevin Bentona305d592016-09-19 04:26:10 -0700159
Federico Ressi06ef8542018-10-25 15:23:52 +0200160 def _is_port_status(self, port, status, update=False):
161 return self._show_port(port, update)['status'] == status
162
163 def _wait_for_port(self, port, status=constants.ACTIVE):
164 utils.wait_until_true(
165 lambda: self._is_port_status(port, status),
166 exception=RuntimeError(
167 "Timed out waiting for port {!r} to transition to get "
168 "status {!r}.".format(port['id'], status)))
169
170 def _wait_for_trunk(self, trunk, status=constants.ACTIVE):
171 utils.wait_until_true(
172 lambda: self._is_trunk_status(trunk, status),
173 exception=RuntimeError(
174 "Timed out waiting for trunk {!r} to transition to get "
175 "status {!r}.".format(trunk['id'], status)))
176
177 def _create_ssh_client(self, floating_ip, use_advanced_image=False):
Huifeng Le1c9f40b2018-11-07 01:14:21 +0800178 if use_advanced_image:
Federico Ressi06ef8542018-10-25 15:23:52 +0200179 username = CONF.neutron_plugin_options.advanced_image_ssh_user
180 else:
181 username = CONF.validation.image_ssh_user
182 return ssh.Client(host=floating_ip['floating_ip_address'],
183 username=username,
184 pkey=self.keypair['private_key'])
Huifeng Le1c9f40b2018-11-07 01:14:21 +0800185
Federico Ressi06ef8542018-10-25 15:23:52 +0200186 def _assert_has_ssh_connectivity(self, ssh_client):
187 ssh_client.exec_command("true")
Huifeng Le1c9f40b2018-11-07 01:14:21 +0800188
Federico Ressi06ef8542018-10-25 15:23:52 +0200189 def _configure_vlan_subport(self, vm, vlan_tag, vlan_subnet):
190 self.wait_for_server_active(server=vm.server)
Slawek Kaplonski2211eab2020-10-20 16:43:53 +0200191 self.wait_for_guest_os_ready(vm.server)
Federico Ressi06ef8542018-10-25 15:23:52 +0200192 self._wait_for_trunk(trunk=vm.trunk)
193 self._wait_for_port(port=vm.port)
194 self._wait_for_port(port=vm.subport)
yatinkarelc4597e62021-11-26 14:09:18 +0530195 self.check_connectivity(
196 host=vm.floating_ip['floating_ip_address'],
197 ssh_client=vm.ssh_client,
198 servers=[vm.server])
Huifeng Le1c9f40b2018-11-07 01:14:21 +0800199
Federico Ressi06ef8542018-10-25 15:23:52 +0200200 ip_command = ip.IPCommand(ssh_client=vm.ssh_client)
201 for address in ip_command.list_addresses(port=vm.port):
202 port_iface = address.device.name
203 break
204 else:
205 self.fail("Parent port fixed IP not found on server.")
Jakub Libosvar6d397d32016-12-30 10:57:52 -0500206
Federico Ressi06ef8542018-10-25 15:23:52 +0200207 subport_iface = ip_command.configure_vlan_subport(
208 port=vm.port, subport=vm.subport, vlan_tag=vlan_tag,
209 subnets=[vlan_subnet])
210 for address in ip_command.list_addresses(port=vm.subport):
211 self.assertEqual(subport_iface, address.device.name)
212 self.assertEqual(port_iface, address.device.parent)
213 break
214 else:
215 self.fail("Sub-port fixed IP not found on server.")
Jakub Libosvar6d397d32016-12-30 10:57:52 -0500216
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000217 @decorators.idempotent_id('bb13fe28-f152-4000-8131-37890a40c79e')
Kevin Bentona305d592016-09-19 04:26:10 -0700218 def test_trunk_subport_lifecycle(self):
219 """Test trunk creation and subport transition to ACTIVE status.
220
221 This is a basic test for the trunk extension to ensure that we
222 can create a trunk, attach it to a server, add/remove subports,
223 while ensuring the status transitions as appropriate.
224
225 This test does not assert any dataplane behavior for the subports.
226 It's just a high-level check to ensure the agents claim to have
227 wired the port correctly and that the trunk port itself maintains
228 connectivity.
229 """
Federico Ressi06ef8542018-10-25 15:23:52 +0200230 vm1 = self._create_server_with_trunk_port()
231 vm2 = self._create_server_with_trunk_port()
232 for vm in (vm1, vm2):
233 self.wait_for_server_active(server=vm.server)
Slawek Kaplonski2211eab2020-10-20 16:43:53 +0200234 self.wait_for_guest_os_ready(vm.server)
Federico Ressi06ef8542018-10-25 15:23:52 +0200235 self._wait_for_trunk(vm.trunk)
236 self._assert_has_ssh_connectivity(vm.ssh_client)
237
Kevin Bentona305d592016-09-19 04:26:10 -0700238 # create a few more networks and ports for subports
Yariv Rachmanifed6f862017-12-19 11:55:25 +0200239 # check limit of networks per project
Federico Ressi06ef8542018-10-25 15:23:52 +0200240 segment_ids = range(
241 3, 3 + CONF.neutron_plugin_options.max_networks_per_project)
242 tagged_networks = [self.create_network() for _ in segment_ids]
243 tagged_ports = [self.create_port(network=network)
244 for network in tagged_networks]
245 subports = [{'port_id': tagged_ports[i]['id'],
246 'segmentation_type': 'vlan',
247 'segmentation_id': segment_id}
248 for i, segment_id in enumerate(segment_ids)]
Jakub Libosvar6d397d32016-12-30 10:57:52 -0500249
Federico Ressi06ef8542018-10-25 15:23:52 +0200250 # add all subports to server1
251 self.client.add_subports(vm1.trunk['id'], subports)
252 self._wait_for_trunk(vm1.trunk)
253 for port in tagged_ports:
254 self._wait_for_port(port)
255
256 # ensure main data-plane wasn't interrupted
257 self._assert_has_ssh_connectivity(vm1.ssh_client)
258
259 # move subports over to other server
260 self.client.remove_subports(vm1.trunk['id'], subports)
261 # ensure all subports go down
262 for port in tagged_ports:
263 self._wait_for_port(port, status=constants.DOWN)
264
265 self.client.add_subports(vm2.trunk['id'], subports)
266
267 # wait for both trunks to go back to ACTIVE
268 for vm in [vm1, vm2]:
269 self._wait_for_trunk(vm.trunk)
270
271 # ensure subports come up on other trunk
272 for port in tagged_ports:
273 self._wait_for_port(port)
274
275 # final connectivity check
276 for vm in [vm1, vm2]:
277 self._wait_for_trunk(vm.trunk)
278 self._assert_has_ssh_connectivity(vm1.ssh_client)
279
Rodolfo Alonso Hernandez370f71e2023-09-09 21:33:55 +0000280 @test.unstable_test("bug 2033887 / bug 2024160")
Yarboa11b68922021-01-07 13:03:35 +0200281 @testtools.skipUnless(
282 (CONF.neutron_plugin_options.advanced_image_ref or
283 CONF.neutron_plugin_options.default_image_is_advanced),
284 "Advanced image is required to run this test.")
285 @testtools.skipUnless(
286 (CONF.neutron_plugin_options.reboots_in_test > 0),
287 "Number of reboots > 0 is reqired for this test")
288 @decorators.idempotent_id('a8a02c9b-b453-49b5-89a2-cce7da6680fb')
289 def test_subport_connectivity_soft_reboot(self):
290 vlan_tag = 10
291 vlan_network = self.create_network()
292 vlan_subnet = self.create_subnet(network=vlan_network, gateway=None)
293 use_advanced_image = (
294 not CONF.neutron_plugin_options.default_image_is_advanced)
295
296 # allow intra-security-group traffic
297 sg_rule = self.create_pingable_secgroup_rule(self.security_group['id'])
298 self.addCleanup(
299 self.os_primary.network_client.delete_security_group_rule,
300 sg_rule['id'])
301
302 vms = self._create_advanced_servers_with_trunk_port(
303 num_servers=2,
304 subport_network=vlan_network,
305 segmentation_id=vlan_tag,
306 vlan_subnet=vlan_subnet,
307 use_advanced_image=use_advanced_image)
308 # check remote connectivity true before reboots
309 self._check_servers_remote_connectivity(vms=vms)
310 client = self.os_tempest.compute.ServersClient()
311 for _ in range(CONF.neutron_plugin_options.reboots_in_test):
312 client.reboot_server(vms[1].server['id'],
313 **{'type': 'SOFT'})
314 self.wait_for_server_active(vms[1].server)
315 self._configure_vlan_subport(vm=vms[1],
316 vlan_tag=vlan_tag,
317 vlan_subnet=vlan_subnet)
318 self._check_servers_remote_connectivity(vms=vms)
319
Slawek Kaplonskic12b50c2020-11-09 11:58:46 +0100320 @test.unstable_test("bug 1897796")
Yariv Rachmanifa1081a2018-11-21 12:46:57 +0200321 @testtools.skipUnless(
322 (CONF.neutron_plugin_options.advanced_image_ref or
323 CONF.neutron_plugin_options.default_image_is_advanced),
324 "Advanced image is required to run this test.")
Yarboa11b68922021-01-07 13:03:35 +0200325 @decorators.idempotent_id('a8a02c9b-b453-49b5-89a2-cce7da66bbcb')
Jakub Libosvar6d397d32016-12-30 10:57:52 -0500326 def test_subport_connectivity(self):
327 vlan_tag = 10
Jakub Libosvar6d397d32016-12-30 10:57:52 -0500328 vlan_network = self.create_network()
Federico Ressi06ef8542018-10-25 15:23:52 +0200329 vlan_subnet = self.create_subnet(network=vlan_network, gateway=None)
Yariv Rachmanifa1081a2018-11-21 12:46:57 +0200330 use_advanced_image = (
331 not CONF.neutron_plugin_options.default_image_is_advanced)
Yarboa11b68922021-01-07 13:03:35 +0200332 vms = self._create_advanced_servers_with_trunk_port(
333 num_servers=2,
Yariv Rachmanifa1081a2018-11-21 12:46:57 +0200334 subport_network=vlan_network,
335 segmentation_id=vlan_tag,
Yarboa11b68922021-01-07 13:03:35 +0200336 vlan_subnet=vlan_subnet,
Yariv Rachmanifa1081a2018-11-21 12:46:57 +0200337 use_advanced_image=use_advanced_image)
Kevin Benton6f1f9d52017-03-01 09:14:45 -0800338 # Ping from server1 to server2 via VLAN interface should fail because
339 # we haven't allowed ICMP
Yarboa11b68922021-01-07 13:03:35 +0200340 self._check_servers_remote_connectivity(vms=vms,
341 should_succeed=False)
Federico Ressi06ef8542018-10-25 15:23:52 +0200342 # allow intra-security-group traffic
Alex Katzbaf14a52020-03-05 11:31:19 +0200343 sg_rule = self.create_pingable_secgroup_rule(self.security_group['id'])
344 self.addCleanup(
345 self.os_primary.network_client.delete_security_group_rule,
346 sg_rule['id'])
Yarboa11b68922021-01-07 13:03:35 +0200347 self._check_servers_remote_connectivity(vms=vms)
Huifeng Le1c9f40b2018-11-07 01:14:21 +0800348
Alex Katzbaf14a52020-03-05 11:31:19 +0200349 @testtools.skipUnless(CONF.compute_feature_enabled.cold_migration,
350 'Cold migration is not available.')
351 @testtools.skipUnless(CONF.compute.min_compute_nodes > 1,
352 'Less than 2 compute nodes, skipping multinode '
353 'tests.')
354 @testtools.skipUnless(
355 (CONF.neutron_plugin_options.advanced_image_ref or
356 CONF.neutron_plugin_options.default_image_is_advanced),
357 "Advanced image is required to run this test.")
358 @decorators.attr(type='slow')
359 @decorators.idempotent_id('ecd7de30-1c90-4280-b97c-1bed776d5d07')
360 def test_trunk_vm_migration(self):
361 '''Test connectivity after migration of the server with trunk
362
363 A successfully migrated server shows a VERIFY_RESIZE status that
364 requires confirmation. Need to reconfigure VLAN interface on server
365 side after migration is finished as the configuration doesn't survive
366 the reboot.
367 '''
368 vlan_tag = 10
369 vlan_network = self.create_network()
370 vlan_subnet = self.create_subnet(vlan_network)
371 sg_rule = self.create_pingable_secgroup_rule(self.security_group['id'])
372 self.addCleanup(
373 self.os_primary.network_client.delete_security_group_rule,
374 sg_rule['id'])
375
376 use_advanced_image = (
377 not CONF.neutron_plugin_options.default_image_is_advanced)
378 servers = {}
379 for role in ['migrate', 'connection_test']:
380 servers[role] = self._create_server_with_trunk_port(
381 subport_network=vlan_network,
382 segmentation_id=vlan_tag,
383 use_advanced_image=use_advanced_image)
384 for role in ['migrate', 'connection_test']:
385 self.wait_for_server_active(servers[role].server)
Slawek Kaplonski2211eab2020-10-20 16:43:53 +0200386 self.wait_for_guest_os_ready(servers[role].server)
Alex Katzbaf14a52020-03-05 11:31:19 +0200387 self._configure_vlan_subport(vm=servers[role],
388 vlan_tag=vlan_tag,
389 vlan_subnet=vlan_subnet)
390
391 self.check_remote_connectivity(
392 servers['connection_test'].ssh_client,
393 servers['migrate'].subport['fixed_ips'][0]['ip_address'])
394
395 client = self.os_admin.compute.ServersClient()
396 client.migrate_server(servers['migrate'].server['id'])
397 self.wait_for_server_status(servers['migrate'].server,
398 'VERIFY_RESIZE')
399 client.confirm_resize_server(servers['migrate'].server['id'])
400 self._configure_vlan_subport(vm=servers['migrate'],
401 vlan_tag=vlan_tag,
402 vlan_subnet=vlan_subnet)
403
404 self.check_remote_connectivity(
405 servers['connection_test'].ssh_client,
406 servers['migrate'].subport['fixed_ips'][0]['ip_address'])
407
Huifeng Le1c9f40b2018-11-07 01:14:21 +0800408 @testtools.skipUnless(
Yariv Rachmanifa1081a2018-11-21 12:46:57 +0200409 (CONF.neutron_plugin_options.advanced_image_ref or
410 CONF.neutron_plugin_options.default_image_is_advanced),
Federico Ressi06ef8542018-10-25 15:23:52 +0200411 "Advanced image is required to run this test.")
Huifeng Le1c9f40b2018-11-07 01:14:21 +0800412 @testtools.skipUnless(
Federico Ressi06ef8542018-10-25 15:23:52 +0200413 CONF.neutron_plugin_options.q_agent == "linuxbridge",
414 "Linux bridge agent is required to run this test.")
Huifeng Le1c9f40b2018-11-07 01:14:21 +0800415 @decorators.idempotent_id('d61cbdf6-1896-491c-b4b4-871caf7fbffe')
416 def test_parent_port_connectivity_after_trunk_deleted_lb(self):
417 vlan_tag = 10
Huifeng Le1c9f40b2018-11-07 01:14:21 +0800418 vlan_network = self.create_network()
419 vlan_subnet = self.create_subnet(vlan_network)
420 self.create_router_interface(self.router['id'], vlan_subnet['id'])
421
Yariv Rachmanifa1081a2018-11-21 12:46:57 +0200422 use_advanced_image = (
423 not CONF.neutron_plugin_options.default_image_is_advanced)
424
Federico Ressi06ef8542018-10-25 15:23:52 +0200425 # Create servers
426 trunk_network_server = self._create_server_with_trunk_port(
427 subport_network=vlan_network,
428 segmentation_id=vlan_tag,
Yariv Rachmanifa1081a2018-11-21 12:46:57 +0200429 use_advanced_image=use_advanced_image)
Huifeng Le1c9f40b2018-11-07 01:14:21 +0800430 normal_network_server = self._create_server_with_network(self.network)
431 vlan_network_server = self._create_server_with_network(vlan_network)
Slawek Kaplonskie58219b2019-12-09 12:10:55 +0100432 vms = [normal_network_server, vlan_network_server]
Huifeng Le1c9f40b2018-11-07 01:14:21 +0800433
Federico Ressi06ef8542018-10-25 15:23:52 +0200434 self._configure_vlan_subport(vm=trunk_network_server,
435 vlan_tag=vlan_tag,
436 vlan_subnet=vlan_subnet)
Slawek Kaplonskie58219b2019-12-09 12:10:55 +0100437 for vm in vms:
Federico Ressi06ef8542018-10-25 15:23:52 +0200438 self.wait_for_server_active(vm.server)
Slawek Kaplonski2211eab2020-10-20 16:43:53 +0200439 self.wait_for_guest_os_ready(vm.server)
Huifeng Le1c9f40b2018-11-07 01:14:21 +0800440
Federico Ressi06ef8542018-10-25 15:23:52 +0200441 # allow ICMP traffic
Alex Katzbaf14a52020-03-05 11:31:19 +0200442 sg_rule = self.create_pingable_secgroup_rule(self.security_group['id'])
443 self.addCleanup(
444 self.os_primary.network_client.delete_security_group_rule,
445 sg_rule['id'])
Huifeng Le1c9f40b2018-11-07 01:14:21 +0800446
447 # Ping from trunk_network_server to normal_network_server
448 # via parent port
449 self.check_remote_connectivity(
Federico Ressi06ef8542018-10-25 15:23:52 +0200450 trunk_network_server.ssh_client,
451 normal_network_server.port['fixed_ips'][0]['ip_address'],
Slawek Kaplonskie58219b2019-12-09 12:10:55 +0100452 should_succeed=True,
453 servers=vms)
Huifeng Le1c9f40b2018-11-07 01:14:21 +0800454
455 # Ping from trunk_network_server to vlan_network_server via VLAN
456 # interface should success
457 self.check_remote_connectivity(
Federico Ressi06ef8542018-10-25 15:23:52 +0200458 trunk_network_server.ssh_client,
459 vlan_network_server.port['fixed_ips'][0]['ip_address'],
Slawek Kaplonskie58219b2019-12-09 12:10:55 +0100460 should_succeed=True,
461 servers=vms)
Huifeng Le1c9f40b2018-11-07 01:14:21 +0800462
463 # Delete the trunk
Federico Ressi06ef8542018-10-25 15:23:52 +0200464 self.delete_trunk(
465 trunk_network_server.trunk,
Huifeng Le1c9f40b2018-11-07 01:14:21 +0800466 detach_parent_port=False)
Federico Ressi06ef8542018-10-25 15:23:52 +0200467 LOG.debug("Trunk %s is deleted.",
468 trunk_network_server.trunk['id'])
Huifeng Le1c9f40b2018-11-07 01:14:21 +0800469
470 # Ping from trunk_network_server to normal_network_server
471 # via parent port success after trunk deleted
472 self.check_remote_connectivity(
Federico Ressi06ef8542018-10-25 15:23:52 +0200473 trunk_network_server.ssh_client,
474 normal_network_server.port['fixed_ips'][0]['ip_address'],
Slawek Kaplonskie58219b2019-12-09 12:10:55 +0100475 should_succeed=True,
476 servers=vms)
Huifeng Le1c9f40b2018-11-07 01:14:21 +0800477
478 # Ping from trunk_network_server to vlan_network_server via VLAN
479 # interface should fail after trunk deleted
480 self.check_remote_connectivity(
Federico Ressi06ef8542018-10-25 15:23:52 +0200481 trunk_network_server.ssh_client,
482 vlan_network_server.port['fixed_ips'][0]['ip_address'],
483 should_succeed=False)