dbt-labs / dbt-adapter-tests

a pytest plugin for dbt adapter test suites
19 stars 11 forks source link

how to debug #19

Open moshir opened 3 years ago

moshir commented 3 years ago

when running pytest --log-level DEBUG test/integration/myadapter.dbtspec i see the test has failed

2021-04-19 08:13:49.747050 (MainThread): 10:13:49 | Building catalog
2021-04-19 08:13:49.747320 (MainThread): Release called
2021-04-19 08:13:49.750699 (MainThread): 10:13:49 | Catalog written to /tmp/tmp6xs48y3t/project/target/catalog.json
2021-04-19 08:13:49.750909 (MainThread): Flushing usage events
2021-04-19 08:13:49.751095 (MainThread): Connection 'generate_catalog' was properly closed.

Executing step 7/8
Executing step 8/8
============================================================================== short test summary info ===============================================================================
FAILED test/integration/myadapter.dbtspec::test_dbt_empty

(i've tried to change pytest options, with no success) Any pointer about how to debug this ?

jtcohen6 commented 3 years ago

@moshir I was going to recommend running pytest -s test/integration/myadapter.dbtspec, which will prevent pytest from "capturing" debug-level logs and instead print them to stdout. It looks like you've managed to do that with --log-level DEBUG. So you're already in decent shape!

Could you provide a bit more context for the log snippet you've included? Are those steps 6-8 of test_dbt_empty? Does it seem that step 8/8 is where failure takes place?

If so, step 8 in the empty sequence is a catalog comparison step:

https://github.com/fishtown-analytics/dbt-adapter-tests/blob/a411336e9493a38c228a876e19af24d70ec53d86/pytest_dbt_adapter/sequences/empty.yml#L18-L23

Basically, dbt wants to introspect the database to double-check that all the sources it expects to be there, and all the nodes it expects to have just created, are indeed present. (Of course, In the case of the empty project, there are 0 sources and 0 models.) It does that by inspecting the catalog.json artifact produced by the previous docs generate step. Here's the code snippet that defines catalog comparison:

https://github.com/fishtown-analytics/dbt-adapter-tests/blob/a411336e9493a38c228a876e19af24d70ec53d86/pytest_dbt_adapter/spec_file.py#L400-L417

Hope this helps a bit with your debugging.