From 3c54611e22f189000f6aa36d8d5c588e6e354751 Mon Sep 17 00:00:00 2001 From: Eduardo Olivares Date: Thu, 23 Jun 2022 17:54:51 +0200 Subject: [PATCH] Skip ubuntu external tests on OSP17.0 and later Due to a problem with ubuntu-images when config-drive is enabled, these tests need to be skipped on OSP17.0 and later releases Change-Id: Ia03defe90d01af406da77821a36007179315f644 --- tobiko/openstack/stacks/_ubuntu.py | 2 ++ tobiko/openstack/topology/_topology.py | 30 ++++++++++++++++++-------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/tobiko/openstack/stacks/_ubuntu.py b/tobiko/openstack/stacks/_ubuntu.py index ebc18f4df..a1d38983f 100644 --- a/tobiko/openstack/stacks/_ubuntu.py +++ b/tobiko/openstack/stacks/_ubuntu.py @@ -18,6 +18,7 @@ import typing import tobiko from tobiko import config from tobiko.openstack import glance +from tobiko.openstack import topology from tobiko.openstack.stacks import _nova from tobiko.openstack.stacks import _vlan from tobiko.shell import sh @@ -217,6 +218,7 @@ class UbuntuServerStackFixture(UbuntuMinimalServerStackFixture, return self.image_fixture.vlan_device +@topology.skip_unless_osp_version('17.0', lower=True) class UbuntuExternalServerStackFixture(UbuntuServerStackFixture, _nova.ExternalServerStackFixture): """Ubuntu server with port on special external network diff --git a/tobiko/openstack/topology/_topology.py b/tobiko/openstack/topology/_topology.py index c0ad03972..9fc16f714 100644 --- a/tobiko/openstack/topology/_topology.py +++ b/tobiko/openstack/topology/_topology.py @@ -682,18 +682,28 @@ def remove_duplications(items: typing.List) -> typing.List: def _is_version_matched(current, required, higher=False, lower=False): - if not higher and not lower: + # return True means the condition has been fulfilled and next items do not + # need to be compared + # return False means the condition has not been fulfilled and next items do + # not need to be compared + # return None means the condition has been fulfilled so far, but next items + # need to be compared too + if not higher and not lower: # this means equal if int(current) != int(required): return False - elif higher and lower: - pass + else: + return None elif higher: if int(current) < int(required): return False elif lower: if int(current) > int(required): return False - return True + else: + raise RuntimeError + if int(current) != int(required): + return True + # else: return None def verify_osp_version(version, higher=False, lower=False): @@ -708,11 +718,13 @@ def verify_osp_version(version, higher=False, lower=False): os_version = current_version.split('.') required_version = version.split('.') for version_type in range(len(required_version)): - if not _is_version_matched(os_version[version_type], - required_version[version_type], - higher=higher, - lower=lower): - correct_version = False + is_version_match = _is_version_matched( + os_version[version_type], + required_version[version_type], + higher=higher, + lower=lower) + if is_version_match is not None: + correct_version = is_version_match break return correct_version