MCPcopy
hub / github.com/grafana/tempo / normalizeTestName

Function normalizeTestName

integration/util/harness.go:608–620  ·  view source on GitHub ↗

normalizeTestName creates a valid Docker service name from a test name

(testName string)

Source from the content-addressed store, hash-verified

606
607// normalizeTestName creates a valid Docker service name from a test name
608func normalizeTestName(testName string) string {
609 // max docker name length is 63. otherwise dns fails silently
610 // max test name length is 40 to leave room prefix and suffix. the full container name will be e2e_<test name>_<service name>
611 // this means that if two tests have the same first 40 characters in their names they will conflict!!
612 maxNameLen := 40
613 name := strings.TrimPrefix(testName, "Test")
614 if len(name) > maxNameLen {
615 name = name[:maxNameLen]
616 }
617 // docker only allows a-zA-Z0-9_.- in a service name. replace everything else with _
618 re := regexp.MustCompile(`[^a-zA-Z0-9_.-]`)
619 return re.ReplaceAllString(name, "_")
620}

Callers 1

runTempoHarnessFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected