Skip to content

Commit

Permalink
UPSTREAM: 12221: Allow custom namespace creation in e2e framework
Browse files Browse the repository at this point in the history
:100644 100644 7ef6dcf... 53c10b6... M	test/e2e/framework.go
  • Loading branch information
deads2k authored and pweil- committed Feb 12, 2016
1 parent 45eadd2 commit 055d8ec
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion test/e2e/framework.go
Expand Up @@ -53,6 +53,9 @@ type Framework struct {
logsSizeWaitGroup sync.WaitGroup
logsSizeCloseChannel chan bool
logsSizeVerifier *LogsSizeVerifier

// Allows to override the initialization of the namespace
nsCreateFunc func(string, *client.Client, map[string]string) (*api.Namespace, error)
}

type TestDataSummary interface {
Expand All @@ -63,9 +66,16 @@ type TestDataSummary interface {
// NewFramework makes a new framework and sets up a BeforeEach/AfterEach for
// you (you can write additional before/after each functions).
func NewFramework(baseName string) *Framework {
return InitializeFramework(baseName, createTestingNS)
}

// InitializeFramework initialize the framework by allowing to pass a custom
// namespace creation function.
func InitializeFramework(baseName string, nsCreateFunc func(string, *client.Client, map[string]string) (*api.Namespace, error)) *Framework {
f := &Framework{
BaseName: baseName,
addonResourceConstraints: make(map[string]resourceConstraint),
nsCreateFunc: nsCreateFunc,
}

BeforeEach(f.beforeEach)
Expand All @@ -84,7 +94,7 @@ func (f *Framework) beforeEach() {
f.Clientset_1_2 = release_1_2.FromUnversionedClient(c)

By("Building a namespace api object")
namespace, err := createTestingNS(f.BaseName, f.Client, map[string]string{
namespace, err := f.nsCreateFunc(f.BaseName, f.Client, map[string]string{
"e2e-framework": f.BaseName,
})
Expect(err).NotTo(HaveOccurred())
Expand Down

0 comments on commit 055d8ec

Please sign in to comment.