Skip to content

Commit

Permalink
more integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
qu1queee committed Jan 19, 2024
1 parent 67f6ebd commit 6b33907
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 31 deletions.
4 changes: 2 additions & 2 deletions pkg/reconciler/build/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
7 changes: 3 additions & 4 deletions test/integration/build_to_buildruns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package integration_test

import (
"fmt"
"strings"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -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())

Expand Down Expand Up @@ -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())

Expand All @@ -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())

Expand Down
72 changes: 61 additions & 11 deletions test/integration/build_to_git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand All @@ -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
Expand All @@ -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())

Expand All @@ -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
Expand All @@ -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())

Expand All @@ -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
Expand All @@ -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())

Expand All @@ -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())
Expand Down Expand Up @@ -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 = "[email protected]:shipwright-io/build-fake.git"
buildObject.Spec.Source = v1beta1.Source{
Type: v1beta1.GitType,
GitSource: &v1beta1.Git{
URL: "[email protected]:shipwright-io/build-fake.git",
},
}

Expect(tb.CreateBuild(buildObject)).To(BeNil())

Expand Down Expand Up @@ -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())

Expand Down
4 changes: 1 addition & 3 deletions test/integration/build_to_taskruns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand All @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion test/integration/buildruns_to_taskruns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions test/integration/integration_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"net/http"
"testing"

"github.com/davecgh/go-spew/spew"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

Expand Down Expand Up @@ -37,7 +36,6 @@ var (

var _ = BeforeSuite(func() {
webhookServer = utils.StartBuildWebhook()
spew.Dump("conversion webhook started")
})

var _ = AfterSuite(func() {
Expand Down
16 changes: 8 additions & 8 deletions test/v1beta1_samples/clusterbuildstrategy_samples.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -269,7 +269,7 @@ kind: ClusterBuildStrategy
metadata:
name: noop
spec:
buildSteps:
steps:
- name: sleep30
image: alpine:latest
command:
Expand All @@ -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)
Expand Down Expand Up @@ -348,7 +348,7 @@ spec:
- name: sleep-time
description: "time in seconds for sleeping"
default: "1"
buildSteps:
steps:
- name: sleep30
image: alpine:latest
command:
Expand Down

0 comments on commit 6b33907

Please sign in to comment.