From 083cd28e5775ce3ce766c063835e97813c84e447 Mon Sep 17 00:00:00 2001 From: AV Date: Tue, 30 Sep 2025 16:30:37 +0000 Subject: [PATCH] test: allow to cache results of image and integration tests --- Makefile | 39 ++++++++++++++++++++------------------- test/e2e/BUILD | 7 +++++++ test/image/BUILD | 2 ++ 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index de5e148a3b..09b0fa845a 100644 --- a/Makefile +++ b/Makefile @@ -232,12 +232,12 @@ nogo-tests: # # FIXME(gvisor.dev/issue/10045): Need to fix broken tests. unit-tests: ## Local package unit tests in pkg/..., tools/.., etc. - @$(call test,--test_tag_filters=-nogo$(COMMA)-requires-kvm --build_tag_filters=-network_plugins -- //:all pkg/... tools/... runsc/... vdso/... test/trace/... -//pkg/metric:metric_test -//pkg/coretag:coretag_test -//tools/tracereplay:tracereplay_test -//test/trace:trace_test) + @$(call test,--test_tag_filters=-nogo$(COMMA)-requires-kvm --build_tag_filters=-network_plugins --test_env=CGROUPV2=$(CGROUPV2) -- //:all pkg/... tools/... runsc/... vdso/... test/trace/... -//pkg/metric:metric_test -//pkg/coretag:coretag_test -//tools/tracereplay:tracereplay_test -//test/trace:trace_test) .PHONY: unit-tests # See unit-tests: this includes runsc/container. container-tests: ## Run all tests in runsc/container/... - @$(call test,--test_tag_filters=-nogo runsc/container/...) + @$(call test,--test_tag_filters=-nogo --test_env=CGROUPV2=$(CGROUPV2) runsc/container/...) .PHONY: container-tests tests: ## Runs all unit tests and syscall tests. @@ -366,45 +366,46 @@ docker-tests: load-basic $(RUNTIME_BIN) @$(call install_runtime,$(RUNTIME)-host-uds,--host-uds=all) # Used by TestHostSocketConnect. @$(call install_runtime,$(RUNTIME)-overlay,--overlay2=all:self) # Used by TestOverlay*. @$(call install_runtime,$(RUNTIME)-save-restore-netstack,--save-restore-netstack=true) # Used by TestRestoreListenConnWithNetstackSR. - @$(call test_runtime,$(RUNTIME),$(INTEGRATION_TARGETS) --test_env=TEST_SAVE_RESTORE_NETSTACK=true //test/e2e:integration_runtime_test //test/e2e:runtime_in_docker_test) + @$(call test_runtime_cached,$(RUNTIME),$(INTEGRATION_TARGETS) --test_env=TEST_SAVE_RESTORE_NETSTACK=true //test/e2e:integration_runtime_test //test/e2e:runtime_in_docker_test) .PHONY: docker-tests plugin-network-tests: load-basic $(RUNTIME_BIN) - @$(call install_runtime,$(RUNTIME),--network=plugin) - @$(call test_runtime,$(RUNTIME), --test_arg=-test.run=ConnectToSelf $(INTEGRATION_TARGETS)) + @$(call install_runtime,$(RUNTIME)-dpdk,--network=plugin) + @$(call test_runtime_cached,$(RUNTIME)-dpdk, --test_arg=-test.run=ConnectToSelf $(INTEGRATION_TARGETS)) plugin-network-tests: RUNSC_TARGET=--config plugin-tldk //runsc:runsc-plugin-stack overlay-tests: load-basic $(RUNTIME_BIN) - @$(call install_runtime,$(RUNTIME),--overlay2=all:dir=/tmp) - @$(call install_runtime,$(RUNTIME)-docker,--net-raw --overlay2=all:dir=/tmp) - @$(call test_runtime,$(RUNTIME),--test_env=TEST_OVERLAY=true $(INTEGRATION_TARGETS)) + @$(call install_runtime,$(RUNTIME)-overlay,--overlay2=all:dir=/tmp) + @$(call install_runtime,$(RUNTIME)-overlay-docker,--net-raw --overlay2=all:dir=/tmp) + @$(call test_runtime_cached,$(RUNTIME)-overlay,--test_env=TEST_OVERLAY=true $(INTEGRATION_TARGETS)) .PHONY: overlay-tests swgso-tests: load-basic $(RUNTIME_BIN) - @$(call install_runtime,$(RUNTIME),--software-gso=true --gso=false) - @$(call install_runtime,$(RUNTIME)-docker,--net-raw --software-gso=true --gso=false) - @$(call test_runtime,$(RUNTIME),$(INTEGRATION_TARGETS)) + @$(call install_runtime,$(RUNTIME)-swgso,--software-gso=true --gso=false) + @$(call install_runtime,$(RUNTIME)-swgso-docker,--net-raw --software-gso=true --gso=false) + @$(call test_runtime_cached,$(RUNTIME)-swgso,$(INTEGRATION_TARGETS)) .PHONY: swgso-tests hostnet-tests: load-basic $(RUNTIME_BIN) - @$(call install_runtime,$(RUNTIME),--network=host --net-raw) - @$(call test_runtime,$(RUNTIME),--test_env=TEST_CHECKPOINT=false --test_env=TEST_HOSTNET=true --test_env=TEST_NET_RAW=true $(INTEGRATION_TARGETS)) + @$(call install_runtime,$(RUNTIME)-hostnet,--network=host --net-raw) + @$(call test_runtime_cached,$(RUNTIME)-hostnet,--test_env=TEST_CHECKPOINT=false --test_env=TEST_HOSTNET=true --test_env=TEST_NET_RAW=true $(INTEGRATION_TARGETS)) .PHONY: hostnet-tests kvm-tests: load-basic $(RUNTIME_BIN) @(lsmod | grep -E '^(kvm_intel|kvm_amd)') || sudo modprobe kvm @if ! test -w /dev/kvm; then sudo chmod a+rw /dev/kvm; fi @$(call test,//pkg/sentry/platform/kvm:kvm_test) - @$(call install_runtime,$(RUNTIME),--platform=kvm) - @$(call install_runtime,$(RUNTIME)-docker,--net-raw --platform=kvm) - @$(call test_runtime,$(RUNTIME),$(INTEGRATION_TARGETS)) + @$(call install_runtime,$(RUNTIME)-kvm,--platform=kvm) + @$(call install_runtime,$(RUNTIME)-kvm-docker,--net-raw --platform=kvm) + @$(call test_runtime_cached,$(RUNTIME)-kvm,$(INTEGRATION_TARGETS)) .PHONY: kvm-tests systrap-tests: load-basic $(RUNTIME_BIN) - @$(call install_runtime,$(RUNTIME),--platform=systrap) - @$(call install_runtime,$(RUNTIME)-docker,--net-raw --platform=systrap) - @$(call test_runtime,$(RUNTIME),$(INTEGRATION_TARGETS)) + @$(call install_runtime,$(RUNTIME)-systrap,--platform=systrap) + @$(call install_runtime,$(RUNTIME)-systrap-docker,--net-raw --platform=systrap) + @$(call test_runtime_cached,$(RUNTIME)-systrap,$(INTEGRATION_TARGETS)) + @$(call test_runtime_cached,$(RUNTIME)-systrap,-s $(INTEGRATION_TARGETS)) .PHONY: systrap-tests iptables-tests: load-iptables $(RUNTIME_BIN) diff --git a/test/e2e/BUILD b/test/e2e/BUILD index ca43d3c6c4..58b14750a1 100644 --- a/test/e2e/BUILD +++ b/test/e2e/BUILD @@ -19,6 +19,9 @@ go_test( "manual", ], visibility = ["//:sandbox"], + + # runsc is needed to invalidate the bazel cache in case of any code changes. + data = ["//runsc"], deps = [ "//pkg/abi/linux", "//pkg/sentry/kernel/auth", @@ -31,6 +34,8 @@ go_test( ) go_test( + # runsc is needed to invalidate the bazel cache in case of any code changes. + data = ["//runsc"], name = "integration_runtime_test", size = "large", srcs = [ @@ -53,6 +58,8 @@ go_test( ) go_test( + # runsc is needed to invalidate the bazel cache in case of any code changes. + data = ["//runsc"], name = "runtime_in_docker_test", size = "large", srcs = [ diff --git a/test/image/BUILD b/test/image/BUILD index ae34c61849..a53798cdea 100644 --- a/test/image/BUILD +++ b/test/image/BUILD @@ -16,6 +16,8 @@ go_test( "mysql.sql", "ruby.rb", "ruby.sh", + # runsc is needed to invalidate the bazel cache in case of any code changes. + "//runsc", ], library = ":image", tags = [