Skip to content

Commit be5660b

Browse files
committed
Fix Makefile install-strategies target for non-cluster-scoped objects and E2E cases
When objects are not cluster-scoped, like rolebindings or local build strategies, if the TEST_NAMESPACE variable is set, the objects should be applied to that given namespace. If not, apply to the current context's namespace. Some test cases were also implementing with an additional creation step for the same buildstrategies defined in the same folder recursively applied by the install-strategies target. This commit deletes those function calls to rely on the Makefile target for creating the non-cluster-scoped build strategies too.
1 parent 475255a commit be5660b

File tree

5 files changed

+2
-60
lines changed

5 files changed

+2
-60
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ install-controller-kind: install-apis
274274

275275
.PHONY: install-strategies
276276
install-strategies: install-apis
277-
kubectl apply -R -f samples/v1beta1/buildstrategy/
277+
[ -n "${TEST_NAMESPACE}" ] && ADDITIONAL_PARAMS="-n ${TEST_NAMESPACE}"; \
278+
kubectl apply $$ADDITIONAL_PARAMS -R -f samples/v1beta1/buildstrategy/
278279

279280
.PHONY: local
280281
local: install-strategies

test/e2e/v1alpha1/e2e_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,10 @@ var _ = Describe("For a Kubernetes cluster with Tekton and build installed", fun
140140
})
141141

