Skip to content

Commit b8ca1bb

Browse files
committed
nix: add new loadtest for errors
Also included it in CI.
1 parent 57c5ff5 commit b8ca1bb

4 files changed

Lines changed: 34 additions & 3 deletions

File tree

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ jobs:
120120
loadtest:
121121
strategy:
122122
matrix:
123-
kind: ['mixed', 'jwt-hs', 'jwt-hs-cache', 'jwt-hs-cache-worst', 'jwt-rsa', 'jwt-rsa-cache', 'jwt-rsa-cache-worst']
123+
kind: ['mixed', 'errors', 'jwt-hs', 'jwt-hs-cache', 'jwt-hs-cache-worst', 'jwt-rsa', 'jwt-rsa-cache', 'jwt-rsa-cache-worst']
124124
name: Loadtest
125125
runs-on: ubuntu-24.04
126126
steps:

nix/tools/loadtest.nix

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ let
4545
"ARG_OPTIONAL_SINGLE([testdir], [t], [Directory to load tests and fixtures from], [./test/load])"
4646
"ARG_OPTIONAL_SINGLE([kind], [k], [Kind of loadtest], [mixed])"
4747
"ARG_OPTIONAL_SINGLE([method],, [HTTP method used for the jwt loadtests], [OPTIONS])"
48-
"ARG_TYPE_GROUP_SET([KIND], [KIND], [kind], [mixed,jwt-hs,jwt-hs-cache,jwt-hs-cache-worst,jwt-rsa,jwt-rsa-cache,jwt-rsa-cache-worst])"
48+
"ARG_TYPE_GROUP_SET([KIND], [KIND], [kind], [mixed,errors,jwt-hs,jwt-hs-cache,jwt-hs-cache-worst,jwt-rsa,jwt-rsa-cache,jwt-rsa-cache-worst])"
4949
"ARG_TYPE_GROUP_SET([METHOD], [METHOD], [method], [OPTIONS,GET])"
5050
"ARG_OPTIONAL_SINGLE([monitor], [m], [Monitoring file], [./loadtest/result.csv])"
5151
"ARG_LEFTOVERS([additional vegeta arguments])"
@@ -152,11 +152,20 @@ let
152152
sh -c "cd \"$_arg_testdir\" && \
153153
${runner} -targets targets.http -output \"$abs_output\" \"''${_arg_leftovers[@]}\""
154154
;;
155+
156+
# here we sleep purposefully to check how much memory does the schema cache consume in the final report
157+
errors)
158+
# shellcheck disable=SC2145
159+
${withTools.withPg} -f "$_arg_testdir"/errors.sql \
160+
${withTools.withPgrst} --timeout 2 --sleep 5 -m "$_arg_monitor" \
161+
sh -c "cd \"$_arg_testdir\" && \
162+
${runner} -targets errors.http -output \"$abs_output\" \"''${_arg_leftovers[@]}\""
163+
;;
155164
esac
156165
157166
${vegeta}/bin/vegeta report -type=text "$_arg_output"
158167
159-
if [ "$_arg_kind" != "mixed" ]; then
168+
if [ "$_arg_kind" != "errors" ]; then
160169
# fail in case 401 happened on jwt loadtests
161170
unauthorized_count="$(${vegeta}/bin/vegeta report -type=json "$_arg_output" \
162171
| ${jq}/bin/jq -r '.status_codes["401"] // 0')"

test/load/errors.http

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Misspelled relations
2+
GET http://postgrest/actoxs?actor=eq.1
3+
Prefer: tx=commit
4+
5+
# Misspelled relations on embeds
6+
GET http://postgrest/actors?select=*,rolws(*,films(*))
7+
Prefer: tx=commit
8+
9+
# Misspelled function names
10+
GET http://postgrest/rpc/call_em_x?name=John
11+
Prefer: tx=commit
12+
13+
# Permission denied errors
14+
GET http://postgrest/actors_1
15+
Prefer: tx=commit

test/load/errors.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
\ir fixtures.sql
2+
3+
SELECT format('CREATE TABLE test.actors_%s ();', n)
4+
FROM generate_series(1, 20000) n
5+
\gexec
6+
7+
-- TODO add many function for fuzzy search (somehow this is making the loadtest start slow)

0 commit comments

Comments
 (0)