aboutsummaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
authorVratko Polak <vrpolak@cisco.com>2024-01-22 15:33:55 +0100
committerVratko Polak <vrpolak@cisco.com>2024-01-22 15:33:55 +0100
commit9391a11948f5dbfd7db396b23d8041a8baf7700e (patch)
treecf86ecc94fa3cd31972756eab20b3104f427b148 /resources
parent2ad025ee3405718b29c3346aa1930d248a9bec85 (diff)
feat(papi): Tolerate behavior after 39871
Even when VPP switches back to (or adds support for) the old behavior, this enables bisect to work for all VPP commits in 2402 cycle. Change-Id: Ic2b71bee1db723d9d13229d9f4288d1699d246c6 Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'resources')
-rw-r--r--resources/libraries/python/PapiExecutor.py45
1 files changed, 31 insertions, 14 deletions
diff --git a/resources/libraries/python/PapiExecutor.py b/resources/libraries/python/PapiExecutor.py
index b629996042..a55638ab7c 100644
--- a/resources/libraries/python/PapiExecutor.py
+++ b/resources/libraries/python/PapiExecutor.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2023 Cisco and/or its affiliates.
+# Copyright (c) 2024 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -285,19 +285,36 @@ class PapiSocketExecutor:
# It is right, we should refactor the code and move initialization
# of package outside.
from vpp_papi.vpp_papi import VPPApiClient as vpp_class
-
- vpp_class.apidir = cls.api_json_path
- # We need to create instance before removing from sys.path.
- # Cannot use loglevel parameter, robot.api.logger lacks the support.
- vpp_instance = vpp_class(
- use_socket=True,
- server_address="TBD",
- async_thread=False,
- # Large read timeout was originally there for VPP-1722,
- # it may still be helping against AVF device creation failures.
- read_timeout=14,
- logger=FilteredLogger(logger, "INFO"),
- )
+ try:
+ # The old way. Deduplicate when pre-2402 support is not needed.
+
+ vpp_class.apidir = cls.api_json_path
+ # We need to create instance before removing from sys.path.
+ # Cannot use loglevel parameter, robot.api.logger lacks the support.
+ vpp_instance = vpp_class(
+ use_socket=True,
+ server_address="TBD",
+ async_thread=False,
+ # Large read timeout was originally there for VPP-1722,
+ # it may still be helping against AVF device creation failures.
+ read_timeout=14,
+ logger=FilteredLogger(logger, "INFO"),
+ )
+ except vpp_class.VPPRuntimeError:
+ # The 39871 way.
+
+ # We need to create instance before removing from sys.path.
+ # Cannot use loglevel parameter, robot.api.logger lacks the support.
+ vpp_instance = vpp_class(
+ apidir=cls.api_json_path,
+ use_socket=True,
+ server_address="TBD",
+ async_thread=False,
+ # Large read timeout was originally there for VPP-1722,
+ # it may still be helping against AVF device creation failures.
+ read_timeout=14,
+ logger=FilteredLogger(logger, "INFO"),
+ )
# The following is needed to prevent union (e.g. Ip4) debug logging
# of VPP part of PAPI from spamming robot logs.
logging.getLogger("vpp_papi.serializer").setLevel(logging.INFO)