Skip to content

Commit aa4199f

Browse files
committed
nix: add new loadtest for errors
Also included it in CI.
1 parent a1cdecb commit aa4199f

File tree

4 files changed

+51
-3
lines changed

4 files changed

+51
-3
lines changed

.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: 10 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,19 @@ let
152152
sh -c "cd \"$_arg_testdir\" && \
153153
${runner} -targets targets.http -output \"$abs_output\" \"''${_arg_leftovers[@]}\""
154154
;;
155+
156+
errors)
157+
# shellcheck disable=SC2145
158+
${withTools.withPg} -f "$_arg_testdir"/errors.sql \
159+
${withTools.withPgrst} --timeout 20 -m "$_arg_monitor" \
160+
sh -c "cd \"$_arg_testdir\" && \
161+
${runner} -targets errors.http -output \"$abs_output\" \"''${_arg_leftovers[@]}\""
162+
;;
155163
esac
156164
157165
${vegeta}/bin/vegeta report -type=text "$_arg_output"
158166
159-
if [ "$_arg_kind" != "mixed" ]; then
167+
if [ "$_arg_kind" != "errors" ]; then
160168
# fail in case 401 happened on jwt loadtests
161169
unauthorized_count="$(${vegeta}/bin/vegeta report -type=json "$_arg_output" \
162170
| ${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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
\ir fixtures.sql
2+
3+
DO
4+
$$
5+
DECLARE
6+
r record;
7+
BEGIN
8+
FOR r IN
9+
SELECT
10+
format('CREATE TABLE test.actors_%s ()', x) AS tbls,
11+
format($__$CREATE FUNCTION test.call_me_%s (name TEXT)
12+
RETURNS TEXT
13+
STABLE
14+
LANGUAGE SQL
15+
AS $func$
16+
SELECT 'Hello ' || name;
17+
$func$;$__$, x) AS funcs
18+
FROM
19+
generate_series(1, 950) x
20+
LOOP
21+
EXECUTE r.tbls;
22+
EXECUTE r.funcs;
23+
END LOOP;
24+
END;
25+
$$;

0 commit comments

Comments
 (0)