Skip to content

Commit fc3f149

Browse files
janniklasroseIsaac
andcommitted
acceptance: add UniqueUUID test.toml knob for distinct UUID numbering
The built-in [UUID] replacement collapses every UUID to one token, so a golden cannot tell two distinct UUIDs apart (raised in review of #6995). Add a UniqueUUID test.toml knob (default false) that, when set, makes the built-in UUID replacement honor the existing Distinct numbering: distinct UUIDs in an output become [UUID][0], [UUID][1], ... in order of first appearance. Existing tests are unaffected (default off); a test opts in with UniqueUUID = true. Co-authored-by: Isaac <no-reply@databricks.com>
1 parent 4d2a3b5 commit fc3f149

12 files changed

Lines changed: 70 additions & 4 deletions

File tree

‎acceptance/acceptance_test.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,8 @@ func runTest(t *testing.T,
953953
cmd.Env = append(cmd.Env, "CLOUD_ENV_BASE="+envBase)
954954

955955
// Must be added PrepareReplacementsUser, otherwise conflicts with [USERNAME]
956-
testdiff.PrepareReplacementsUUID(t, &repls)
956+
// UniqueUUID defaults to false: number distinct UUIDs only when a test opts in.
957+
testdiff.PrepareReplacementsUUID(t, &repls, isTruePtr(config.UniqueUUID))
957958

958959
// User replacements:
959960
repls.Repls = append(repls.Repls, config.Repls...)

‎acceptance/internal/config.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ type TestConfig struct {
6363
// Old is a regexp, New is a replacement expression.
6464
Repls []testdiff.Replacement
6565

66+
// If true, distinct UUIDs in an output are numbered ([UUID][0], [UUID][1], ...) so
67+
// the golden pins which value appears where. If absent, defaults to false and every
68+
// UUID collapses to [UUID]. Enable it for tests that need to tell distinct UUIDs
69+
// apart; leave it off when they appear in a non-deterministic order (the index
70+
// assignment would be unstable).
71+
UniqueUUID *bool
72+
6673
// List of server stubs to load. Example configuration:
6774
//
6875
// [[Server]]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Cloud = false
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
=== UniqueUUID = true numbers distinct UUIDs
3+
first: [UUID][0]
4+
second: [UUID][1]
5+
first again: [UUID][0]

‎acceptance/selftest/uuid/script‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
title "UniqueUUID = true numbers distinct UUIDs\n"
2+
# Distinct UUIDs get a stable [N] suffix in order of first appearance, so a golden
3+
# pins which value appears where; a repeated UUID keeps its number.
4+
echo "first: 11111111-1111-1111-1111-111111111111"
5+
echo "second: 22222222-2222-2222-2222-222222222222"
6+
echo "first again: 11111111-1111-1111-1111-111111111111"

‎acceptance/selftest/uuid/test.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Opt in to UUID numbering so distinct UUIDs in the output can be told apart.
2+
UniqueUUID = true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Cloud = false
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
=== UniqueUUID = false collapses every UUID to [UUID]
3+
first: [UUID]
4+
second: [UUID]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
title "UniqueUUID = false collapses every UUID to [UUID]\n"
2+
echo "first: 11111111-1111-1111-1111-111111111111"
3+
echo "second: 22222222-2222-2222-2222-222222222222"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Opt out of UUID numbering: every UUID collapses to [UUID], regardless of value.
2+
# Use this for tests that emit multiple distinct UUIDs in a non-deterministic order
3+
# (the [N] assignment would be unstable), or where the distinction is not worth the
4+
# extra tokens.
5+
UniqueUUID = false

0 commit comments

Comments
 (0)