Skip to content

Commit 7dbfc08

Browse files
committed
Move deploy tests into a test namespace too instead of default
1 parent 2be11b8 commit 7dbfc08

2 files changed

Lines changed: 27 additions & 13 deletions

File tree

test/e2e/bundle_test.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ var _ = Describe("Bundle", Label("bundle"), Ordered, func() {
109109
_, _ = fmt.Fprint(GinkgoWriter, out)
110110

111111
By("Cleanup resources")
112-
cleanupNamespaces(testNamespaces)
112+
cleanupTestNamespaces(testNamespaces...)
113113
}
114114
})
115115

@@ -147,7 +147,7 @@ var _ = Describe("Bundle", Label("bundle"), Ordered, func() {
147147
_, _ = fmt.Fprint(GinkgoWriter, out)
148148

149149
By("Cleanup resources")
150-
cleanupNamespaces(testNamespaces)
150+
cleanupTestNamespaces(testNamespaces...)
151151
}
152152
})
153153

@@ -187,7 +187,7 @@ var _ = Describe("Bundle", Label("bundle"), Ordered, func() {
187187
_, _ = fmt.Fprint(GinkgoWriter, out)
188188

189189
By("Cleanup resources")
190-
cleanupNamespaces(testNamespaces)
190+
cleanupTestNamespaces(testNamespaces...)
191191
}
192192
})
193193

@@ -244,7 +244,7 @@ var _ = Describe("Bundle", Label("bundle"), Ordered, func() {
244244
_, _ = fmt.Fprint(GinkgoWriter, out)
245245

246246
By("Cleanup resources")
247-
cleanupNamespaces(testNamespaces)
247+
cleanupTestNamespaces(testNamespaces...)
248248
}
249249
})
250250

@@ -284,7 +284,7 @@ var _ = Describe("Bundle", Label("bundle"), Ordered, func() {
284284
_, _ = fmt.Fprint(GinkgoWriter, out)
285285

286286
By("Cleanup resources")
287-
cleanupNamespaces(testNamespaces)
287+
cleanupTestNamespaces(testNamespaces...)
288288
}
289289
})
290290

@@ -410,10 +410,17 @@ func createMultipleNamespaceAndDeployFunction(count int) []TestNamespace {
410410
return testNamespaces
411411
}
412412

413-
func cleanupNamespaces(testNamespaces []TestNamespace) {
414-
By("Cleaning up all resources")
413+
func cleanupTestNamespaces(testNamespaces ...TestNamespace) {
414+
By("Cleaning up test namespaces resources")
415415
for _, testNs := range testNamespaces {
416-
cmd := exec.Command("kubectl", "delete", "namespace", testNs.Name, "--ignore-not-found")
416+
cleanupNamespaces(testNs.Name)
417+
}
418+
}
419+
420+
func cleanupNamespaces(namespaces ...string) {
421+
for _, ns := range namespaces {
422+
By("Cleaning up namespace " + ns)
423+
cmd := exec.Command("kubectl", "delete", "namespace", ns, "--ignore-not-found")
417424
_, err := utils.Run(cmd)
418425
Expect(err).NotTo(HaveOccurred())
419426
}

test/e2e/func_deploy_test.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,13 @@ var _ = Describe("Operator", func() {
5858
Expect(err).NotTo(HaveOccurred())
5959
DeferCleanup(os.RemoveAll, repoDir)
6060

61+
functionNamespace, err = utils.GetTestNamespace()
62+
Expect(err).NotTo(HaveOccurred())
63+
DeferCleanup(cleanupNamespaces, functionNamespace)
64+
6165
// Deploy function using func CLI
6266
cmd := exec.Command("func", "deploy",
67+
"--namespace", functionNamespace,
6368
"--path", repoDir,
6469
"--registry", registry,
6570
"--registry-insecure", strconv.FormatBool(registryInsecure))
@@ -69,7 +74,7 @@ var _ = Describe("Operator", func() {
6974

7075
// Cleanup func deployment
7176
DeferCleanup(func() {
72-
cmd := exec.Command("func", "delete", "--path", repoDir)
77+
cmd := exec.Command("func", "delete", "--path", repoDir, "--namespace", functionNamespace)
7378
_, _ = utils.Run(cmd)
7479
})
7580

@@ -114,7 +119,7 @@ var _ = Describe("Operator", func() {
114119
function := &functionsdevv1alpha1.Function{
115120
ObjectMeta: metav1.ObjectMeta{
116121
GenerateName: "my-function-",
117-
Namespace: "default",
122+
Namespace: functionNamespace,
118123
},
119124
Spec: functionsdevv1alpha1.FunctionSpec{
120125
Source: functionsdevv1alpha1.FunctionSpecSource{
@@ -131,7 +136,6 @@ var _ = Describe("Operator", func() {
131136
Expect(err).NotTo(HaveOccurred())
132137

133138
functionName = function.Name
134-
functionNamespace = function.Namespace
135139

136140
funcBecomeReady := func(g Gomega) {
137141
fn := &functionsdevv1alpha1.Function{}
@@ -172,6 +176,10 @@ var _ = Describe("Operator", func() {
172176
repoDir, err = InitializeRepoWithFunction(repoURL, username, password, "go")
173177
Expect(err).NotTo(HaveOccurred())
174178
DeferCleanup(os.RemoveAll, repoDir)
179+
180+
functionNamespace, err = utils.GetTestNamespace()
181+
Expect(err).NotTo(HaveOccurred())
182+
DeferCleanup(cleanupNamespaces, functionNamespace)
175183
})
176184

177185
AfterEach(func() {
@@ -188,7 +196,7 @@ var _ = Describe("Operator", func() {
188196
function := &functionsdevv1alpha1.Function{
189197
ObjectMeta: metav1.ObjectMeta{
190198
GenerateName: "my-undeployed-function-",
191-
Namespace: "default",
199+
Namespace: functionNamespace,
192200
},
193201
Spec: functionsdevv1alpha1.FunctionSpec{
194202
Source: functionsdevv1alpha1.FunctionSpecSource{
@@ -205,7 +213,6 @@ var _ = Describe("Operator", func() {
205213
Expect(err).NotTo(HaveOccurred())
206214

207215
functionName = function.Name
208-
functionNamespace = function.Namespace
209216

210217
funcBecomeReady := func(g Gomega) {
211218
fn := &functionsdevv1alpha1.Function{}

0 commit comments

Comments
 (0)