-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68cf0de
commit 06d2163
Showing
5 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
{ buildToolbox | ||
, checkedShellScript | ||
, vegeta | ||
, withTools | ||
}: | ||
let | ||
runner = | ||
checkedShellScript | ||
{ | ||
name = "postgrest-loadtest-runner"; | ||
docs = "Run vegeta. Assume PostgREST to be running."; | ||
args = [ | ||
"ARG_LEFTOVERS([additional vegeta arguments])" | ||
"ARG_USE_ENV([PGRST_SERVER_UNIX_SOCKET], [], [Unix socket to connect to running PostgREST instance])" | ||
]; | ||
} | ||
'' | ||
# ARG_USE_ENV only adds defaults or docs for environment variables | ||
# We manually implement a required check here | ||
# See also: https://github.com/matejak/argbash/issues/80 | ||
PGRST_SERVER_UNIX_SOCKET="''${PGRST_SERVER_UNIX_SOCKET:?PGRST_SERVER_UNIX_SOCKET is required}" | ||
${vegeta}/bin/vegeta -cpus 1 attack \ | ||
-unix-socket "$PGRST_SERVER_UNIX_SOCKET" \ | ||
-max-workers 1 \ | ||
-workers 1 \ | ||
-rate 0 \ | ||
-duration 5s \ | ||
"''${_arg_leftovers[@]}" | ||
''; | ||
|
||
loadtest = | ||
checkedShellScript | ||
{ | ||
name = "postgrest-loadtest"; | ||
docs = "Run the vegeta loadtests with PostgREST."; | ||
args = [ | ||
"ARG_OPTIONAL_SINGLE([testfile], [t], [File to load tests from], [./test/loadtest.http])" | ||
"ARG_LEFTOVERS([additional vegeta arguments])" | ||
]; | ||
inRootDir = true; | ||
} | ||
'' | ||
export PGRST_DB_POOL="1" | ||
export PGRST_LOG_LEVEL="crit" | ||
export PGRST_DB_CONFIG="false" | ||
${withTools.latest} \ | ||
${withTools.pgrst} \ | ||
${runner} -targets "$_arg_testfile" "''${_arg_leftovers[@]}" \ | ||
| ${vegeta}/bin/vegeta report -type=text | ||
''; | ||
|
||
loadtestAgainst = | ||
checkedShellScript | ||
{ | ||
name = "postgrest-loadtest-against"; | ||
docs = | ||
'' | ||
Run the vegeta loadtest twice: | ||
- once on the <target> branch | ||
- once in the current worktree | ||
''; | ||
args = [ | ||
"ARG_POSITIONAL_SINGLE([target], [Commit-ish reference to compare with])" | ||
"ARG_LEFTOVERS([additional vegeta arguments])" | ||
]; | ||
inRootDir = true; | ||
} | ||
'' | ||
cat << EOF | ||
Running loadtest on "$_arg_target"... | ||
EOF | ||
# Runs the test files from the current working tree | ||
# to make sure both tests are run with the same files. | ||
${withTools.git} "$_arg_target" ${loadtest} --testfile "$PWD/test/loadtest.http" "''${_arg_leftovers[@]}" | ||
cat << EOF | ||
Done running on "$_arg_target". | ||
EOF | ||
cat << EOF | ||
Running loadtest on HEAD... | ||
EOF | ||
${loadtest} --testfile "$PWD/test/loadtest.http" "''${_arg_leftovers[@]}" | ||
cat << EOF | ||
Done running on HEAD. | ||
EOF | ||
''; | ||
|
||
in | ||
buildToolbox { | ||
name = "postgrest-loadtest"; | ||
tools = [ loadtest loadtestAgainst ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
GET http://postgrest/orders?select=name#no-headers |