From 6b3390733c400d7e9349480d94d5e1aedfd4a13e Mon Sep 17 00:00:00 2001 From: encalada Date: Fri, 19 Jan 2024 17:13:46 +0100 Subject: [PATCH] more integration test --- pkg/reconciler/build/controller.go | 4 +- test/integration/build_to_buildruns_test.go | 7 +- test/integration/build_to_git_test.go | 72 ++++++++++++++++--- test/integration/build_to_taskruns_test.go | 4 +- .../integration/buildruns_to_taskruns_test.go | 2 +- test/integration/integration_suite_test.go | 2 - .../clusterbuildstrategy_samples.go | 16 ++--- 7 files changed, 76 insertions(+), 31 deletions(-) diff --git a/pkg/reconciler/build/controller.go b/pkg/reconciler/build/controller.go index d8767a2d69..3398c4b681 100644 --- a/pkg/reconciler/build/controller.go +++ b/pkg/reconciler/build/controller.go @@ -157,12 +157,12 @@ func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler, maxCo flagReconcile := false for _, build := range buildList.Items { - if build.GetSourceCredentials() != nil && build.GetSourceCredentials() == &secret.Name { + if build.GetSourceCredentials() != nil && *build.GetSourceCredentials() == secret.Name { flagReconcile = true } if build.Spec.Output.PushSecret != nil { - if build.Spec.Output.PushSecret == &secret.Name { + if *build.Spec.Output.PushSecret == secret.Name { flagReconcile = true } } diff --git a/test/integration/build_to_buildruns_test.go b/test/integration/build_to_buildruns_test.go index e426b11ac1..d397322558 100644 --- a/test/integration/build_to_buildruns_test.go +++ b/test/integration/build_to_buildruns_test.go @@ -5,7 +5,6 @@ package integration_test import ( - "fmt" "strings" corev1 "k8s.io/api/core/v1" @@ -399,7 +398,7 @@ var _ = Describe("Integration tests Build and BuildRuns", func() { Expect(err).To(BeNil()) // we modify the annotation so automatic delete does not take place - data := []byte(fmt.Sprintf(`{"spec":{"retention":{"atBuildDeletion":false}}}`)) + data := []byte(`{"spec":{"retention":{"atBuildDeletion":false}}}`) _, err = tb.PatchBuild(BUILD+tb.Namespace, data) Expect(err).To(BeNil()) @@ -428,7 +427,7 @@ var _ = Describe("Integration tests Build and BuildRuns", func() { Expect(tb.CreateBR(autoDeleteBuildRun)).To(BeNil()) // we modify the annotation for the automatic deletion to not take place - data := []byte(fmt.Sprintf(`{"spec":{"retention":{"atBuildDeletion":"false"}}}`)) + data := []byte(`{"spec":{"retention":{"atBuildDeletion":false}}}`) _, err = tb.PatchBuild(BUILD+tb.Namespace, data) Expect(err).To(BeNil()) @@ -440,7 +439,7 @@ var _ = Describe("Integration tests Build and BuildRuns", func() { Expect(err).To(BeNil()) // we modify the annotation one more time, to validate that the build should be deleted this time - data = []byte(fmt.Sprintf(`{"spec":{"retention":{"atBuildDeletion":"true"}}}`)) + data = []byte(`{"spec":{"retention":{"atBuildDeletion":true}}}`) _, err = tb.PatchBuild(BUILD+tb.Namespace, data) Expect(err).To(BeNil()) diff --git a/test/integration/build_to_git_test.go b/test/integration/build_to_git_test.go index 128c8cf8b5..5fb1f74a12 100644 --- a/test/integration/build_to_git_test.go +++ b/test/integration/build_to_git_test.go @@ -47,7 +47,12 @@ var _ = Describe("Integration tests Build and referenced Source url", func() { Expect(err).To(BeNil()) buildObject.ObjectMeta.Annotations["build.shipwright.io/verify.repository"] = "true" - buildObject.Spec.Source.GitSource.URL = "http://github.com/shipwright-io/sample-go" + buildObject.Spec.Source = v1beta1.Source{ + Type: v1beta1.GitType, + GitSource: &v1beta1.Git{ + URL: "http://github.com/shipwright-io/sample-go", + }, + } Expect(tb.CreateBuild(buildObject)).To(BeNil()) @@ -72,7 +77,12 @@ var _ = Describe("Integration tests Build and referenced Source url", func() { ) Expect(err).To(BeNil()) - buildObject.Spec.Source.GitSource.URL = "http://github.com/shipwright-io/sample-go-fake" + buildObject.Spec.Source = v1beta1.Source{ + Type: v1beta1.GitType, + GitSource: &v1beta1.Git{ + URL: "http://github.com/shipwright-io/sample-go-fake", + }, + } Expect(tb.CreateBuild(buildObject)).To(BeNil()) // wait until the Build finish the validation @@ -98,7 +108,12 @@ var _ = Describe("Integration tests Build and referenced Source url", func() { Expect(err).To(BeNil()) buildObject.ObjectMeta.Annotations["build.shipwright.io/verify.repository"] = "true" - buildObject.Spec.Source.GitSource.URL = "https://github.com/shipwright-io/sample-go" + buildObject.Spec.Source = v1beta1.Source{ + Type: v1beta1.GitType, + GitSource: &v1beta1.Git{ + URL: "https://github.com/shipwright-io/sample-go", + }, + } Expect(tb.CreateBuild(buildObject)).To(BeNil()) @@ -123,7 +138,12 @@ var _ = Describe("Integration tests Build and referenced Source url", func() { ) Expect(err).To(BeNil()) - buildObject.Spec.Source.GitSource.URL = "https://github.com/shipwright-io/sample-go-fake" + buildObject.Spec.Source = v1beta1.Source{ + Type: v1beta1.GitType, + GitSource: &v1beta1.Git{ + URL: "https://github.com/shipwright-io/sample-go-fake", + }, + } Expect(tb.CreateBuild(buildObject)).To(BeNil()) // wait until the Build finish the validation @@ -149,7 +169,12 @@ var _ = Describe("Integration tests Build and referenced Source url", func() { Expect(err).To(BeNil()) buildObject.ObjectMeta.Annotations["build.shipwright.io/verify.repository"] = "true" - buildObject.Spec.Source.GitSource.URL = "foobar" + buildObject.Spec.Source = v1beta1.Source{ + Type: v1beta1.GitType, + GitSource: &v1beta1.Git{ + URL: "foobar", + }, + } Expect(tb.CreateBuild(buildObject)).To(BeNil()) @@ -176,7 +201,12 @@ var _ = Describe("Integration tests Build and referenced Source url", func() { Expect(err).To(BeNil()) buildObject.ObjectMeta.Annotations["build.shipwright.io/verify.repository"] = "false" - buildObject.Spec.Source.GitSource.URL = "foobar" + buildObject.Spec.Source = v1beta1.Source{ + Type: v1beta1.GitType, + GitSource: &v1beta1.Git{ + URL: "foobar", + }, + } Expect(tb.CreateBuild(buildObject)).To(BeNil()) // wait until the Build finish the validation @@ -202,7 +232,12 @@ var _ = Describe("Integration tests Build and referenced Source url", func() { Expect(err).To(BeNil()) buildObject.ObjectMeta.Annotations["build.shipwright.io/verify.repository"] = "true" - buildObject.Spec.Source.GitSource.URL = "https://github.yourco.com/org/build-fake" + buildObject.Spec.Source = v1beta1.Source{ + Type: v1beta1.GitType, + GitSource: &v1beta1.Git{ + URL: "https://github.yourco.com/org/build-fake", + }, + } Expect(tb.CreateBuild(buildObject)).To(BeNil()) @@ -228,8 +263,13 @@ var _ = Describe("Integration tests Build and referenced Source url", func() { Expect(err).To(BeNil()) buildObject.ObjectMeta.Annotations["build.shipwright.io/verify.repository"] = "true" - buildObject.Spec.Source.GitSource.URL = "https://github.yourco.com/org/build-fake" - buildObject.Spec.Source.GitSource.CloneSecret = pointer.String("foobar") + buildObject.Spec.Source = v1beta1.Source{ + Type: v1beta1.GitType, + GitSource: &v1beta1.Git{ + URL: "https://github.yourco.com/org/build-fake", + CloneSecret: pointer.String("foobar"), + }, + } sampleSecret := tb.Catalog.SecretWithAnnotation(*buildObject.Spec.Source.GitSource.CloneSecret, buildObject.Namespace) Expect(tb.CreateSecret(sampleSecret)).To(BeNil()) @@ -260,7 +300,12 @@ var _ = Describe("Integration tests Build and referenced Source url", func() { Expect(err).To(BeNil()) buildObject.ObjectMeta.Annotations["build.shipwright.io/verify.repository"] = "true" - buildObject.Spec.Source.GitSource.URL = "git@github.com:shipwright-io/build-fake.git" + buildObject.Spec.Source = v1beta1.Source{ + Type: v1beta1.GitType, + GitSource: &v1beta1.Git{ + URL: "git@github.com:shipwright-io/build-fake.git", + }, + } Expect(tb.CreateBuild(buildObject)).To(BeNil()) @@ -288,7 +333,12 @@ var _ = Describe("Integration tests Build and referenced Source url", func() { Expect(err).To(BeNil()) buildObject.ObjectMeta.Annotations["build.shipwright.io/verify.repository"] = "true" - buildObject.Spec.Source.GitSource.URL = "ssh://github.com/shipwright-io/build-fake.git" + buildObject.Spec.Source = v1beta1.Source{ + Type: v1beta1.GitType, + GitSource: &v1beta1.Git{ + URL: "ssh://github.com/shipwright-io/build-fake.git", + }, + } Expect(tb.CreateBuild(buildObject)).To(BeNil()) diff --git a/test/integration/build_to_taskruns_test.go b/test/integration/build_to_taskruns_test.go index 1b351998f9..706f485502 100644 --- a/test/integration/build_to_taskruns_test.go +++ b/test/integration/build_to_taskruns_test.go @@ -5,7 +5,6 @@ package integration_test import ( - "github.com/davecgh/go-spew/spew" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" @@ -146,7 +145,7 @@ var _ = Describe("Integration tests Build and TaskRun", func() { }) Context("when creating the taskrun", func() { - FIt("should contain an image-processing step to mutate the image", func() { + It("should contain an image-processing step to mutate the image", func() { buildObject.Spec.Output.Annotations = map[string]string{ "org.opencontainers.image.url": "https://my-company.com/images", @@ -164,7 +163,6 @@ var _ = Describe("Integration tests Build and TaskRun", func() { tr, err := tb.GetTaskRunFromBuildRun(buildRunObject.Name) Expect(err).To(BeNil()) - spew.Dump(tr.Spec.TaskSpec.Steps) Expect(tr.Spec.TaskSpec.Steps[3].Name).To(Equal("image-processing")) Expect(tr.Spec.TaskSpec.Steps[3].Command[0]).To(Equal("/ko-app/image-processing")) Expect(tr.Spec.TaskSpec.Steps[3].Args).To(Equal([]string{ diff --git a/test/integration/buildruns_to_taskruns_test.go b/test/integration/buildruns_to_taskruns_test.go index ec5e83061b..33362d15f8 100644 --- a/test/integration/buildruns_to_taskruns_test.go +++ b/test/integration/buildruns_to_taskruns_test.go @@ -42,7 +42,7 @@ var _ = Describe("Integration tests BuildRuns and TaskRuns", func() { } timeout := int64(tb.TimeOut.Seconds()) - buildRunWatcher, err := tb.BuildClientSet.ShipwrightV1alpha1().BuildRuns(tb.Namespace).Watch(context.TODO(), metav1.ListOptions{TimeoutSeconds: &timeout}) + buildRunWatcher, err := tb.BuildClientSet.ShipwrightV1beta1().BuildRuns(tb.Namespace).Watch(context.TODO(), metav1.ListOptions{TimeoutSeconds: &timeout}) Expect(err).To(BeNil()) buildObject, err = tb.Catalog.LoadBuildWithNameAndStrategy(BUILD+tb.Namespace, strategyName, buildDef) diff --git a/test/integration/integration_suite_test.go b/test/integration/integration_suite_test.go index 5a3d78cf38..916fde550b 100644 --- a/test/integration/integration_suite_test.go +++ b/test/integration/integration_suite_test.go @@ -9,7 +9,6 @@ import ( "net/http" "testing" - "github.com/davecgh/go-spew/spew" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -37,7 +36,6 @@ var ( var _ = BeforeSuite(func() { webhookServer = utils.StartBuildWebhook() - spew.Dump("conversion webhook started") }) var _ = AfterSuite(func() { diff --git a/test/v1beta1_samples/clusterbuildstrategy_samples.go b/test/v1beta1_samples/clusterbuildstrategy_samples.go index 2e30046e92..4ba67066c3 100644 --- a/test/v1beta1_samples/clusterbuildstrategy_samples.go +++ b/test/v1beta1_samples/clusterbuildstrategy_samples.go @@ -17,7 +17,7 @@ spec: - name: buildah-images volumeSource: emptyDir: {} - buildSteps: + steps: - name: buildah-bud image: quay.io/containers/buildah:v1.33.2 workingDir: $(params.shp-source-root) @@ -75,7 +75,7 @@ spec: - name: buildah-images volumeSource: emptyDir: {} - buildSteps: + steps: - name: buildah-bud image: quay.io/containers/buildah:v1.33.2 workingDir: $(params.shp-source-root) @@ -129,7 +129,7 @@ kind: ClusterBuildStrategy metadata: name: kaniko spec: - buildSteps: + steps: - name: step-build-and-push image: gcr.io/kaniko-project/executor:v1.19.2 workingDir: $(params.shp-source-root) @@ -178,7 +178,7 @@ kind: ClusterBuildStrategy metadata: name: kaniko spec: - buildSteps: + steps: - name: step-build-and-push image: gcr.io/kaniko-project/executor:v1.19.2 workingDir: $(params.shp-source-root) @@ -229,7 +229,7 @@ spec: - name: exit-command description: "Exit command for the pod" default: "true" - buildSteps: + steps: - name: step-no-and-op image: alpine:latest workingDir: $(params.shp-source-root) @@ -269,7 +269,7 @@ kind: ClusterBuildStrategy metadata: name: noop spec: - buildSteps: + steps: - name: sleep30 image: alpine:latest command: @@ -296,7 +296,7 @@ metadata: kubectl.kubernetes.io/last-applied-configuration: anotherValue name: kaniko spec: - buildSteps: + steps: - name: step-build-and-push image: gcr.io/kaniko-project/executor:v1.19.2 workingDir: $(params.shp-source-root) @@ -348,7 +348,7 @@ spec: - name: sleep-time description: "time in seconds for sleeping" default: "1" - buildSteps: + steps: - name: sleep30 image: alpine:latest command: