Skip to content

Commit 1fef8f3

Browse files
revert to old script
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent d426655 commit 1fef8f3

File tree

5 files changed

+37
-287
lines changed

5 files changed

+37
-287
lines changed

examples/experimental/sea_connector_test.py

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
"""
22
Main script to run all SEA connector tests.
33
4-
This script imports and runs all the individual test modules and displays
4+
This script runs all the individual test modules and displays
55
a summary of test results with visual indicators.
66
"""
77
import os
88
import sys
99
import logging
10-
import importlib.util
11-
from typing import Dict, Callable, List, Tuple
10+
import subprocess
11+
from typing import List, Tuple
1212

13-
# Configure logging
14-
logging.basicConfig(level=logging.INFO)
13+
logging.basicConfig(level=logging.DEBUG)
1514
logger = logging.getLogger(__name__)
1615

17-
# Define test modules and their main test functions
1816
TEST_MODULES = [
1917
"test_sea_session",
2018
"test_sea_sync_query",
@@ -23,29 +21,27 @@
2321
]
2422

2523

26-
def load_test_function(module_name: str) -> Callable:
27-
"""Load a test function from a module."""
24+
def run_test_module(module_name: str) -> bool:
25+
"""Run a test module and return success status."""
2826
module_path = os.path.join(
2927
os.path.dirname(os.path.abspath(__file__)), "tests", f"{module_name}.py"
3028
)
3129

32-
spec = importlib.util.spec_from_file_location(module_name, module_path)
33-
module = importlib.util.module_from_spec(spec)
34-
spec.loader.exec_module(module)
30+
# Simply run the module as a script - each module handles its own test execution
31+
result = subprocess.run(
32+
[sys.executable, module_path], capture_output=True, text=True
33+
)
3534

36-
# Get the main test function (assuming it starts with "test_")
37-
for name in dir(module):
38-
if name.startswith("test_") and callable(getattr(module, name)):
39-
# For sync and async query modules, we want the main function that runs both tests
40-
if name == f"test_sea_{module_name.replace('test_sea_', '')}_exec":
41-
return getattr(module, name)
35+
# Log the output from the test module
36+
if result.stdout:
37+
for line in result.stdout.strip().split("\n"):
38+
logger.info(line)
4239

43-
# Fallback to the first test function found
44-
for name in dir(module):
45-
if name.startswith("test_") and callable(getattr(module, name)):
46-
return getattr(module, name)
40+
if result.stderr:
41+
for line in result.stderr.strip().split("\n"):
42+
logger.error(line)
4743

48-
raise ValueError(f"No test function found in module {module_name}")
44+
return result.returncode == 0
4945

5046

5147
def run_tests() -> List[Tuple[str, bool]]:
@@ -54,12 +50,11 @@ def run_tests() -> List[Tuple[str, bool]]:
5450

5551
for module_name in TEST_MODULES:
5652
try:
57-
test_func = load_test_function(module_name)
5853
logger.info(f"\n{'=' * 50}")
5954
logger.info(f"Running test: {module_name}")
6055
logger.info(f"{'-' * 50}")
6156

62-
success = test_func()
57+
success = run_test_module(module_name)
6358
results.append((module_name, success))
6459

6560
status = "✅ PASSED" if success else "❌ FAILED"

examples/experimental/tests/test_sea_async_query.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ def test_sea_async_query_with_cloud_fetch():
5151
f"Successfully opened SEA session with ID: {connection.get_session_id_hex()}"
5252
)
5353

54-
# Execute a query that returns 100 rows asynchronously
54+
# Execute a simple query asynchronously
5555
cursor = connection.cursor()
56-
logger.info("Executing asynchronous query with cloud fetch: SELECT 100 rows")
57-
cursor.execute_async(
58-
"SELECT id, 'test_value_' || CAST(id as STRING) as test_value FROM range(1, 101)"
56+
logger.info(
57+
"Executing asynchronous query with cloud fetch: SELECT 1 as test_value"
5958
)
59+
cursor.execute_async("SELECT 1 as test_value")
6060
logger.info(
6161
"Asynchronous query submitted successfully with cloud fetch enabled"
6262
)
@@ -69,8 +69,6 @@ def test_sea_async_query_with_cloud_fetch():
6969

7070
logger.info("Query is no longer pending, getting results...")
7171
cursor.get_async_execution_result()
72-
rows = cursor.fetchall()
73-
logger.info(f"Retrieved rows: {rows}")
7472
logger.info(
7573
"Successfully retrieved asynchronous query results with cloud fetch enabled"
7674
)
@@ -132,12 +130,12 @@ def test_sea_async_query_without_cloud_fetch():
132130
f"Successfully opened SEA session with ID: {connection.get_session_id_hex()}"
133131
)
134132

135-
# Execute a query that returns 100 rows asynchronously
133+
# Execute a simple query asynchronously
136134
cursor = connection.cursor()
137-
logger.info("Executing asynchronous query without cloud fetch: SELECT 100 rows")
138-
cursor.execute_async(
139-
"SELECT id, 'test_value_' || CAST(id as STRING) as test_value FROM range(1, 101)"
135+
logger.info(
136+
"Executing asynchronous query without cloud fetch: SELECT 1 as test_value"
140137
)
138+
cursor.execute_async("SELECT 1 as test_value")
141139
logger.info(
142140
"Asynchronous query submitted successfully with cloud fetch disabled"
143141
)
@@ -150,8 +148,6 @@ def test_sea_async_query_without_cloud_fetch():
150148

151149
logger.info("Query is no longer pending, getting results...")
152150
cursor.get_async_execution_result()
153-
rows = cursor.fetchall()
154-
logger.info(f"Retrieved rows: {rows}")
155151
logger.info(
156152
"Successfully retrieved asynchronous query results with cloud fetch disabled"
157153
)

examples/experimental/tests/test_sea_duplicate_rows.py

Lines changed: 0 additions & 199 deletions
This file was deleted.

examples/experimental/tests/test_sea_metadata.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,16 @@ def test_sea_metadata():
5656
cursor = connection.cursor()
5757
logger.info("Fetching catalogs...")
5858
cursor.catalogs()
59-
rows = cursor.fetchall()
60-
logger.info(f"Rows: {rows}")
6159
logger.info("Successfully fetched catalogs")
6260

6361
# Test schemas
6462
logger.info(f"Fetching schemas for catalog '{catalog}'...")
6563
cursor.schemas(catalog_name=catalog)
66-
rows = cursor.fetchall()
67-
logger.info(f"Rows: {rows}")
6864
logger.info("Successfully fetched schemas")
6965

7066
# Test tables
7167
logger.info(f"Fetching tables for catalog '{catalog}', schema 'default'...")
7268
cursor.tables(catalog_name=catalog, schema_name="default")
73-
rows = cursor.fetchall()
74-
logger.info(f"Rows: {rows}")
7569
logger.info("Successfully fetched tables")
7670

7771
# Test columns for a specific table
@@ -82,8 +76,6 @@ def test_sea_metadata():
8276
cursor.columns(
8377
catalog_name=catalog, schema_name="default", table_name="customer"
8478
)
85-
rows = cursor.fetchall()
86-
logger.info(f"Rows: {rows}")
8779
logger.info("Successfully fetched columns")
8880

8981
# Close resources

0 commit comments

Comments
 (0)