Skip to content

Commit f4e24d9

Browse files
committed
Update e2e to create test namespace if it does not exist
This commit updates the OLM e2e test framework to create the test namespace if it does not already exist. Signed-off-by: Alexander Greene <[email protected]>
1 parent 6e0d407 commit f4e24d9

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Diff for: Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ endif
139139
E2E_OPTS ?= $(if $(E2E_SEED),-seed '$(E2E_SEED)') $(if $(SKIP), -skip '$(SKIP)') $(if $(TEST),-focus '$(TEST)') $(if $(ARTIFACT_DIR), -output-dir $(ARTIFACT_DIR) -junit-report junit_e2e.xml) -flake-attempts $(E2E_FLAKE_ATTEMPTS) -nodes $(E2E_NODES) -timeout $(E2E_TIMEOUT) -v -randomize-suites -race -trace -progress
140140
E2E_INSTALL_NS ?= operator-lifecycle-manager
141141
E2E_CATALOG_NS ?= $(E2E_INSTALL_NS)
142-
E2E_TEST_NS ?= operators
142+
E2E_TEST_NS ?= nonexistent-namespace
143143

144144
e2e:
145145
$(GINKGO) $(E2E_OPTS) $(or $(run), ./test/e2e) $< -- -namespace=$(E2E_TEST_NS) -olmNamespace=$(E2E_INSTALL_NS) -catalogNamespace=$(E2E_CATALOG_NS) -dummyImage=bitnami/nginx:latest $(or $(extra_args), -kubeconfig=${KUBECONFIG})

Diff for: test/e2e/e2e_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99

1010
. "github.com/onsi/ginkgo/v2"
1111
. "github.com/onsi/gomega"
12+
corev1 "k8s.io/api/core/v1"
13+
k8serrors "k8s.io/apimachinery/pkg/api/errors"
1214
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1315
"sigs.k8s.io/controller-runtime/pkg/client"
1416

@@ -91,6 +93,22 @@ var _ = BeforeSuite(func() {
9193
deprovision = ctx.MustProvision(ctx.Ctx())
9294
ctx.MustInstall(ctx.Ctx())
9395

96+
// Create the test namespace if it doesn't exist
97+
Eventually(func() error {
98+
err := ctx.Ctx().Client().Create(context.Background(), &corev1.Namespace{
99+
ObjectMeta: metav1.ObjectMeta{
100+
Name: testNamespace,
101+
Annotations: map[string]string{
102+
"olm.e2e": "testNamespace",
103+
},
104+
},
105+
})
106+
if err != nil && !k8serrors.IsAlreadyExists(err) {
107+
return err
108+
}
109+
return nil
110+
}).Should(Succeed())
111+
94112
var groups operatorsv1.OperatorGroupList
95113
Expect(ctx.Ctx().Client().List(context.Background(), &groups, client.InNamespace(testNamespace))).To(Succeed())
96114
if len(groups.Items) == 0 {

0 commit comments

Comments
 (0)