Skip to content

Commit 9d2b5ab

Browse files
Reorganize test_common: move helpers into helpers/, split test_helpers.py (#232)
Signed-off-by: Aykut Bozkurt <aykut.bozkurt@snowflake.com>
1 parent 3bc6c9f commit 9d2b5ab

76 files changed

Lines changed: 3845 additions & 4139 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ __pycache__
3838
delete_old_cluster.sh
3939
**/isolation/output
4040
**/isolation/isolation.conf
41-
pg_lake_iceberg/logs/polaris.log
41+
pg_lake_iceberg/logs/*
4242
pg_lake_table/logs/
4343
.volume/
4444
Dockerfile.alpine
Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1 @@
1-
import pytest
2-
import psycopg2
3-
import server_params
4-
import time
5-
import os
6-
from utils_pytest import *
7-
8-
PG_DIR = "/tmp/pg_extension_base_tests"
9-
10-
11-
@pytest.fixture(scope="module")
12-
def pg_extension_base():
13-
superuser_conn = open_pg_conn()
14-
15-
run_command(
16-
f"""
17-
CREATE EXTENSION IF NOT EXISTS pg_extension_base CASCADE;
18-
""",
19-
superuser_conn,
20-
)
21-
superuser_conn.commit()
22-
superuser_conn.close()
23-
24-
yield
25-
26-
superuser_conn = open_pg_conn()
27-
28-
run_command(
29-
f"""
30-
DROP EXTENSION IF EXISTS pg_extension_base CASCADE;
31-
""",
32-
superuser_conn,
33-
)
34-
superuser_conn.commit()
35-
superuser_conn.close()
1+
from utils_pytest import pytest_addoption, pytest_sessionstart

pg_extension_base/tests/pytests/test_attached_workers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import psycopg2
33
import time
44
from utils_pytest import *
5-
import server_params
65

76

87
def test_simple(superuser_conn, pg_extension_base):

pg_extension_base/tests/pytests/test_base_worker_launcher.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import psycopg2
33
import time
44
from utils_pytest import *
5-
import server_params
65

76

87
def test_server_start(superuser_conn):

pg_lake/tests/conftest.py

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1 @@
1-
import duckdb
2-
import os
3-
import psycopg2
4-
import psycopg2.extras
5-
import pytest
6-
import shutil
7-
import subprocess
8-
import queue
9-
import threading
10-
import time
11-
from pathlib import Path
12-
from utils_pytest import *
13-
14-
reduce_werkzeug_log_level()
15-
16-
17-
@pytest.fixture(scope="module")
18-
def superuser_conn(postgres):
19-
conn = open_pg_conn()
20-
yield conn
21-
conn.close()
22-
23-
24-
@pytest.fixture(scope="module")
25-
def pg_lake_extension():
26-
superuser_conn = open_pg_conn()
27-
28-
run_command(
29-
f"""
30-
CREATE EXTENSION IF NOT EXISTS pg_lake CASCADE;
31-
""",
32-
superuser_conn,
33-
)
34-
superuser_conn.commit()
35-
superuser_conn.close()
36-
37-
yield
38-
39-
superuser_conn = open_pg_conn()
40-
run_command(
41-
f"""
42-
DROP EXTENSION IF EXISTS pg_lake CASCADE;
43-
""",
44-
superuser_conn,
45-
)
46-
superuser_conn.commit()
47-
superuser_conn.close()
1+
from utils_pytest import pytest_addoption, pytest_sessionstart
Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1 @@
1-
import duckdb
2-
import os
3-
import psycopg2
4-
import psycopg2.extras
5-
import pytest
6-
import shutil
7-
import subprocess
8-
import queue
9-
import threading
10-
import time
11-
from pathlib import Path
12-
from utils_pytest import *
13-
14-
reduce_werkzeug_log_level()
15-
16-
17-
@pytest.fixture(scope="module")
18-
def superuser_conn(postgres):
19-
conn = open_pg_conn()
20-
yield conn
21-
conn.close()
22-
23-
24-
@pytest.fixture(scope="module")
25-
def pgduck_conn(postgres):
26-
conn = psycopg2.connect(
27-
host=server_params.PGDUCK_UNIX_DOMAIN_PATH, port=server_params.PGDUCK_PORT
28-
)
29-
yield conn
30-
conn.close()
31-
32-
33-
@pytest.fixture(scope="module")
34-
def pg_lake_benchmark_extension():
35-
superuser_conn = open_pg_conn()
36-
37-
run_command(
38-
f"""
39-
CREATE EXTENSION IF NOT EXISTS pg_lake_benchmark CASCADE;
40-
""",
41-
superuser_conn,
42-
)
43-
superuser_conn.commit()
44-
superuser_conn.close()
45-
46-
yield
47-
48-
superuser_conn = open_pg_conn()
49-
run_command(
50-
f"""
51-
DROP EXTENSION IF EXISTS pg_lake_benchmark;
52-
""",
53-
superuser_conn,
54-
)
55-
superuser_conn.commit()
56-
superuser_conn.close()
1+
from utils_pytest import pytest_addoption, pytest_sessionstart

pg_lake_copy/tests/conftest.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
1-
import os
2-
import psycopg2
3-
import psycopg2.extras
41
import pytest
5-
import shutil
6-
import subprocess
7-
import queue
8-
import threading
9-
import time
10-
from pathlib import Path
112
from utils_pytest import *
12-
import server_params
13-
14-
reduce_werkzeug_log_level()
153

164

175
# This fixture ensures that the app_user can read/write URLs for all tests in this file
@@ -26,27 +14,3 @@ def setup_readwrite_perms(superuser_conn, app_user):
2614
superuser_conn.commit()
2715

2816
yield
29-
30-
31-
@pytest.fixture(scope="module")
32-
def pg_conn(postgres, app_user):
33-
conn = open_pg_conn(app_user)
34-
yield conn
35-
conn.close()
36-
37-
38-
@pytest.fixture(scope="module")
39-
def pgduck_conn(postgres):
40-
conn = psycopg2.connect(
41-
host=server_params.PGDUCK_UNIX_DOMAIN_PATH,
42-
port=server_params.PGDUCK_PORT,
43-
)
44-
yield conn
45-
conn.close()
46-
47-
48-
@pytest.fixture(scope="module")
49-
def duckdb_conn(s3):
50-
conn = create_duckdb_conn()
51-
yield conn
52-
conn.close()

pg_lake_copy/tests/pytests/test_delta_copy.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import psycopg2
33
import time
44
import duckdb
5-
from fixtures.delta import *
65
from utils_pytest import *
76

87

pg_lake_iceberg/tests/conftest.py

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1 @@
1-
import duckdb
2-
import os
3-
import psycopg2
4-
import psycopg2.extras
5-
import pytest
6-
import shutil
7-
import queue
8-
import threading
9-
import time
10-
from utils_pytest import *
11-
import server_params
12-
13-
reduce_werkzeug_log_level()
14-
15-
16-
@pytest.fixture(scope="module")
17-
def pgduck_conn(postgres):
18-
conn = psycopg2.connect(
19-
host=server_params.PGDUCK_UNIX_DOMAIN_PATH, port=server_params.PGDUCK_PORT
20-
)
21-
yield conn
22-
conn.close()
23-
24-
25-
@pytest.fixture(scope="module")
26-
def test_s3_path(request, s3):
27-
return f"s3://{TEST_BUCKET}/{request.node.name}"
28-
29-
30-
@pytest.fixture(scope="module")
31-
def iceberg_catalog(superuser_conn, iceberg_extension, s3):
32-
catalog = create_iceberg_test_catalog(superuser_conn)
33-
yield catalog
34-
tables = catalog.list_tables("public")
35-
for table in tables:
36-
catalog.drop_table(table)
37-
catalog.drop_namespace("public")
38-
catalog.engine.dispose()
39-
40-
41-
@pytest.fixture(scope="module")
42-
def duckdb_conn(s3):
43-
conn = duckdb.connect(database=":memory:")
44-
conn.execute(
45-
"""
46-
CREATE SECRET s3test (
47-
TYPE S3, KEY_ID 'testing', SECRET 'testing',
48-
ENDPOINT 'localhost:5999',
49-
SCOPE 's3://testbucketcdw', URL_STYLE 'path', USE_SSL false
50-
);
51-
"""
52-
)
53-
conn.execute(
54-
"""
55-
CREATE SECRET gcstest (
56-
TYPE GCS, KEY_ID 'testing', SECRET 'testing',
57-
ENDPOINT 'localhost:5998',
58-
SCOPE 'gs://testbucketgcs', URL_STYLE 'path', USE_SSL false
59-
);
60-
"""
61-
)
62-
yield conn
63-
conn.close()
1+
from utils_pytest import pytest_addoption, pytest_sessionstart

pg_lake_iceberg/tests/pytests/test_iceberg_data_file_stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import string
55
import sys
66
from utils_pytest import *
7-
from spark_utils import *
7+
from helpers.spark import *
88

99
SPARK_TABLE_NAME = "test_pg_lake_iceberg_file_stats"
1010
SPARK_TABLE_NAMESPACE = "public"

0 commit comments

Comments
 (0)