test: optionally build postgrest with cabal in postgrest-loadtest

By default, postgrest-with-pgrst builds postgrest as a nix package,
which means that source changes cause a full rebuild. With this
change, running the loadtest as

PGRST_BUILD_CABAL=1 postgrest-loadtest

rebuilds directly using cabal, like postgrest-build. Note that
results between nix and cabal builds aren't necessarily comparable
due to differing build parameters.
This commit is contained in:
Robert Vollmert
2023-03-20 15:00:11 +01:00
committed by Robert
parent 216dc833fd
commit e731241b97
4 changed files with 22 additions and 11 deletions
+3 -3
View File
@@ -122,6 +122,9 @@ rec {
cabalTools = cabalTools =
pkgs.callPackage nix/tools/cabalTools.nix { inherit devCabalOptions postgrest; }; pkgs.callPackage nix/tools/cabalTools.nix { inherit devCabalOptions postgrest; };
withTools =
pkgs.callPackage nix/tools/withTools.nix { inherit cabalTools devCabalOptions postgresqlVersions postgrest; };
# Development tools. # Development tools.
devTools = devTools =
pkgs.callPackage nix/tools/devTools.nix { inherit tests style devCabalOptions hsie withTools; }; pkgs.callPackage nix/tools/devTools.nix { inherit tests style devCabalOptions hsie withTools; };
@@ -154,9 +157,6 @@ rec {
inherit (pkgs.haskell.packages."${compiler}") hpc-codecov; inherit (pkgs.haskell.packages."${compiler}") hpc-codecov;
inherit (pkgs.haskell.packages."${compiler}") weeder; inherit (pkgs.haskell.packages."${compiler}") weeder;
}; };
withTools =
pkgs.callPackage nix/tools/withTools.nix { inherit devCabalOptions postgresqlVersions postgrest; };
} // pkgs.lib.optionalAttrs pkgs.stdenv.isLinux rec { } // pkgs.lib.optionalAttrs pkgs.stdenv.isLinux rec {
# Static executable. # Static executable.
inherit postgrestStatic; inherit postgrestStatic;
+3
View File
@@ -207,6 +207,9 @@ postgrest-loadtest-against master
# You can simulate latency client/postgrest and postgrest/database # You can simulate latency client/postgrest and postgrest/database
PGRST_DELAY=5ms PGDELAY=5ms postgrest-loadtest PGRST_DELAY=5ms PGDELAY=5ms postgrest-loadtest
# You can build postgrest directly with cabal for faster iteration
PGRST_BUILD_CABAL=1 postgrest-loadtest
# Produce a markdown report to be used on CI # Produce a markdown report to be used on CI
postgrest-loadtest-report postgrest-loadtest-report
``` ```
+1 -1
View File
@@ -37,7 +37,7 @@ let
checkedShellScript checkedShellScript
{ {
name = "postgrest-run"; name = "postgrest-run";
docs = "Run PostgREST after buidling it interactively with cabal-install"; docs = "Run PostgREST after building it interactively with cabal-install";
args = [ "ARG_LEFTOVERS([PostgREST arguments])" ]; args = [ "ARG_LEFTOVERS([PostgREST arguments])" ];
inRootDir = true; inRootDir = true;
withEnv = postgrest.env; withEnv = postgrest.env;
+15 -7
View File
@@ -1,6 +1,7 @@
{ bash-completion { bash-completion
, buildToolbox , buildToolbox
, cabal-install , cabal-install
, cabalTools
, checkedShellScript , checkedShellScript
, curl , curl
, devCabalOptions , devCabalOptions
@@ -333,16 +334,23 @@ let
export PGRST_SERVER_UNIX_SOCKET="$tmpdir"/postgrest.socket export PGRST_SERVER_UNIX_SOCKET="$tmpdir"/postgrest.socket
rm -f result rm -f result
echo -n "Building postgrest... " if [ -z "''${PGRST_BUILD_CABAL:-}" ]; then
nix-build -A postgrestPackage > "$tmpdir"/build.log 2>&1 || { echo -n "Building postgrest (nix)... "
echo "failed, output:" nix-build -A postgrestPackage > "$tmpdir"/build.log 2>&1 || {
cat "$tmpdir"/build.log echo "failed, output:"
exit 1 cat "$tmpdir"/build.log
} exit 1
}
PGRST_CMD=./result/bin/postgrest
else
echo -n "Building postgrest (cabal)... "
postgrest-build
PGRST_CMD=postgrest-run
fi
echo "done." echo "done."
echo -n "Starting postgrest... " echo -n "Starting postgrest... "
./result/bin/postgrest ${legacyConfig} > "$tmpdir"/run.log 2>&1 & $PGRST_CMD ${legacyConfig} > "$tmpdir"/run.log 2>&1 &
pid=$! pid=$!
# shellcheck disable=SC2317 # shellcheck disable=SC2317
cleanup() { cleanup() {