Skip to content

Commit

Permalink
Implemented a filtering function that removes host and thread lab…
Browse files Browse the repository at this point in the history
…els to prevent #40 (#43)
  • Loading branch information
ubermensch01 committed Feb 10, 2022
1 parent f3ba8e0 commit f6f99a0
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,24 @@ func getSha256(labels []label, name string) string {
hash.Write([]byte(fmt.Sprintf("%v", struct {
Labels []label
Name string
}{labels, name})))
}{sanitizeLabels(labels), name})))

return fmt.Sprintf("%x", hash.Sum(nil))
}

// This function filters out 'host' and 'thread' labels that are dynamic and cause issues for
// testCaseId and historyId attributes which should be identical across hosts with dynamic host naming,
//e.g. in a container in Kubernetes cluster.
func sanitizeLabels(labels []label) []label {
sanitizedLabels := make([]label, 0)

for _, label := range labels {
if label.Name == "host" || label.Name == "thread" {
continue
} else {
sanitizedLabels = append(sanitizedLabels, label)
}
}

return sanitizedLabels
}

0 comments on commit f6f99a0

Please sign in to comment.