Create skip_if_is_old_ovn decorator

It assumes that old OVN configuration will not have the two
agents we typically use to recognise OVN and OVS configurations

 has OVS agent: -> is OVS (OSP 13 or OSP 16+)
 has OVN agent: -> is OVN (OSP 16+)
 has any agent: -> is OVN (OSP 13)

Change-Id: I2588ebe38aeb9e07026abe5585085335d377ea89
This commit is contained in:
Federico Ressi 2021-07-20 14:57:55 +02:00
parent 801ed2fea3
commit 2991ef9a32
2 changed files with 19 additions and 6 deletions

View File

@ -41,7 +41,7 @@ list_networking_agents = _agent.list_networking_agents
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
NeutronClientFixture = _client.NeutronClientFixture
ServiceUnavailable = _client.ServiceUnavailable

View File

@ -14,6 +14,7 @@
from __future__ import absolute_import
import collections
import re
import typing
import tobiko
@ -101,9 +102,14 @@ DecoratorType = typing.Callable[[typing.Union[typing.Callable, typing.Type]],
typing.Union[typing.Callable, typing.Type]]
def skip_if_missing_networking_agents(binary: typing.Optional[str] = None,
count: int = 1, **params) -> \
DecoratorType:
AgentBinaryType = typing.Union[str, typing.Pattern[str]]
def skip_if_missing_networking_agents(
binary: AgentBinaryType = None,
count: int = 1,
**params) \
-> DecoratorType:
if binary is not None:
params['binary'] = binary
message = "missing {return_value!r} agent(s)"
@ -115,8 +121,9 @@ def skip_if_missing_networking_agents(binary: typing.Optional[str] = None,
def skip_unless_missing_networking_agents(
binary: typing.Optional[str] = None,
count: int = 1, **params) \
binary: AgentBinaryType = None,
count: int = 1,
**params) \
-> DecoratorType:
if binary is not None:
params['binary'] = binary
@ -128,6 +135,12 @@ def skip_unless_missing_networking_agents(
**params)
def skip_if_is_old_ovn():
"""Skip the test if OVN is not configured"""
binary = re.compile(f'({OPENVSWITCH_AGENT}|{OVN_CONTROLLER})')
return skip_if_missing_networking_agents(binary)
def skip_unless_is_ovn():
"""Skip the test if OVN is not configured"""
return skip_unless_missing_networking_agents(OPENVSWITCH_AGENT)