diff --git a/CHANGELOG.md b/CHANGELOG.md index eb6f4c354ea..a572833d9d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/core/dbt/contracts/results.py b/core/dbt/contracts/results.py index ea42ad81ede..8b3ee378d2a 100644 --- a/core/dbt/contracts/results.py +++ b/core/dbt/contracts/results.py @@ -69,6 +69,10 @@ def skipped(self): class WritableRunModelResult(PartialResult): skip: bool = False + @property + def skipped(self): + return self.skip + @dataclass class RunModelResult(WritableRunModelResult): diff --git a/test/integration/001_simple_copy_test/test_simple_copy.py b/test/integration/001_simple_copy_test/test_simple_copy.py index bcc72d130a1..4866eb79a6a 100644 --- a/test/integration/001_simple_copy_test/test_simple_copy.py +++ b/test/integration/001_simple_copy_test/test_simple_copy.py @@ -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): @@ -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: @@ -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 diff --git a/test/integration/021_concurrency_test/test_concurrency.py b/test/integration/021_concurrency_test/test_concurrency.py index 1dc4ebc49e1..418a22590fe 100644 --- a/test/integration/021_concurrency_test/test_concurrency.py +++ b/test/integration/021_concurrency_test/test_concurrency.py @@ -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") @@ -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") diff --git a/test/integration/base.py b/test/integration/base.py index 408129f665b..f1e3c56a38f 100644 --- a/test/integration/base.py +++ b/test/integration/base.py @@ -1,5 +1,6 @@ import json import os +import io import random import shutil import tempfile @@ -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: