Skip to content

Commit

Permalink
Add tests and CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-chavez committed Dec 22, 2021
1 parent 727e54f commit 15d8b87
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<host>:<admin_server_port>/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
Expand Down
41 changes: 41 additions & 0 deletions test/io-tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(f"http://localhost:{env['PGRST_ADMIN_SERVER_PORT']}/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(f"http://localhost:{env['PGRST_ADMIN_SERVER_PORT']}/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(f"http://localhost:{env['PGRST_ADMIN_SERVER_PORT']}/notfound")
assert response.status_code == 404

0 comments on commit 15d8b87

Please sign in to comment.