mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 12:32:03 +00:00
Allow custom namespace creation in e2e framework
This commit is contained in:
parent
5a3dec8dad
commit
7f61f62ec2
@ -225,6 +225,10 @@ func (f *Framework) afterEach() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *Framework) CreateNamespace(baseName string, labels map[string]string) (*api.Namespace, error) {
|
func (f *Framework) CreateNamespace(baseName string, labels map[string]string) (*api.Namespace, error) {
|
||||||
|
createTestingNS := testContext.CreateTestingNS
|
||||||
|
if createTestingNS == nil {
|
||||||
|
createTestingNS = CreateTestingNS
|
||||||
|
}
|
||||||
ns, err := createTestingNS(baseName, f.Client, labels)
|
ns, err := createTestingNS(baseName, f.Client, labels)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
f.namespacesToDelete = append(f.namespacesToDelete, ns)
|
f.namespacesToDelete = append(f.namespacesToDelete, ns)
|
||||||
|
@ -152,6 +152,8 @@ type CloudConfig struct {
|
|||||||
// unique identifier of the e2e run
|
// unique identifier of the e2e run
|
||||||
var runId = util.NewUUID()
|
var runId = util.NewUUID()
|
||||||
|
|
||||||
|
type CreateTestingNSFn func(baseName string, c *client.Client, labels map[string]string) (*api.Namespace, error)
|
||||||
|
|
||||||
type TestContextType struct {
|
type TestContextType struct {
|
||||||
KubeConfig string
|
KubeConfig string
|
||||||
KubeContext string
|
KubeContext string
|
||||||
@ -178,6 +180,10 @@ type TestContextType struct {
|
|||||||
GatherMetricsAfterTest bool
|
GatherMetricsAfterTest bool
|
||||||
// Currently supported values are 'hr' for human-readable and 'json'. It's a comma separated list.
|
// Currently supported values are 'hr' for human-readable and 'json'. It's a comma separated list.
|
||||||
OutputPrintType string
|
OutputPrintType string
|
||||||
|
// CreateTestingNS is responsible for creating namespace used for executing e2e tests.
|
||||||
|
// It accepts namespace base name, which will be prepended with e2e prefix, kube client
|
||||||
|
// and labels to be applied to a namespace.
|
||||||
|
CreateTestingNS CreateTestingNSFn
|
||||||
}
|
}
|
||||||
|
|
||||||
var testContext TestContextType
|
var testContext TestContextType
|
||||||
@ -652,9 +658,9 @@ func waitForPersistentVolumePhase(phase api.PersistentVolumePhase, c *client.Cli
|
|||||||
return fmt.Errorf("PersistentVolume %s not in phase %s within %v", pvName, phase, timeout)
|
return fmt.Errorf("PersistentVolume %s not in phase %s within %v", pvName, phase, timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
// createTestingNS should be used by every test, note that we append a common prefix to the provided test name.
|
// CreateTestingNS should be used by every test, note that we append a common prefix to the provided test name.
|
||||||
// Please see NewFramework instead of using this directly.
|
// Please see NewFramework instead of using this directly.
|
||||||
func createTestingNS(baseName string, c *client.Client, labels map[string]string) (*api.Namespace, error) {
|
func CreateTestingNS(baseName string, c *client.Client, labels map[string]string) (*api.Namespace, error) {
|
||||||
if labels == nil {
|
if labels == nil {
|
||||||
labels = map[string]string{}
|
labels = map[string]string{}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user