normalizeTestName creates a valid Docker service name from a test name
(testName string)
| 606 | |
| 607 | // normalizeTestName creates a valid Docker service name from a test name |
| 608 | func 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 | } |