nix: add loadtest with unique JWTs

This loadtests the jwt decoding logic. For this it adds an optional
`-k`(kind) parameter to `postgrest-loadtest` and
`postgrest-loadtest-against`.

Old kind (default):

```
postgrest-loadtest -k mixed
postgrest-loadtest-against -k mixed
```

New kind:

```
postgrest-loadtest -k jwt
postgrest-loadtest-against -k jwt
```

Internally it uses a dynamically generated targets file using python
which looks like:

```
GET http://postgrest/authors_only
Authorization: Bearer <jwt>

GET http://postgrest/authors_only
Authorization: Bearer <another-jwt>
...
```

Then this is used to run vegeta with the `-lazy` option.
This commit is contained in:
steve-chavez
2025-04-17 23:11:33 -05:00
committed by Steve Chavez
parent a37ec1e1a5
commit 608f7ca45a
5 changed files with 122 additions and 14 deletions
+11 -1
View File
@@ -1,5 +1,7 @@
CREATE ROLE postgrest_test_anonymous;
CREATE ROLE postgrest_test_author;
GRANT postgrest_test_anonymous TO :PGUSER;
GRANT postgrest_test_author TO :PGUSER;
CREATE SCHEMA test;
-- PUT+PATCH target needs one record and column to modify
@@ -31,10 +33,18 @@ CREATE TABLE test.roles (
character TEXT
);
CREATE TABLE test.authors_only ();
CREATE FUNCTION test.call_me (name TEXT) RETURNS TEXT
STABLE LANGUAGE SQL AS $$
SELECT 'Hello ' || name || ', how are you?';
$$;
GRANT USAGE ON SCHEMA test TO postgrest_test_anonymous;
GRANT USAGE ON SCHEMA test TO postgrest_test_anonymous, postgrest_test_author;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA test TO postgrest_test_anonymous;
REVOKE ALL PRIVILEGES ON TABLE
authors_only
FROM postgrest_test_anonymous;
GRANT ALL ON TABLE authors_only TO postgrest_test_author;