Skip to content

Commit

Permalink
Added integration test 058_fail_fast
Browse files Browse the repository at this point in the history
  • Loading branch information
Raalsky committed Mar 22, 2020
1 parent a23ad3a commit 42a0461
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/integration/058_fail_fast/models/one.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select 1 /failed
1 change: 1 addition & 0 deletions test/integration/058_fail_fast/models/two.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select 1 /failed
49 changes: 49 additions & 0 deletions test/integration/058_fail_fast/test_fail_fast_run.py
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_run_duplicate_hook_defs(self):
with self.assertRaises(FailFastException):
self.run_dbt(['run', '--threads', '1', '--fail-fast'])
self.check_audit_table()

0 comments on commit 42a0461

Please sign in to comment.