Skip to content

Commit

Permalink
add new interop tests for black-box json log schema testing (#4327) (#…
Browse files Browse the repository at this point in the history
…4428)

Co-authored-by: Nathaniel May <[email protected]>
  • Loading branch information
jtcohen6 and Nathaniel May authored Dec 3, 2021
1 parent 79cc811 commit 9882d08
Show file tree
Hide file tree
Showing 5 changed files with 545 additions and 12 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/structured-logging-schema-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# This Action checks makes a dbt run to sample json structured logs
# and checks that they conform to the currently documented schema.
#
# If this action fails it either means we have unintentionally deviated
# from our documented structured logging schema, or we need to bump the
# version of our structured logging and add new documentation to
# communicate these changes.


name: Structured Logging Schema Check
on:
push:
branches:
- "main"
- "*.latest"
- "releases/*"
pull_request:
workflow_dispatch:

permissions: read-all

jobs:
# run the performance measurements on the current or default branch
test-schema:
name: Test Log Schema
runs-on: ubuntu-latest
env:
# turns warnings into errors
RUSTFLAGS: "-D warnings"
# points tests to the log file
LOG_DIR: "/home/runner/work/dbt-core/dbt-core/logs"
# tells integration tests to output into json format
DBT_LOG_FORMAT: 'json'
steps:

- name: checkout dev
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Setup Python
uses: actions/[email protected]
with:
python-version: "3.8"

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: install dbt
run: pip install -r dev-requirements.txt -r editable-requirements.txt

- name: Set up postgres
uses: ./.github/actions/setup-postgres-linux

- name: ls
run: ls

# integration tests generate a ton of logs in different files. the next step will find them all.
# we actually care if these pass, because the normal test run doesn't usually include many json log outputs
- name: Run integration tests
run: tox -e py38-postgres -- -nauto

# apply our schema tests to every log event from the previous step
# skips any output that isn't valid json
- uses: actions-rs/cargo@v1
with:
command: run
args: --manifest-path test/interop/log_parsing/Cargo.toml
12 changes: 0 additions & 12 deletions test/integration/030_statement_test/test_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,3 @@ def test_postgres_statements(self):
self.assertEqual(len(results), 1)

self.assertTablesEqual("statement_actual", "statement_expected")

@use_profile("presto")
def test_presto_statements(self):
self.use_default_project({"seed-paths": [self.dir("seed")]})

results = self.run_dbt(["seed"])
self.assertEqual(len(results), 2)
results = self.run_dbt()
self.assertEqual(len(results), 1)

self.assertTablesEqual("statement_actual", "statement_expected")

204 changes: 204 additions & 0 deletions test/interop/log_parsing/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions test/interop/log_parsing/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "log_parsing"
version = "0.1.0"
edition = "2018"

[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0" }
chrono = { version = "0.4", features = ["serde"] }
walkdir = "2"
Loading

0 comments on commit 9882d08

Please sign in to comment.