282 Commits
Author SHA1 Message Date
Taimoor Zaeem 02d83d1c01 test(io): move remaining tests in test_io.py to their modules
We had just 3 tests remaining in test_io.py. This commit moves them to
their modules. So we have:

* test_graceful_shutdown.py

* test_zero_downtime.py

* test_pg_internal.py

Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-08-13 03:42:29 +05:00
Taimoor Zaeem e89e0bc255 test(io): move config related behavior tests to test_config.py
Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-08-13 03:42:29 +05:00
Taimoor Zaeem 9e20e5df90 test(io): move logs and observations tests to test_log.py
Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-08-13 03:42:29 +05:00
Taimoor Zaeem 2122dcef97 test(io): move connection related tests to test_connection.py
Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-08-13 03:42:29 +05:00
Taimoor Zaeem d84d00be8e test(io): move reloading related tests to test_reloading.py
Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-08-13 03:42:29 +05:00
steve-chavez 932c4f6328 perf: no caching for prefer timezone
`Prefer: timezone` no longer requires the schema cache.
Previously this required caching `pg_timezone_names` which was slow in some systems.

Closes https://github.com/PostgREST/postgrest/issues/5100 and
https://github.com/PostgREST/postgrest/issues/4751.
2026-08-04 13:41:40 -05:00
steve-chavez a41396c425 Revert "add: config db-timezone-enabled for optional querying of timezones"
This reverts commit d6c338d588.
2026-08-04 13:41:40 -05:00
Wolfgang Walther f84c44dafa nix: add postgrest-with-oriole-18 2026-08-02 14:51:50 +00:00
Wolfgang Walther 42754cb6c9 chore(deps): update nixpkgs pin
Nixpkgs has removed support for x86_64-darwin, so removing that from
CI's flake check.

A x86_64-darwin binary is still built via Stack.
2026-08-02 14:51:50 +00:00
Taimoor ZaeemandWolfgang Walther 8ede8fb0dc test(io): move settings related tests to test_settings.py
Towards #4946.

Moves app and pg settings related tests from test_io.py to
test_settings.py.

Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-08-02 11:53:32 +00:00
Joel JacobsonandWolfgang Walther 131df9b578 perf: use pg_basetype on PG 17+ for schema cache 2026-08-02 11:47:26 +00:00
Taimoor Zaeem 6a7ad33524 fix: db-channel-enabled not reloadable on config reload
Fixes #4894.

Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-07-31 21:39:27 +05:00
Taimoor Zaeem 022f0faa38 add: make config log-level reloadable
Closes #5113.

Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-07-28 11:33:33 +05:00
steve-chavez 03c67f3410 test: move psql_as_superuser as util and reuse it 2026-07-24 13:44:58 -05:00
Taimoor ZaeemandWolfgang Walther 8faf9c0519 test: resolve pytest warning when running io tests
When running `postgrest-test-io`, pytest raises a `InsecureKeyLengthWarning`
for a test. To clear that warning, this commit increases the key length to
more than 32 characters.

Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-07-17 17:42:51 +00:00
Michał KłeczekandSteve Chavez c297d051dc add: use SO_REUSEPORT on platform supporting it 2026-07-15 11:51:21 -05:00
Taimoor Zaeem 51e9fd6efd fix: schema cache dump missing RPC transaction isolation level
Fixes #5079.

Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-07-14 23:13:21 +05:00
Taimoor ZaeemandWolfgang Walther 8776ece7d5 test(io): move admin server tests to test_admin.py
Towards #4946.

Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-07-11 19:20:59 +00:00
steve-chavezandLaurence Isla 490d1dc5d3 add: config to emit warning for legacy target names
Adds the `url_use_legacy_target_names` config.

Enabled (default):
* It allows using the resource name in filters,
  orders or limits when it has an alias, e.g.
  `table?select=alias:target(*)&target.id=eq.1`
* Logs a WARNING with a hint to use the alias
* Returns a Warning header in the response

Disabled:
* It returns an error, only the alias is allowed
* No warnings returned

This feature is deprecated
2026-07-11 02:15:07 +00:00
Taimoor Zaeem c03ac09dbb test: move prepared statements config related tests to spec tests
Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-07-07 23:32:40 +05:00
Taimoor Zaeem 44edf962d8 test: move db-pre-config with pg reserved word func to spec tests
Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-07-07 23:32:40 +05:00
Taimoor Zaeem 6670b1a4b6 test(io): add test to db-pre-config with non-existent function
Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-07-07 23:32:40 +05:00
Taimoor Zaeem c73c676849 test: move error verbosity test from io tests to spec tests
Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-07-07 23:32:40 +05:00
Wolfgang Walther 0bd2821937 chore(deps): update hackage freeze, stackage snapshot and nixpkgs pin
This brings in PostgreSQL 19 beta 1 to start testing against.
2026-07-05 12:50:14 +00:00
Taimoor ZaeemandWolfgang Walther bb63c3fade change: use RFC 9535 syntax for jwt-role-claim-key config
BREAKING CHANGE

