Skip to content

Commit

Permalink
add test for schema cache reload with no resource embedding
Browse files Browse the repository at this point in the history
  • Loading branch information
taimoorzaeem committed Jan 23, 2025
1 parent 8d850c2 commit f008e21
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions test/io/test_big_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from postgrest import *


def test_requests_wait_for_schema_cache_reload(defaultenv):
"requests that use the schema cache (e.g. resource embedding) wait for the schema cache to reload"
def test_requests_with_resource_embedding_wait_for_schema_cache_reload(defaultenv):
"requests that use the schema cache with resource embedding wait long for the schema cache to reload"

env = {
**defaultenv,
Expand All @@ -34,6 +34,32 @@ def test_requests_wait_for_schema_cache_reload(defaultenv):
assert plan_dur > 10000.0


def test_requests_without_resource_embedding_wait_for_schema_cache_reload(defaultenv):
"requests that use the schema cache without resource embedding wait less for the schema cache to reload"

env = {
**defaultenv,
"PGRST_DB_SCHEMAS": "apflora",
"PGRST_DB_POOL": "2",
"PGRST_DB_ANON_ROLE": "postgrest_test_anonymous",
"PGRST_SERVER_TIMING_ENABLED": "true",
}

with run(env=env, wait_max_seconds=30) as postgrest:
# reload the schema cache
response = postgrest.session.get("/rpc/notify_pgrst")
assert response.status_code == 204

postgrest.wait_until_scache_starts_loading()

response = postgrest.session.get("/tpopmassn")
assert response.status_code == 200

plan_dur = parse_server_timings_header(response.headers["Server-Timing"])[
"plan"
]
assert plan_dur < 10000.0

# TODO: This test fails now because of https://github.com/PostgREST/postgrest/pull/2122
# The stack size of 1K(-with-rtsopts=-K1K) is not enough and this fails with "stack overflow"
# A stack size of 200K seems to be enough for succeess
Expand Down

0 comments on commit f008e21

Please sign in to comment.