Fix VlanServerStackFixture.list_vlan_fixed_ips when has any IPs
It allows Ubuntu server to work without VLAN when not trunk is available Change-Id: If0ac6aa7482ab83ef69d5849bb6efb96c518a077
This commit is contained in:
parent
8213faaa0b
commit
04b7a66e52
@ -218,7 +218,9 @@ class ServerStackFixture(heat.HeatStackFixture, abc.ABC):
|
|||||||
def fixed_ipv6(self):
|
def fixed_ipv6(self):
|
||||||
return self.find_fixed_ip(ip_version=6)
|
return self.find_fixed_ip(ip_version=6)
|
||||||
|
|
||||||
has_vlan = False
|
@property
|
||||||
|
def has_vlan(self) -> bool:
|
||||||
|
return False
|
||||||
|
|
||||||
#: Schedule on different host that this Nova server instance ID
|
#: Schedule on different host that this Nova server instance ID
|
||||||
different_host = None
|
different_host = None
|
||||||
|
@ -41,10 +41,11 @@ class VlanProxyServerStackFixture(_cirros.CirrosServerStackFixture):
|
|||||||
network_stack = tobiko.required_fixture(VlanNetworkStackFixture)
|
network_stack = tobiko.required_fixture(VlanNetworkStackFixture)
|
||||||
|
|
||||||
|
|
||||||
@neutron.skip_if_missing_networking_extensions('trunk')
|
|
||||||
class VlanServerStackFixture(_nova.ServerStackFixture, abc.ABC):
|
class VlanServerStackFixture(_nova.ServerStackFixture, abc.ABC):
|
||||||
|
|
||||||
has_vlan = True
|
@property
|
||||||
|
def has_vlan(self) -> bool:
|
||||||
|
return neutron.has_networking_extensions('trunk')
|
||||||
|
|
||||||
#: stack with the newtwork where the trunk support is attached
|
#: stack with the newtwork where the trunk support is attached
|
||||||
vlan_network_stack = tobiko.required_fixture(VlanNetworkStackFixture)
|
vlan_network_stack = tobiko.required_fixture(VlanNetworkStackFixture)
|
||||||
@ -77,11 +78,12 @@ class VlanServerStackFixture(_nova.ServerStackFixture, abc.ABC):
|
|||||||
def list_vlan_fixed_ips(self,
|
def list_vlan_fixed_ips(self,
|
||||||
ip_version: int = None) \
|
ip_version: int = None) \
|
||||||
-> tobiko.Selection[netaddr.IPAddress]:
|
-> tobiko.Selection[netaddr.IPAddress]:
|
||||||
fixed_ips: tobiko.Selection[netaddr.IPAddress] = tobiko.Selection(
|
fixed_ips = tobiko.Selection[netaddr.IPAddress]()
|
||||||
netaddr.IPAddress(fixed_ip['ip_address'])
|
if self.vlan_fixed_ips:
|
||||||
for fixed_ip in self.vlan_fixed_ips)
|
fixed_ips.extend(netaddr.IPAddress(fixed_ip['ip_address'])
|
||||||
if ip_version is not None:
|
for fixed_ip in self.vlan_fixed_ips)
|
||||||
fixed_ips = fixed_ips.with_attributes(version=ip_version)
|
if ip_version is not None and fixed_ips:
|
||||||
|
fixed_ips = fixed_ips.with_attributes(version=ip_version)
|
||||||
return fixed_ips
|
return fixed_ips
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -91,18 +93,25 @@ class VlanServerStackFixture(_nova.ServerStackFixture, abc.ABC):
|
|||||||
def assert_vlan_is_reachable(self,
|
def assert_vlan_is_reachable(self,
|
||||||
ip_version: int = None):
|
ip_version: int = None):
|
||||||
fixed_ips = self.list_vlan_fixed_ips(ip_version=ip_version)
|
fixed_ips = self.list_vlan_fixed_ips(ip_version=ip_version)
|
||||||
ping.assert_reachable_hosts(fixed_ips,
|
if fixed_ips:
|
||||||
ssh_client=self.vlan_ssh_proxy_client)
|
ping.assert_reachable_hosts(
|
||||||
|
fixed_ips, ssh_client=self.vlan_ssh_proxy_client)
|
||||||
|
else:
|
||||||
|
tobiko.fail(f'Server {self.stack_name} has any IP on VLAN port')
|
||||||
|
|
||||||
def assert_vlan_is_unreachable(self,
|
def assert_vlan_is_unreachable(self,
|
||||||
ip_version: int = None):
|
ip_version: int = None):
|
||||||
fixed_ips = self.list_vlan_fixed_ips(ip_version=ip_version)
|
fixed_ips = self.list_vlan_fixed_ips(ip_version=ip_version)
|
||||||
ping.assert_unreachable_hosts(fixed_ips,
|
if fixed_ips:
|
||||||
ssh_client=self.vlan_ssh_proxy_client)
|
ping.assert_unreachable_hosts(
|
||||||
|
fixed_ips, ssh_client=self.vlan_ssh_proxy_client)
|
||||||
|
else:
|
||||||
|
tobiko.fail(f'Server {self.stack_name} has any IP on VLAN port')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def neutron_required_quota_set(self) -> typing.Dict[str, int]:
|
def neutron_required_quota_set(self) -> typing.Dict[str, int]:
|
||||||
requirements = super().neutron_required_quota_set
|
requirements = super().neutron_required_quota_set
|
||||||
requirements['port'] += 1
|
if self.has_vlan:
|
||||||
requirements['trunk'] += 1
|
requirements['trunk'] += 1
|
||||||
|
requirements['port'] += 1
|
||||||
return requirements
|
return requirements
|
||||||
|
@ -20,6 +20,7 @@ import testtools
|
|||||||
|
|
||||||
import tobiko
|
import tobiko
|
||||||
from tobiko import config
|
from tobiko import config
|
||||||
|
from tobiko.openstack import neutron
|
||||||
from tobiko.openstack import stacks
|
from tobiko.openstack import stacks
|
||||||
|
|
||||||
|
|
||||||
@ -31,29 +32,16 @@ class RebootTrunkServerStackFixture(stacks.UbuntuServerStackFixture):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TrunkTest(testtools.TestCase):
|
@neutron.skip_if_missing_networking_extensions('trunk')
|
||||||
|
class RebootTrunkTest(testtools.TestCase):
|
||||||
"""Tests trunk functionality"""
|
"""Tests trunk functionality"""
|
||||||
|
|
||||||
stack = tobiko.required_fixture(RebootTrunkServerStackFixture)
|
stack = tobiko.required_fixture(RebootTrunkServerStackFixture)
|
||||||
|
|
||||||
vlan_proxy_stack = tobiko.required_fixture(
|
|
||||||
stacks.VlanProxyServerStackFixture)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def vlan_proxy_ssh_client(self):
|
|
||||||
return self.vlan_proxy_stack.ssh_client
|
|
||||||
|
|
||||||
def test_activate_server(self):
|
|
||||||
self.stack.ensure_server_status('ACTIVE')
|
|
||||||
self.stack.assert_is_reachable()
|
|
||||||
self.stack.assert_vlan_is_reachable(ip_version=4)
|
|
||||||
|
|
||||||
def test_shutoff_server(self):
|
|
||||||
self.stack.ensure_server_status('SHUTOFF')
|
|
||||||
self.stack.assert_is_unreachable()
|
|
||||||
self.stack.assert_vlan_is_unreachable(ip_version=4)
|
|
||||||
|
|
||||||
@pytest.mark.ovn_migration
|
@pytest.mark.ovn_migration
|
||||||
def test_shutoff_then_activate_server(self):
|
def test_reboot(self):
|
||||||
self.test_shutoff_server()
|
self.stack.ensure_server_status('SHUTOFF')
|
||||||
self.test_activate_server()
|
self.stack.assert_vlan_is_unreachable()
|
||||||
|
|
||||||
|
self.stack.ensure_server_status('ACTIVE')
|
||||||
|
self.stack.assert_vlan_is_reachable()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user