Skip to content

Commit

Permalink
Fix Makefile install-strategies target for non-cluster-scoped objects…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
aleskandro committed Jul 24, 2024
1 parent da72c97 commit ee72f5e
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 57 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ install-controller-kind: install-apis

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

.PHONY: local
local: install-strategies
Expand Down
16 changes: 0 additions & 16 deletions test/e2e/v1alpha1/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,10 @@ var _ = Describe("For a Kubernetes cluster with Tekton and build installed", fun
})

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

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

buildStrategy, err = buildStrategyTestData(testBuild.Namespace, "samples/v1alpha1/buildstrategy/buildpacks-v3/buildstrategy_buildpacks-v3-heroku_namespaced_cr.yaml")
Expect(err).ToNot(HaveOccurred())

err = testBuild.CreateBuildStrategy(buildStrategy)
Expect(err).ToNot(HaveOccurred())

// create the build definition
build = createBuild(
testBuild,
Expand All @@ -169,7 +162,6 @@ var _ = Describe("For a Kubernetes cluster with Tekton and build installed", fun
})

AfterEach(func() {
err = testBuild.DeleteBuildStrategy(buildStrategy.Name)
Expect(err).ToNot(HaveOccurred())
})
})
Expand Down Expand Up @@ -198,17 +190,10 @@ var _ = Describe("For a Kubernetes cluster with Tekton and build installed", fun
})

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

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

buildStrategy, err = buildStrategyTestData(testBuild.Namespace, "samples/v1alpha1/buildstrategy/buildpacks-v3/buildstrategy_buildpacks-v3_namespaced_cr.yaml")
Expect(err).ToNot(HaveOccurred())

err = testBuild.CreateBuildStrategy(buildStrategy)
Expect(err).ToNot(HaveOccurred())

// create the build definition
build = createBuild(
testBuild,
Expand All @@ -226,7 +211,6 @@ var _ = Describe("For a Kubernetes cluster with Tekton and build installed", fun
})

AfterEach(func() {
err = testBuild.DeleteBuildStrategy(buildStrategy.Name)
Expect(err).ToNot(HaveOccurred())
})
})
Expand Down
13 changes: 0 additions & 13 deletions test/e2e/v1alpha1/validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,19 +292,6 @@ func readAndDecode(filePath string) (runtime.Object, error) {
return obj, err
}

// buildStrategyTestData gets the us the BuildStrategy test data set up
func buildStrategyTestData(ns string, buildStrategyCRPath string) (*buildv1alpha1.BuildStrategy, error) {
obj, err := readAndDecode(buildStrategyCRPath)
if err != nil {
return nil, err
}

buildStrategy := obj.(*buildv1alpha1.BuildStrategy)
buildStrategy.SetNamespace(ns)

return buildStrategy, err
}

func buildTestData(namespace string, identifier string, filePath string) (*buildv1alpha1.Build, error) {
obj, err := readAndDecode(filePath)
if err != nil {
Expand Down
14 changes: 0 additions & 14 deletions test/e2e/v1beta1/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,6 @@ var _ = Describe("For a Kubernetes cluster with Tekton and build installed", fun
BeforeEach(func() {
testID = generateTestID("buildpacks-v3-heroku-namespaced")

buildStrategy, err = buildStrategyTestData(testBuild.Namespace, "samples/v1beta1/buildstrategy/buildpacks-v3/buildstrategy_buildpacks-v3-heroku_namespaced_cr.yaml")
Expect(err).ToNot(HaveOccurred())

err = testBuild.CreateBuildStrategy(buildStrategy)
Expect(err).ToNot(HaveOccurred())

// create the build definition
build = createBuild(
testBuild,
Expand Down Expand Up @@ -197,17 +191,10 @@ var _ = Describe("For a Kubernetes cluster with Tekton and build installed", fun
})

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

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

buildStrategy, err = buildStrategyTestData(testBuild.Namespace, "samples/v1beta1/buildstrategy/buildpacks-v3/buildstrategy_buildpacks-v3_namespaced_cr.yaml")
Expect(err).ToNot(HaveOccurred())

err = testBuild.CreateBuildStrategy(buildStrategy)
Expect(err).ToNot(HaveOccurred())

// create the build definition
build = createBuild(
testBuild,
Expand All @@ -225,7 +212,6 @@ var _ = Describe("For a Kubernetes cluster with Tekton and build installed", fun
})

AfterEach(func() {
err = testBuild.DeleteBuildStrategy(buildStrategy.Name)
Expect(err).ToNot(HaveOccurred())
})
})
Expand Down
13 changes: 0 additions & 13 deletions test/e2e/v1beta1/validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,19 +294,6 @@ func readAndDecode(filePath string) (runtime.Object, error) {
return obj, err
}

// buildStrategyTestData gets the us the BuildStrategy test data set up
func buildStrategyTestData(ns string, buildStrategyCRPath string) (*buildv1beta1.BuildStrategy, error) {
obj, err := readAndDecode(buildStrategyCRPath)
if err != nil {
return nil, err
}

buildStrategy := obj.(*buildv1beta1.BuildStrategy)
buildStrategy.SetNamespace(ns)

return buildStrategy, err
}

func buildTestData(namespace string, identifier string, filePath string) (*buildv1beta1.Build, error) {
obj, err := readAndDecode(filePath)
if err != nil {
Expand Down

0 comments on commit ee72f5e

Please sign in to comment.