Skip to content

bundle/fuzz: add create-payload parity fuzz test for terraform vs direct#5686

Draft
radakam wants to merge 8 commits into
mainfrom
deco-25361-fuzz-create-payload
Draft

bundle/fuzz: add create-payload parity fuzz test for terraform vs direct#5686
radakam wants to merge 8 commits into
mainfrom
deco-25361-fuzz-create-payload

Conversation

@radakam

@radakam radakam commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Changes

Adds a fuzz-testing harness (bundle/fuzz) that verifies the terraform and direct deploy engines produce equivalent job create payloads from the same bundle config — the first technique from DECO-25361.

  • generate.go / rand.go — seeded, reproducible random resources.Job generator (math/rand/v2 PCG). Produces deploy-safe configs across a wide field surface: schedules/triggers/continuous, email & webhook notifications, health rules, git sources, job clusters, and tasks (notebook, spark-python, python-wheel, condition) with retries, libraries, and rich new_cluster specs.
  • capture.go / capture_deploy.go — runs a real bundle deploy for each engine against an in-process testserver and captures the POST /api/2.2/jobs/create body. Both engines go through the identical mutator pipeline, so shared transformations cancel out in the diff. Terraform is auto-skipped when not provisioned (RequireTerraform).
  • compare.go — JSON payload diff (numeric-aware via UseNumber, bracket-quoted paths for dotted map keys like spark_conf entries) with a small, justified DefaultIgnorePaths.
  • fuzz_test.go — seed-driven property test (TestJobCreateParity, FUZZ_SEEDS override) plus a native FuzzJobCreateParity target for deep ad-hoc runs.

Two divergences surfaced by the fuzzer:

  1. tasks[*].new_cluster.num_workers (single-node task cluster) — terraform sends num_workers: 0, direct omits it. This is a real, currently-unhandled gap: JobClustersFixups.initializeNumWorkers force-sends num_workers for job_clusters but is not applied to task-level new_cluster. The known job_clusters case is already at parity (verified — no ignore needed). Ignored here with a comment; the product fix to cluster_fixups.go will follow in a separate PR so this stays purely about the fuzz harness.
  2. spark_conf["spark.databricks.delta.preview.enabled"] — terraform's provider strips this key; direct forwards it. Backend ignores it either way; benign provider-side filter, ignored.

Why

We want confidence that the direct engine is behaviorally equivalent to terraform before it becomes the default. Hand-written acceptance tests only cover known shapes; randomized generation surfaces divergences in field combinations no one thought to test — as proven by the task-level num_workers gap above.

Tests

  • go test ./bundle/fuzz/ passes (terraform-backed; ~50s).
  • task lint-q → 0 issues.
  • Terraform provisioned via python3 acceptance/install_terraform.py --targetdir build.

Implements the first technique from DECO-25361: generate random job
configs and check for differences in the create payload between the
terraform and direct deploy engines.

Both engines run the same `bundle deploy` pipeline in-process (via
testcli) against a testserver, differing only in DATABRICKS_BUNDLE_ENGINE,
and the POST /api/2.2/jobs/create body each sends is captured and diffed.
Because only the engine differs, shared mutators cancel out and any
remaining diff is a genuine engine divergence.

The fuzzer already surfaced two real (benign) divergences, documented in
DefaultIgnorePaths:
  - num_workers: 0 is sent explicitly by terraform but dropped by direct
    (omitempty).
  - the terraform provider strips the deprecated spark conf
    "spark.databricks.delta.preview.enabled"; direct forwards it.

Run with: go test ./bundle/fuzz -run TestJobCreateParity
(FUZZ_SEEDS overrides the seed count; auto-skips when terraform is not
provisioned via acceptance/install_terraform.py).
@radakam radakam temporarily deployed to test-trigger-is June 23, 2026 07:44 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 23, 2026 07:44 — with GitHub Actions Inactive
…ignore

Address golangci-lint failures (intrange loops, strconv.FormatBool over
fmt.Sprintf) and tighten the create-payload ignore list: drop the dead
job_clusters num_workers entry (those are at parity) and document the
task-level num_workers divergence as a real CLI gap to fix separately.
@radakam radakam temporarily deployed to test-trigger-is June 23, 2026 08:06 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 23, 2026 08:06 — with GitHub Actions Inactive
@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: e596815

Run: 28102500302

