Skip to content

eBPF-based security platform

ci: run the test suite in parallel jobs

Andrea Lattuada9fa2b452434f
diff --git a/.github/scripts/tests.sh b/.github/scripts/tests.sh
index 07a4ef09..6ebd3073 100755
--- a/.github/scripts/tests.sh
+++ b/.github/scripts/tests.sh
@@ -9,11 +9,12 @@
# unit, ci-checks, functional and end2end tests, each family of target tests
# in a VM of its own, or one part of them: unit runs the unit and
# ci-checks tests, functional and end2end the tier of that name.
+# functional-ci-N runs shard N of the functional tests.
# With VM=0, setup installs only host test dependencies using the kernel
# CI artifact's BTF, and run leaves out target VMs. CI supplies this artifact
# built from testing/kernel.
#
-# .github/scripts/tests.sh setup|run [unit|functional|end2end]
+# .github/scripts/tests.sh setup|run [unit|functional|functional-ci-[1-4]|end2end]
#
# Runs as a user with passwordless sudo, from the checkout.
@@ -117,7 +118,7 @@ setup() {
case "${1:-}" in
setup|run) ;;
*)
- echo "usage: $0 setup|run [unit|functional|end2end]" >&2
+ echo "usage: $0 setup|run [unit|functional|functional-ci-[1-4]|end2end]" >&2
exit 2
;;
esac
@@ -126,8 +127,9 @@ case "${2:-}" in
'') goals=tests ;;
unit) goals='-C testing unit ci-checks' ;;
functional|end2end) goals="-C testing $2" ;;
+functional-ci-[1-4]) goals="-C testing -k $2" ;;
*)
- echo "usage: $0 setup|run [unit|functional|end2end]" >&2
+ echo "usage: $0 setup|run [unit|functional|functional-ci-[1-4]|end2end]" >&2
exit 2
;;
esac
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index c3ac2669..c79664d4 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -70,7 +70,7 @@ jobs:
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: build/test-vm/cache
- key: test-vm-images-${{ hashFiles('testing/vm/runtime-packages', 'testing/vm/operator-packages', 'testing/vm/prepare-runtime.sh', 'testing/vm/build-bundle.sh', 'testing/vm/arch.sh', '.github/scripts/install-clang.sh', '.github/scripts/install-static-libcrypto-deps.sh', 'testing/container/Containerfile', 'testing/container/packages', 'Makefile.target-deps') }}
+ key: test-vm-runtime-and-operator-${{ hashFiles('testing/vm/runtime-packages', 'testing/vm/operator-packages', 'testing/vm/prepare-runtime.sh', 'testing/vm/build-bundle.sh', 'testing/vm/arch.sh', '.github/scripts/install-clang.sh', '.github/scripts/install-static-libcrypto-deps.sh', 'testing/container/Containerfile', 'testing/container/packages', 'Makefile.target-deps') }}
- name: Prepare the test environment
id: setup
diff --git a/.github/workflows/guides-linux.yml b/.github/workflows/guides-linux.yml
index 293c055e..6f03c033 100644
--- a/.github/workflows/guides-linux.yml
+++ b/.github/workflows/guides-linux.yml
@@ -62,7 +62,7 @@ jobs:
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: build/test-vm/cache
- key: test-vm-images-${{ hashFiles('testing/vm/runtime-packages', 'testing/vm/operator-packages', 'testing/vm/prepare-runtime.sh', 'testing/vm/build-bundle.sh', 'testing/vm/arch.sh', '.github/scripts/install-clang.sh', '.github/scripts/install-static-libcrypto-deps.sh', 'testing/container/Containerfile', 'testing/container/packages', 'Makefile.target-deps') }}
+ key: test-vm-runtime-and-operator-${{ hashFiles('testing/vm/runtime-packages', 'testing/vm/operator-packages', 'testing/vm/prepare-runtime.sh', 'testing/vm/build-bundle.sh', 'testing/vm/arch.sh', '.github/scripts/install-clang.sh', '.github/scripts/install-static-libcrypto-deps.sh', 'testing/container/Containerfile', 'testing/container/packages', 'Makefile.target-deps') }}
- name: Prepare the test environment
env:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index ffce970a..fe05cda0 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -56,12 +56,34 @@ jobs:
fail-fast: false
matrix:
include:
- - name: CI tests
+ - name: CI unit tests
+ runner: ubuntu-latest
+ vm: '0'
+ suite: unit
+ - name: CI functional tests (shard 1)
+ runner: ubuntu-latest
+ vm: '1'
+ suite: functional-ci-1
+ - name: CI functional tests (shard 2)
runner: ubuntu-latest
vm: '1'
+ suite: functional-ci-2
+ - name: CI functional tests (shard 3)
+ runner: ubuntu-latest
+ vm: '1'
+ suite: functional-ci-3
+ - name: CI functional tests (shard 4)
+ runner: ubuntu-latest
+ vm: '1'
+ suite: functional-ci-4
+ - name: CI end-to-end tests
+ runner: ubuntu-latest
+ vm: '1'
+ suite: end2end
- name: CI host tests (arm64)
runner: ubuntu-24.04-arm
vm: '0'
+ suite: host
env:
VM: ${{ matrix.vm }}
@@ -118,7 +140,7 @@ jobs:
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: build/test-vm/cache
- key: test-vm-images-${{ hashFiles('testing/vm/runtime-packages', 'testing/vm/operator-packages', 'testing/vm/prepare-runtime.sh', 'testing/vm/build-bundle.sh', 'testing/vm/arch.sh', '.github/scripts/install-clang.sh', '.github/scripts/install-static-libcrypto-deps.sh', 'testing/container/Containerfile', 'testing/container/packages', 'Makefile.target-deps') }}
+ key: test-vm-runtime-and-operator-${{ hashFiles('testing/vm/runtime-packages', 'testing/vm/operator-packages', 'testing/vm/prepare-runtime.sh', 'testing/vm/build-bundle.sh', 'testing/vm/arch.sh', '.github/scripts/install-clang.sh', '.github/scripts/install-static-libcrypto-deps.sh', 'testing/container/Containerfile', 'testing/container/packages', 'Makefile.target-deps') }}
- name: Prepare the test environment
id: setup
@@ -127,44 +149,25 @@ jobs:
run: .github/scripts/tests.sh setup
- name: Run unit tests
- id: unit
+ if: matrix.suite == 'unit' || matrix.suite == 'host'
run: .github/scripts/tests.sh run unit
- - name: Upload unit guest logs
- if: always() && steps.unit.outcome == 'failure'
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
- with:
- name: guest-logs-unit
- path: |
- build/test-vm/vms/*/result
- build/test-vm/vms/*/console.log
- if-no-files-found: ignore
-
- - name: Run functional tests
- id: functional
- if: ${{ !cancelled() && steps.setup.outcome == 'success' }}
+ - name: Run host functional tests
+ if: ${{ !cancelled() && steps.setup.outcome == 'success' && matrix.suite == 'host' }}
run: .github/scripts/tests.sh run functional
- - name: Upload functional guest logs
- if: always() && steps.functional.outcome == 'failure'
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
- with:
- name: guest-logs-functional
- path: |
- build/test-vm/vms/*/result
- build/test-vm/vms/*/console.log
- if-no-files-found: ignore
-
- - name: Run end-to-end tests
- id: end2end
- if: ${{ !cancelled() && steps.setup.outcome == 'success' && matrix.vm == '1' }}
- run: .github/scripts/tests.sh run end2end
+ - name: Run selected test suite
+ if: matrix.vm == '1'
+ id: suite
+ env:
+ TEST_SUITE: ${{ matrix.suite }}
+ run: .github/scripts/tests.sh run "$TEST_SUITE"
- - name: Upload end-to-end guest logs
- if: always() && steps.end2end.outcome == 'failure'
+ - name: Upload guest logs
+ if: always() && steps.suite.outcome == 'failure'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
- name: guest-logs-end2end
+ name: guest-logs-${{ matrix.suite }}
path: |
build/test-vm/vms/*/result
build/test-vm/vms/*/console.log
@@ -193,11 +196,10 @@ jobs:
path: build/host-libtpms
key: ${{ steps.host-libtpms.outputs.cache-primary-key }}
- # hashFiles reads every byte it matches and gives up after two
- # minutes, too short for an image; the key file beside one is
- # written once the image is complete.
+ # Only end-to-end builds the operator image. Save the shared cache
+ # from that job once the image's key file marks it complete.
- name: Save the VM images
- if: always() && matrix.vm == '1' && steps.images.outputs.cache-hit != 'true' && hashFiles('build/test-vm/cache/runtime/.*.key') != ''
+ if: always() && matrix.suite == 'end2end' && steps.images.outputs.cache-hit != 'true' && hashFiles('build/test-vm/cache/runtime/.operator-*.key') != ''
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: build/test-vm/cache
diff --git a/Documentation/contribute/code/developer-guide.rst b/Documentation/contribute/code/developer-guide.rst
index 0b8d902a..ff3f3011 100644
--- a/Documentation/contribute/code/developer-guide.rst
+++ b/Documentation/contribute/code/developer-guide.rst
@@ -549,11 +549,14 @@ the commit at ``HEAD`` alone without them.
``shirudo-gen-runtime`` holds the target binary, and how much
space it leaves. When it fails, raise ``size=`` in
:src:`tools/gen-image/shirudo-gen-runtime`.
- * - ``tests.sh setup|run [unit|functional|end2end]``
+ * - ``tests.sh setup|run [unit|functional|functional-ci-N|end2end]``
- Prepares a CI runner as the VM host and runs ``make tests``, or
one part of it: ``unit`` runs the unit and ``ci-checks`` tests,
- ``functional`` and ``end2end`` the tier of that name. The ``CI
- suite`` workflow runs the three parts as checks of their own.
+ ``functional`` and ``end2end`` the tier of that name.
+ ``functional-ci-N`` runs one of the four functional shards,
+ where ``N`` is 1 through 4. The ``CI suite`` workflow runs
+ the unit and script checks, functional shards, and end-to-end
+ tests in parallel on x86-64.
With ``VM=0``, setup uses the kernel CI artifact's BTF and installs
only host test dependencies. The arm64 job uses this to run unit,
``ci-checks`` and host functional tests without target VMs.
diff --git a/Documentation/contribute/testing/testing.rst b/Documentation/contribute/testing/testing.rst
index f292bf61..09878fc5 100644
--- a/Documentation/contribute/testing/testing.rst
+++ b/Documentation/contribute/testing/testing.rst
@@ -52,6 +52,12 @@ Before you begin
operator's build dependencies, a JDK among them, to the image of the
operator VM.
+The ``CI suite`` workflow runs the x86-64 unit and script checks,
+four functional shards, and the end-to-end tests in parallel jobs.
+The functional shards run upatch, tamperproof, the BPM families, and
+the remaining families. The arm64 host job runs unit, script, and host
+functional tests together.
+
The ``CI suite`` workflow uses the x86-64 CI kernel package.
:src:`testing/vm/kernel-artifact.sh` pins its build run ID and checksums.
When a change touches the kernel build inputs, CI builds packages for
diff --git a/testing/Makefile b/testing/Makefile
index 44fc4aaa..bbbe24bb 100644
--- a/testing/Makefile
+++ b/testing/Makefile
@@ -280,11 +280,14 @@ family-list = $(shell cd $(ROOT)/testing/functional && \
ls */t[0-9]$(1)[0-9][0-9]-*.sh | \
awk -F/ '{ print substr($$2, 2, 1), $$1 }' | sort -u | cut -d' ' -f2)
FAMILIES := $(call family-list,[0-9])
+CI_BPM_FAMILIES := $(filter bpm bpm-%,$(FAMILIES))
VM_SUITES := $(call family-list,1) end2end
# The host runs the end-to-end VM's target tests over SSH, where it can act
# between them; the families' VMs run theirs themselves.
VM_SERVE_SUITES := end2end
-vm-tests = $(if $(filter 0,$(VM)),:,$(MAKE) $(addprefix vm-test-,$(1)))
+vm-tests = $(if $(strip $(1)),$(if $(filter 0,$(VM)),:,\
+ $(MAKE) $(addprefix vm-test-,$(1))),:)
+.PHONY: functional-ci-1 functional-ci-2 functional-ci-3 functional-ci-4
.PHONY: $(addprefix unit/,$(UNIT_SUITES)) $(addprefix functional/,$(FAMILIES)) \
$(addprefix vm-test-,register $(VM_SUITES)) vm-node-end2end
@@ -316,6 +319,13 @@ $(addprefix functional/,$(FAMILIES)): functional/%: build-operator
$(Q)$(ROOT)/testing/run-tests.sh functional/$*
+$(Q)$(call vm-tests,$(filter $*,$(VM_SUITES)))
+# Keep the slow upatch and tamperproof VMs on their own runners. The last
+# shard also picks up new families outside BPM.
+functional-ci-1: functional/upatch
+functional-ci-2: functional/tamperproof
+functional-ci-3: $(addprefix functional/,$(CI_BPM_FAMILIES))
+functional-ci-4: $(addprefix functional/,$(filter-out upatch tamperproof $(CI_BPM_FAMILIES),$(FAMILIES)))
+
# The end-to-end test boots the operator VM, which builds the operator
# package and alone gets the signing key on its own disk; while it serves,
# host.sh has it publish kernel-obs, runs node A and has it verify what
@@ -439,6 +449,7 @@ help:
' make -C testing unit[/<suite>] suites: $(UNIT_SUITES)' \
' make -C testing ci-checks the scripts CI runs' \
' make -C testing functional[/<family>] families: $(FAMILIES)' \
+ ' make -C testing functional-ci-<1-4> one CI functional shard' \
' make -C testing end2end' \
' make -C testing backend the SQL tests of tools/backend' \
' TEST_FILTER=<regex> selects test filenames (empty runs everything).' \