Skip to content

Commit 862faa8

Browse files
authored
acc: Added materialised test config as out.config.json golden file (#3174)
## Changes Added materialised test config as `out.config.toml` golden file. Now each tests compares the test config it has (defined in test.toml and nested folders) with the config stored in `out.config.toml` which is materialised as golden file. ## Why This gives us transparency and visibility into what are the settings each tests is run against. Any changes to the parent test settings won't go unnoticed due to golden file comparison. ## Tests Existing tests succeed <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent fd9c3c7 commit 862faa8

File tree

310 files changed

+1674
-8
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

310 files changed

+1674
-8
lines changed

acceptance/acceptance_test.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ const (
7373
MaxFileSize = 100_000
7474
// Filename to save replacements to (used by diff.py)
7575
ReplsFile = "repls.json"
76+
// Filename for materialized config (used as golden file)
77+
MaterializedConfigFile = "out.test.toml"
7678

7779
// ENVFILTER allows filtering subtests matching certain env var.
7880
// e.g. ENVFILTER=SERVERLESS=yes will run all tests that run SERVERLESS to "yes"
@@ -464,11 +466,19 @@ func runTest(t *testing.T,
464466
scriptContents := readMergedScriptContents(t, dir)
465467
testutil.WriteFile(t, filepath.Join(tmpDir, EntryPointScript), scriptContents)
466468

469+
// Generate materialized config for this test
470+
materializedConfig, err := internal.GenerateMaterializedConfig(config)
471+
require.NoError(t, err)
472+
testutil.WriteFile(t, filepath.Join(tmpDir, internal.MaterializedConfigFile), materializedConfig)
473+
467474
inputs := make(map[string]bool, 2)
468475
outputs := make(map[string]bool, 2)
469476
err = CopyDir(dir, tmpDir, inputs, outputs)
470477
require.NoError(t, err)
471478

479+
// Add materialized config to outputs for comparison
480+
outputs[internal.MaterializedConfigFile] = true
481+
472482
bundleConfigTarget := "databricks.yml"
473483
if config.BundleConfigTarget != nil {
474484
bundleConfigTarget = *config.BundleConfigTarget
@@ -600,7 +610,11 @@ func runTest(t *testing.T,
600610

601611
// Compare expected outputs
602612
for relPath := range outputs {
603-
doComparison(t, repls, dir, tmpDir, relPath, &printedRepls)
613+
skipRepls := false
614+
if relPath == internal.MaterializedConfigFile {
615+
skipRepls = true
616+
}
617+
doComparison(t, repls, dir, tmpDir, relPath, &printedRepls, skipRepls)
604618
}
605619

606620
// Make sure there are not unaccounted for new files
@@ -623,7 +637,7 @@ func runTest(t *testing.T,
623637
if strings.HasPrefix(relPath, "out") {
624638
// We have a new file starting with "out"
625639
// Show the contents & support overwrite mode for it:
626-
doComparison(t, repls, dir, tmpDir, relPath, &printedRepls)
640+
doComparison(t, repls, dir, tmpDir, relPath, &printedRepls, false)
627641
}
628642
}
629643

@@ -662,7 +676,7 @@ func addEnvVar(t *testing.T, env []string, repls *testdiff.ReplacementsContext,
662676
return append(env, key+"="+newValue)
663677
}
664678

665-
func doComparison(t *testing.T, repls testdiff.ReplacementsContext, dirRef, dirNew, relPath string, printedRepls *bool) {
679+
func doComparison(t *testing.T, repls testdiff.ReplacementsContext, dirRef, dirNew, relPath string, printedRepls *bool, skipRepls bool) {
666680
pathRef := filepath.Join(dirRef, relPath)
667681
pathNew := filepath.Join(dirNew, relPath)
668682
bufRef, okRef := tryReading(t, pathRef)
@@ -677,7 +691,7 @@ func doComparison(t *testing.T, repls testdiff.ReplacementsContext, dirRef, dirN
677691

678692
// Apply replacements to the new value only.
679693
// The reference value is stored after applying replacements.
680-
if !NoRepl {
694+
if !NoRepl && !skipRepls {
681695
valueNew = repls.Replace(valueNew)
682696
}
683697

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Local = true
2+
Cloud = false
3+
4+
[EnvMatrix]
5+
DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Local = true
2+
Cloud = false
3+
4+
[EnvMatrix]
5+
DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Local = true
2+
Cloud = false
3+
4+
[EnvMatrix]
5+
DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Local = true
2+
Cloud = false
3+
4+
[EnvMatrix]
5+
DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Local = true
2+
Cloud = false
3+
4+
[EnvMatrix]
5+
DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Local = true
2+
Cloud = false
3+
4+
[EnvMatrix]
5+
DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Local = false
2+
Cloud = true
3+
RequiresUnityCatalog = true
4+
5+
[EnvMatrix]
6+
DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Local = false
2+
Cloud = true
3+
RequiresUnityCatalog = true
4+
5+
[EnvMatrix]
6+
DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Local = true
2+
Cloud = false
3+
4+
[EnvMatrix]
5+
DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"]

0 commit comments

Comments
 (0)