File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"IO tests for PostgREST started on the big schema."
22
3+ import re
4+
35import pytest
46
57from postgrest import run
@@ -57,6 +59,35 @@ def test_requests_without_resource_embedding_wait_for_schema_cache_reload(defaul
5759 )
5860
5961
62+ def test_schema_cache_load_max_duration (defaultenv ):
63+ "schema cache load should not surpass a max_duration of elapsed milliseconds"
64+
65+ max_duration = 500.0
66+
67+ env = {
68+ ** defaultenv ,
69+ "PGRST_DB_SCHEMAS" : "apflora" ,
70+ "PGRST_DB_POOL" : "2" ,
71+ "PGRST_DB_ANON_ROLE" : "postgrest_test_anonymous" ,
72+ }
73+
74+ with run (env = env , wait_max_seconds = 30 , no_startup_stdout = False ) as postgrest :
75+ log_lines = postgrest .read_stdout (nlines = 50 )
76+ schema_cache_lines = [
77+ line for line in log_lines if "Schema cache loaded in" in line
78+ ]
79+
80+ match = re .search (
81+ r"Schema cache loaded in ([0-9]+(?:\.[0-9])?) milliseconds" ,
82+ schema_cache_lines [- 1 ],
83+ )
84+
85+ assert match , f"unexpected log format: { schema_cache_lines [- 1 ]} "
86+ duration_ms = float (match .group (1 ))
87+
88+ assert duration_ms < max_duration
89+
90+
6091# TODO: This test fails now because of https://github.com/PostgREST/postgrest/pull/2122
6192# The stack size of 1K(-with-rtsopts=-K1K) is not enough and this fails with "stack overflow"
6293# A stack size of 200K seems to be enough for succeess
You can’t perform that action at this time.
0 commit comments