Commit 33654b8b authored by Kris's avatar Kris

Sanitize test names before using them as namespaces

parent ce91f2ab
...@@ -21,6 +21,8 @@ import ( ...@@ -21,6 +21,8 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"regexp"
"strings"
"sync" "sync"
"time" "time"
...@@ -122,10 +124,7 @@ var _ = framework.KubeDescribe("Downgrade [Feature:Downgrade]", func() { ...@@ -122,10 +124,7 @@ var _ = framework.KubeDescribe("Downgrade [Feature:Downgrade]", func() {
// Create the frameworks here because we can only create them // Create the frameworks here because we can only create them
// in a "Describe". // in a "Describe".
testFrameworks := map[string]*framework.Framework{} testFrameworks := createUpgradeFrameworks()
for _, t := range upgradeTests {
testFrameworks[t.Name()] = framework.NewDefaultFramework(t.Name())
}
framework.KubeDescribe("cluster downgrade", func() { framework.KubeDescribe("cluster downgrade", func() {
It("should maintain a functioning cluster [Feature:ClusterDowngrade]", func() { It("should maintain a functioning cluster [Feature:ClusterDowngrade]", func() {
...@@ -236,9 +235,12 @@ func finalizeUpgradeTest(start time.Time, tc *junit.TestCase) { ...@@ -236,9 +235,12 @@ func finalizeUpgradeTest(start time.Time, tc *junit.TestCase) {
} }
func createUpgradeFrameworks() map[string]*framework.Framework { func createUpgradeFrameworks() map[string]*framework.Framework {
nsFilter := regexp.MustCompile("[^[:word:]-]+") // match anything that's not a word character or hyphen
testFrameworks := map[string]*framework.Framework{} testFrameworks := map[string]*framework.Framework{}
for _, t := range upgradeTests { for _, t := range upgradeTests {
testFrameworks[t.Name()] = framework.NewDefaultFramework(t.Name()) ns := nsFilter.ReplaceAllString(t.Name(), "-") // and replace with a single hyphen
ns = strings.Trim(ns, "-")
testFrameworks[t.Name()] = framework.NewDefaultFramework(ns)
} }
return testFrameworks return testFrameworks
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment