Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion docs/runbooks/scenario-runner.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

The scenario runner executes end-to-end managed-warehouse flows against a configured dev environment. The first smoke scenario provisions a warehouse, waits for readiness, runs `SELECT 1` over PGWire with managed-hostname SNI, then deprovisions and verifies cleanup.

The frozen metadata and perf scenarios provision the same fresh dev warehouse shape, create read-only views over frozen persons/events parquet supplied by `DUCKGRES_SCENARIO_FROZEN_S3_URI`, run their workload, then deprovision.
The frozen metadata, perf, and dbt scenarios provision the same fresh dev warehouse shape, create read-only views over frozen persons/events parquet supplied by `DUCKGRES_SCENARIO_FROZEN_S3_URI`, run their workload, then deprovision.

## Required Environment

Expand All @@ -26,6 +26,7 @@ export DUCKGRES_SCENARIO_OUTPUT_BASE="artifacts/scenario"
export DUCKGRES_SCENARIO_RUN_ID="scenario-smoke-manual"
export DUCKGRES_SCENARIO_PG_PORT="5432"
export DUCKGRES_SCENARIO_PG_CONNECT_TIMEOUT="10"
export DUCKGRES_SCENARIO_DBT_BIN="dbt"
export DUCKGRES_SCENARIO_MAX_RUNTIME="30m"
export DUCKGRES_SCENARIO_GO_TEST_TIMEOUT="60m"
```
Expand Down Expand Up @@ -71,6 +72,12 @@ Run frozen perf queries:
just scenario-frozen-perf
```

Run frozen dbt lifecycle:

```bash
just scenario-frozen-dbt
```

Run a specific scenario file:

```bash
Expand All @@ -92,6 +99,13 @@ The frozen perf scenario uses:

Perf artifacts are written under `artifacts/scenario/<run_id>/perf/` using the existing `tests/perf/core` artifact schema, including `query_results.csv`, `summary.json`, and `server_metrics.prom`.

The frozen dbt scenario uses:

- `tests/scenario/scenarios/posthog_frozen_dbt.yaml`
- `tests/scenario/dbt/posthog_frozen_project/`

dbt artifacts are written under `artifacts/scenario/<run_id>/dbt/`, including per-command stdout/stderr logs, `target/` artifacts, and dbt logs. Install `dbt-postgres` locally or set `DUCKGRES_SCENARIO_DBT_BIN` to the dbt executable to use.

`DUCKGRES_SCENARIO_FROZEN_S3_URI` must point at a dev-owned frozen dataset prefix with `persons/` and `events/` parquet children.
The provisioned Duckgres worker role also needs read/list access to that prefix; the runner process only supplies the URI, while the worker performs the S3 reads during `read_parquet`.

Expand Down
5 changes: 5 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@ scenario-frozen-metadata:
scenario-frozen-perf:
./scripts/scenario_run.sh tests/scenario/scenarios/posthog_frozen_perf.yaml

# Run the dev frozen dataset dbt scenario
[group('test')]
scenario-frozen-dbt:
./scripts/scenario_run.sh tests/scenario/scenarios/posthog_frozen_dbt.yaml

# Lint (matches CI — uses golangci-lint, not go vet)
[group('test')]
lint:
Expand Down
1 change: 1 addition & 0 deletions scripts/scenario_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Optional environment:
DUCKGRES_SCENARIO_PG_CONNECT_TIMEOUT
DUCKGRES_SCENARIO_FLIGHT_ADDR (required by frozen perf scenarios)
DUCKGRES_SCENARIO_FLIGHT_INSECURE_SKIP_VERIFY
DUCKGRES_SCENARIO_DBT_BIN
DUCKGRES_SCENARIO_MAX_RUNTIME
DUCKGRES_SCENARIO_GO_TEST_TIMEOUT
DUCKGRES_SCENARIO_FROZEN_S3_URI (required by frozen dataset scenarios)
Expand Down
28 changes: 28 additions & 0 deletions tests/scenario/dbt/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package dbt

const (
ErrorClassConfig = "dbt_config"
ErrorClassDBT = "dbt_execution"
ErrorClassUnsupportedStep = "unsupported_step"
)

type classifiedError struct {
class string
err error
}

func (e classifiedError) Error() string {
return e.err.Error()
}

func (e classifiedError) Unwrap() error {
return e.err
}

func (e classifiedError) ErrorClass() string {
return e.class
}

func classified(class string, err error) error {
return classifiedError{class: class, err: err}
}
13 changes: 13 additions & 0 deletions tests/scenario/dbt/posthog_frozen_project/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: posthog_frozen_scenario
version: "1.0.0"
profile: duckgres_scenario

model-paths: ["models"]
test-paths: ["tests"]

models:
posthog_frozen_scenario:
staging:
+materialized: view
marts:
+materialized: table
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SELECT
date_trunc('day', event_timestamp) AS event_day,
event,
count(*) AS events
FROM {{ ref('stg_events') }}
GROUP BY 1, 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SELECT
person_id,
count(*) AS events,
min(event_timestamp) AS first_event_timestamp,
max(event_timestamp) AS last_event_timestamp
FROM {{ ref('stg_events') }}
WHERE person_id IS NOT NULL
GROUP BY 1
38 changes: 38 additions & 0 deletions tests/scenario/dbt/posthog_frozen_project/models/schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: 2

models:
- name: stg_persons_daily
columns:
- name: person_day
tests:
- not_null
- name: persons
tests:
- not_null

- name: stg_events
columns:
- name: event
tests:
- not_null
- name: event_timestamp
tests:
- not_null

- name: daily_event_counts
columns:
- name: event_day
tests:
- not_null
- name: events
tests:
- not_null

- name: person_event_rollup
columns:
- name: person_id
tests:
- not_null
- name: events
tests:
- not_null
8 changes: 8 additions & 0 deletions tests/scenario/dbt/posthog_frozen_project/models/sources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2

sources:
- name: frozen_v1
schema: frozen_v1
tables:
- name: persons_file_view
- name: events_file_view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SELECT
event,
person_id,
"timestamp" AS event_timestamp
FROM {{ source('frozen_v1', 'events_file_view') }}
WHERE "timestamp" IS NOT NULL
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SELECT
date_trunc('day', _timestamp) AS person_day,
count(*) AS persons
FROM {{ source('frozen_v1', 'persons_file_view') }}
WHERE _timestamp IS NOT NULL
GROUP BY 1
14 changes: 14 additions & 0 deletions tests/scenario/dbt/posthog_frozen_project/profiles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
duckgres_scenario:
target: dev
outputs:
dev:
type: postgres
host: "{{ env_var('DUCKGRES_DBT_HOST') }}"
port: "{{ env_var('DUCKGRES_DBT_PORT') | int }}"
user: "{{ env_var('DUCKGRES_DBT_USER') }}"
pass: "{{ env_var('DBT_ENV_SECRET_DUCKGRES_PASSWORD') }}"
dbname: "{{ env_var('DUCKGRES_DBT_DBNAME') }}"
schema: "{{ env_var('DUCKGRES_DBT_SCHEMA') }}"
sslmode: "{{ env_var('DUCKGRES_DBT_SSLMODE', 'require') }}"
connect_timeout: "{{ env_var('DUCKGRES_DBT_CONNECT_TIMEOUT', '10') | int }}"
threads: 1
Loading
Loading