Breaks the string comparison operators implemented in #3813. Those can
be replaced with regex searches using JSON Path `search()` function.

Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-06-26 18:32:05 +00:00
Taimoor ZaeemandSteve Chavez b5f10be167 test: move jwt cache tests from io tests to spec tests
Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-06-25 11:21:28 -05:00
Taimoor ZaeemandSteve Chavez 0bc9fe813f test: move jwt iat claim test from io tests to spec tests
Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-06-25 11:21:28 -05:00
Taimoor ZaeemandSteve Chavez feb4853273 test(io): add test for admin server listening observation
Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-06-25 10:39:16 -05:00
Taimoor Zaeem f5fd2e71b6 test: move jwt error tests from io tests to spec tests
Towards #4946.

Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-06-22 23:52:45 +05:00
Taimoor Zaeem ee30bd03ac test(io): remove needless server-timing config coverage tests
These 2 tests don't test any specific behavior - they were added
only to please code coverage.

Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-06-22 23:52:45 +05:00
Taimoor ZaeemandSteve Chavez 9048332b0e test(io): clarify test names
Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-06-16 13:13:51 -05:00
Taimoor ZaeemandSteve Chavez b6c12abf0e test: move http header related tests from io tests to spec tests
Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-06-16 13:13:51 -05:00
Michał KłeczekandSteve Chavez 8fa26ee865 fix: Start listening after schema cache load
This change ensures PostgREST starts listening on a server socket only after it loaded the schema cache and is ready to handle requests. It is no longer going to return 503 errors during startup until the schema cache is loaded.
2026-06-16 12:30:51 -05:00
Wolfgang Walther 2976eb047b add: support running admin server on unix socket
This is useful when multiple instances run on the same machine, for
example behind a proxy. Unix sockets for web and admin servers can then
be put in the same folder for each instance.

Can be helpful when writing tests as well.
2026-06-14 17:18:37 +00:00
Wolfgang Walther f24bc7092f test(io): fix UnboundLocalError
The `if response` check a few rows down would not actually work without
initializing the variable first. It'd throw:

```
E       UnboundLocalError: cannot access local variable 'response' where
it is not associated with a value
```
2026-06-14 17:18:37 +00:00
Wolfgang Walther 6d87fc5879 test(io): move some tests to unix sockets
No need to run these with TCP and freeport, I believe.
2026-06-14 17:18:37 +00:00
Michał KłeczekandSteve Chavez 54430c3a2c fix: Do not clear the schema cache during retries
retryingSchemaCacheLoad should not clear existing schema cache upon failure - there is no reason to do that. If there is a communication issue with the database server or db is down, clients are going to get 502 anyway. If it was a glitch when loading the schema cache - the clients are going to use old (stale) schema cache for some time until next retry re-loads it successfully.
2026-06-11 13:14:37 -05:00
Taimoor Zaeem e9a016670f Revert "add: string slicing operator for jwt-role-claim-key"
This reverts commit fe0386e9c4.

As discussed in https://github.com/PostgREST/postgrest/pull/4984#issuecomment-4652725178.
2026-06-11 23:07:05 +05:00
steve-chavez 1ebf480258 amend: required membership for postgrest_test_anonymous
Previous test correction required GRANTing membership for
postgrest_test_anonymous.
2026-06-11 12:00:02 -05:00
steve-chavez e7c8d70333 test: correct test_admin_ready_includes_schema_cache_state
There was an oversight on d556cea, `timeout_authenticator` doesn't have
any privileges on the tables so it shouldn't be making requests to the
API server or it will end up with 401 responses.
2026-06-11 11:51:14 -05:00
Taimoor ZaeemandWolfgang Walther 8bde0ad474 test: move cors related tests from io tests to spec tests
Towards #4946.

Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-06-10 10:27:49 +00:00
Taimoor ZaeemandWolfgang Walther 21433d10c2 refactor(config): use correct data type for server-cors-allowed-origins
Replaces the `Maybe [Text]` with `[Text]`. The `Maybe` is unnecessary
because we handle `Just []` and `Nothing` the same way.

Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-06-09 12:35:47 +00:00
Laurence IslaandSteve Chavez 416a15480f fix: request failures when work_mem is set on a role 2026-06-03 13:45:34 -05:00
netandWolfgang Walther 3d596e2dbc fix: don't mention retrying in the database connection error message
The PGRST000 database connection error message was "Database connection
error. Retrying the connection.", but reconnection attempts are already
logged separately by the reconnection observation, and on fatal errors
(e.g. authentication failure) PostgREST does not retry at all. Drop the
"Retrying the connection." part, leaving "Database connection error.".
2026-06-03 08:04:40 +00:00
netandWolfgang Walther 097a1de67d chore: sort config dump alphabetically
The config dump in Config.hs listed db-config, db-pre-config and the
db-pool-* settings out of alphabetical order, while the rest of the dump
was sorted. Now the whole dump is consistently alphabetical and update
the expected IO test configs to match.
2026-06-02 07:32:11 +00:00
Taimoor ZaeemandSteve Chavez 9162cea7ba test(io): remove unused config variables from config test
Config variables are tested already via reading the config files in
the `configs/` directory.

If more are to be tested, it should be done via adding a file in
`configs/` and compare it with its associated file in `configs/expected/`.

Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-05-30 09:51:26 -05:00
Michał KłeczekandSteve Chavez 913fe001e5 refactor(remove): schema cache load delay config
Remove internal schema cache load and relationship load sleep settings plus
the delay wrappers they enabled. Drop IO tests that depended on the removed
settings.
2026-05-19 10:59:27 -05:00
Michał KłeczekandSteve Chavez 86d6ed10bb test: cover stale schema cache database error
Add an IO test that drops a table while schema cache reload is delayed. It verifies the stale cache path returns PostgreSQL 42P01 and the refreshed cache returns PGRST205.
2026-05-19 09:11:04 -05:00
steve-chavez 6220ab3f31 test: adjust test_positive_pool_metric
Adjusted so it waits for liveness instead of requiring sleeping
2026-05-18 10:46:02 -05:00
steve-chavez 1eba9855c1 test: change wait_for_readiness to an enum
This so we can wait for both readiness and liveness
2026-05-18 10:45:36 -05:00