mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Sanitize test names before using them as namespaces
This commit is contained in:
parent
ce91f2ab26
commit
33654b8b61
@ -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() {
|
|||||||
|
|
||||||
// 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) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user