criu/scripts/ci/Makefile
Adrian Reber 4d76d1acdc ci: shard alpine-test into parallel jobs to reduce CI time
The alpine-test CI job runs all ~483 zdtm tests sequentially three
times (normal, mntns-compat-mode, criu-config), followed by many
non-shardable tests. This dominates overall CI wait time. With only
2 jobs running in parallel (GCC and CLANG) the alpine tests take
around 30 minutes.

Use the existing --test-shard-index and --test-shard-count flags
already built into test/zdtm.py to split the zdtm test suite across
four parallel runners (shards 0-3). A fifth shard runs all
non-shardable tests (lazy pages, fault injection, test/others/*,
rootless, compel, plugins, etc.) independently and in parallel with
the zdtm shards. This increases parallelism from 2 to 10 jobs and
reduces the alpine test wall-clock time from ~30 to ~10 minutes.

Changes:
- run-ci-tests.sh: Build SHARD_OPTS from ZDTM_SHARD_INDEX/COUNT
  env vars and pass them to zdtm.py. Extract all non-shardable
  tests into a run_non_shardable_tests() function. Dispatch based
  on shard index: 0-3 run zdtm slices, 4 runs non-shardable
  tests, unset runs everything sequentially (preserving existing
  behavior). Validate that ZDTM_SHARD_INDEX is set when
  ZDTM_SHARD_COUNT is set.
- Makefile: Pass ZDTM_SHARD_INDEX and ZDTM_SHARD_COUNT into the
  container when set. Split long container run command across
  multiple lines for readability.
- ci.yml: Add shard: [0, 1, 2, 3, 4] to the alpine-test matrix,
  producing 10 jobs (2 compilers x 5 shards). Job labels now show
  descriptive shard names (e.g. "zdtm 1/4", "non-zdtm") instead
  of raw indices.

When sharding is not configured the script behaves identically to
before, so other CI jobs (aarch64, compat, gcov, etc.) are
unaffected.

Assisted-by: Claude:claude-opus-4-6
Signed-off-by: Adrian Reber <areber@redhat.com>
2026-05-24 07:19:51 +01:00

105 lines
2.5 KiB
Makefile

local:
./run-ci-tests.sh
.PHONY: local
after_success:
./ci-after-success.sh
.PHONY: after_success
target-suffix =
ifdef CLANG
target-suffix = -clang
endif
TARGETS := alpine fedora-rawhide archlinux
ZDTM_OPTS :=
UNAME := $(shell uname -m)
export UNAME
CONTAINER_RUNTIME := docker
export CONTAINER_RUNTIME
alpine: ZDTM_OPTS=-x zdtm/static/sched_policy00
ifeq ($(GITHUB_ACTIONS),true)
# GitHub Actions does not give us a real TTY and errors out with
# 'the input device is not a TTY' if using '-t'
CONTAINER_TERMINAL := -i
else
CONTAINER_TERMINAL := -it
endif
export CONTAINER_TERMINAL
# Here we assume that any CPU architecture besides x86_64 is running in containers
# that may not support running docker with '--privileged'.
ifeq ($(UNAME),x86_64)
CONTAINER_OPTS := --rm $(CONTAINER_TERMINAL) --privileged --userns=host --cgroupns=host -v /lib/modules:/lib/modules --tmpfs /run
else
CONTAINER_OPTS := --rm -v /lib/modules:/lib/modules --tmpfs /run
endif
ifeq ($(CONTAINER_RUNTIME),podman)
# Podman limits the number of processes in a container using cgroups.
# Disable it as it breaks the thread-bomb test
CONTAINER_OPTS += --pids-limit=-1
CONTAINER_OPTS += --ulimit nproc=-1:-1
endif
export ZDTM_OPTS
export ZDTM_SHARD_INDEX
export ZDTM_SHARD_COUNT
$(TARGETS):
$(MAKE) -C ../build $@$(target-suffix)
$(CONTAINER_RUNTIME) run \
--env-file docker.env \
-v `pwd`/../../:/criu \
$(if $(ZDTM_OPTS),-e ZDTM_OPTS) \
$(if $(ZDTM_SHARD_INDEX),-e ZDTM_SHARD_INDEX) \
$(if $(ZDTM_SHARD_COUNT),-e ZDTM_SHARD_COUNT) \
$(CONTAINER_OPTS) \
criu-$@ scripts/ci/run-ci-tests.sh
fedora-asan:
$(MAKE) -C ../build $@$(target-suffix)
$(CONTAINER_RUNTIME) run $(CONTAINER_OPTS) -v `pwd`/../../:/criu criu-$@ ./scripts/ci/asan.sh $(ZDTM_OPTS)
docker-test:
./docker-test.sh
podman-test:
./podman-test.sh
java-test:
./java-test.sh
setup-vagrant:
./vagrant.sh setup
vagrant-fedora-no-vdso: setup-vagrant
./vagrant.sh fedora-no-vdso
vagrant-fedora-rawhide: setup-vagrant
./vagrant.sh fedora-rawhide
vagrant-fedora-non-root: setup-vagrant
./vagrant.sh fedora-non-root
.PHONY: setup-vagrant vagrant-fedora-no-vdso vagrant-fedora-rawhide vagrant-fedora-non-root
check-commit:
(cd ../.. && git clean -dfx)
($(MAKE) -j $$(nproc) -C ../.. && \
echo "Commit $$(git rev-parse --short HEAD) built successfully") || \
(echo "Build failed for $$(git rev-list -n 1 --pretty HEAD)" && \
exit 1)
.PHONY: check-commit
loongarch64-qemu-test:
./loongarch64-qemu-test.sh
.PHONY: loongarch64-qemu-test
%:
$(MAKE) -C ../build $@$(target-suffix)