Env 🟨​KNOWN 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
🟨​ aws linux 7 13 244 1024 5:29
🟨​ aws windows 7 13 246 1022 8:12
💚​ aws-ucws linux 7 13 334 940 5:03
💚​ aws-ucws windows 7 13 336 938 5:28
💚​ azure linux 1 15 247 1022 5:04
💚​ azure windows 1 15 249 1020 5:30
💚​ azure-ucws linux 1 15 339 936 5:47
💚​ azure-ucws windows 1 15 341 934 5:38
💚​ gcp linux 1 15 246 1024 4:20
💚​ gcp windows 1 15 248 1022 4:51
20 interesting tests: 13 SKIP, 7 KNOWN
Test Name aws linux aws windows aws-ucws linux aws-ucws windows azure linux azure windows azure-ucws linux azure-ucws windows gcp linux gcp windows
🟨​ TestAccept 🟨​K 🟨​K 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/invariant/no_drift 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/permissions 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions 🟨​K 🟨​K 💚​R 💚​R 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=direct 🟨​K 🟨​K 💚​R 💚​R
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=terraform 🟨​K 🟨​K 💚​R 💚​R
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions 🟨​K 🟨​K 💚​R 💚​R 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=direct 🟨​K 🟨​K 💚​R 💚​R
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=terraform 🟨​K 🟨​K 💚​R 💚​R
🙈​ TestAccept/bundle/resources/postgres_branches/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/recreate 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/replace_existing 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/update_protected 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/without_branch_id 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_endpoints/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_projects/update_display_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/synced_database_tables/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_endpoints/drift/recreated_same_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_indexes/recreate/embedding_dimension 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/ssh/connection 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
Top 4 slowest tests (at least 2 minutes):
duration env testname
3:10 azure-ucws windows TestAccept
3:09 aws-ucws windows TestAccept
3:09 gcp windows TestAccept
3:04 azure windows TestAccept

- Add a `test-fuzz` task and a nightly CI job that provisions terraform
  and runs the create-payload parity tests. They previously always
  skipped because terraform was never provisioned in the test path.
- Ignore repo-root build/ so the provisioned terraform binary and
  provider mirror are not accidentally committed.
- Skip cleanly when build/ is only partially provisioned (missing
  provider mirror or .terraformrc) instead of failing mid-deploy.
- Document that the harness covers jobs only for now (DECO-25361).
@radakam radakam temporarily deployed to test-trigger-is June 23, 2026 09:47 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 23, 2026 09:47 — with GitHub Actions Inactive
Make the create-payload parity fuzz suite explore new configs over time and
be reproducible from a reported seed:

- FUZZ_SEED (comma-separated) runs exactly those seeds, overriding the range,
  so a reported divergence reproduces with one command. The failure message
  now prints this knob.
- FUZZ_SEED_OFFSET shifts the deterministic window; push.yml derives it from
  GITHUB_RUN_NUMBER so each nightly run checks seeds it has never tested
  before instead of re-checking a fixed set. Windows are non-overlapping
  because the run number is unique and monotonic.
- Guard FUZZ_SEEDS > 0 so a negative value no longer panics make() and zero
  no longer passes as a no-op.
- Drop the test-fuzz Task sources fingerprint: the seeds depend on env vars
  Task can't see, so skipping on an unchanged checksum would silently no-op a
  repro run or a shifted window.
- Keep the nightly window modest (25); exploration comes from rotation, not
  size, and it can be raised once nightly timings are known.
@radakam radakam temporarily deployed to test-trigger-is June 24, 2026 08:29 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 24, 2026 08:29 — with GitHub Actions Inactive
radakam added 2 commits June 24, 2026 12:03
The terraform provider force-sends num_workers: 0 for a single-node
new_cluster (no autoscale) on both job_clusters and task-level clusters,
but JobClustersFixups only applied initializeNumWorkers to job_clusters.
The direct engine therefore omitted num_workers on task clusters, so the
two engines produced divergent create payloads. This divergence was
surfaced by the bundle/fuzz parity harness.

Apply initializeNumWorkers to task new_cluster too so the direct engine
matches terraform, and drop the now-obsolete tasks[*].new_cluster.num_workers
entry from the fuzz DefaultIgnorePaths.
The nightly test-fuzz job is intentionally excluded from test-result, so
a failure was only visible in the Actions tab. Add a failure step that
opens (or comments on) a single deduped GitHub issue with a one-command
repro.

Also correct the jobsCreatePath comment: a different API version shows up
as a capture failure (the testserver registers only this route, so a
mismatched version 404s and the deploy fails), not as a payload diff.
@radakam radakam temporarily deployed to test-trigger-is June 24, 2026 12:05 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 24, 2026 12:05 — with GitHub Actions Inactive
…ion test

Rename the capture/deploy/recorder helpers to *_test.go so the parity
harness compiles only under `go test` instead of into the package's
regular build, and add a committed regression test (cluster_fixups_test.go)
covering the single-node task-cluster num_workers force-send fix so the
divergence is guarded at PR time, not just in the nightly suite.
@radakam radakam temporarily deployed to test-trigger-is June 24, 2026 13:27 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 24, 2026 13:27 — with GitHub Actions Inactive
…ting

Move the remaining generator/diff/rand implementation into _test.go files
(keeping only a doc.go for the package comment) so nothing in the harness
compiles into the regular build, since no product code imports it.

Distinguish deploy/capture failures from create-payload divergences in
checkJobParity: skip when neither engine deploys the generated config, fail
distinctly when exactly one engine accepts it (an acceptance divergence, not
a payload diff), and only diff payloads when both deploys succeed. This keeps
nightly triage from misdirecting a deploy failure into regressionSeeds.

Also document the unique-identity-key assumption in diffKeyedSlice.
@radakam radakam temporarily deployed to test-trigger-is June 24, 2026 13:35 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 24, 2026 13:35 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants