Skip to content

Commit 7835e78

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Make unit tests compatible with neutron-lib 3.4.2" into stable/2023.1
2 parents 15f07dc + 0aeb703 commit 7835e78

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

neutron/tests/tools.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import fixtures
2121
import netaddr
22+
from neutron_lib.callbacks import priority_group
2223
from neutron_lib import constants
2324
from neutron_lib.services.logapi import constants as log_const
2425
from neutron_lib.utils import helpers
@@ -27,15 +28,15 @@
2728
from oslo_utils import timeutils
2829

2930

30-
# NOTE(yamahata): from neutron-lib 1.9.1, callback priority was added and
31-
# priority_group module was added for constants of priority.
32-
# test the existence of the module of priority_group to check if
33-
# callback priority is supported or not.
34-
_CALLBACK_PRIORITY_SUPPORTED = True
31+
# NOTE(ykarel): from neutron-lib 3.9.0, cancellable flag was added
32+
# test the existence of the is_cancellable_event function to check if
33+
# cancellable flag is supported or not. This compatibility check can
34+
# be removed once neutron-lib >= 3.9.0 in requirements.txt.
35+
_CANCELLABLE_FLAG_SUPPORTED = True
3536
try:
36-
from neutron_lib.callbacks import priority_group # noqa
37+
from neutron_lib.callbacks.events import is_cancellable_event # noqa
3738
except ImportError:
38-
_CALLBACK_PRIORITY_SUPPORTED = False
39+
_CANCELLABLE_FLAG_SUPPORTED = False
3940

4041
LAST_RANDOM_PORT_RANGE_GENERATED = 1
4142

@@ -146,12 +147,14 @@ def make_mock_plugin_json_encodable(plugin_instance_mock):
146147

147148

148149
def get_subscribe_args(*args):
149-
# NOTE(yamahata): from neutron-lib 1.9.1, callback priority was added.
150-
# old signature: (callback, resource, event)
151-
# new signature: (callback, resource, event, priority=PRIORITY_DEFAULT)
152-
if len(args) == 3 and _CALLBACK_PRIORITY_SUPPORTED:
153-
args = list(args) # don't modify original list
154-
args.append(priority_group.PRIORITY_DEFAULT)
150+
args = list(args) # don't modify original list
151+
args.append(priority_group.PRIORITY_DEFAULT)
152+
# NOTE(ykarel): from neutron-lib 3.9.0, cancellable flag was added.
153+
# old signature: (callback, resource, event, priority=PRIORITY_DEFAULT)
154+
# new signature: (callback, resource, event, priority=PRIORITY_DEFAULT,
155+
# cancellable=False)
156+
if len(args) == 4 and _CANCELLABLE_FLAG_SUPPORTED:
157+
args.append(False)
155158
return args
156159

157160

0 commit comments

Comments
 (0)