-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
180 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
test/integration/067_store_test_failures_tests/data/expected/expected_failing_test.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
id,first_name,last_name,email,gender,ip_address | ||
1,Jack,Hunter,jhunter0@pbs.org,Male,59.80.20.168 | ||
2,Kathryn,Walker,kwalker1@ezinearticles.com,Female,194.121.179.35 | ||
3,Gerald,Ryan,gryan2@com.com,Male,11.3.212.243 | ||
4,Bonnie,Spencer,bspencer3@ameblo.jp,Female,216.32.196.175 | ||
5,Harold,Taylor,htaylor4@people.com.cn,Male,253.10.246.136 | ||
6,Jacqueline,Griffin,jgriffin5@t.co,Female,16.13.192.220 | ||
7,Wanda,Arnold,warnold6@google.nl,Female,232.116.150.64 | ||
8,Craig,Ortiz,cortiz7@sciencedaily.com,Male,199.126.106.13 | ||
9,Gary,Day,gday8@nih.gov,Male,35.81.68.186 | ||
10,Rose,Wright,rwright9@yahoo.co.jp,Female,236.82.178.100 |
3 changes: 3 additions & 0 deletions
3
...on/067_store_test_failures_tests/data/expected/expected_not_null_problematic_model_id.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
id,first_name,last_name,email,gender,ip_address | ||
,Gerald,Ryan,gryan2@com.com,Male,11.3.212.243 | ||
,Bonnie,Spencer,bspencer3@ameblo.jp,Female,216.32.196.175 |
3 changes: 3 additions & 0 deletions
3
...tion/067_store_test_failures_tests/data/expected/expected_unique_problematic_model_id.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
value,num | ||
2,2 | ||
1,2 |
11 changes: 11 additions & 0 deletions
11
test/integration/067_store_test_failures_tests/data/people.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
id,first_name,last_name,email,gender,ip_address | ||
1,Jack,Hunter,jhunter0@pbs.org,Male,59.80.20.168 | ||
2,Kathryn,Walker,kwalker1@ezinearticles.com,Female,194.121.179.35 | ||
3,Gerald,Ryan,gryan2@com.com,Male,11.3.212.243 | ||
4,Bonnie,Spencer,bspencer3@ameblo.jp,Female,216.32.196.175 | ||
5,Harold,Taylor,htaylor4@people.com.cn,Male,253.10.246.136 | ||
6,Jacqueline,Griffin,jgriffin5@t.co,Female,16.13.192.220 | ||
7,Wanda,Arnold,warnold6@google.nl,Female,232.116.150.64 | ||
8,Craig,Ortiz,cortiz7@sciencedaily.com,Male,199.126.106.13 | ||
9,Gary,Day,gday8@nih.gov,Male,35.81.68.186 | ||
10,Rose,Wright,rwright9@yahoo.co.jp,Female,236.82.178.100 |
1 change: 1 addition & 0 deletions
1
test/integration/067_store_test_failures_tests/models/fine_model.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
select * from {{ ref('people') }} |
11 changes: 11 additions & 0 deletions
11
test/integration/067_store_test_failures_tests/models/problematic_model.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
select * from {{ ref('people') }} | ||
|
||
union all | ||
|
||
select * from {{ ref('people') }} | ||
where id in (1,2) | ||
|
||
union all | ||
|
||
select null as id, first_name, last_name, email, gender, ip_address from {{ ref('people') }} | ||
where id in (3,4) |
17 changes: 17 additions & 0 deletions
17
test/integration/067_store_test_failures_tests/models/schema.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: 2 | ||
|
||
models: | ||
|
||
- name: fine_model | ||
columns: | ||
- name: id | ||
tests: | ||
- unique | ||
- not_null | ||
|
||
- name: problematic_model | ||
columns: | ||
- name: id | ||
tests: | ||
- unique | ||
- not_null |
97 changes: 97 additions & 0 deletions
97
test/integration/067_store_test_failures_tests/test_store_test_failures.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
from test.integration.base import DBTIntegrationTest, FakeArgs, use_profile | ||
|
||
from dbt.task.test import TestTask | ||
from dbt.task.list import ListTask | ||
|
||
|
||
class TestStoreTestFailures(DBTIntegrationTest): | ||
@property | ||
def schema(self): | ||
return "test_store_test_failures_067" | ||
|
||
@property | ||
def models(self): | ||
return "models" | ||
|
||
@property | ||
def project_config(self): | ||
return { | ||
"config-version": 2, | ||
"test-paths": ["tests"], | ||
"seeds": { | ||
"quote_columns": False, | ||
"test": { | ||
"expected": self.column_type_overrides() | ||
}, | ||
}, | ||
} | ||
|
||
def column_type_overrides(self): | ||
return {} | ||
|
||
def run_tests_store_failures_and_assert(self): | ||
test_audit_schema = self.unique_schema() + "_dbt_test__audit" | ||
|
||
self.run_dbt(["seed"]) | ||
self.run_dbt(["run"]) | ||
# make sure this works idempotently | ||
self.run_dbt(["test", "--store-failures"], expect_pass=False) | ||
results = self.run_dbt(["test", "--store-failures"], expect_pass=False) | ||
|
||
# compare test results | ||
actual = [(r.status, r.message) for r in results] | ||
expected = [('pass', 0), ('fail', 10), ('pass', 0), ('fail', 2), ('pass', 0), ('fail', 2)] | ||
self.assertEqual(sorted(actual), sorted(expected)) | ||
|
||
# compare test results stored in database | ||
self.assertTablesEqual("failing_test", "expected_failing_test", test_audit_schema) | ||
self.assertTablesEqual("not_null_problematic_model_id", "expected_not_null_problematic_model_id", test_audit_schema) | ||
self.assertTablesEqual("unique_problematic_model_id", "expected_unique_problematic_model_id", test_audit_schema) | ||
|
||
class PostgresTestStoreTestFailures(TestStoreTestFailures): | ||
@property | ||
def schema(self): | ||
return "067" # otherwise too long + truncated | ||
|
||
def column_type_overrides(self): | ||
return { | ||
"expected_unique_problematic_model_id": { | ||
"+column_types": { | ||
"num": "bigint", | ||
}, | ||
}, | ||
} | ||
|
||
@use_profile('postgres') | ||
def test__postgres__store_and_assert(self): | ||
self.run_tests_store_failures_and_assert() | ||
|
||
class RedshiftTestStoreTestFailures(TestStoreTestFailures): | ||
def column_type_overrides(self): | ||
return { | ||
"expected_not_null_problematic_model_id": { | ||
"+column_types": { | ||
"email": "varchar(26)", | ||
"first_name": "varchar(10)", | ||
}, | ||
}, | ||
"expected_unique_problematic_model_id": { | ||
"+column_types": { | ||
"num": "bigint", | ||
}, | ||
}, | ||
} | ||
|
||
@use_profile('redshift') | ||
def test__redshift__store_and_assert(self): | ||
self.run_tests_store_failures_and_assert() | ||
|
||
class SnowflakeTestStoreTestFailures(TestStoreTestFailures): | ||
@use_profile('snowflake') | ||
def test__snowflake__store_and_assert(self): | ||
self.run_tests_store_failures_and_assert() | ||
|
||
class BigQueryTestStoreTestFailures(TestStoreTestFailures): | ||
@use_profile('bigquery') | ||
def test__bigquery__store_and_assert(self): | ||
self.run_tests_store_failures_and_assert() |
1 change: 1 addition & 0 deletions
1
test/integration/067_store_test_failures_tests/tests/failing_test.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
select * from {{ ref('fine_model') }} |
2 changes: 2 additions & 0 deletions
2
test/integration/067_store_test_failures_tests/tests/passing_test.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
select * from {{ ref('fine_model') }} | ||
where false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters