mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-24 17:08:28 +00:00
MINOR: use archive instead of volume for postgres test (#16245)
* using archive instead of volume for postgres test * format * remove usage of request
This commit is contained in:
parent
2e52475b68
commit
c277233ef1
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import tarfile
|
||||||
import zipfile
|
import zipfile
|
||||||
from subprocess import CalledProcessError
|
from subprocess import CalledProcessError
|
||||||
|
|
||||||
@ -11,9 +12,10 @@ def postgres_container(tmp_path_factory):
|
|||||||
data_dir = tmp_path_factory.mktemp("data")
|
data_dir = tmp_path_factory.mktemp("data")
|
||||||
dvd_rental_zip = os.path.join(os.path.dirname(__file__), "data", "dvdrental.zip")
|
dvd_rental_zip = os.path.join(os.path.dirname(__file__), "data", "dvdrental.zip")
|
||||||
zipfile.ZipFile(dvd_rental_zip, "r").extractall(str(data_dir))
|
zipfile.ZipFile(dvd_rental_zip, "r").extractall(str(data_dir))
|
||||||
|
with tarfile.open(data_dir / "dvdrental_data.tar", "w") as tar:
|
||||||
|
tar.add(data_dir / "dvdrental.tar", arcname="dvdrental.tar")
|
||||||
|
|
||||||
container = PostgresContainer("postgres:15", dbname="dvdrental")
|
container = PostgresContainer("postgres:15", dbname="dvdrental")
|
||||||
container.volumes = {str(data_dir): {"bind": "/data"}}
|
|
||||||
container._command = [
|
container._command = [
|
||||||
"-c",
|
"-c",
|
||||||
"shared_preload_libraries=pg_stat_statements",
|
"shared_preload_libraries=pg_stat_statements",
|
||||||
@ -25,6 +27,10 @@ def postgres_container(tmp_path_factory):
|
|||||||
|
|
||||||
with container as container:
|
with container as container:
|
||||||
docker_container = container.get_wrapped_container()
|
docker_container = container.get_wrapped_container()
|
||||||
|
docker_container.exec_run(["mkdir", "/data"])
|
||||||
|
docker_container.put_archive(
|
||||||
|
"/data/", open(data_dir / "dvdrental_data.tar", "rb")
|
||||||
|
)
|
||||||
for query in (
|
for query in (
|
||||||
"CREATE USER postgres SUPERUSER;",
|
"CREATE USER postgres SUPERUSER;",
|
||||||
"CREATE EXTENSION pg_stat_statements;",
|
"CREATE EXTENSION pg_stat_statements;",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user