-
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.
Merge pull request #2224 from Raalsky/fail-fast
Add --fail-fast argument for dbt run and dbt test
- Loading branch information
Showing
9 changed files
with
159 additions
and
36 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
select 1 /failed |
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 1 /failed |
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,49 @@ | ||
from test.integration.base import DBTIntegrationTest, use_profile | ||
from dbt.exceptions import FailFastException | ||
|
||
|
||
class TestFastFailingDuringRun(DBTIntegrationTest): | ||
@property | ||
def schema(self): | ||
return "fail_fast_058" | ||
|
||
@property | ||
def project_config(self): | ||
return { | ||
"on-run-start": "create table if not exists {{ target.schema }}.audit (model text)", | ||
'models': { | ||
'test': { | ||
'pre-hook': [ | ||
{ | ||
# we depend on non-deterministic nature of tasks execution | ||
# there is possibility to run next task in-between | ||
# first task failure and adapter connections cancellations | ||
# if you encounter any problems with these tests please report | ||
# the sleep command with random time minimize the risk | ||
'sql': "select pg_sleep(random())", | ||
'transaction': False | ||
}, | ||
{ | ||
'sql': "insert into {{ target.schema }}.audit values ('{{ this }}')", | ||
'transaction': False | ||
} | ||
], | ||
} | ||
} | ||
} | ||
|
||
@property | ||
def models(self): | ||
return "models" | ||
|
||
def check_audit_table(self, count=1): | ||
query = "select * from {schema}.audit".format(schema=self.unique_schema()) | ||
|
||
vals = self.run_sql(query, fetch='all') | ||
self.assertFalse(len(vals) == count, 'Execution was not stopped before run end') | ||
|
||
@use_profile('postgres') | ||
def test_postgres_fail_fast_run(self): | ||
with self.assertRaises(FailFastException): | ||
self.run_dbt(['run', '--threads', '1', '--fail-fast']) | ||
self.check_audit_table() |