-
Notifications
You must be signed in to change notification settings - Fork 479
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compute_ctl: Add endpoint that allows extensions to be installed (#9344)
Adds endpoint to install extensions: **POST** `/extensions` ``` {"extension":"pg_sessions_jwt","database":"neondb","version":"1.0.0"} ``` Will be used by `local-proxy`. Example, for the JWT authentication to work the database needs to have the pg_session_jwt extension and also to enable JWT to work in RLS policies. --------- Co-authored-by: Conrad Ludgate <[email protected]>
- Loading branch information
1 parent
15fecff
commit 3532ae7
Showing
8 changed files
with
231 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from logging import info | ||
|
||
from fixtures.neon_fixtures import NeonEnv | ||
|
||
|
||
def test_extensions(neon_simple_env: NeonEnv): | ||
"""basic test for the extensions endpoint testing installing extensions""" | ||
|
||
env = neon_simple_env | ||
|
||
env.create_branch("test_extensions") | ||
|
||
endpoint = env.endpoints.create_start("test_extensions") | ||
extension = "neon_test_utils" | ||
database = "test_extensions" | ||
|
||
endpoint.safe_psql("CREATE DATABASE test_extensions") | ||
|
||
with endpoint.connect(dbname=database) as pg_conn: | ||
with pg_conn.cursor() as cur: | ||
cur.execute( | ||
"SELECT default_version FROM pg_available_extensions WHERE name = 'neon_test_utils'" | ||
) | ||
res = cur.fetchone() | ||
assert res is not None | ||
version = res[0] | ||
|
||
with pg_conn.cursor() as cur: | ||
cur.execute( | ||
"SELECT extname, extversion FROM pg_extension WHERE extname = 'neon_test_utils'", | ||
) | ||
res = cur.fetchone() | ||
assert not res, "The 'neon_test_utils' extension is installed" | ||
|
||
client = endpoint.http_client() | ||
install_res = client.extensions(extension, version, database) | ||
|
||
info("Extension install result: %s", res) | ||
assert install_res["extension"] == extension and install_res["version"] == version | ||
|
||
with endpoint.connect(dbname=database) as pg_conn: | ||
with pg_conn.cursor() as cur: | ||
cur.execute( | ||
"SELECT extname, extversion FROM pg_extension WHERE extname = 'neon_test_utils'", | ||
) | ||
res = cur.fetchone() | ||
assert res is not None | ||
(db_extension_name, db_extension_version) = res | ||
|
||
assert db_extension_name == extension and db_extension_version == version |
3532ae7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5229 tests run: 5012 passed, 3 failed, 214 skipped (full report)
Failures on Postgres 16
test_compaction_downloads_on_demand_with_image_creation
: release-x86-64Failures on Postgres 14
test_close_on_connections_exit
: release-arm64test_sql_over_http_serverless_driver
: release-arm64Flaky tests (1)
Postgres 17
test_logical_replication[cross-validation]
: release-x86-64Test coverage report is not available
3532ae7 at 2024-10-18T13:21:07.818Z :recycle: