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

spike unit test versions #9302

Draft
wants to merge 47 commits into
base: main
Choose a base branch
from
Draft

spike unit test versions #9302

wants to merge 47 commits into from

Conversation

emmyoop
Copy link
Member

@emmyoop emmyoop commented Dec 18, 2023

resolves #8799

Problem

Unit tests do not account for model versions.

Solution

Add functionality to

  1. unit test all versions of a model when a model is versions and no versions are specified in the unit test spec
  2. exclude specific model versions
  3. include only specific model version

Since the model versions are defined in the schema files we don't have this until the end of parsing. We need to patch unit tests to be able to determine what versions of the model needs to be unit tested.

This PR is a first pass at that. It fails in partial parsing because the unique ids have been modified to include the model version but when we're partial parsing we don't know the versions yet so it doesn't recognize them. When the model names is changed, it currently continues to run the old unit test and just adds a new unit test with a new name.

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX
  • This PR includes type annotations for new and modified functions

gshank and others added 30 commits August 14, 2023 16:04
Co-authored-by: Michelle Ark <michelle.ark@dbtlabs.com>
* WIP

* remove breakpoint

* fix tests, fix schema
* use unit test name as top level

* remove breakpoints

* finish converting tests

* fix unit test node name

* breakpoints

* fix partial parsing bug

* comment out duplicate test

* fix test and make unique id match other uniqu id patterns

* clean up

* fix incremental test

* Update tests/functional/unit_testing/test_unit_testing.py
* WIP

* adding tests

* fix tests

* more tests

* fix broken tests

* fix broken tests

* change to csv extension

* fix unit test yaml

* add mixed inline and file csv test

* add mixed inline and file csv test

* additional changes

* read file directly

* some cleanup and soem test fixes - wip

* fix test

* use better file searching

* fix final test

* cleanup

* use absolute path and fix tests
* Add unit tests to state:modified selection

* Get defer working too yolo

* Refactor per marky suggestion

* Add changelog

* separate out unit test state tests + fix csv fixture tests

* formatting

* detect changes to fixture files with state:modified

---------

Co-authored-by: Michelle Ark <michelle.ark@dbtlabs.com>
…fied in YAML config (#9064)

Co-authored-by: Michelle Ark <MichelleArk@users.noreply.github.com>
Fix #8652: Use seed value if rows not specified
gshank and others added 9 commits November 21, 2023 12:31
* Switch to using 'test' command instead of 'unit-test'

* Remove old unit test

* Put daff changes into task/test.py

* changie

* test_type:unit

* Add unit test to build and make test

* Select test_type:data

* Add unit tets to test_graph_selector_methods.py

* Fix fqn to incude path components

* Update build test

* Remove part of message in test_csv_fixtures.py that's different on Windows

* Rename build test directory
* convert test to data_test

* generate proto types

* fixing tests

* add tests

* add more tests

* test cleanup

* WIP

* fix graph

* fix testing manifest

* set resource type back to test and reset unique id

* reset expected run results

* cleanup

* changie

* modify to only look for tests under columns in schema files

* stop using dashes
more WIP

WIP

    version: Optional[UnitTestNodeVersion] = None
@cla-bot cla-bot bot added the cla:yes label Dec 18, 2023
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

Copy link

codecov bot commented Dec 18, 2023

Codecov Report

Attention: 145 lines in your changes are missing coverage. Please review.

Comparison is base (56dfb34) 86.88% compared to head (f693bdc) 80.26%.

Files Patch % Lines
core/dbt/parser/unit_tests.py 20.83% 95 Missing ⚠️
core/dbt/contracts/graph/manifest.py 36.95% 29 Missing ⚠️
core/dbt/contracts/graph/unparsed.py 67.74% 10 Missing ⚠️
core/dbt/parser/manifest.py 76.92% 6 Missing ⚠️
core/dbt/contracts/graph/nodes.py 90.00% 2 Missing ⚠️
core/dbt/contracts/files.py 75.00% 1 Missing ⚠️
core/dbt/exceptions.py 66.66% 1 Missing ⚠️
core/dbt/parser/schemas.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                       Coverage Diff                       @@
##           unit_testing_feature_branch    #9302      +/-   ##
===============================================================
- Coverage                        86.88%   80.26%   -6.62%     
===============================================================
  Files                              223      223              
  Lines                            27657    27865     +208     
===============================================================
- Hits                             24029    22367    -1662     
- Misses                            3628     5498    +1870     
Flag Coverage Δ
integration 80.26% <42.23%> (-3.63%) ⬇️
unit ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gshank gshank force-pushed the unit_testing_feature_branch branch from 5e98353 to 8fbbb65 Compare January 2, 2024 22:38
@gshank gshank force-pushed the unit_testing_feature_branch branch from 8fbbb65 to 56dfb34 Compare January 2, 2024 22:53
Base automatically changed from unit_testing_feature_branch to main January 16, 2024 22:37
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.

5 participants