From 84e2a0c829d1ea926e422c868e49335e363c28c1 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sat, 27 Jun 2026 17:11:39 +0200 Subject: [PATCH] nix(loadtest): generate targets at nix build time Instead of generating them at loadtest runtime, we generate these dynamic targets once via Nix. Because we're using libfaketime, we're not bound to doing it at the same time as running the tests. This allows us to run each loadtest right after each other, with minimal other stuff going on inbetween. It's also a tiny bit more reproducible, because the loadtests against both branches run with exactly the same set of targets, where they did not before. --- nix/tools/loadtest.nix | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/nix/tools/loadtest.nix b/nix/tools/loadtest.nix index 27fe35566..9ceb0e48e 100644 --- a/nix/tools/loadtest.nix +++ b/nix/tools/loadtest.nix @@ -3,7 +3,9 @@ , git , jq , libfaketime +, python3 , python3Packages +, runCommand , vegeta , withTools , writers @@ -65,15 +67,13 @@ let case "$_arg_kind" in jwt-cache) - export PGRST_JWT_SECRET="@test/load/gen_jwks.json" - - ${libfaketime}/bin/faketime '2000-01-01 00:00:00' ${genTargets} test/load + export PGRST_JWT_SECRET="@${generatedTargets}/gen_jwks.json" # shellcheck disable=SC2145 ${withTools.withPg} -f test/load/fixtures.sql \ ${withTools.withPgrst} --faketime '2000-01-01 00:00:00' -m "$_arg_monitor" \ sh -c "cd test/load && \ - ${runner} -targets gen_targets.http -output \"$abs_output\" \"''${_arg_leftovers[@]}\"" + ${runner} -targets ${generatedTargets}/gen_targets.http -output \"$abs_output\" \"''${_arg_leftovers[@]}\"" ;; # here we sleep purposefully to check how much memory does the schema cache consume in the final report @@ -291,13 +291,15 @@ let | ${mergeMonitorResults} ''; - genTargets = - writers.writePython3 "postgrest-gen-loadtest-targets" + generatedTargets = + runCommand "postgrest-loadtest-targets" { - libraries = [ python3Packages.jwcrypto ]; - doCheck = false; # postgrest-style conflicts with this + nativeBuildInputs = [ (python3.withPackages (pyps: [ pyps.jwcrypto ])) ]; } - (builtins.readFile ./generate_targets.py); + '' + mkdir -p "$out" + ${libfaketime}/bin/faketime '2000-01-01 00:00:00' python3 ${./generate_targets.py} "$out" + ''; mergeMonitorResults = writers.writePython3 "postgrest-merge-monitor-results"