From 803c96a702afbf9f6562117c7747e1fec0123c11 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Thu, 9 Jun 2022 10:11:21 +0200 Subject: [PATCH] nix: more explicit logging in load test (fixes #2308) * Write vegeta output to file explicitly. The previous version using `tee` captured the standard output of the `withPgrst` helper, too, causing weird errors when those had unexpected output. * Log and fail the postgrest build explicitly. In situations such as changing nix dependencies, the `cabal build` run could fail, but this wasn't visible in CI. With these changes, the load test now fails with a nice error message when the build fails. --- nix/tools/loadtest.nix | 5 ++--- nix/tools/withTools.nix | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/nix/tools/loadtest.nix b/nix/tools/loadtest.nix index 0f097a113b7..742e8525c11 100644 --- a/nix/tools/loadtest.nix +++ b/nix/tools/loadtest.nix @@ -60,9 +60,8 @@ let # shellcheck disable=SC2145 ${withTools.withPg} --fixtures "$_arg_testdir"/fixtures.sql \ ${withTools.withPgrst} \ - sh -c "cd \"$_arg_testdir\" && ${runner} -targets targets.http \"''${_arg_leftovers[@]}\"" \ - | tee "$_arg_output" \ - | ${vegeta}/bin/vegeta report -type=text + sh -c "cd \"$_arg_testdir\" && ${runner} -targets targets.http -output \"$_arg_output\" \"''${_arg_leftovers[@]}\"" + ${vegeta}/bin/vegeta report -type=text "$_arg_output" ''; loadtestAgainst = diff --git a/nix/tools/withTools.nix b/nix/tools/withTools.nix index 816c7105a7f..a19b97f2895 100644 --- a/nix/tools/withTools.nix +++ b/nix/tools/withTools.nix @@ -244,7 +244,16 @@ let '' export PGRST_SERVER_UNIX_SOCKET="$tmpdir"/postgrest.socket - ${cabal-install}/bin/cabal v2-build ${devCabalOptions} > "$tmpdir"/build.log 2>&1 + echo -n "Building postgrest... " + ${cabal-install}/bin/cabal v2-build ${devCabalOptions} > "$tmpdir"/build.log 2>&1 \ + || { + echo "failed, output:" + cat "$tmpdir"/build.log + exit 1 + } + echo "done." + + echo "Starting postgrest... " ${cabal-install}/bin/cabal v2-run ${devCabalOptions} --verbose=0 -- \ postgrest ${legacyConfig} > "$tmpdir"/run.log 2>&1 & @@ -256,7 +265,12 @@ let } trap cleanup EXIT - timeout -s TERM 5 ${waitForPgrstReady} + timeout -s TERM 5 ${waitForPgrstReady} || { + echo "timed out, output:" + cat "$tmpdir"/run.log + exit 1 + } + echo "done." ("$_arg_command" "''${_arg_leftovers[@]}") '';