test reals3

This commit is contained in:
Alek Westover
2023-06-23 15:51:49 -04:00
parent ca59330df8
commit a8f848b5de
2 changed files with 22 additions and 21 deletions
+1
View File
@@ -215,6 +215,7 @@ fn main() -> Result<()> {
.await
.context("get_avilable_extensions error")
})?;
drop(rt);
if !spec_set {
// No spec provided, hang waiting for it.
+21 -21
View File
@@ -42,7 +42,7 @@ relocatable = true"""
return output
@pytest.mark.parametrize("remote_storage_kind", [RemoteStorageKind.MOCK_S3])
@pytest.mark.parametrize("remote_storage_kind", [RemoteStorageKind.REAL_S3])
def test_file_download(neon_env_builder: NeonEnvBuilder, remote_storage_kind: RemoteStorageKind):
"""
Tests we can download a file
@@ -73,7 +73,7 @@ def test_file_download(neon_env_builder: NeonEnvBuilder, remote_storage_kind: Re
# Upload test_ext{i}.control files to the bucket (for MOCK_S3)
# Note: In real life this is done by CI/CD
for i in ["", "B"]:
for i in range(5):
# public extensions
public_ext = BytesIO(bytes(ext_contents("public", i), "utf-8"))
public_remote_name = f"{BUCKET_PREFIX}/{PUB_EXT_ROOT}/test_ext{i}.control"
@@ -89,11 +89,11 @@ def test_file_download(neon_env_builder: NeonEnvBuilder, remote_storage_kind: Re
env.remote_storage_client.upload_fileobj(
public_ext, env.ext_remote_storage.bucket_name, public_remote_name
)
env.remote_storage_client.upload_fileobj(
private_ext, env.ext_remote_storage.bucket_name, private_remote_name
)
# env.remote_storage_client.upload_fileobj(
# private_ext, env.ext_remote_storage.bucket_name, private_remote_name
# )
TEST_EXT_SQL_PATH = "v14/share/postgresql/extension/test_ext--1.0.sql"
TEST_EXT_SQL_PATH = "v14/share/postgresql/extension/test_ext0--1.0.sql"
test_ext_sql_file = BytesIO(
b"""
CREATE FUNCTION test_ext_add(integer, integer) RETURNS integer
@@ -110,7 +110,7 @@ def test_file_download(neon_env_builder: NeonEnvBuilder, remote_storage_kind: Re
)
# upload some fake library file
TEST_LIB_PATH = "v14/lib/test_ext.so"
TEST_LIB_PATH = "v14/lib/test_ext0.so"
test_lib_file = BytesIO(
b"""
111
@@ -154,24 +154,24 @@ def test_file_download(neon_env_builder: NeonEnvBuilder, remote_storage_kind: Re
all_extensions = [x[0] for x in cur.fetchall()]
log.info("ALEK*" * 100)
log.info(all_extensions)
for i in ["", "B"]:
for i in range(5):
assert f"test_ext{i}" in all_extensions
# assert f"private_ext{i}" in all_extensions
cur.execute("CREATE EXTENSION test_ext")
cur.execute("SELECT extname FROM pg_extension")
all_extensions = [x[0] for x in cur.fetchall()]
log.info(all_extensions)
assert "test_ext" in all_extensions
# cur.execute("CREATE EXTENSION test_ext0")
# cur.execute("SELECT extname FROM pg_extension")
# all_extensions = [x[0] for x in cur.fetchall()]
# log.info(all_extensions)
# assert "test_ext0" in all_extensions
try:
cur.execute("LOAD 'test_ext.so'")
except Exception as e:
# expected to fail with
# could not load library ... test_ext.so: file too short
# because test_ext.so is not real library file
log.info("LOAD test_ext.so failed (expectedly): %s", e)
assert "file too short" in str(e)
# try:
# cur.execute("LOAD 'test_ext0.so'")
# except Exception as e:
# # expected to fail with
# # could not load library ... test_ext.so: file too short
# # because test_ext.so is not real library file
# log.info("LOAD test_ext0.so failed (expectedly): %s", e)
# assert "file too short" in str(e)
# TODO add more test cases:
# - try to load non-existing library