Merge "Document and refine scenario tests"
This commit is contained in:
commit
34a3223e58
|
@ -281,8 +281,8 @@ class HeatStackOutputs(object):
|
|||
try:
|
||||
return self.outputs[name]
|
||||
except KeyError:
|
||||
InvalidHeatStackOutputKey(name=self.stack_name,
|
||||
key=name)
|
||||
raise InvalidHeatStackOutputKey(name=self.stack_name,
|
||||
key=name)
|
||||
|
||||
|
||||
def check_stack_status(stack, expected):
|
||||
|
|
|
@ -37,5 +37,10 @@ ping_until_delivered = _ping.ping_until_delivered
|
|||
ping_until_undelivered = _ping.ping_until_undelivered
|
||||
ping_until_received = _ping.ping_until_received
|
||||
ping_until_unreceived = _ping.ping_until_unreceived
|
||||
TRANSMITTED = _ping.TRANSMITTED
|
||||
UNDELIVERED = _ping.UNDELIVERED
|
||||
DELIVERED = _ping.DELIVERED
|
||||
RECEIVED = _ping.RECEIVED
|
||||
UNRECEIVED = _ping.UNRECEIVED
|
||||
|
||||
PingStatistics = _statistics.PingStatistics
|
||||
|
|
|
@ -28,49 +28,85 @@ TEMPLATE_DIRS = [os.path.join(os.path.dirname(__file__), 'templates')]
|
|||
|
||||
|
||||
def heat_template_file(template_file):
|
||||
"""Fixture to load template files from templates directory
|
||||
|
||||
Return fixtures to loads templates from
|
||||
'tobiko/tests/scenario/neutron/templates' directory
|
||||
"""
|
||||
return heat.heat_template_file(template_file=template_file,
|
||||
template_dirs=TEMPLATE_DIRS)
|
||||
|
||||
|
||||
class InternalNetworkFixture(heat.HeatStackFixture):
|
||||
"""Heat stack for creating internal network with a router to external
|
||||
|
||||
"""
|
||||
|
||||
#: Heat template file
|
||||
template = heat_template_file('internal_network.yaml')
|
||||
|
||||
#: Floating IP network where the Neutron floating IP is created
|
||||
floating_network = CONF.tobiko.neutron.floating_network
|
||||
|
||||
#: Disable port security by default for new network ports
|
||||
port_security_enabled = False
|
||||
|
||||
#: whenever has net-mtu networking extension
|
||||
@property
|
||||
def has_net_mtu(self):
|
||||
return neutron.has_networking_extensions('net-mtu')
|
||||
|
||||
#: Value for maximum transfer unit on the internal network
|
||||
mtu = None
|
||||
|
||||
def setup_parameters(self):
|
||||
"""Setup template parameters
|
||||
|
||||
"""
|
||||
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):
|
||||
"""Setup default port security value for internal network ports
|
||||
|
||||
"""
|
||||
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):
|
||||
"""Setup maximum transfer unit size for internal network
|
||||
|
||||
"""
|
||||
self.parameters.setdefault('value_specs', {}).update(mtu=self.mtu)
|
||||
|
||||
|
||||
class InternalNetworkFixtureWithPortSecurity(InternalNetworkFixture):
|
||||
"""Heat stack for creating internal network with port security
|
||||
|
||||
"""
|
||||
#: Enable port security by default for new network ports
|
||||
port_security_enabled = True
|
||||
|
||||
|
||||
@neutron.skip_if_missing_networking_extensions('net-mtu-writable')
|
||||
class InternalNetworkWithNetMtuWritableFixture(InternalNetworkFixture):
|
||||
"""Heat stack for creating internal network with custom mtu parameter
|
||||
|
||||
"""
|
||||
#: Force value for internal network maximum transfer unit
|
||||
mtu = 1000
|
||||
|
||||
|
||||
@neutron.skip_if_missing_networking_extensions('security-group')
|
||||
class SecurityGroupsFixture(heat.HeatStackFixture):
|
||||
"""Heat stack with some security groups
|
||||
|
||||
"""
|
||||
#: Heat template file
|
||||
template = heat_template_file('security_groups.yaml')
|
||||
|
|
|
@ -57,5 +57,12 @@ resources:
|
|||
|
||||
|
||||
outputs:
|
||||
|
||||
floating_ip_address:
|
||||
value: {get_attr: [floating_ip, floating_ip_address]}
|
||||
|
||||
port_security_enabled:
|
||||
value: {get_attr: [port, port_security_enabled]}
|
||||
|
||||
security_groups:
|
||||
value: {get_attr: [port, security_groups]}
|
||||
|
|
|
@ -27,123 +27,253 @@ CONF = config.CONF
|
|||
|
||||
|
||||
class FloatingIPFixture(heat.HeatStackFixture):
|
||||
"""Heat stack for testing a floating IP instance
|
||||
"""
|
||||
|
||||
#: Heat template file
|
||||
template = stacks.heat_template_file('floating_ip.yaml')
|
||||
|
||||
# --- template parameters ---
|
||||
#: Floating IP network where the Neutron floating IP is created
|
||||
floating_network = CONF.tobiko.neutron.floating_network
|
||||
|
||||
#: Glance image used to create a Nova server instance
|
||||
image = CONF.tobiko.nova.image
|
||||
|
||||
#: Nova flavor used to create a Nova server instance
|
||||
flavor = CONF.tobiko.nova.flavor
|
||||
|
||||
@property
|
||||
def internal_network(self):
|
||||
"""Internal network where the Nova server instance is connected
|
||||
|
||||
"""
|
||||
return self.internal_network_stack.outputs.network_id
|
||||
|
||||
# --- required fixtures ---
|
||||
|
||||
#: Heat stack for creating internal network with a router to floating
|
||||
#: network
|
||||
internal_network_stack = tobiko.required_setup_fixture(
|
||||
stacks.InternalNetworkFixture)
|
||||
|
||||
# --- class parameters ---
|
||||
|
||||
#: Whenever port security on internal network is enable
|
||||
port_security_enabled = False
|
||||
security_groups = None
|
||||
|
||||
#: Security groups to be associated to network ports
|
||||
security_groups = []
|
||||
|
||||
def setup_parameters(self):
|
||||
"""Setup template parameters
|
||||
|
||||
"""
|
||||
super(FloatingIPFixture, self).setup_parameters()
|
||||
if self.port_security_enabled:
|
||||
self.setup_port_security()
|
||||
|
||||
@neutron.skip_if_missing_networking_extensions('port-security')
|
||||
def setup_port_security(self):
|
||||
"""Setup port security template parameters
|
||||
|
||||
"""
|
||||
self.parameters.update(
|
||||
port_security_enabled=self.port_security_enabled,
|
||||
security_groups=self.security_groups or [])
|
||||
|
||||
# --- outputs ---
|
||||
|
||||
class FloatingIPTest(base.TobikoTest):
|
||||
"""Tests connectivity to Nova instances via floating IPs"""
|
||||
|
||||
#: Resources stack with floating IP and Nova server
|
||||
floating_ip_stack = tobiko.required_setup_fixture(FloatingIPFixture)
|
||||
|
||||
@property
|
||||
def floating_ip_address(self):
|
||||
return self.outputs.floating_ip_address
|
||||
|
||||
@property
|
||||
def internal_network_mtu(self):
|
||||
return self.internal_network_stack.outputs.mtu
|
||||
|
||||
|
||||
class FloatingIPTest(base.TobikoTest):
|
||||
"""Tests server connectivity"""
|
||||
|
||||
floating_ip_stack = tobiko.required_setup_fixture(FloatingIPFixture)
|
||||
|
||||
def setUp(self):
|
||||
super(FloatingIPTest, self).setUp()
|
||||
stack = self.floating_ip_stack
|
||||
self.floating_ip_address = stack.floating_ip_address
|
||||
self.internal_network_mtu = stack.internal_network_mtu
|
||||
"""Floating IP address"""
|
||||
return self.floating_ip_stack.outputs.floating_ip_address
|
||||
|
||||
def test_ping(self):
|
||||
"""Test connectivity to floating IP address"""
|
||||
ping.ping_until_received(self.floating_ip_address).assert_replied()
|
||||
|
||||
@neutron.skip_if_missing_networking_extensions('net-mtu')
|
||||
def test_ping_with_mtu(self):
|
||||
ping.ping_until_received(self.floating_ip_address,
|
||||
packet_size=self.internal_network_mtu,
|
||||
fragmentation=False).assert_replied()
|
||||
# --- test port-security extension ---------------------------------------
|
||||
|
||||
# Send 5 over-sized packets
|
||||
@neutron.skip_if_missing_networking_extensions('port-security')
|
||||
def test_port_security_enabled_port_attribute(self):
|
||||
"""Test port security enabled port attribute"""
|
||||
self.assertEqual(self.expected_port_security_enabled,
|
||||
self.observed_port_security_enabled)
|
||||
|
||||
@property
|
||||
def expected_port_security_enabled(self):
|
||||
"""Expected port security enabled value"""
|
||||
return self.floating_ip_stack.port_security_enabled
|
||||
|
||||
@property
|
||||
def observed_port_security_enabled(self):
|
||||
"""Actual MTU value for internal network"""
|
||||
return self.floating_ip_stack.outputs.port_security_enabled
|
||||
|
||||
# --- test security_group extension --------------------------------------
|
||||
|
||||
@neutron.skip_if_missing_networking_extensions('security-group')
|
||||
def test_security_groups_port_attribute(self):
|
||||
"""Test security groups port attribute"""
|
||||
self.assertEqual(self.expected_security_groups,
|
||||
self.observed_security_groups)
|
||||
|
||||
@property
|
||||
def expected_security_groups(self):
|
||||
"""Expected port security groups"""
|
||||
return self.floating_ip_stack.security_groups
|
||||
|
||||
@property
|
||||
def observed_security_groups(self):
|
||||
"""Actual port security group"""
|
||||
return self.floating_ip_stack.outputs.security_groups
|
||||
|
||||
# --- test net-mtu and net-mtu-writable extensions -----------------------
|
||||
|
||||
@neutron.skip_if_missing_networking_extensions('net-mtu')
|
||||
def test_ping_with_net_mtu(self):
|
||||
"""Test connectivity to floating IP address with MTU sized packets"""
|
||||
# Wait until it can reach remote port with maximum-sized packets
|
||||
ping.ping(self.floating_ip_address,
|
||||
packet_size=self.internal_network_mtu + 1,
|
||||
fragmentation=False, count=5,
|
||||
until=ping.RECEIVED,
|
||||
packet_size=self.observed_net_mtu,
|
||||
fragmentation=False).assert_replied()
|
||||
|
||||
# Verify it can't reach remote port with over-sized packets
|
||||
ping.ping(self.floating_ip_address,
|
||||
packet_size=self.observed_net_mtu + 1,
|
||||
fragmentation=False,
|
||||
count=5,
|
||||
check=False).assert_not_replied()
|
||||
|
||||
@neutron.skip_if_missing_networking_extensions('net-mtu-writable')
|
||||
def test_mtu_net_attribute(self):
|
||||
"""Test 'mtu' network attribute"""
|
||||
if self.expected_net_mtu:
|
||||
self.assertEqual(self.expected_net_mtu,
|
||||
self.observed_net_mtu)
|
||||
|
||||
@property
|
||||
def expected_net_mtu(self):
|
||||
"""Expected MTU value for internal network"""
|
||||
return self.floating_ip_stack.internal_network_stack.mtu
|
||||
|
||||
@property
|
||||
def observed_net_mtu(self):
|
||||
"""Actual MTU value for internal network"""
|
||||
return self.floating_ip_stack.internal_network_stack.outputs.mtu
|
||||
|
||||
|
||||
@neutron.skip_if_missing_networking_extensions('port-security')
|
||||
class FloatingIPWithPortSecurityFixture(FloatingIPFixture):
|
||||
"""Heat stack for testing a floating IP instance with port security enabled
|
||||
|
||||
"""
|
||||
|
||||
#: Enable port security on internal network
|
||||
port_security_enabled = True
|
||||
|
||||
|
||||
class FloatingIPWithPortSecurityTest(base.TobikoTest):
|
||||
floating_ip_stack = tobiko.required_setup_fixture(FloatingIPFixture)
|
||||
floating_ip_with_securtity_stack = tobiko.required_setup_fixture(
|
||||
@neutron.skip_if_missing_networking_extensions('port-security')
|
||||
class FloatingIPWithPortSecurityTest(FloatingIPTest):
|
||||
"""Tests connectivity to Nova instances via floating IPs with port security
|
||||
|
||||
"""
|
||||
|
||||
#: Resources stack with floating IP and Nova server with port security
|
||||
floating_ip_stack = tobiko.required_setup_fixture(
|
||||
FloatingIPWithPortSecurityFixture)
|
||||
|
||||
def setUp(self):
|
||||
super(FloatingIPWithPortSecurityTest, self).setUp()
|
||||
#: Resources stack with floating IP and Nova server without port security
|
||||
unsecured_floating_ip_stack = tobiko.required_setup_fixture(
|
||||
FloatingIPFixture)
|
||||
|
||||
# Setup VM with port security
|
||||
self.floating_ip_address_with_security = (
|
||||
self.floating_ip_with_securtity_stack.outputs.floating_ip_address)
|
||||
|
||||
# Setup VM without port security
|
||||
self.floating_ip_address = (
|
||||
self.floating_ip_stack.outputs.floating_ip_address)
|
||||
@property
|
||||
def unsecured_floating_ip_address(self):
|
||||
"""Floating IP address to unsecured port"""
|
||||
return self.unsecured_floating_ip_stack.outputs.floating_ip_address
|
||||
|
||||
def test_ping(self):
|
||||
ping.ping_until_received(self.floating_ip_address).assert_replied()
|
||||
ping.ping(self.floating_ip_address_with_security,
|
||||
count=5, check=False).assert_not_replied()
|
||||
"""Test connectivity to floating IP address"""
|
||||
# Ping until unsecured port is reachable via floating IP
|
||||
ping.ping(self.unsecured_floating_ip_address,
|
||||
until=ping.RECEIVED).assert_replied()
|
||||
|
||||
# Check can't reach secured port via floating IP
|
||||
ping.ping(self.floating_ip_address,
|
||||
count=5,
|
||||
check=False).assert_not_replied()
|
||||
|
||||
@neutron.skip_if_missing_networking_extensions('net-mtu')
|
||||
def test_ping_with_net_mtu(self):
|
||||
"""Test connectivity to floating IP address"""
|
||||
# Ping until unsecured port is reachable via floating IP
|
||||
ping.ping(self.unsecured_floating_ip_address,
|
||||
until=ping.RECEIVED).assert_replied()
|
||||
|
||||
# Verify it can't reach secured port with maximum-sized packets
|
||||
ping.ping(self.floating_ip_address,
|
||||
packet_size=self.observed_net_mtu,
|
||||
fragmentation=False,
|
||||
count=5,
|
||||
check=False).assert_not_replied()
|
||||
|
||||
# Verify it can't reach secured port with over-sized packets
|
||||
ping.ping(self.floating_ip_address,
|
||||
packet_size=self.observed_net_mtu + 1,
|
||||
fragmentation=False,
|
||||
count=5,
|
||||
check=False).assert_not_replied()
|
||||
|
||||
|
||||
class FloatingIPWithSecurityGroupFixture(FloatingIPWithPortSecurityFixture):
|
||||
class FloatingIPWithICMPSecurityGroupFixture(
|
||||
FloatingIPWithPortSecurityFixture):
|
||||
"""Heat stack for testing a floating IP instance with security groups
|
||||
|
||||
"""
|
||||
|
||||
#: Resources stack with security group to allow ping Nova servers
|
||||
security_groups_stack = tobiko.required_setup_fixture(
|
||||
stacks.SecurityGroupsFixture)
|
||||
|
||||
@property
|
||||
def security_groups(self):
|
||||
"""List with ICMP security group"""
|
||||
return [self.security_groups_stack.outputs.icmp_security_group_id]
|
||||
|
||||
|
||||
class FloatingIPWithSecurityGroupTest(FloatingIPTest):
|
||||
@neutron.skip_if_missing_networking_extensions('port-security',
|
||||
'security-group')
|
||||
class FloatingIPWithICMPSecurityGroupTest(FloatingIPTest):
|
||||
"""Tests connectivity via floating IP with security ICMP security group
|
||||
|
||||
"""
|
||||
#: Resources stack with floating IP and Nova server
|
||||
floating_ip_stack = tobiko.required_setup_fixture(
|
||||
FloatingIPWithSecurityGroupFixture)
|
||||
FloatingIPWithICMPSecurityGroupFixture)
|
||||
|
||||
|
||||
class FloatingIPWithNetMtuWritableFixture(FloatingIPFixture):
|
||||
"""Heat stack for testing setting MTU value to internal network
|
||||
|
||||
"""
|
||||
|
||||
#: Heat stack for creating internal network with custom MTU value
|
||||
internal_network_stack = tobiko.required_setup_fixture(
|
||||
stacks.InternalNetworkWithNetMtuWritableFixture)
|
||||
|
||||
|
||||
@neutron.skip_if_missing_networking_extensions('net-mtu-writable')
|
||||
class FlatingIpWithMtuWritableTest(FloatingIPTest):
|
||||
"""Tests connectivity via floating IP with modified MTU value
|
||||
|
||||
"""
|
||||
|
||||
#: Resources stack with floating IP and Nova server
|
||||
floating_ip_stack = tobiko.required_setup_fixture(
|
||||
FloatingIPWithNetMtuWritableFixture)
|
||||
|
|
Loading…
Reference in New Issue