From e07d5d00e9bed719169dd9c20eb9bd84f512f83b Mon Sep 17 00:00:00 2001 From: Alek Westover Date: Fri, 16 Jun 2023 16:20:05 -0400 Subject: [PATCH] actually write correct data --- alek/env.txt | 1 + alek/output.txt | 1 + alek/test_ext.control | 5 +++++ test_runner/regress/test_download_extensions.py | 13 ++++++------- 4 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 alek/env.txt create mode 100644 alek/output.txt create mode 100644 alek/test_ext.control diff --git a/alek/env.txt b/alek/env.txt new file mode 100644 index 0000000000..d46e4e83e9 --- /dev/null +++ b/alek/env.txt @@ -0,0 +1 @@ +{'repo_dir': PosixPath('/home/alek/Desktop/neonX/test_output/test_file_download[debug-pg14]/repo'), 'rust_log_override': None, 'port_distributor': , 's3_mock_server': , 'neon_cli': , 'endpoints': , 'safekeepers': [Safekeeper(env=, port=SafekeeperPort(pg=15007, http=15008), id=1, running=True), Safekeeper(env=, port=SafekeeperPort(pg=15009, http=15010), id=2, running=True), Safekeeper(env=, port=SafekeeperPort(pg=15011, http=15012), id=3, running=True)], 'broker': NeonBroker(logfile=PosixPath('/home/alek/Desktop/neonX/test_output/test_file_download[debug-pg14]/repo/storage_broker.log'), port=15004, neon_binpath=PosixPath('/home/alek/Desktop/neonX/target/debug'), handle=), 'remote_storage': S3Storage(bucket_name='test_file_download', bucket_region='us-east-1', access_key='test', secret_key='test', endpoint='http://127.0.0.1:15003', prefix_in_bucket=None), 'remote_storage_users': , 'pg_version': '14', 'neon_binpath': PosixPath('/home/alek/Desktop/neonX/target/debug'), 'pg_distrib_dir': PosixPath('/home/alek/Desktop/neonX/pg_install'), 'endpoint_counter': 0, 'initial_tenant': `TenantId("861cf3b88b5e53ac412227ed9fd26d10"), 'initial_timeline': TimelineId("04179cf8c30a9d3652cd39d790b4e4b7"), 'pageserver': } \ No newline at end of file diff --git a/alek/output.txt b/alek/output.txt new file mode 100644 index 0000000000..50a5b6f9f0 --- /dev/null +++ b/alek/output.txt @@ -0,0 +1 @@ +NoneNone \ No newline at end of file diff --git a/alek/test_ext.control b/alek/test_ext.control new file mode 100644 index 0000000000..2db215bcb8 --- /dev/null +++ b/alek/test_ext.control @@ -0,0 +1,5 @@ +# mock extension +comment = 'Mock extension' +default_version = '1.0' +module_pathname = '$libdir/test_ext' +relocatable = true diff --git a/test_runner/regress/test_download_extensions.py b/test_runner/regress/test_download_extensions.py index 55f355e211..398edd77a1 100644 --- a/test_runner/regress/test_download_extensions.py +++ b/test_runner/regress/test_download_extensions.py @@ -35,7 +35,7 @@ def test_file_download(neon_env_builder: NeonEnvBuilder): neon_env_builder.num_safekeepers = 3 env = neon_env_builder.init_start() - with open("loggg", "w") as f: + with open("alek/env.txt", "w") as f: f.write(str(env.__dict__)) TEST_EXT_PATH = "v15/share/extension/test_ext.control" @@ -45,7 +45,7 @@ def test_file_download(neon_env_builder: NeonEnvBuilder): # 4. Upload test_ext.control file to the bucket # Later this will be done by CI/CD - with open("test_ext.control", "rb") as data: + with open("alek/test_ext.control", "rb") as data: neon_env_builder.remote_storage_client.upload_fileobj( data, neon_env_builder.remote_storage.bucket_name, TEST_EXT_PATH ) @@ -55,10 +55,9 @@ def test_file_download(neon_env_builder: NeonEnvBuilder): resp = neon_env_builder.remote_storage_client.get_object( Bucket=neon_env_builder.remote_storage.bucket_name, Key=TEST_EXT_PATH ) - content_length = resp["ResponseMetadata"]["HTTPHeaders"]["content-length"] - # TODO: this is not the correct path, nor the correct data to write - with open("pg_install/v15/lib/test_ext.control", "w") as f: - f.write(str(resp)) + response = resp["Body"] + with open("pg_install/v15/lib/test_ext.control", "wb") as f: + f.write(response.read()) # env.neon_cli @@ -72,7 +71,7 @@ def test_file_download(neon_env_builder: NeonEnvBuilder): # TODO: we should see the test_ext extension here other = cur.execute("SELECT * FROM pg_catalog.pg_tables;") whatsup = cur.execute("select * from pg_available_extensions;") - with open("output.txt", "w") as f: + with open("alek/output.txt", "w") as f: f.write(str(whatsup) + str(other)) # this is returning None????