Create test case for Neutron ports
Change-Id: Ie7cb2d7943928228899503894d2cdf60693fed79
This commit is contained in:
parent
ebbfbf4337
commit
4098a5786b
|
@ -81,7 +81,7 @@ class FlavorStackFixture(heat.HeatStackFixture):
|
|||
class ServerStackFixture(heat.HeatStackFixture):
|
||||
|
||||
#: Heat template file
|
||||
template = _hot.heat_template_file('neutron/floating_ip_server.yaml')
|
||||
template = _hot.heat_template_file('nova/server.yaml')
|
||||
|
||||
#: stack with the key pair for the server instance
|
||||
key_pair_stack = tobiko.required_setup_fixture(KeyPairStackFixture)
|
||||
|
@ -173,6 +173,10 @@ class ServerStackFixture(heat.HeatStackFixture):
|
|||
def server_details(self):
|
||||
return nova.get_server(self.server_id)
|
||||
|
||||
@property
|
||||
def port_details(self):
|
||||
return neutron.get_port(self.port_id)
|
||||
|
||||
def getDetails(self):
|
||||
# pylint: disable=W0212
|
||||
details = super(ServerStackFixture, self).getDetails()
|
||||
|
|
|
@ -123,3 +123,6 @@ outputs:
|
|||
|
||||
server_id:
|
||||
value: {get_resource: server}
|
||||
|
||||
port_id:
|
||||
value: {get_resource: port}
|
|
@ -0,0 +1,69 @@
|
|||
# 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 testtools
|
||||
|
||||
import tobiko
|
||||
from tobiko.shell import ping
|
||||
from tobiko.shell import sh
|
||||
from tobiko.openstack import neutron
|
||||
from tobiko.openstack import stacks
|
||||
|
||||
|
||||
class PortTest(testtools.TestCase):
|
||||
"""Test Neutron ports"""
|
||||
|
||||
#: Resources stack with Nova server to send messages to
|
||||
stack = tobiko.required_setup_fixture(stacks.CirrosServerStackFixture)
|
||||
|
||||
def test_port_addresses(self):
|
||||
port = self.stack.port_details
|
||||
server_addresses = sh.list_ip_addresses(
|
||||
ssh_client=self.stack.ssh_client)
|
||||
for address in neutron.list_port_ip_addresses(port=port):
|
||||
self.assertIn(address, server_addresses)
|
||||
|
||||
def test_port_network(self):
|
||||
port = self.stack.port_details
|
||||
self.assertEqual(self.stack.network_stack.network_id,
|
||||
port['network_id'])
|
||||
|
||||
def test_port_subnets(self):
|
||||
port_subnets = {fixed_ip['subnet_id']
|
||||
for fixed_ip in self.stack.port_details['fixed_ips']}
|
||||
subnets = set(self.stack.network_stack.network_details['subnets'])
|
||||
self.assertEqual(port_subnets, subnets)
|
||||
|
||||
def test_ping_gateway_ip(self):
|
||||
if not self.stack.network_stack.has_gateway:
|
||||
self.skip('Server network has no gateway router')
|
||||
|
||||
subnets = neutron.list_subnets(
|
||||
network_id=self.stack.network_stack.network_id)
|
||||
for subnet in subnets:
|
||||
ping.ping(host=subnet['gateway_ip'],
|
||||
ssh_client=self.stack.ssh_client).assert_replied()
|
||||
|
||||
|
||||
# --- Test la-h3 extension ----------------------------------------------------
|
||||
|
||||
@neutron.skip_if_missing_networking_extensions('l3-ha')
|
||||
@neutron.skip_if_missing_networking_agents(binary='neutron-l3-agent',
|
||||
count=2)
|
||||
class L3HAPortTest(PortTest):
|
||||
#: Resources stack with floating IP and Nova server
|
||||
stack = tobiko.required_setup_fixture(stacks.L3haServerStackFixture)
|
Loading…
Reference in New Issue