Merge "Test net-mtu-writable networking API extension"
This commit is contained in:
commit
2e4030d8ad
@ -1,49 +0,0 @@
|
|||||||
# Copyright (c) 2019 Red Hat
|
|
||||||
# All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
from __future__ import absolute_import
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
import tobiko
|
|
||||||
from tobiko import config
|
|
||||||
from tobiko.openstack import heat
|
|
||||||
from tobiko.tests import base
|
|
||||||
|
|
||||||
CONF = config.CONF
|
|
||||||
|
|
||||||
|
|
||||||
TEMPLATE_DIRS = [os.path.join(os.path.dirname(__file__), 'templates')]
|
|
||||||
|
|
||||||
|
|
||||||
def heat_template_file(template_file):
|
|
||||||
return heat.heat_template_file(template_file=template_file,
|
|
||||||
template_dirs=TEMPLATE_DIRS)
|
|
||||||
|
|
||||||
|
|
||||||
class InternalNetworkFixture(heat.HeatStackFixture):
|
|
||||||
template = heat_template_file('internal_network.yaml')
|
|
||||||
floating_network = CONF.tobiko.neutron.floating_network
|
|
||||||
|
|
||||||
|
|
||||||
class SecurityGroupsFixture(heat.HeatStackFixture):
|
|
||||||
template = heat_template_file('security_groups.yaml')
|
|
||||||
|
|
||||||
|
|
||||||
class NeutronTest(base.TobikoTest):
|
|
||||||
|
|
||||||
def setup_fixture(self, fixture_type):
|
|
||||||
stack = tobiko.setup_fixture(fixture_type)
|
|
||||||
stack.wait_for_outputs()
|
|
||||||
return stack
|
|
76
tobiko/tests/scenario/neutron/stacks.py
Normal file
76
tobiko/tests/scenario/neutron/stacks.py
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# Copyright (c) 2019 Red Hat
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from tobiko import config
|
||||||
|
from tobiko.openstack import heat
|
||||||
|
from tobiko.openstack import neutron
|
||||||
|
|
||||||
|
|
||||||
|
CONF = config.CONF
|
||||||
|
|
||||||
|
|
||||||
|
TEMPLATE_DIRS = [os.path.join(os.path.dirname(__file__), 'templates')]
|
||||||
|
|
||||||
|
|
||||||
|
def heat_template_file(template_file):
|
||||||
|
return heat.heat_template_file(template_file=template_file,
|
||||||
|
template_dirs=TEMPLATE_DIRS)
|
||||||
|
|
||||||
|
|
||||||
|
class InternalNetworkFixture(heat.HeatStackFixture):
|
||||||
|
template = heat_template_file('internal_network.yaml')
|
||||||
|
floating_network = CONF.tobiko.neutron.floating_network
|
||||||
|
port_security_enabled = False
|
||||||
|
mtu = None
|
||||||
|
|
||||||
|
def setup_parameters(self):
|
||||||
|
super(InternalNetworkFixture, self).setup_parameters()
|
||||||
|
if self.port_security_enabled or neutron.has_networking_extensions(
|
||||||
|
'port-security'):
|
||||||
|
self.setup_port_security()
|
||||||
|
if neutron.has_networking_extensions('net-mtu'):
|
||||||
|
self.setup_net_mtu()
|
||||||
|
if self.mtu:
|
||||||
|
self.setup_net_mtu_writable()
|
||||||
|
|
||||||
|
@neutron.skip_if_missing_networking_extensions('port-security')
|
||||||
|
def setup_port_security(self):
|
||||||
|
self.parameters.update(
|
||||||
|
port_security_enabled=self.port_security_enabled)
|
||||||
|
|
||||||
|
@neutron.skip_if_missing_networking_extensions('net-mtu')
|
||||||
|
def setup_net_mtu(self):
|
||||||
|
self.parameters.update(has_net_mtu=True)
|
||||||
|
|
||||||
|
@neutron.skip_if_missing_networking_extensions('net-mtu-writable')
|
||||||
|
def setup_net_mtu_writable(self):
|
||||||
|
self.parameters.setdefault('value_specs', {}).update(mtu=self.mtu)
|
||||||
|
|
||||||
|
|
||||||
|
class InternalNetworkFixtureWithPortSecurity(InternalNetworkFixture):
|
||||||
|
port_security_enabled = True
|
||||||
|
|
||||||
|
|
||||||
|
@neutron.skip_if_missing_networking_extensions('net-mtu-writable')
|
||||||
|
class InternalNetworkWithNetMtuWritableFixture(InternalNetworkFixture):
|
||||||
|
mtu = 1000
|
||||||
|
|
||||||
|
|
||||||
|
@neutron.skip_if_missing_networking_extensions('security-group')
|
||||||
|
class SecurityGroupsFixture(heat.HeatStackFixture):
|
||||||
|
template = heat_template_file('security_groups.yaml')
|
@ -8,15 +8,20 @@ description: |
|
|||||||
parameters:
|
parameters:
|
||||||
flavor:
|
flavor:
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
image:
|
image:
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
floating_network:
|
floating_network:
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
internal_network:
|
internal_network:
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
port_security_enabled:
|
port_security_enabled:
|
||||||
type: boolean
|
type: boolean
|
||||||
default: false
|
default: false
|
||||||
|
|
||||||
security_groups:
|
security_groups:
|
||||||
type: comma_delimited_list
|
type: comma_delimited_list
|
||||||
default: []
|
default: []
|
||||||
|
@ -8,22 +8,38 @@ description: |
|
|||||||
parameters:
|
parameters:
|
||||||
floating_network:
|
floating_network:
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
subnet_ipv4_cidr:
|
subnet_ipv4_cidr:
|
||||||
type: string
|
type: string
|
||||||
default: 190.40.2.0/24
|
default: 190.40.2.0/24
|
||||||
|
|
||||||
dns_nameservers:
|
dns_nameservers:
|
||||||
type: comma_delimited_list
|
type: comma_delimited_list
|
||||||
default: ["8.8.8.8", "8.8.4.4"]
|
default: ["8.8.8.8", "8.8.4.4"]
|
||||||
|
|
||||||
|
port_security_enabled:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
value_specs:
|
value_specs:
|
||||||
type: json
|
type: json
|
||||||
default: {}
|
default: {}
|
||||||
|
|
||||||
|
has_net_mtu:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
|
|
||||||
|
conditions:
|
||||||
|
has_net_mtu: {get_param: has_net_mtu}
|
||||||
|
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
|
|
||||||
network:
|
network:
|
||||||
type: OS::Neutron::Net
|
type: OS::Neutron::Net
|
||||||
properties:
|
properties:
|
||||||
|
port_security_enabled: {get_param: port_security_enabled}
|
||||||
value_specs: {get_param: value_specs}
|
value_specs: {get_param: value_specs}
|
||||||
|
|
||||||
subnet_ipv4:
|
subnet_ipv4:
|
||||||
@ -48,7 +64,10 @@ resources:
|
|||||||
|
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
|
|
||||||
network_id:
|
network_id:
|
||||||
value: {get_resource: network}
|
value: {get_resource: network}
|
||||||
|
|
||||||
mtu:
|
mtu:
|
||||||
value: {get_attr: [network, mtu]}
|
value: {get_attr: [network, mtu]}
|
||||||
|
condition: has_net_mtu
|
||||||
|
@ -16,36 +16,50 @@ from __future__ import absolute_import
|
|||||||
|
|
||||||
import tobiko
|
import tobiko
|
||||||
from tobiko import config
|
from tobiko import config
|
||||||
from tobiko.openstack import heat
|
|
||||||
from tobiko.tests.scenario.neutron import base
|
|
||||||
from tobiko.shell import ping
|
from tobiko.shell import ping
|
||||||
|
from tobiko.openstack import heat
|
||||||
|
from tobiko.openstack import neutron
|
||||||
|
from tobiko.tests import base
|
||||||
|
from tobiko.tests.scenario.neutron import stacks
|
||||||
|
|
||||||
|
|
||||||
CONF = config.CONF
|
CONF = config.CONF
|
||||||
|
|
||||||
|
|
||||||
class FloatingIPFixture(heat.HeatStackFixture):
|
class FloatingIPFixture(heat.HeatStackFixture):
|
||||||
template = base.heat_template_file('floating_ip.yaml')
|
template = stacks.heat_template_file('floating_ip.yaml')
|
||||||
|
|
||||||
# template parameters
|
# template parameters
|
||||||
floating_network = CONF.tobiko.neutron.floating_network
|
floating_network = CONF.tobiko.neutron.floating_network
|
||||||
image = CONF.tobiko.nova.image
|
image = CONF.tobiko.nova.image
|
||||||
flavor = CONF.tobiko.nova.flavor
|
flavor = CONF.tobiko.nova.flavor
|
||||||
|
|
||||||
internal_network_fixture = base.InternalNetworkFixture
|
internal_network_fixture = stacks.InternalNetworkFixture
|
||||||
|
|
||||||
|
# derived attributes
|
||||||
internal_network = None
|
internal_network = None
|
||||||
|
port_security_enabled = False
|
||||||
|
security_groups = None
|
||||||
|
|
||||||
def setup_parameters(self):
|
def setup_parameters(self):
|
||||||
super(FloatingIPFixture, self).setup_parameters()
|
super(FloatingIPFixture, self).setup_parameters()
|
||||||
self.setup_internal_network()
|
self.setup_internal_network()
|
||||||
self.parameters['internal_network'] = self.internal_network.network_id
|
if self.port_security_enabled:
|
||||||
|
self.setup_port_security()
|
||||||
|
|
||||||
def setup_internal_network(self):
|
def setup_internal_network(self):
|
||||||
self.internal_network = tobiko.setup_fixture(
|
self.internal_network = tobiko.setup_fixture(
|
||||||
self.internal_network_fixture).wait_for_outputs()
|
self.internal_network_fixture).wait_for_outputs()
|
||||||
|
self.parameters['internal_network'] = self.internal_network.network_id
|
||||||
|
|
||||||
|
@neutron.skip_if_missing_networking_extensions('port-security')
|
||||||
|
def setup_port_security(self):
|
||||||
|
self.parameters.update(
|
||||||
|
port_security_enabled=self.port_security_enabled,
|
||||||
|
security_groups=self.security_groups or [])
|
||||||
|
|
||||||
|
|
||||||
class FloatingIPTest(base.NeutronTest):
|
class FloatingIPTest(base.TobikoTest):
|
||||||
"""Tests server connectivity"""
|
"""Tests server connectivity"""
|
||||||
|
|
||||||
floating_ip_fixture = FloatingIPFixture
|
floating_ip_fixture = FloatingIPFixture
|
||||||
@ -61,11 +75,13 @@ class FloatingIPTest(base.NeutronTest):
|
|||||||
def test_ping(self):
|
def test_ping(self):
|
||||||
ping.ping_until_received(self.floating_ip_address).assert_replied()
|
ping.ping_until_received(self.floating_ip_address).assert_replied()
|
||||||
|
|
||||||
|
@neutron.skip_if_missing_networking_extensions('net-mtu')
|
||||||
def test_ping_with_mtu_packet(self):
|
def test_ping_with_mtu_packet(self):
|
||||||
ping.ping_until_received(self.floating_ip_address,
|
ping.ping_until_received(self.floating_ip_address,
|
||||||
packet_size=self.mtu,
|
packet_size=self.mtu,
|
||||||
fragmentation=False).assert_replied()
|
fragmentation=False).assert_replied()
|
||||||
|
|
||||||
|
@neutron.skip_if_missing_networking_extensions('net-mtu')
|
||||||
def test_ping_with_oversized_packet(self):
|
def test_ping_with_oversized_packet(self):
|
||||||
# Wait for VM to get ready
|
# Wait for VM to get ready
|
||||||
ping.ping_until_received(self.floating_ip_address)
|
ping.ping_until_received(self.floating_ip_address)
|
||||||
@ -76,11 +92,12 @@ class FloatingIPTest(base.NeutronTest):
|
|||||||
check=False).assert_not_replied()
|
check=False).assert_not_replied()
|
||||||
|
|
||||||
|
|
||||||
|
@neutron.skip_if_missing_networking_extensions('port-security')
|
||||||
class FloatingIPWithPortSecurityFixture(FloatingIPFixture):
|
class FloatingIPWithPortSecurityFixture(FloatingIPFixture):
|
||||||
port_security_enabled = True
|
port_security_enabled = True
|
||||||
|
|
||||||
|
|
||||||
class FloatingIPWithPortSecurityTest(base.NeutronTest):
|
class FloatingIPWithPortSecurityTest(base.TobikoTest):
|
||||||
floating_ip_fixture = FloatingIPFixture
|
floating_ip_fixture = FloatingIPFixture
|
||||||
floating_ip_with_securtity_fixture = FloatingIPWithPortSecurityFixture
|
floating_ip_with_securtity_fixture = FloatingIPWithPortSecurityFixture
|
||||||
|
|
||||||
@ -101,11 +118,11 @@ class FloatingIPWithPortSecurityTest(base.NeutronTest):
|
|||||||
def test_ping(self):
|
def test_ping(self):
|
||||||
ping.ping_until_received(self.floating_ip_address).assert_replied()
|
ping.ping_until_received(self.floating_ip_address).assert_replied()
|
||||||
ping.ping(self.floating_ip_address_with_security,
|
ping.ping(self.floating_ip_address_with_security,
|
||||||
count=5).assert_not_replied()
|
count=5, check=False).assert_not_replied()
|
||||||
|
|
||||||
|
|
||||||
class FloatingIPWithSecurityGroupFixture(FloatingIPWithPortSecurityFixture):
|
class FloatingIPWithSecurityGroupFixture(FloatingIPWithPortSecurityFixture):
|
||||||
security_groups_fixture = base.SecurityGroupsFixture
|
security_groups_fixture = stacks.SecurityGroupsFixture
|
||||||
security_groups = None
|
security_groups = None
|
||||||
|
|
||||||
def setup_parameters(self):
|
def setup_parameters(self):
|
||||||
@ -121,3 +138,11 @@ class FloatingIPWithSecurityGroupFixture(FloatingIPWithPortSecurityFixture):
|
|||||||
|
|
||||||
class FloatingIPWithSecurityGroupTest(FloatingIPTest):
|
class FloatingIPWithSecurityGroupTest(FloatingIPTest):
|
||||||
floating_ip_fixture = FloatingIPWithSecurityGroupFixture
|
floating_ip_fixture = FloatingIPWithSecurityGroupFixture
|
||||||
|
|
||||||
|
|
||||||
|
class FloatingIPWithNetMtuWritableFixture(FloatingIPFixture):
|
||||||
|
internal_network_fixture = stacks.InternalNetworkWithNetMtuWritableFixture
|
||||||
|
|
||||||
|
|
||||||
|
class FlatingIpWithMtuWritableTest(FloatingIPTest):
|
||||||
|
floating_ip_fixture = FloatingIPWithNetMtuWritableFixture
|
||||||
|
Loading…
Reference in New Issue
Block a user