Skip to content

Commit

Permalink
Ele 1773 package tests fixes (#547)
Browse files Browse the repository at this point in the history
* test-warehouse: upload HTML report even when tests fail

* test-warehouse: add warehouse type to branch name

* test-warehouse: bugfix

* test-warehouse: change schema name
  • Loading branch information
haritamar authored and dapollak committed Sep 26, 2023
1 parent 75eddb4 commit 6cd3893
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-warehouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ jobs:
run: |
mkdir -p ~/.dbt
DBT_VERSION=$(pip show dbt-core | grep -i version | awk '{print $2}' | sed 's/\.//g')
UNDERSCORED_REF_NAME=$(echo "dbt_${DBT_VERSION}_${BRANCH_NAME}" | head -c 32 | sed "s/-/_/g")
echo "$PROFILES_YML" | base64 -d | sed "s/<SCHEMA_NAME>/dbt_$UNDERSCORED_REF_NAME/g" > ~/.dbt/profiles.yml
UNDERSCORED_REF_NAME=$(echo "${{ inputs.warehouse-type }}_dbt_${DBT_VERSION}_${BRANCH_NAME}" | head -c 32 | sed "s/-/_/g")
echo "$PROFILES_YML" | base64 -d | sed "s/<SCHEMA_NAME>/dbt_pkg_$UNDERSCORED_REF_NAME/g" > ~/.dbt/profiles.yml
- name: Check DWH connection
working-directory: ${{ env.TESTS_DIR }}
Expand Down
18 changes: 12 additions & 6 deletions integration_tests/tests/test_anomalies_backfill_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def test_longer_backfill_in_case_of_a_gap(dbt_project: DbtProject, test_id: str)
for _ in range(5)
if cur_date < utc_today - timedelta(date_gap_size)
]
dbt_project.test(
test_result = dbt_project.test(
test_id,
DBT_TEST_NAME,
DBT_TEST_ARGS,
Expand All @@ -137,6 +137,7 @@ def test_longer_backfill_in_case_of_a_gap(dbt_project: DbtProject, test_id: str)
).isoformat()
},
)
assert test_result["status"] != "error"
assert get_row_count_metrics(dbt_project, test_id) == {
cur_date: 5
for cur_date in data_dates
Expand All @@ -148,14 +149,15 @@ def test_longer_backfill_in_case_of_a_gap(dbt_project: DbtProject, test_id: str)
data = [
{TIMESTAMP_COLUMN: cur_date.strftime(DATE_FORMAT)} for cur_date in data_dates
]
dbt_project.test(
test_result = dbt_project.test(
test_id,
DBT_TEST_NAME,
DBT_TEST_ARGS,
data=data,
as_model=True,
materialization="incremental",
)
assert test_result["status"] != "error"
assert get_row_count_metrics(dbt_project, test_id) == {
cur_date: 5 if cur_date < utc_today - timedelta(date_gap_size) else 1
for cur_date in data_dates
Expand All @@ -176,7 +178,7 @@ def test_full_backfill_if_metric_not_updated_for_a_long_time(
for _ in range(5)
if cur_date < utc_today - timedelta(date_gap_size)
]
dbt_project.test(
test_result = dbt_project.test(
test_id,
DBT_TEST_NAME,
DBT_TEST_ARGS,
Expand All @@ -189,6 +191,7 @@ def test_full_backfill_if_metric_not_updated_for_a_long_time(
).isoformat()
},
)
assert test_result["status"] != "error"
assert get_row_count_metrics(dbt_project, test_id) == {
cur_date: 5
for cur_date in data_dates
Expand All @@ -200,14 +203,15 @@ def test_full_backfill_if_metric_not_updated_for_a_long_time(
data = [
{TIMESTAMP_COLUMN: cur_date.strftime(DATE_FORMAT)} for cur_date in data_dates
]
dbt_project.test(
test_result = dbt_project.test(
test_id,
DBT_TEST_NAME,
DBT_TEST_ARGS,
data=data,
as_model=True,
materialization="incremental",
)
assert test_result["status"] != "error"
assert get_row_count_metrics(dbt_project, test_id) == {
cur_date: 5 if cur_date < utc_today - timedelta(DAYS_BACK) else 1
for cur_date in data_dates
Expand All @@ -231,14 +235,15 @@ def test_backfill_when_metric_doesnt_exist_back_enough(
for cur_date in data_dates
for _ in range(5)
]
dbt_project.test(
test_result = dbt_project.test(
test_id,
DBT_TEST_NAME,
DBT_TEST_ARGS,
data=data,
as_model=True,
materialization="incremental",
)
assert test_result["status"] != "error"
assert get_row_count_metrics(dbt_project, test_id) == {
cur_date: 5
for cur_date in data_dates
Expand All @@ -248,7 +253,7 @@ def test_backfill_when_metric_doesnt_exist_back_enough(
data = [
{TIMESTAMP_COLUMN: cur_date.strftime(DATE_FORMAT)} for cur_date in data_dates
]
dbt_project.test(
test_result = dbt_project.test(
test_id,
DBT_TEST_NAME,
DBT_TEST_ARGS,
Expand All @@ -257,6 +262,7 @@ def test_backfill_when_metric_doesnt_exist_back_enough(
materialization="incremental",
test_vars={"days_back": 21},
)
assert test_result["status"] != "error"
assert get_row_count_metrics(dbt_project, test_id) == {
cur_date: 1 for cur_date in data_dates if cur_date >= utc_today - timedelta(21)
}

0 comments on commit 6cd3893

Please sign in to comment.