Skip to content

Commit

Permalink
fix(e2e): Create next namespace if one exists
Browse files Browse the repository at this point in the history
 Do not error out if the namespace to run e2e into exists, try creating
 next one in row. Retry at 20 next namespaces, before erroring out.
  • Loading branch information
navidshaikh committed May 13, 2020
1 parent 9bbce80 commit 7c60100
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/test/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,22 @@ type KnTest struct {

// NewKnTest creates a new KnTest object
func NewKnTest() (*KnTest, error) {
ns := NextNamespace()

err := CreateNamespace(ns)
if err != nil {
return nil, err
ns := ""
// try next 20 namespace before giving up creating a namespace if it already exists
for i := 0; i < 20; i++ {
ns = NextNamespace()
err := CreateNamespace(ns)
if err == nil {
break
}
if strings.Contains(err.Error(), "AlreadyExists") {
continue
} else {
return nil, err
}
}
err = WaitForNamespaceCreated(ns)

err := WaitForNamespaceCreated(ns)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 7c60100

Please sign in to comment.