summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMaxime Peim <mpeim@cisco.com>2023-11-14 15:26:41 +0100
committerDave Wallace <dwallacelf@gmail.com>2024-01-18 20:14:54 +0000
commit77caeb1b193404e76beb27a1aa81321e8eb1cf1f (patch)
treebffb3aa51d53f96ad45a55d337f262260c191461 /test
parent87241fefd94423cdc50cfe6b1b54fec955b5f0d3 (diff)
tests: preload api files
When sanity test is not done, API files are not loaded until the first test case is run. Hence, it is not possible to use enums, etc. outside of a test class. By preloading API files before running any tests, it prevents its issue. Type: fix Change-Id: I8730150374e6c5f8d6933ec037811372ac2a8da0 Signed-off-by: Maxime Peim <mpeim@cisco.com>
Diffstat (limited to 'test')
-rw-r--r--test/Makefile8
-rw-r--r--test/config.py1
-rw-r--r--test/run_tests.py4
-rw-r--r--test/vpp_papi_provider.py5
4 files changed, 13 insertions, 5 deletions
diff --git a/test/Makefile b/test/Makefile
index 281c7bd8b44..7ea83acfff7 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -259,6 +259,12 @@ ifneq ($(findstring $(DECODE_PCAPS),1 y yes),)
ARG18=--decode-pcaps
endif
+ifneq ($(findstring $(API_PRELOAD),1 y yes),)
+ARG19=--api-preload
+else
+ARG19=
+endif
+
EXC_PLUGINS_ARG=
ifneq ($(VPP_EXCLUDED_PLUGINS),)
# convert the comma-separated list into N invocations of the argument to exclude a plugin
@@ -267,7 +273,7 @@ endif
-EXTRA_ARGS=$(ARG0) $(ARG1) $(ARG2) $(ARG3) $(ARG4) $(ARG5) $(ARG6) $(ARG7) $(ARG8) $(ARG9) $(ARG10) $(ARG11) $(ARG12) $(ARG13) $(ARG14) $(ARG15) $(ARG16) $(ARG17) $(ARG18)
+EXTRA_ARGS=$(ARG0) $(ARG1) $(ARG2) $(ARG3) $(ARG4) $(ARG5) $(ARG6) $(ARG7) $(ARG8) $(ARG9) $(ARG10) $(ARG11) $(ARG12) $(ARG13) $(ARG14) $(ARG15) $(ARG16) $(ARG17) $(ARG18) $(ARG19)
RUN_TESTS_ARGS=--failed-dir=$(FAILED_DIR) --verbose=$(V) --jobs=$(TEST_JOBS) --filter=$(TEST) --retries=$(RETRIES) --venv-dir=$(VENV_PATH) --vpp-ws-dir=$(WS_ROOT) --vpp-tag=$(TAG) --rnd-seed=$(RND_SEED) --vpp-worker-count="$(VPP_WORKER_COUNT)" --keep-pcaps $(PLUGIN_PATH_ARGS) $(EXC_PLUGINS_ARG) $(TEST_PLUGIN_PATH_ARGS) $(EXTRA_ARGS)
RUN_SCRIPT_ARGS=--python-opts=$(PYTHON_OPTS)
diff --git a/test/config.py b/test/config.py
index 2fa93ddef3b..32cc4cac5fa 100644
--- a/test/config.py
+++ b/test/config.py
@@ -201,6 +201,7 @@ parser.add_argument(
parser.add_argument(
"--sanity", action="store_true", help="perform sanity vpp run before running tests"
)
+parser.add_argument("--api-preload", action="store_true", help="preload API files")
parser.add_argument(
"--force-foreground",
diff --git a/test/run_tests.py b/test/run_tests.py
index 19ab9052d5c..f20c43af7d7 100644
--- a/test/run_tests.py
+++ b/test/run_tests.py
@@ -14,6 +14,7 @@ from multiprocessing import Process, Pipe, get_context
from multiprocessing.queues import Queue
from multiprocessing.managers import BaseManager
from config import config, num_cpus, available_cpus, max_vpp_cpus
+from vpp_papi import VPPApiJSONFiles
from asfframework import (
VppTestRunner,
get_testcase_doc_name,
@@ -906,6 +907,9 @@ def parse_results(results):
if __name__ == "__main__":
print(f"Config is: {config}")
+ if config.api_preload:
+ VPPApiJSONFiles.load_api(apidir=config.extern_apidir + [config.vpp_install_dir])
+
if config.sanity:
print("Running sanity test case.")
try:
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index 6c3cd7f83fa..d1c40a97bce 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -236,11 +236,8 @@ class VppPapiProvider(object):
self._expect_api_retval = self._zero
self._expect_stack = []
- # install_dir is a class attribute. We need to set it before
- # calling the constructor.
- VPPApiClient.apidir = config.extern_apidir + [config.vpp_install_dir]
-
self.vpp = VPPApiClient(
+ apidir=config.extern_apidir + [config.vpp_install_dir],
logger=test_class.logger,
read_timeout=read_timeout,
use_socket=True,