Merge "Add simple functions to check if neutron is configured with OVN or OVS"

This commit is contained in:
Zuul 2021-07-21 22:05:43 +00:00 committed by Gerrit Code Review
commit 9bfdee622b
5 changed files with 27 additions and 22 deletions

View File

@ -42,6 +42,8 @@ skip_if_missing_networking_agents = _agent.skip_if_missing_networking_agents
skip_unless_is_ovn = _agent.skip_unless_is_ovn
skip_unless_is_ovs = _agent.skip_unless_is_ovs
skip_if_is_old_ovn = _agent.skip_if_is_old_ovn
has_ovn = _agent.has_ovn
has_ovs = _agent.has_ovs
NeutronClientFixture = _client.NeutronClientFixture
ServiceUnavailable = _client.ServiceUnavailable

View File

@ -89,13 +89,25 @@ def list_networking_agents(**attributes):
NetworkingAgentFixture).agents.with_items(**attributes)
def missing_networking_agents(count=1, **params):
agents = list_networking_agents(**params)
return max(0, count - len(agents))
def count_networking_agents(**params) -> int:
return len(list_networking_agents(**params))
def has_networking_agents(count=1, **params):
return not missing_networking_agents(count=count, **params)
def missing_networking_agents(count=1, **params) -> int:
actual_count = count_networking_agents(**params)
return max(0, count - actual_count)
def has_networking_agents(**params) -> bool:
return count_networking_agents(**params) > 0
def has_ovn() -> bool:
return not has_ovs()
def has_ovs() -> bool:
return has_networking_agents(binary=OPENVSWITCH_AGENT)
DecoratorType = typing.Callable[[typing.Union[typing.Callable, typing.Type]],

View File

@ -10,16 +10,11 @@ from tobiko.openstack import neutron
from tobiko.openstack import topology
from tobiko.shell import ip
from tobiko.shell import sh
from tobiko.tripleo import containers
from tobiko.tripleo import pacemaker
LOG = log.getLogger(__name__)
def is_ovn_configured():
return containers.ovn_used_on_overcloud()
def build_ovn_db_show_dict(ovn_db_show_str):
# returns a dictionary with OVN NB or OVN SB DB information
# each dict key is a section from the OVN DB command output
@ -76,6 +71,7 @@ def test_neutron_agents_are_alive(timeout=300., interval=5.) \
def ovn_dbs_are_synchronized(test_case):
from tobiko.tripleo import containers
# declare commands
search_container_cmd = (
"%s ps --format '{{.Names}}' -f name=ovn-dbs-bundle" %
@ -215,7 +211,7 @@ def ovn_dbs_vip_bindings(test_case):
def test_ovn_dbs_validations():
if not is_ovn_configured():
if not neutron.has_ovn():
LOG.debug('OVN not configured. OVN DB sync validations skipped')
return
@ -231,7 +227,7 @@ def test_ovs_bridges_mac_table_size():
expected_mac_table_size = '50000'
get_mac_table_size_cmd = ('ovs-vsctl get bridge {br_name} '
'other-config:mac-table-size')
if is_ovn_configured():
if neutron.has_ovn():
get_br_mappings_cmd = ('ovs-vsctl get Open_vSwitch . '
'external_ids:ovn-bridge-mappings')
else:

View File

@ -12,6 +12,7 @@ import docker as dockerlib
import tobiko
from tobiko import podman
from tobiko import docker
from tobiko.openstack import neutron
from tobiko.openstack import topology
from tobiko.shell import sh
from tobiko.shell import ssh
@ -218,15 +219,9 @@ def assert_all_tripleo_containers_running():
assert_ovn_containers_running()
@functools.lru_cache()
def ovn_used_on_overcloud():
return list_containers_df()['container_name'].\
str.contains('ovn').any(axis=None)
def assert_ovn_containers_running():
# specific OVN verifications
if ovn_used_on_overcloud():
if neutron.has_ovn():
ovn_controller_containers = ['ovn_controller',
'ovn-dbs-bundle-{}-'.
format(container_runtime_name)]
@ -252,7 +247,7 @@ def run_container_config_validations():
# TODO add here any generic configuration validation
config_checkings = []
if ovn_used_on_overcloud():
if neutron.has_ovn():
ovn_config_checkings = \
[{'node_group': 'controller',
'container_name': 'neutron_api',

View File

@ -8,8 +8,8 @@ import pandas
import six
import tobiko
from tobiko.openstack import neutron
from tobiko.openstack import topology
from tobiko.tripleo import containers
from tobiko.tripleo import overcloud
from tobiko.shell import sh
@ -167,7 +167,7 @@ class OvercloudProcessesStatus(object):
expected overcloud node or nodes
:return: Bool
"""
if not containers.ovn_used_on_overcloud():
if not neutron.has_ovn():
LOG.info("Networking OVN not configured")
return True