diff options
Diffstat (limited to 'pkgs/populate/tests/scenarios.nix')
| -rw-r--r-- | pkgs/populate/tests/scenarios.nix | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/pkgs/populate/tests/scenarios.nix b/pkgs/populate/tests/scenarios.nix index 0c0ce9e..7fa0964 100644 --- a/pkgs/populate/tests/scenarios.nix +++ b/pkgs/populate/tests/scenarios.nix @@ -2496,4 +2496,59 @@ in ]) ]) targetKinds; + # A benchmark: 100 sources, 50 file, 30 symlink, and 20 git ones, + # delivered once and then twice with nothing to change, whose times the + # log shows. Locally, and to a remote target with 30 ms of delay on its + # interfaces, which the scenario sets up, and which lasts for the rest + # of the test, so the bench test runs these alone, and nix-build tests + # doesn't. + bench = let + n = lib.fixedWidthNumber 2; + count = lib.range 1; + names = prefix: k: map (i: "${prefix}${n i}") (count k); + sources = + lib.genAttrs (names "f" 50) (name: { file = "/bench/${name}"; }) // + lib.listToAttrs (lib.zipListsWith + (name: target: lib.nameValuePair name { symlink = target; }) + (names "s" 30) (names "f" 30)) // + lib.genAttrs (names "g" 20) (_: { git = { url = gitUrl; ref = gitHead; }; }); + nothingChanged = '' + expect_eq changed "$(record changed)" false + ''; + in map (targetKind: scenario { + name = "bench-${targetKind}"; + inherit targetKind; + # Directories of 11 files each, for the file sources. + prepareDeployer = '' + for i in $(seq -w 1 50); do + if ! test -e /bench/f$i; then + mkdir -p /bench/f$i/sub + for j in $(seq 1 10); do + echo "$i $j" > /bench/f$i/sub/$j + done + echo "$i" > /bench/f$i/top + fi + done + ''; + prepare = lib.optionalString (targetKind == "remote") '' + for dev in $(ls /sys/class/net); do + if test "$dev" != lo; then + tc qdisc replace dev "$dev" root netem delay 30ms + fi + done + ''; + phases = [ + { + inherit sources; + check = '' + test -e "$T"/f50/sub/10 || fail "f50 missing" + expect_eq s30 "$(readlink "$T"/s30)" f30 + expect_eq g20 "$(git -C "$T"/g20 rev-parse HEAD)" ${gitHead} + ''; + } + { inherit sources; check = nothingChanged; } + { inherit sources; check = nothingChanged; } + ]; + }) [ "local" "remote" ]; + } |
