From 927c3ee9495eefcb06e1c2b0c1cb531ac21beadc Mon Sep 17 00:00:00 2001 From: steve-chavez Date: Tue, 21 Dec 2021 21:31:09 -0500 Subject: [PATCH] Add tests and CHANGELOG --- CHANGELOG.md | 3 +++ test/io-tests/test_io.py | 41 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed9c6f07c52..7faa5ec9587 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added + - #1933, Add a minimal health check endpoint on an admin port at the `:/health` endpoint - @steve-chavez + + For enabling this, the `admin-server-port` config must be set explictly + ### Fixed - #2020, Execute deferred constraint triggers when using `Prefer: tx=rollback` - @wolfgangwalther diff --git a/test/io-tests/test_io.py b/test/io-tests/test_io.py index 94ff66a9de4..a05f5a196fc 100644 --- a/test/io-tests/test_io.py +++ b/test/io-tests/test_io.py @@ -729,3 +729,44 @@ def test_db_prepared_statements_disable(defaultenv): with run(env=env) as postgrest: response = postgrest.session.post("/rpc/uses_prepared_statements") assert response.text == "false" + + +def test_admin_healthy_w_channel(defaultenv): + "Should get a success response from the admin server health endpoint when the LISTEN channel is enabled" + + env = { + **defaultenv, + "PGRST_ADMIN_SERVER_PORT": "3001", + "PGRST_DB_CHANNEL_ENABLED": "true", + } + + with run(env=env) as postgrest: + response = requests.get('http://localhost:3001/health') + assert response.status_code == 200 + + +def test_admin_healthy_wo_channel(defaultenv): + "Should get a success response from the admin server health endpoint when the LISTEN channel is disabled" + + env = { + **defaultenv, + "PGRST_ADMIN_SERVER_PORT": "3001", + "PGRST_DB_CHANNEL_ENABLED": "false", + } + + with run(env=env) as postgrest: + response = requests.get('http://localhost:3001/health') + assert response.status_code == 200 + + +def test_admin_not_found(defaultenv): + "Should get a success response from the admin server health endpoint when the LISTEN channel is enabled" + + env = { + **defaultenv, + "PGRST_ADMIN_SERVER_PORT": "3001", + } + + with run(env=env) as postgrest: + response = requests.get('http://localhost:3001/notfound') + assert response.status_code == 404