Skip to content

Commit

Permalink
tests: add function to create uuid per version of test
Browse files Browse the repository at this point in the history
With blackbox test being deepcopied for each version
of ignition that is being tested this can result in
id collision for keyfields in ignition config. Add a
parse function to blackbox test register to create a
new UUID per version of ignition being tested.
  • Loading branch information
prestist committed Aug 2, 2023
1 parent 930168b commit d06b0f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/register/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func Register(tType TestType, t types.Test) {
test := types.DeepCopy(t)
version, semverErr := semver.NewVersion(test.ConfigMinVersion)
test.ReplaceAllVersionVars(test.ConfigMinVersion)
test.ReplaceUUIDKeyword()
test.ConfigVersion = test.ConfigMinVersion
register(tType, test) // some tests purposefully don't have config version

Expand All @@ -64,6 +65,7 @@ func Register(tType TestType, t types.Test) {
if version.LessThan(v) {
test = types.DeepCopy(t)
test.ReplaceAllVersionVars(v.String())
test.ReplaceUUIDKeyword()
test.ConfigVersion = v.String()
register(tType, test)
}
Expand Down
6 changes: 6 additions & 0 deletions tests/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ func (t *Test) ReplaceAllVersionVars(version string) {
t.Name += " " + version
}

// Does a string Replace on `$UUID` to allow it to be unique per version of the test.
func (t *Test) ReplaceUUIDKeyword() {
uuid := uuid.New()
t.Config = strings.Replace(t.Config, "$UUID", uuid.String(), -1)
}

// Deep copy Test struct fields In, Out, MntDevices, SystemDirFiles
// so each BB test with identical Test structs have their own independent Test copies
func DeepCopy(t Test) Test {
Expand Down

0 comments on commit d06b0f0

Please sign in to comment.