Skip to content

Commit

Permalink
(#2095) fix incorrect SKIP count in stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbanin committed Apr 14, 2020
1 parent 6424b65 commit 96a3736
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- When a Redshift table is defined as "auto", don't provide diststyle ([#2246](https://github.com/fishtown-analytics/dbt/issues/2246), [#2298](https://github.com/fishtown-analytics/dbt/pull/2298))
- Made file names lookups case-insensitve (.sql, .SQL, .yml, .YML) and if .yaml files are found, raise a warning indicating dbt will parse these files in future releases. ([#1681](https://github.com/fishtown-analytics/dbt/issues/1681), [#2263](https://github.com/fishtown-analytics/dbt/pull/2263))
- Return error message when profile is empty in profiles.yml. ([#2292](https://github.com/fishtown-analytics/dbt/issues/2292), [#2297](https://github.com/fishtown-analytics/dbt/pull/2297))
- Fix skipped node count in stdout at the end of a run ([#2095](https://github.com/fishtown-analytics/dbt/issues/2095), [#2310](https://github.com/fishtown-analytics/dbt/pull/2310))

Contributors:
- [@raalsky](https://github.com/Raalsky) ([#2224](https://github.com/fishtown-analytics/dbt/pull/2224), [#2228](https://github.com/fishtown-analytics/dbt/pull/2228))
Expand Down
4 changes: 4 additions & 0 deletions core/dbt/contracts/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def skipped(self):
class WritableRunModelResult(PartialResult):
skip: bool = False

@property
def skipped(self):
return self.skip


@dataclass
class RunModelResult(WritableRunModelResult):
Expand Down
19 changes: 4 additions & 15 deletions test/integration/001_simple_copy_test/test_simple_copy.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import io
import json
import os
from pytest import mark

from test.integration.base import DBTIntegrationTest, use_profile
from dbt.logger import log_manager


class BaseTestSimpleCopy(DBTIntegrationTest):
Expand Down Expand Up @@ -409,24 +407,14 @@ def project_config(self):
"data-paths": [self.dir("seed-initial")],
})

def setUp(self):
super().setUp()
self.initial_stdout = log_manager.stdout
self.initial_stderr = log_manager.stderr
self.stringbuf = io.StringIO()
log_manager.set_output_stream(self.stringbuf)

def tearDown(self):
log_manager.set_output_stream(self.initial_stdout, self.initial_stderr)
super().tearDown()

def seed_get_json(self, expect_pass=True):
self.run_dbt(
results, output = self.run_dbt_and_capture(
['--debug', '--log-format=json', '--single-threaded', 'seed'],
expect_pass=expect_pass
)

logs = []
for line in self.stringbuf.getvalue().split('\n'):
for line in output.split('\n'):
try:
log = json.loads(line)
except ValueError:
Expand All @@ -435,6 +423,7 @@ def seed_get_json(self, expect_pass=True):
if log['extra'].get('run_state') != 'internal':
continue
logs.append(log)

self.assertGreater(len(logs), 0)
return logs

Expand Down
4 changes: 3 additions & 1 deletion test/integration/021_concurrency_test/test_concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test__postgres__concurrency(self):

self.run_sql_file("update.sql")

results = self.run_dbt(expect_pass=False)
results, output = self.run_dbt_and_capture(expect_pass=False)
self.assertEqual(len(results), 7)

self.assertTablesEqual("seed", "view_model")
Expand All @@ -36,6 +36,8 @@ def test__postgres__concurrency(self):
self.assertTableDoesNotExist("invalid")
self.assertTableDoesNotExist("skip")

self.assertIn('PASS=5 WARN=0 ERROR=1 SKIP=1 TOTAL=7', output)

@use_profile('snowflake')
def test__snowflake__concurrency(self):
self.run_sql_file("seed.sql")
Expand Down
17 changes: 17 additions & 0 deletions test/integration/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import io
import random
import shutil
import tempfile
Expand Down Expand Up @@ -537,6 +538,22 @@ def run_dbt(self, args=None, expect_pass=True, strict=True, parser=True, profile

return res


def run_dbt_and_capture(self, *args, **kwargs):
try:
initial_stdout = log_manager.stdout
initial_stderr = log_manager.stderr
stringbuf = io.StringIO()
log_manager.set_output_stream(stringbuf)

res = self.run_dbt(*args, **kwargs)
stdout = stringbuf.getvalue()

finally:
log_manager.set_output_stream(initial_stdout, initial_stderr)

return res, stdout

def run_dbt_and_check(self, args=None, strict=True, parser=False, profiles_dir=True):
log_manager.reset_handlers()
if args is None:
Expand Down

0 comments on commit 96a3736

Please sign in to comment.