at 23.05-pre 2.0 kB view raw
1import ./make-test-python.nix ({ pkgs, ... }: { 2 name = "tracee-integration"; 3 nodes = { 4 machine = { config, pkgs, ... }: { 5 # EventFilters/trace_only_events_from_new_containers requires docker 6 # podman with docker compat will suffice 7 virtualisation.podman.enable = true; 8 virtualisation.podman.dockerCompat = true; 9 10 environment.systemPackages = [ 11 # build the go integration tests as a binary 12 (pkgs.tracee.overrideAttrs (oa: { 13 pname = oa.pname + "-integration"; 14 patches = oa.patches or [] ++ [ 15 # change the prefix from /usr/bin to /run to find nix processes 16 ../../pkgs/tools/security/tracee/test-EventFilters-prefix-nix-friendly.patch 17 ]; 18 buildPhase = '' 19 runHook preBuild 20 # just build the static lib we need for the go test binary 21 make $makeFlags ''${enableParallelBuilding:+-j$NIX_BUILD_CORES -l$NIX_BUILD_CORES} bpf-core ./dist/btfhub 22 23 # remove the /usr/bin prefix to work with the patch above 24 substituteInPlace tests/integration/integration_test.go \ 25 --replace "/usr/bin/ls" "ls" 26 27 # then compile the tests to be ran later 28 CGO_LDFLAGS="$(pkg-config --libs libbpf)" go test -tags core,ebpf,integration -p 1 -c -o $GOPATH/tracee-integration ./tests/integration/... 29 runHook postBuild 30 ''; 31 doCheck = false; 32 installPhase = '' 33 mkdir -p $out/bin 34 cp $GOPATH/tracee-integration $out/bin 35 ''; 36 doInstallCheck = false; 37 })) 38 ]; 39 }; 40 }; 41 42 testScript = '' 43 with subtest("run integration tests"): 44 # EventFilters/trace_only_events_from_new_containers also requires a container called "alpine" 45 machine.succeed('tar cv -C ${pkgs.pkgsStatic.busybox} . | podman import - alpine --change ENTRYPOINT=sleep') 46 47 print(machine.succeed('TRC_BIN="${pkgs.tracee}" tracee-integration -test.v')) 48 ''; 49})