build: add ability to disable some plugins from packaging and tests 50/39150/8
authorAndrew Yourtchenko <ayourtch@gmail.com>
Tue, 26 Sep 2023 14:01:21 +0000 (16:01 +0200)
committerDamjan Marion <dmarion@0xa5.net>
Tue, 3 Oct 2023 13:23:25 +0000 (13:23 +0000)
When custom-packaging the VPP artifacts, it can be useful to exclude
some of the core plugins from packaging/testing, for some reasons.
A removal of a plugin(s) from the worktree needs to be tracked as
a separate change, and thus is tricky from the maintenance
point of view.

This change adds the ability to "pretend they do not exist" -
plugins which are added to the comma-separated environment
variable "VPP_EXCLUDED_PLUGINS" will not be added to the build
process and not packaged.

The tests do not have the 1:1 relationship as plugins,
so they might need to be modified separately. This change
includes some of these modifications as an example.

Type: feature
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Change-Id: Id31562d00a01ced1acbb4996a633517cbd6f09d8

build-data/packages/vpp.mk
src/plugins/CMakeLists.txt
test/Makefile
test/asf/test_quic.py
test/config.py
test/test_abf.py
test/test_acl_plugin.py
test/test_acl_plugin_l2l3.py
test/test_acl_plugin_macip.py
test/test_ikev2.py
test/test_wireguard.py

index ad1d1fc..40aa8c7 100644 (file)
@@ -30,6 +30,9 @@ vpp_cmake_args += -DCMAKE_PREFIX_PATH:PATH="$(vpp_cmake_prefix_path)"
 ifeq ("$(V)","1")
 vpp_cmake_args += -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
 endif
+ifneq ($(VPP_EXCLUDED_PLUGINS),)
+vpp_cmake_args += -DVPP_EXCLUDED_PLUGINS="$(VPP_EXCLUDED_PLUGINS)"
+endif
 
 ifneq ($(VPP_EXTRA_CMAKE_ARGS),)
 vpp_cmake_args += $(VPP_EXTRA_CMAKE_ARGS)
index e54eaa2..43ad4cc 100644 (file)
@@ -23,7 +23,27 @@ FILE(GLOB files RELATIVE
   ${CMAKE_CURRENT_SOURCE_DIR}
   ${CMAKE_CURRENT_SOURCE_DIR}/*/CMakeLists.txt
 )
+
+set(VPP_EXCLUDED_PLUGINS
+  ""
+  CACHE
+  STRING "Comma-separated list of core plugins excluded from packaging and tests"
+)
+
+# create the list of the plugins that we need to exclude from packaging
+SET(excluded_plugins "")
+STRING(REGEX REPLACE "[,]+" ";" exc_plugins "${VPP_EXCLUDED_PLUGINS}")
+foreach (e ${exc_plugins})
+  message(WARNING "Excluding plugin due to VPP_EXCLUDED_PLUGINS: '${e}'")
+  list(APPEND excluded_plugins ${e})
+endforeach()
+
 foreach (f ${files})
   get_filename_component(dir ${f} DIRECTORY)
-  add_subdirectory(${dir})
+
+  # if a plugin is in the list of excluded plugin, do not add that subdirectory
+  LIST(FIND excluded_plugins "${dir}" exc_index)
+  if(${exc_index} EQUAL "-1")
+    add_subdirectory(${dir})
+  endif()
 endforeach()
index 939b0e1..4ff0c15 100644 (file)
@@ -254,9 +254,17 @@ ifneq ($(EXTERN_APIDIR),)
 ARG17=--extern-apidir=$(EXTERN_APIDIR)
 endif
 
+EXC_PLUGINS_ARG=
+ifneq ($(VPP_EXCLUDED_PLUGINS),)
+# convert the comma-separated list into N invocations of the argument to exclude a plugin
+EXC_PLUGINS_ARG=$(shell echo "${VPP_EXCLUDED_PLUGINS}" | sed 's/\([^,]*\)/--excluded-plugin=\1/g; s/,/ /g')
+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_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)
 
 define retest-func
index 4f816a3..0d615d5 100644 (file)
@@ -52,6 +52,7 @@ class QUICAppWorker(Worker):
         return False
 
 
+@unittest.skipIf("quic" in config.excluded_plugins, "Exclude QUIC plugin tests")
 class QUICTestCase(VppTestCase):
     """QUIC Test Case"""
 
index 5d2ef1d..e5c52b9 100644 (file)
@@ -386,6 +386,15 @@ parser.add_argument(
     help="Runs tests against a running VPP.",
 )
 
+parser.add_argument(
+    "--excluded-plugin",
+    dest="excluded_plugins",
+    required=False,
+    action="append",
+    default=[],
+    help="Exclude the tests that indicate they require this plugin(s)",
+)
+
 parser.add_argument(
     "-d",
     "--socket-dir",
index 87e6842..d284c7a 100644 (file)
@@ -3,6 +3,8 @@
 from socket import inet_pton, inet_ntop, AF_INET, AF_INET6
 import unittest
 
+from config import config
+
 from framework import VppTestCase, VppTestRunner
 from vpp_ip import DpoProto
 from vpp_ip_route import (
@@ -119,6 +121,11 @@ class VppAbfAttach(VppObject):
         return "abf-attach-%d-%d" % (self.policy_id, self.sw_if_index)
 
 
+@unittest.skipIf(
+    "acl" in config.excluded_plugins,
+    "Exclude ABF plugin tests due to absence of ACL plugin",
+)
+@unittest.skipIf("abf" in config.excluded_plugins, "Exclude ABF plugin tests")
 class TestAbf(VppTestCase):
     """ABF Test Case"""
 
index 036a5db..235016e 100644 (file)
@@ -5,6 +5,7 @@
 import unittest
 import random
 
+from config import config
 from scapy.packet import Raw
 from scapy.layers.l2 import Ether
 from scapy.layers.inet import IP, TCP, UDP, ICMP
@@ -20,6 +21,7 @@ from vpp_acl import AclRule, VppAcl, VppAclInterface, VppEtypeWhitelist
 from vpp_ip import INVALID_INDEX
 
 
+@unittest.skipIf("acl" in config.excluded_plugins, "Exclude ACL plugin tests")
 @tag_fixme_vpp_workers
 class TestACLplugin(VppTestCase):
     """ACL plugin Test Case"""
index 343e611..8caca0b 100644 (file)
@@ -29,6 +29,7 @@ from socket import inet_pton, AF_INET, AF_INET6
 from random import choice, shuffle
 from pprint import pprint
 from ipaddress import ip_network
+from config import config
 
 import scapy.compat
 from scapy.packet import Raw
@@ -45,6 +46,7 @@ import time
 from vpp_acl import AclRule, VppAcl, VppAclInterface
 
 
+@unittest.skipIf("acl" in config.excluded_plugins, "Exclude ACL plugin tests")
 class TestACLpluginL2L3(VppTestCase):
     """TestACLpluginL2L3 Test Case"""
 
index 6a1ba58..9543ee2 100644 (file)
@@ -11,6 +11,7 @@ from struct import pack, unpack
 import re
 import unittest
 from ipaddress import ip_network, IPv4Network, IPv6Network
+from config import config
 
 import scapy.compat
 from scapy.packet import Raw
@@ -39,6 +40,7 @@ from vpp_acl import (
 from vpp_papi import MACAddress
 
 
+@unittest.skipIf("acl" in config.excluded_plugins, "Exclude ACL plugin tests")
 class MethodHolder(VppTestCase):
     DEBUG = False
 
index f0fd205..5e2625d 100644 (file)
@@ -580,6 +580,7 @@ class IKEv2SA(object):
         return digest.finalize()
 
 
+@unittest.skipIf("ikev2" in config.excluded_plugins, "Exclude IKEv2 plugin tests")
 class IkePeer(VppTestCase):
     """common class for initiator and responder"""
 
@@ -1667,6 +1668,7 @@ class Ikev2Params(object):
             )
 
 
+@unittest.skipIf("ikev2" in config.excluded_plugins, "Exclude IKEv2 plugin tests")
 class TestApi(VppTestCase):
     """Test IKEV2 API"""
 
index 5511dc4..4e96792 100644 (file)
@@ -6,6 +6,7 @@ import base64
 import os
 
 from hashlib import blake2s
+from config import config
 from scapy.packet import Packet
 from scapy.packet import Raw
 from scapy.layers.l2 import Ether, ARP
@@ -509,6 +510,9 @@ def is_handshake_init(p):
     return wg_p[Wireguard].message_type == 1
 
 
+@unittest.skipIf(
+    "wireguard" in config.excluded_plugins, "Exclude Wireguard plugin tests"
+)
 class TestWg(VppTestCase):
     """Wireguard Test Case"""
 
@@ -2848,6 +2852,9 @@ class WireguardHandoffTests(TestWg):
         """Multi-tunnel on the same port"""
 
 
+@unittest.skipIf(
+    "wireguard" in config.excluded_plugins, "Exclude Wireguard plugin tests"
+)
 class TestWgFIB(VppTestCase):
     """Wireguard FIB Test Case"""