tests: multiple apidir locations 36/37736/7
authorOle Troan <otroan@cisco.com>
Thu, 1 Dec 2022 10:22:06 +0000 (11:22 +0100)
committerAndrew Yourtchenko <ayourtch@gmail.com>
Wed, 7 Dec 2022 10:33:20 +0000 (10:33 +0000)
To support testing of external plugins, add support to the test framework and PAPI
for specifying a list of locations to look for api.json files.

Type: improvement
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: I128a306e3c091dc8ef994801b1470b82d2f4595d
Signed-off-by: Ole Troan <ot@cisco.com>
src/vpp-api/python/vpp_papi/vpp_papi.py
test/Makefile
test/config.py
test/vpp_papi_provider.py

index 6755e22..34d5723 100644 (file)
@@ -449,7 +449,12 @@ class VPPApiClient:
         if not apifiles:
             # Pick up API definitions from default directory
             try:
-                apifiles = VPPApiJSONFiles.find_api_files(self.apidir)
+                if isinstance(self.apidir, list):
+                    apifiles = []
+                    for d in self.apidir:
+                        apifiles += VPPApiJSONFiles.find_api_files(d)
+                else:
+                    apifiles = VPPApiJSONFiles.find_api_files(self.apidir)
             except (RuntimeError, VPPApiError):
                 # In test mode we don't care that we can't find the API files
                 if testmode:
index 87b121a..e5e9975 100644 (file)
@@ -249,7 +249,12 @@ ifneq ($(findstring $(API_FUZZ),1 y yes),)
 ARG16=--api-fuzz=on
 endif
 
-EXTRA_ARGS=$(ARG0) $(ARG1) $(ARG2) $(ARG3) $(ARG4) $(ARG5) $(ARG6) $(ARG7) $(ARG8) $(ARG9) $(ARG10) $(ARG11) $(ARG12) $(ARG13) $(ARG14) $(ARG15) $(ARG16)
+ARG17=
+ifneq ($(EXTERN_APIDIR),)
+ARG17=--extern-apidir=$(EXTERN_APIDIR)
+endif
+
+EXTRA_ARGS=$(ARG0) $(ARG1) $(ARG2) $(ARG3) $(ARG4) $(ARG5) $(ARG6) $(ARG7) $(ARG8) $(ARG9) $(ARG10) $(ARG11) $(ARG12) $(ARG13) $(ARG14) $(ARG15) $(ARG16) $(ARG17)
 
 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) $(TEST_PLUGIN_PATH_ARGS) $(EXTRA_ARGS)
 RUN_SCRIPT_ARGS=--python-opts=$(PYTHON_OPTS)
index e735557..d2f14c8 100644 (file)
@@ -301,6 +301,14 @@ parser.add_argument(
     help="directory containing external plugins",
 )
 
+parser.add_argument(
+    "--extern-apidir",
+    action="append",
+    type=directory,
+    default=[],
+    help="directory to look for API JSON files",
+)
+
 parser.add_argument(
     "--coredump-size",
     action="store",
index 148eca2..6c3cd7f 100644 (file)
@@ -238,7 +238,7 @@ class VppPapiProvider(object):
 
         # install_dir is a class attribute. We need to set it before
         # calling the constructor.
-        VPPApiClient.apidir = config.vpp_install_dir
+        VPPApiClient.apidir = config.extern_apidir + [config.vpp_install_dir]
 
         self.vpp = VPPApiClient(
             logger=test_class.logger,