tests: implement test for nix log with ssh-ng:// builds

A few notes:

* The `echo hi` is needed to make sure that a file that can be read by
  `nix log` is properly created (i.e. some output is needed). This is
  known and to be fixed in #6051.
* We explicitly ignore the floating-CA case here: the `$out` of `input3`
  depends on `$out` of `input2`. This means that there are actually two
  derivations - I assume that this is because at eval time (i.e.
  `nix-instantiate -A`) the hash of `input2` isn't known yet and the
  other .drv is created as soon as `input2` was built. This is another
  issue on its own, so we ignore the case here explicitly.
This commit is contained in:
Maximilian Bosch 2022-02-20 15:56:22 +01:00
parent cd92ea5885
commit 287642f132
No known key found for this signature in database
GPG key ID: 091DBF4D1FC46B8E
3 changed files with 20 additions and 8 deletions

View file

@ -11,13 +11,13 @@ let
args = ["sh" "-e" args.builder or (builtins.toFile "builder-${args.name}.sh" "if [ -e .attrs.sh ]; then source .attrs.sh; fi; eval \"$buildCommand\"")]; args = ["sh" "-e" args.builder or (builtins.toFile "builder-${args.name}.sh" "if [ -e .attrs.sh ]; then source .attrs.sh; fi; eval \"$buildCommand\"")];
outputHashMode = "recursive"; outputHashMode = "recursive";
outputHashAlgo = "sha256"; outputHashAlgo = "sha256";
} // removeAttrs args ["builder" "meta"]) } // removeAttrs args ["builder" "meta" "passthru"])
// { meta = args.meta or {}; }; // { meta = args.meta or {}; passthru = args.passthru or {}; };
input1 = mkDerivation { input1 = mkDerivation {
shell = busybox; shell = busybox;
name = "build-remote-input-1"; name = "build-remote-input-1";
buildCommand = "echo FOO > $out"; buildCommand = "echo hi; echo FOO > $out";
requiredSystemFeatures = ["foo"]; requiredSystemFeatures = ["foo"];
outputHash = "sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="; outputHash = "sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc=";
}; };
@ -25,7 +25,7 @@ let
input2 = mkDerivation { input2 = mkDerivation {
shell = busybox; shell = busybox;
name = "build-remote-input-2"; name = "build-remote-input-2";
buildCommand = "echo BAR > $out"; buildCommand = "echo hi; echo BAR > $out";
requiredSystemFeatures = ["bar"]; requiredSystemFeatures = ["bar"];
outputHash = "sha256-XArauVH91AVwP9hBBQNlkX9ccuPpSYx9o0zeIHb6e+Q="; outputHash = "sha256-XArauVH91AVwP9hBBQNlkX9ccuPpSYx9o0zeIHb6e+Q=";
}; };
@ -34,6 +34,7 @@ let
shell = busybox; shell = busybox;
name = "build-remote-input-3"; name = "build-remote-input-3";
buildCommand = '' buildCommand = ''
echo hi
read x < ${input2} read x < ${input2}
echo $x BAZ > $out echo $x BAZ > $out
''; '';
@ -46,6 +47,7 @@ in
mkDerivation { mkDerivation {
shell = busybox; shell = busybox;
name = "build-remote"; name = "build-remote";
passthru = { inherit input1 input2 input3; };
buildCommand = buildCommand =
'' ''
read x < ${input1} read x < ${input1}

View file

@ -9,20 +9,20 @@ let
inherit system; inherit system;
builder = busybox; builder = busybox;
args = ["sh" "-e" args.builder or (builtins.toFile "builder-${args.name}.sh" "if [ -e .attrs.sh ]; then source .attrs.sh; fi; eval \"$buildCommand\"")]; args = ["sh" "-e" args.builder or (builtins.toFile "builder-${args.name}.sh" "if [ -e .attrs.sh ]; then source .attrs.sh; fi; eval \"$buildCommand\"")];
} // removeAttrs args ["builder" "meta"]) } // removeAttrs args ["builder" "meta" "passthru"])
// { meta = args.meta or {}; }; // { meta = args.meta or {}; passthru = args.passthru or {}; };
input1 = mkDerivation { input1 = mkDerivation {
shell = busybox; shell = busybox;
name = "build-remote-input-1"; name = "build-remote-input-1";
buildCommand = "echo FOO > $out"; buildCommand = "echo hi; echo FOO > $out";
requiredSystemFeatures = ["foo"]; requiredSystemFeatures = ["foo"];
}; };
input2 = mkDerivation { input2 = mkDerivation {
shell = busybox; shell = busybox;
name = "build-remote-input-2"; name = "build-remote-input-2";
buildCommand = "echo BAR > $out"; buildCommand = "echo hi; echo BAR > $out";
requiredSystemFeatures = ["bar"]; requiredSystemFeatures = ["bar"];
}; };
@ -30,6 +30,7 @@ let
shell = busybox; shell = busybox;
name = "build-remote-input-3"; name = "build-remote-input-3";
buildCommand = '' buildCommand = ''
echo hi
read x < ${input2} read x < ${input2}
echo $x BAZ > $out echo $x BAZ > $out
''; '';
@ -41,6 +42,7 @@ in
mkDerivation { mkDerivation {
shell = busybox; shell = busybox;
name = "build-remote"; name = "build-remote";
passthru = { inherit input1 input2 input3; };
buildCommand = buildCommand =
'' ''
read x < ${input1} read x < ${input1}

View file

@ -54,6 +54,14 @@ nix path-info --store $TEST_ROOT/machine3 --all \
| grep -v builder-build-remote-input-2.sh \ | grep -v builder-build-remote-input-2.sh \
| grep builder-build-remote-input-3.sh | grep builder-build-remote-input-3.sh
if [[ -z "$CONTENT_ADDRESSED" ]]; then
for i in input1 input3; do
drv="$(nix-instantiate $file -A passthru.$i --store $TEST_ROOT/machine0 --arg busybox $busybox)"
nix log --store $TEST_ROOT/machine0 "$drv"
done
fi
# Behavior of keep-failed # Behavior of keep-failed
out="$(nix-build 2>&1 failing.nix \ out="$(nix-build 2>&1 failing.nix \
--builders "$(join_by '; ' "${builders[@]}")" \ --builders "$(join_by '; ' "${builders[@]}")" \