nix: avoid rebuilding memory tests when entering nix-shell
The memory tests are now run in the same way as the regular tests.
This commit is contained in:
@@ -105,7 +105,7 @@ jobs:
|
||||
uses: ./.github/actions/setup-nix
|
||||
with:
|
||||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
||||
tools: memory.test.bin
|
||||
tools: tests.testMemory.bin
|
||||
- name: Run memory tests
|
||||
run: postgrest-test-memory
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ site
|
||||
.#*
|
||||
*.swp
|
||||
result*
|
||||
dist-newstyle
|
||||
dist-*
|
||||
postgrest.hp
|
||||
postgrest.prof
|
||||
__pycache__
|
||||
|
||||
@@ -123,10 +123,6 @@ rec {
|
||||
loadtest =
|
||||
pkgs.callPackage nix/tools/loadtest.nix { inherit withTools; };
|
||||
|
||||
# Script for running memory tests.
|
||||
memory =
|
||||
pkgs.callPackage nix/tools/memory.nix { inherit postgrestProfiled withTools; };
|
||||
|
||||
# Scripts for publishing new releases.
|
||||
release =
|
||||
pkgs.callPackage nix/tools/release.nix { };
|
||||
|
||||
@@ -60,6 +60,35 @@ let
|
||||
postgrest "''${_arg_leftovers[@]}"
|
||||
'';
|
||||
|
||||
|
||||
runProfiled =
|
||||
checkedShellScript
|
||||
{
|
||||
name = "postgrest-profiled-run";
|
||||
docs = "Run a profiled build of postgREST. This will generate a postgrest.prof file that can be used to do optimization.";
|
||||
args =
|
||||
[
|
||||
"ARG_USE_ENV([PGRST_DB_ANON_ROLE], [postgrest_test_anonymous], [PostgREST anonymous role])"
|
||||
"ARG_USE_ENV([PGRST_DB_POOL], [1], [PostgREST pool size])"
|
||||
"ARG_USE_ENV([PGRST_DB_POOL_ACQUISITION_TIMEOUT], [1], [PostgREST pool timeout])"
|
||||
"ARG_USE_ENV([PGRST_JWT_SECRET], [reallyreallyreallyreallyverysafe], [PostgREST JWT secret])"
|
||||
"ARG_LEFTOVERS([PostgREST arguments])"
|
||||
];
|
||||
workingDir = "/";
|
||||
withEnv = postgrest.env;
|
||||
}
|
||||
''
|
||||
export PGRST_DB_ANON_ROLE
|
||||
export PGRST_DB_POOL
|
||||
export PGRST_DB_POOL_ACQUISITION_TIMEOUT
|
||||
export PGRST_JWT_SECRET
|
||||
|
||||
${cabal-install}/bin/cabal v2-update
|
||||
${cabal-install}/bin/cabal --builddir="dist-prof" v2-build --enable-profiling --disable-shared exe:postgrest
|
||||
${cabal-install}/bin/cabal --builddir="dist-prof" v2-run -- \
|
||||
postgrest +RTS -p -h -RTS "''${_arg_leftovers[@]}"
|
||||
'';
|
||||
|
||||
repl =
|
||||
checkedShellScript
|
||||
{
|
||||
@@ -81,6 +110,7 @@ buildToolbox
|
||||
build
|
||||
clean
|
||||
run
|
||||
runProfiled
|
||||
repl;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
# The memory tests have large dependencies (a profiled build of PostgREST)
|
||||
# and are run less often than the spec tests, so we don't include them in
|
||||
# the default test environment. We make them available through a separate module.
|
||||
# TODO both of these require reentering the nix-shell if you make a change to the code
|
||||
{ buildToolbox
|
||||
, checkedShellScript
|
||||
, curl
|
||||
, postgrestProfiled
|
||||
, withTools
|
||||
}:
|
||||
let
|
||||
test =
|
||||
checkedShellScript
|
||||
{
|
||||
name = "postgrest-test-memory";
|
||||
docs = "Run the memory tests.";
|
||||
workingDir = "/";
|
||||
withPath = [ postgrestProfiled curl ];
|
||||
}
|
||||
''
|
||||
${withTools.withPg} -f test/spec/fixtures/load.sql test/memory/memory-tests.sh
|
||||
'';
|
||||
|
||||
runProfiled =
|
||||
checkedShellScript
|
||||
{
|
||||
name = "postgrest-profiled-run";
|
||||
docs = "Run a profiled build of postgREST. This will generate a postgrest.prof file that can be used to do optimization. Note: if you make a change to the code, you must reenter the nix-shell for an updated profiled build.";
|
||||
args =
|
||||
[
|
||||
"ARG_USE_ENV([PGRST_DB_ANON_ROLE], [postgrest_test_anonymous], [PostgREST anonymous role])"
|
||||
"ARG_USE_ENV([PGRST_DB_POOL], [1], [PostgREST pool size])"
|
||||
"ARG_USE_ENV([PGRST_DB_POOL_ACQUISITION_TIMEOUT], [1], [PostgREST pool timeout])"
|
||||
"ARG_LEFTOVERS([PostgREST arguments])"
|
||||
];
|
||||
workingDir = "/";
|
||||
withPath = [ postgrestProfiled ];
|
||||
}
|
||||
''
|
||||
export PGRST_DB_ANON_ROLE
|
||||
export PGRST_DB_POOL
|
||||
export PGRST_DB_POOL_ACQUISITION_TIMEOUT
|
||||
|
||||
postgrest +RTS -p -h -RTS "''${_arg_leftovers[@]}"
|
||||
'';
|
||||
in
|
||||
buildToolbox
|
||||
{
|
||||
name = "postgrest-memory";
|
||||
tools = { inherit test runProfiled; };
|
||||
}
|
||||
+19
-1
@@ -1,6 +1,7 @@
|
||||
{ buildToolbox
|
||||
, cabal-install
|
||||
, checkedShellScript
|
||||
, curl
|
||||
, devCabalOptions
|
||||
, ghc
|
||||
, glibcLocales ? null
|
||||
@@ -235,6 +236,22 @@ let
|
||||
sed -i 's|^module \(.*\):|module \1/|g' test/coverage.overlay
|
||||
'';
|
||||
|
||||
testMemory =
|
||||
checkedShellScript
|
||||
{
|
||||
name = "postgrest-test-memory";
|
||||
docs = "Run the memory tests.";
|
||||
workingDir = "/";
|
||||
withEnv = postgrest.env;
|
||||
withPath = [ curl ];
|
||||
}
|
||||
''
|
||||
${cabal-install}/bin/cabal v2-update
|
||||
${cabal-install}/bin/cabal --builddir="dist-prof" v2-build --enable-profiling --disable-shared exe:postgrest
|
||||
${cabal-install}/bin/cabal --builddir="dist-prof" v2-exec -- ${withTools.withPg} -f test/spec/fixtures/load.sql \
|
||||
test/memory/memory-tests.sh
|
||||
'';
|
||||
|
||||
in
|
||||
buildToolbox
|
||||
{
|
||||
@@ -249,6 +266,7 @@ buildToolbox
|
||||
testReplica
|
||||
dumpSchema
|
||||
coverage
|
||||
coverageDraftOverlay;
|
||||
coverageDraftOverlay
|
||||
testMemory;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ let
|
||||
postgrest.devTools
|
||||
postgrest.docs
|
||||
postgrest.loadtest
|
||||
postgrest.memory
|
||||
postgrest.release
|
||||
postgrest.style
|
||||
postgrest.tests
|
||||
|
||||
@@ -102,21 +102,21 @@ postJsonArrayTest(){
|
||||
|
||||
echo "Running memory usage tests.."
|
||||
|
||||
jsonKeyTest "1M" "POST" "/rpc/leak?columns=blob" "27M"
|
||||
jsonKeyTest "1M" "POST" "/leak?columns=blob" "21M"
|
||||
jsonKeyTest "1M" "PATCH" "/leak?id=eq.1&columns=blob" "21M"
|
||||
jsonKeyTest "1M" "POST" "/rpc/leak?columns=blob" "22M"
|
||||
jsonKeyTest "1M" "POST" "/leak?columns=blob" "22M"
|
||||
jsonKeyTest "1M" "PATCH" "/leak?id=eq.1&columns=blob" "22M"
|
||||
|
||||
jsonKeyTest "10M" "POST" "/rpc/leak?columns=blob" "32M"
|
||||
jsonKeyTest "10M" "POST" "/leak?columns=blob" "32M"
|
||||
jsonKeyTest "10M" "PATCH" "/leak?id=eq.1&columns=blob" "32M"
|
||||
|
||||
jsonKeyTest "50M" "POST" "/rpc/leak?columns=blob" "72M"
|
||||
jsonKeyTest "50M" "POST" "/leak?columns=blob" "72M"
|
||||
jsonKeyTest "50M" "PATCH" "/leak?id=eq.1&columns=blob" "72M"
|
||||
jsonKeyTest "50M" "POST" "/rpc/leak?columns=blob" "73M"
|
||||
jsonKeyTest "50M" "POST" "/leak?columns=blob" "73M"
|
||||
jsonKeyTest "50M" "PATCH" "/leak?id=eq.1&columns=blob" "73M"
|
||||
|
||||
postJsonArrayTest "1000" "/perf_articles?columns=id,body" "20M"
|
||||
postJsonArrayTest "10000" "/perf_articles?columns=id,body" "20M"
|
||||
postJsonArrayTest "100000" "/perf_articles?columns=id,body" "24M"
|
||||
postJsonArrayTest "1000" "/perf_articles?columns=id,body" "21M"
|
||||
postJsonArrayTest "10000" "/perf_articles?columns=id,body" "22M"
|
||||
postJsonArrayTest "100000" "/perf_articles?columns=id,body" "25M"
|
||||
|
||||
trap - int term exit
|
||||
|
||||
|
||||
Reference in New Issue
Block a user