Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: requests wait for schema cache load #3328

Merged
merged 1 commit into from
Mar 15, 2024

Conversation

steve-chavez
Copy link
Member

Proves #3327

@steve-chavez
Copy link
Member Author

steve-chavez commented Mar 15, 2024

CI says:

$ postgrest-test-big-schema: command not found

(https://github.com/PostgREST/postgrest/actions/runs/8289451731/job/22685899055?pr=3328)

Why is the new Nix command not working here? Am I getting the nix commands from cache somehow?


It does work locally:

$ postgrest-with-postgresql-15 postgrest-test-big-schema 

test/io/test_big_schema.py::test_requests_wait_for_schema_cache_to_be_loaded 
PASSED                                                                                                 [ 50%]
test/io/test_big_schema.py::test_openapi_in_big_schema SKIPPED (unconditional skip)                                                                                                 [100%]

============================================================================== 1 passed, 1 skipped in 43.73s ==============================================================================

@steve-chavez steve-chavez force-pushed the prove-3327 branch 2 times, most recently from 7e96867 to 1eb8011 Compare March 15, 2024 00:31
@steve-chavez
Copy link
Member Author

steve-chavez commented Mar 15, 2024

@wolfgangwalther @develop7 Could you guys advice on how to refresh the Nix cache 🙏? Not sure what I'm doing wrong


Edit: Oh, nevermind. I needed to add this line https://github.com/PostgREST/postgrest/pull/3328/files#diff-245392b692a50c38ecab4381b118862db514035c10983f3bd4f4b7f1f4be4692R84

Follow up idea: How about renaming tests.testSpec.bin tests.testIO.bin .. to test.postgrest-test-spec.bin tests.postgrest-test-io.bin ... That way at least is easier to note what has to be added on CI.

* nix: add postgrest-test-big-schema command
Comment on lines +10 to +29
def test_requests_wait_for_schema_cache_to_be_loaded(defaultenv):
"requests that use the schema cache (e.g. resource embedding) wait for schema cache to be loaded"

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_for_readiness=False) as postgrest:
time.sleep(1.5) # manually wait for schema cache to start loading

response = postgrest.session.get("/tpopmassn?select=*,tpop(*)")
assert response.status_code == 200

server_timings = parse_server_timings_header(response.headers["Server-Timing"])
plan_dur = server_timings["plan"]
assert plan_dur > 10000.0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the gist of the PR

@wolfgangwalther
Copy link
Member

Follow up idea: How about renaming tests.testSpec.bin tests.testIO.bin .. to test.postgrest-test-spec.bin tests.postgrest-test-io.bin ... That way at least is easier to note what has to be added on CI.

I'll put that on my TODO list. It might be possible to change it to use postgrest-test-spec instead of test.postgrest-test-spec.bin etc., too.

@steve-chavez steve-chavez merged commit 4b289b1 into PostgREST:main Mar 15, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants