Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove duplicate logging during integration tests #4275

Merged
merged 1 commit into from
Nov 15, 2021

Conversation

jtcohen6
Copy link
Contributor

@jtcohen6 jtcohen6 commented Nov 12, 2021

This attemps to fix behavior that is unique to our integration testing framework. Adding (and re-adding) multiple log handlers, for multiple invocations-within-invocations, isn't something that should ever happen in real-world dbt use.

  • Try clearing existing FILE_LOG handlers before adding new one
  • Try clearing existing STDOUT_LOG handlers before adding new one. The catch: only clear TextIOWrapper handlers, to avoid messing up StringIO stdout handler used by run_dbt_and_capture

Before

$ python3 -m pytest -m profile_postgres test/integration/001_simple_copy_test/ -s
============================================================== test session starts ==============================================================
platform darwin -- Python 3.8.9, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /Users/jerco/dev/product/dbt, configfile: tox.ini
plugins: csv-3.0.0, logbook-1.2.0, flaky-3.7.0, xdist-2.4.0, dotenv-0.5.2, forked-1.3.0
collected 6 items

test/integration/001_simple_copy_test/test_simple_copy.py 15:38:40 | [ info  ] | Integration Test: Invoking dbt with ['seed', '--profiles-dir', '/var/folders/7h/hj5_fw9j291c58hwfdvy5xbm0000gp/T/dbt-int-test-atu19b64', '--log-cache-events']
15:38:40 | [ info  ] | Running with dbt=1.0.0-rc1
15:38:40 | [ info  ] | Partial parse save file not found. Starting full parse.
15:38:40 | [ info  ] | Partial parse save file not found. Starting full parse.
15:38:40 | [ warn  ] | [WARNING]: Test 'test.test.unique_disabled_id.a14f65086d' (models/schema.yml) depends on a node named 'disabled' which is disabled
15:38:40 | [ warn  ] | [WARNING]: Test 'test.test.unique_disabled_id.a14f65086d' (models/schema.yml) depends on a node named 'disabled' which is disabled
15:38:40 | [ info  ] | Found 8 models, 0 tests, 0 snapshots, 0 analyses, 165 macros, 0 operations, 1 seed file, 0 sources, 0 exposures, 0 metrics
15:38:40 | [ info  ] | Found 8 models, 0 tests, 0 snapshots, 0 analyses, 165 macros, 0 operations, 1 seed file, 0 sources, 0 exposures, 0 metrics
15:38:40 | [ info  ] |
15:38:40 | [ info  ] |
15:38:40 | [ info  ] | Concurrency: 4 threads (target='default2')
15:38:40 | [ info  ] | Concurrency: 4 threads (target='default2')
15:38:40 | [ info  ] |
15:38:40 | [ info  ] |
15:38:40 | [ info  ] | 1 of 1 START seed file test16367279223558005339_simple_copy_001.seed............ [RUN]
15:38:40 | [ info  ] | 1 of 1 START seed file test16367279223558005339_simple_copy_001.seed............ [RUN]
15:38:40 | [ info  ] | 1 of 1 OK loaded seed file test16367279223558005339_simple_copy_001.seed........ [INSERT 100 in 0.13s]
15:38:40 | [ info  ] | 1 of 1 OK loaded seed file test16367279223558005339_simple_copy_001.seed........ [INSERT 100 in 0.13s]
15:38:40 | [ info  ] |
15:38:40 | [ info  ] |
15:38:40 | [ info  ] | Finished running 1 seed in 0.24s.
15:38:40 | [ info  ] | Finished running 1 seed in 0.24s.
15:38:40 | [ info  ] |
15:38:40 | [ info  ] |
15:38:40 | [ info  ] | Completed successfully
15:38:40 | [ info  ] | Completed successfully
15:38:40 | [ info  ] |
Done. PASS=1 WARN=0 ERROR=0 SKIP=0 TOTAL=1
15:38:40 | [ info  ] |
Done. PASS=1 WARN=0 ERROR=0 SKIP=0 TOTAL=1
15:38:40 | [ info  ] | Integration Test: Invoking dbt with ['run', '--profiles-dir', '/var/folders/7h/hj5_fw9j291c58hwfdvy5xbm0000gp/T/dbt-int-test-atu19b64', '--log-cache-events']
15:38:40 | [ info  ] | Integration Test: Invoking dbt with ['run', '--profiles-dir', '/var/folders/7h/hj5_fw9j291c58hwfdvy5xbm0000gp/T/dbt-int-test-atu19b64', '--log-cache-events']
15:38:40 | [ info  ] | Running with dbt=1.0.0-rc1
15:38:40 | [ info  ] | Running with dbt=1.0.0-rc1
15:38:40 | [ info  ] | Found 8 models, 0 tests, 0 snapshots, 0 analyses, 165 macros, 0 operations, 1 seed file, 0 sources, 0 exposures, 0 metrics
15:38:40 | [ info  ] | Found 8 models, 0 tests, 0 snapshots, 0 analyses, 165 macros, 0 operations, 1 seed file, 0 sources, 0 exposures, 0 metrics
15:38:40 | [ info  ] | Found 8 models, 0 tests, 0 snapshots, 0 analyses, 165 macros, 0 operations, 1 seed file, 0 sources, 0 exposures, 0 metrics
15:38:40 | [ info  ] |
15:38:40 | [ info  ] |
15:38:40 | [ info  ] |
15:38:40 | [ info  ] | Concurrency: 4 threads (target='default2')
15:38:40 | [ info  ] | Concurrency: 4 threads (target='default2')
15:38:40 | [ info  ] | Concurrency: 4 threads (target='default2')

