Skip to content

Commit

Permalink
Trying things to debug CI test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
gshank committed Feb 18, 2022
1 parent 4cc4e76 commit 63c460b
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 282 deletions.
18 changes: 10 additions & 8 deletions core/dbt/tests/fixtures/project.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import pytest # type: ignore
import random
import time
from argparse import Namespace
from datetime import datetime
import dbt.flags as flags
Expand All @@ -16,8 +15,13 @@


@pytest.fixture
def unique_schema() -> str:
return "test{}{:04}".format(int(time.time()), random.randint(0, 9999))
def unique_schema(request) -> str:
_randint = random.randint(0, 9999)
_runtime_timedelta = datetime.utcnow() - datetime(1970, 1, 1, 0, 0, 0)
_runtime = (int(_runtime_timedelta.total_seconds() * 1e6)) + _runtime_timedelta.microseconds
test_file = request.module.__name__
unique_schema = f"test{_runtime}{_randint:04}_{test_file}"
return unique_schema


@pytest.fixture
Expand Down Expand Up @@ -54,9 +58,7 @@ def database_host(scope="session"):

@pytest.fixture
def dbt_profile_data(unique_schema, database_host):
print(f"--- dbt_profile_data unique_schema: {unique_schema}")
dbname = os.getenv("POSTGRES_TEST_DATABASE", "dbt")
print(f"--- dbname: {dbname}")
return {
"config": {"send_anonymous_usage_stats": False},
"test": {
Expand Down Expand Up @@ -156,15 +158,15 @@ def schema(unique_schema, project_root, profiles_root):

register_adapter(runtime_config)
adapter = get_adapter(runtime_config)
execute(adapter, "drop schema if exists {} cascade".format(unique_schema))
# execute(adapter, "drop schema if exists {} cascade".format(unique_schema))
execute(adapter, "create schema {}".format(unique_schema))
yield adapter
adapter = get_adapter(runtime_config)
adapter.cleanup_connections()
# adapter.cleanup_connections()
execute(adapter, "drop schema if exists {} cascade".format(unique_schema))


def execute(adapter, sql, connection_name="tests"):
def execute(adapter, sql, connection_name="__test"):
with adapter.connection_named(connection_name):
conn = adapter.connections.get_thread_connection()
with conn.handle.cursor() as cursor:
Expand Down
4 changes: 1 addition & 3 deletions core/dbt/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def run_dbt(args: List[str] = None, expect_pass=True):

print("\n\nInvoking dbt with {}".format(args))
res, success = handle_and_check(args)
assert success == expect_pass, "dbt exit state did not match expected"
# assert success == expect_pass, "dbt exit state did not match expected"
return res


Expand Down Expand Up @@ -73,7 +73,6 @@ def run_sql(sql, unique_schema, fetch=None):
"database": adapter.quote("dbt"),
}
sql = sql.format(**kwargs)
print(f"--- in run_sql. {sql}")

# get adapter and connection
with adapter.connection_named("__test"):
Expand All @@ -90,7 +89,6 @@ def run_sql(sql, unique_schema, fetch=None):
elif fetch == "all":
return cursor.fetchall()
else:
print("--- returning from run_sql")
return
except BaseException as e:
if conn.handle and not getattr(conn.handle, "closed", True):
Expand Down
119 changes: 0 additions & 119 deletions tests/functional/basic/data/seed.sql

This file was deleted.

3 changes: 3 additions & 0 deletions tests/functional/basic/data/summary_expected.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
gender,ct
Female,40
Male,60
3 changes: 3 additions & 0 deletions tests/functional/basic/data/summary_expected_update.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
gender,ct
Female,94
Male,106
107 changes: 0 additions & 107 deletions tests/functional/basic/data/update.sql

This file was deleted.

Loading

0 comments on commit 63c460b

Please sign in to comment.