Skip to content

acc: Select subset of tests that cover all output#4800

Merged
denik merged 8 commits intomainfrom
tests-subset
Mar 23, 2026
Merged

acc: Select subset of tests that cover all output#4800
denik merged 8 commits intomainfrom
tests-subset

Conversation

@denik
Copy link
Copy Markdown
Contributor

@denik denik commented Mar 20, 2026

Changes

If -subset (or -update) option is passed, only a few tests selected from EnvMatrix-generated test cases: by default a single test is selected from the whole matrix. The configurations with DATABRICKS_BUNDLE_ENGINE=direct setting get 10x weight, so they are preferred over terraform (but we still run a few tests on terraform).

We can do this, because all subtests are supposed to generate the same output.

The exception is tests that do > out.$DATABRICKS_BUNDLE_ENGINE.txt redirects. Those need both terraform and direct variants to run. For such tests, we select two variants, one with "terraform" and another with "direct" engine. The exact rule for triggering this: either script in current directory or _script in any parent directories contains "$DATABRICKS_BUNDLE_ENGINE" substring.

Why

  • Speed up "make test-update".
  • Potentially more correct update, since parallel runs do not write the same files at the same time.

Tests

Just like in #4795 remove all output files and check that "make test-update" regenerates them all.

This branch:

% git grep -l 'Local = true'  '**/out.test.toml' | find_out_files.py | xargs rm
% time make test-update # This branch 
…
make test-update  561.48s user 266.50s system 659% cpu 2:05.49 total

main:

% git grep -l 'Local = true'  '**/out.test.toml' | find_out_files.py | xargs rm
…
% time make test-update # main
make test-update  1063.22s user 442.75s system 709% cpu 3:32.27 total

denik and others added 6 commits March 20, 2026 13:40
Adds a -subset flag that reduces each EnvMatrix variable to a single
value using consistent hashing, cutting test runtime when full coverage
is not needed. DATABRICKS_BUNDLE_ENGINE is biased 90% toward "direct"
unless the script references the variable, in which case all variants
are kept. The flag is automatically enabled during -update mode.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ghts

Replace per-variable SubsetEnvMatrix with SubsetExpanded which operates
on the already-expanded and exclusion-filtered combo list. This ensures
EnvMatrixExclude rules are respected before selection.

DATABRICKS_BUNDLE_ENGINE=direct gets weight 10; all other variants
weight 1, giving ~10/11 probability of selecting a direct variant.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…NDLE_ENGINE

When the script references \$DATABRICKS_BUNDLE_ENGINE (e.g. in output
filenames), SubsetExpanded groups combos by engine value and picks one
per group, ensuring both terraform and direct variants run. Otherwise
it picks one combo total with direct weighted 10x over terraform.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…UNDLE_ENGINE

When determining whether to keep all engine variants, walk parent
directories checking script.prepare files in addition to the test's
own script. Results are cached via sync.Map since parent prepare
scripts are shared across many tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…DLE_ENGINE

_script files are bash helpers sourced by test scripts via
'source \$TESTDIR/../_script'. Check these (not script.prepare) when
determining whether to keep all engine variants during subset selection.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@denik denik temporarily deployed to test-trigger-is March 20, 2026 13:03 — with GitHub Actions Inactive
@eng-dev-ecosystem-bot
Copy link
Copy Markdown
Collaborator

eng-dev-ecosystem-bot commented Mar 20, 2026

Commit: 569a2a6

Run: 23429796537

Env 🟨​KNOWN 🔄​flaky 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
🟨​ aws linux 7 1 9 271 798 6:11
🟨​ aws windows 7 1 9 273 796 4:47
🔄​ aws-ucws linux 4 7 9 366 713 7:08
🔄​ aws-ucws windows 3 7 9 369 711 4:56
💚​ azure linux 2 11 274 796 5:21
💚​ azure windows 2 11 276 794 3:42
🔄​ azure-ucws linux 3 1 11 372 709 6:34
💚​ azure-ucws windows 2 11 376 707 5:00
💚​ gcp linux 2 11 270 799 4:30
💚​ gcp windows 2 11 272 797 3:36
20 interesting tests: 9 SKIP, 7 KNOWN, 4 flaky
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 🔄​f 💚​R 💚​R 🔄​f 💚​R 💚​R 💚​R
🙈​ 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/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_endpoints/recreate 🙈​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/ssh/connect-serverless-gpu 🙈​s 🙈​s 🔄​f 🔄​f 🙈​s 🙈​s 🔄​f ✅​p 🙈​s 🙈​s
🔄​ TestAccept/ssh/connect-serverless-gpu/DATABRICKS_BUNDLE_ENGINE=direct 🔄​f 🔄​f 🔄​f ✅​p
🔄​ TestAccept/ssh/connection 💚​R 💚​R 🔄​f 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🔄​ TestAccept/ssh/connection/DATABRICKS_BUNDLE_ENGINE=direct ✅​p ✅​p 🔄​f ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
Top 20 slowest tests (at least 2 minutes):
duration env testname
3:16 gcp windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:15 aws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:14 azure-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:13 aws-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:13 gcp windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:12 azure windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:11 gcp linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:07 gcp linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:05 azure-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:46 aws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:45 aws-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:43 aws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:42 azure linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:40 aws-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:36 aws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:35 aws-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:34 azure linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:33 azure windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:09 azure-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:06 azure-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct

@denik denik marked this pull request as ready for review March 20, 2026 13:14
@github-actions
Copy link
Copy Markdown

Suggested reviewers

Based on git history of the changed files, these people are best suited to review:

Confidence: low

Eligible reviewers

Based on CODEOWNERS, these people or teams could also review:

@andrewnester, @anton-107, @pietern, @simonfaltum

Suggestions based on git history of 3 changed files (2 scored). See CODEOWNERS for path-specific ownership rules.

Copy link
Copy Markdown
Member

@simonfaltum simonfaltum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Swarm Summary (2 independent reviewers + cross-review)

Verdict: APPROVE - Clean, well-thought-out optimization. No blocking issues.

The weighted consistent hashing approach is clever and the tests are solid. make test-update going from 3:32 to 2:05 is a meaningful win.

Minor suggestions below (none blocking).

result := (err == nil && strings.Contains(string(content), "$DATABRICKS_BUNDLE_ENGINE")) ||
anyHelperScriptUsesEngine(filepath.Dir(dir))
helperScriptUsesEngineCache.Store(dir, result)
return result
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SUGGESTION] anyHelperScriptUsesEngine() and the Subset wiring at line 395-400 are new harness control flow, but the unit tests only exercise SubsetExpanded() in isolation. A regression in the ancestor _script scan or the -update auto-enable path would not be caught. Consider adding a selftest acceptance case whose output varies by engine only through an ancestor _script, run under -subset/-update so the harness behavior is pinned end-to-end.

Copy link
Copy Markdown
Contributor Author

@denik denik Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea to add self-test as it also serves as documentation. 22304e1

h.Write([]byte(testDir))
return weighted[h.Sum64()%uint64(len(weighted))]
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SUGGESTION] weightedSelect will panic on empty input (division by zero). Currently unreachable since SubsetExpanded returns early for len(expanded) <= 1, but a precondition comment would help future maintainers:

// Precondition: envsets must be non-empty.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

panic on unsupported input is okay

}
var result [][]string
for _, group := range groups {
result = append(result, weightedSelect(group, testDir))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[NITPICK] The groups map iteration order is non-deterministic, so the order of the returned result slice varies across runs. Doesn't affect correctness but makes debugging harder. Sorting by engine name would make it deterministic.

Copy link
Copy Markdown
Contributor Author

@denik denik Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While sorting would be overkill, this give me an idea that we should build slice directly (and use side map to dedup): 569a2a6

@denik denik temporarily deployed to test-trigger-is March 23, 2026 09:05 — with GitHub Actions Inactive
…map->slice conversion

Replaces map[string][][]string (engine -> group) with a parallel pair of
slices (result, groups) indexed by first-seen insertion order, using a
keyToIdx map[string]int as the side structure for deduplication. This
eliminates the non-deterministic map iteration that determined result order.

Co-authored-by: Isaac
@denik denik temporarily deployed to test-trigger-is March 23, 2026 09:14 — with GitHub Actions Inactive
@denik denik enabled auto-merge March 23, 2026 09:17
@denik denik added this pull request to the merge queue Mar 23, 2026
Merged via the queue into main with commit 9abc853 Mar 23, 2026
19 checks passed
@denik denik deleted the tests-subset branch March 23, 2026 09:55
denik added a commit that referenced this pull request Mar 25, 2026
When -update is used with a -run filter that includes a specific
EnvMatrix variant (detected by presence of '='), subset selection is
not needed — Go's test framework already limits execution to the
requested variant.

Follow-up to #4800.

Co-authored-by: Isaac
denik added a commit that referenced this pull request Mar 25, 2026
When -update is used with a -run filter that likely includes a specific
EnvMatrix variant (detected by presence of '='), subset selection is not
needed — Go's test framework already limits execution to the requested
variant.

Follow-up to #4800.
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.

3 participants