After

$ python3 -m pytest -m profile_postgres test/integration/001_simple_copy_test/ -s
============================================================== test session starts ==============================================================
platform darwin -- Python 3.8.9, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /Users/jerco/dev/product/dbt, configfile: tox.ini
plugins: csv-3.0.0, logbook-1.2.0, flaky-3.7.0, xdist-2.4.0, dotenv-0.5.2, forked-1.3.0
collected 6 items

test/integration/001_simple_copy_test/test_simple_copy.py 15:39:25 | [ info  ] | Integration Test: Invoking dbt with ['seed', '--profiles-dir', '/var/folders/7h/hj5_fw9j291c58hwfdvy5xbm0000gp/T/dbt-int-test-vhtwd3xm', '--log-cache-events']
15:39:25 | [ info  ] | Running with dbt=1.0.0-rc1
15:39:25 | [ info  ] | Partial parse save file not found. Starting full parse.
15:39:25 | [ warn  ] | [WARNING]: Test 'test.test.unique_disabled_id.a14f65086d' (models/schema.yml) depends on a node named 'disabled' which is disabled
15:39:25 | [ info  ] | Found 8 models, 0 tests, 0 snapshots, 0 analyses, 165 macros, 0 operations, 1 seed file, 0 sources, 0 exposures, 0 metrics
15:39:25 | [ info  ] |
15:39:25 | [ info  ] | Concurrency: 4 threads (target='default2')
15:39:25 | [ info  ] |
15:39:25 | [ info  ] | 1 of 1 START seed file test16367279671834065649_simple_copy_001.seed............ [RUN]
15:39:25 | [ info  ] | 1 of 1 OK loaded seed file test16367279671834065649_simple_copy_001.seed........ [INSERT 100 in 0.12s]
15:39:25 | [ info  ] |
15:39:25 | [ info  ] | Finished running 1 seed in 0.22s.
15:39:25 | [ info  ] |
15:39:25 | [ info  ] | Completed successfully
15:39:25 | [ info  ] |
Done. PASS=1 WARN=0 ERROR=0 SKIP=0 TOTAL=1
15:39:25 | [ info  ] | Integration Test: Invoking dbt with ['run', '--profiles-dir', '/var/folders/7h/hj5_fw9j291c58hwfdvy5xbm0000gp/T/dbt-int-test-vhtwd3xm', '--log-cache-events']
15:39:25 | [ info  ] | Running with dbt=1.0.0-rc1
15:39:25 | [ info  ] | Found 8 models, 0 tests, 0 snapshots, 0 analyses, 165 macros, 0 operations, 1 seed file, 0 sources, 0 exposures, 0 metrics
15:39:25 | [ info  ] |
15:39:25 | [ info  ] | Concurrency: 4 threads (target='default2')

@cla-bot cla-bot bot added the cla:yes label Nov 12, 2021
@jtcohen6 jtcohen6 marked this pull request as ready for review November 12, 2021 14:40
@jtcohen6 jtcohen6 requested a review from gshank November 12, 2021 14:40
@jtcohen6 jtcohen6 mentioned this pull request Nov 12, 2021
26 tasks
Copy link
Contributor

@nathaniel-may nathaniel-may left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright. If it works it works. Thanks for finding this fix!

@jtcohen6 jtcohen6 merged commit 4a8a680 into main Nov 15, 2021
@jtcohen6 jtcohen6 deleted the rm/int-test-dupe-logging branch November 15, 2021 10:00
iknox-fa pushed a commit that referenced this pull request Feb 8, 2022
automatic commit by git-black, original commits:
  4a8a680
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants