Avoid running pkg/datapath/linux tests twice in CI Conformance Runtime
https://github.com/cilium/cilium/pull/39250 fixed the tests-privileged Makefile target used in ci-runtime workflow to run privileged tests. Because pkg/datapath/linux package is now part of the UNPARALLELTESTPKGS variable, all the tests in the linux node package, except for the ones in node_linux_test.go are executed twice.
The recipe for tests-privileged is:
https://github.com/cilium/cilium/blob/07f37d3a5b0d0158c7a137690a961c18fae05a2c/Makefile#L83-L95
TESTPKGS and UNPARALLELTESTPKGS are defined as:
https://github.com/cilium/cilium/blob/07f37d3a5b0d0158c7a137690a961c18fae05a2c/Makefile#L38-L39
So, the first run of go test runs all the tests under pkg/datapath/linux once (except for the ones in node_linux_test.go, that is tagged with //go:build unparallel) while the second run of go test will run again the tests under pkg/datapath/linux, this time including the ones in node_linux_test.go. All the tests in linux subpackages are therefore run twice.
A possible way to fix this is to:
- move the functions to setup the test environment used in both
TestNodeChurnXFRMLeaksEncryptedOverlayand the other tests in/pkg/datapath/linuxinto a file without any build tag. This will be built in both cases: with and without theunparalleltag. - move
TestNodeChurnXFRMLeaksEncryptedOverlay(the only test that should not run in parallel with other tests, see https://github.com/cilium/cilium/pull/38172) in a separate file to be tagged with//go:build unparallel. - tag all the other test files in
/pkg/datapath/linuxwith//go:build !unparallel.
Source: cilium/cilium