142142
Context("when a heroku Buildpacks build is defined using a namespaced strategy", func() {
143-
var buildStrategy *buildv1alpha1.BuildStrategy
144143

145144
BeforeEach(func() {
146145
testID = generateTestID("buildpacks-v3-heroku-namespaced")
147146

148-
buildStrategy, err = buildStrategyTestData(testBuild.Namespace, "samples/v1alpha1/buildstrategy/buildpacks-v3/buildstrategy_buildpacks-v3-heroku_namespaced_cr.yaml")
149-
Expect(err).ToNot(HaveOccurred())
150-
151-
err = testBuild.CreateBuildStrategy(buildStrategy)
152-
Expect(err).ToNot(HaveOccurred())
153-
154147
// create the build definition
155148
build = createBuild(
156149
testBuild,
@@ -169,7 +162,6 @@ var _ = Describe("For a Kubernetes cluster with Tekton and build installed", fun
169162
})
170163

171164
AfterEach(func() {
172-
err = testBuild.DeleteBuildStrategy(buildStrategy.Name)
173165
Expect(err).ToNot(HaveOccurred())
174166
})
175167
})
@@ -198,17 +190,10 @@ var _ = Describe("For a Kubernetes cluster with Tekton and build installed", fun
198190
})
199191

200192
Context("when a Buildpacks v3 build is defined using a namespaced strategy", func() {
201-
var buildStrategy *buildv1alpha1.BuildStrategy
202193

203194
BeforeEach(func() {
204195
testID = generateTestID("buildpacks-v3-namespaced")
205196

206-
buildStrategy, err = buildStrategyTestData(testBuild.Namespace, "samples/v1alpha1/buildstrategy/buildpacks-v3/buildstrategy_buildpacks-v3_namespaced_cr.yaml")
207-
Expect(err).ToNot(HaveOccurred())
208-
209-
err = testBuild.CreateBuildStrategy(buildStrategy)
210-
Expect(err).ToNot(HaveOccurred())
211-
212197
// create the build definition
213198
build = createBuild(
214199
testBuild,
@@ -226,7 +211,6 @@ var _ = Describe("For a Kubernetes cluster with Tekton and build installed", fun
226211
})
227212

228213
AfterEach(func() {
229-
err = testBuild.DeleteBuildStrategy(buildStrategy.Name)
230214
Expect(err).ToNot(HaveOccurred())
231215
})
232216
})

test/e2e/v1alpha1/validators_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -292,19 +292,6 @@ func readAndDecode(filePath string) (runtime.Object, error) {
292292
return obj, err
293293
}
294294

295-
// buildStrategyTestData gets the us the BuildStrategy test data set up
296-
func buildStrategyTestData(ns string, buildStrategyCRPath string) (*buildv1alpha1.BuildStrategy, error) {
297-
obj, err := readAndDecode(buildStrategyCRPath)
298-
if err != nil {
299-
return nil, err
300-
}
301-
302-
buildStrategy := obj.(*buildv1alpha1.BuildStrategy)
303-
buildStrategy.SetNamespace(ns)
304-
305-
return buildStrategy, err
306-
}
307-
308295
func buildTestData(namespace string, identifier string, filePath string) (*buildv1alpha1.Build, error) {
309296
obj, err := readAndDecode(filePath)
310297
if err != nil {

test/e2e/v1beta1/e2e_test.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,9 @@ var _ = Describe("For a Kubernetes cluster with Tekton and build installed", fun
139139
})
140140

141141
Context("when a heroku Buildpacks build is defined using a namespaced strategy", func() {
142-
var buildStrategy *buildv1beta1.BuildStrategy
143-
144142
BeforeEach(func() {
145143
testID = generateTestID("buildpacks-v3-heroku-namespaced")
146144

147-
buildStrategy, err = buildStrategyTestData(testBuild.Namespace, "samples/v1beta1/buildstrategy/buildpacks-v3/buildstrategy_buildpacks-v3-heroku_namespaced_cr.yaml")
148-
Expect(err).ToNot(HaveOccurred())
149-
150-
err = testBuild.CreateBuildStrategy(buildStrategy)
151-
Expect(err).ToNot(HaveOccurred())
152-
153145
// create the build definition
154146
build = createBuild(
155147
testBuild,
@@ -168,7 +160,6 @@ var _ = Describe("For a Kubernetes cluster with Tekton and build installed", fun
168160
})
169161

170162
AfterEach(func() {
171-
err = testBuild.DeleteBuildStrategy(buildStrategy.Name)
172163
Expect(err).ToNot(HaveOccurred())
173164
})
174165
})
@@ -197,17 +188,10 @@ var _ = Describe("For a Kubernetes cluster with Tekton and build installed", fun
197188
})
198189

199190
Context("when a Buildpacks v3 build is defined using a namespaced strategy", func() {
200-
var buildStrategy *buildv1beta1.BuildStrategy
201191

202192
BeforeEach(func() {
203193
testID = generateTestID("buildpacks-v3-namespaced")
204194

205-
buildStrategy, err = buildStrategyTestData(testBuild.Namespace, "samples/v1beta1/buildstrategy/buildpacks-v3/buildstrategy_buildpacks-v3_namespaced_cr.yaml")
206-
Expect(err).ToNot(HaveOccurred())
207-
208-
err = testBuild.CreateBuildStrategy(buildStrategy)
209-
Expect(err).ToNot(HaveOccurred())
210-
211195
// create the build definition
212196
build = createBuild(
213197
testBuild,
@@ -225,7 +209,6 @@ var _ = Describe("For a Kubernetes cluster with Tekton and build installed", fun
225209
})
226210

227211
AfterEach(func() {
228-
err = testBuild.DeleteBuildStrategy(buildStrategy.Name)
229212
Expect(err).ToNot(HaveOccurred())
230213
})
231214
})

test/e2e/v1beta1/validators_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -294,19 +294,6 @@ func readAndDecode(filePath string) (runtime.Object, error) {
294294
return obj, err
295295
}
296296

297-
// buildStrategyTestData gets the us the BuildStrategy test data set up
298-
func buildStrategyTestData(ns string, buildStrategyCRPath string) (*buildv1beta1.BuildStrategy, error) {
299-
obj, err := readAndDecode(buildStrategyCRPath)
300-
if err != nil {
301-
return nil, err
302-
}
303-
304-
buildStrategy := obj.(*buildv1beta1.BuildStrategy)
305-
buildStrategy.SetNamespace(ns)
306-
307-
return buildStrategy, err
308-
}
309-
310297
func buildTestData(namespace string, identifier string, filePath string) (*buildv1beta1.Build, error) {
311298
obj, err := readAndDecode(filePath)
312299
if err != nil {

0 commit comments

Comments
 (0)