Skip to content

Commit

Permalink
Updates e2e tests for v1beta1
Browse files Browse the repository at this point in the history
initial changes to e2e & test/utils

enhanced & more structured changes to test samples

resolved import dependencies

add v1beta1 to API scheme & restructure test/data
  • Loading branch information
apoorvajagtap committed Oct 10, 2023
1 parent 01e34d6 commit 80ff8f9
Show file tree
Hide file tree
Showing 155 changed files with 7,782 additions and 473 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ test-integration: install-apis ginkgo
-trace \
test/integration/...

# .PHONY: test-e2e-alpha
# test-e2e:
# $(eval TEST_API := v1alpha1)
# $(MAKE) install-strategies test-e2e-plain

.PHONY: test-e2e
test-e2e: install-strategies test-e2e-plain

Expand All @@ -222,7 +227,7 @@ test-e2e-plain: ginkgo
TEST_E2E_SERVICEACCOUNT_NAME=${TEST_E2E_SERVICEACCOUNT_NAME} \
TEST_E2E_TIMEOUT_MULTIPLIER=${TEST_E2E_TIMEOUT_MULTIPLIER} \
TEST_E2E_VERIFY_TEKTONOBJECTS=${TEST_E2E_VERIFY_TEKTONOBJECTS} \
$(GINKGO) ${TEST_E2E_FLAGS} test/e2e
$(GINKGO) ${TEST_E2E_FLAGS} test/e2e/v1beta1

.PHONY: test-e2e-kind-with-prereq-install
test-e2e-kind-with-prereq-install: ginkgo install-controller-kind install-strategies test-e2e-plain
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
k8s.io/client-go v0.25.6
k8s.io/code-generator v0.25.6
k8s.io/kubectl v0.25.6
k8s.io/utils v0.0.0-20221012122500-cfd413dd9e85
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
knative.dev/pkg v0.0.0-20221123011842-b78020c16606
sigs.k8s.io/controller-runtime v0.13.1
sigs.k8s.io/yaml v1.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -837,8 +837,8 @@ k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 h1:+70TFaan3hfJzs+7VK2o+O
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280/go.mod h1:+Axhij7bCpeqhklhUTe3xmOn6bWxolyZEeyaFpjGtl4=
k8s.io/kubectl v0.25.6 h1:uGoNw4vF+O62NTwRqM40gMCEI5ujw2g0ocT6dDPt55c=
k8s.io/kubectl v0.25.6/go.mod h1:sqtVRxDlZdaSusmLVysYo8S7h4mB/Fe8YWvt2KCle3k=
k8s.io/utils v0.0.0-20221012122500-cfd413dd9e85 h1:cTdVh7LYu82xeClmfzGtgyspNh6UxpwLWGi8R4sspNo=
k8s.io/utils v0.0.0-20221012122500-cfd413dd9e85/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI=
k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
knative.dev/pkg v0.0.0-20221123011842-b78020c16606 h1:bHozIhJtQE9/SVQkVX2vqnoJGJt6zo7J0jnkLFX3Crw=
knative.dev/pkg v0.0.0-20221123011842-b78020c16606/go.mod h1:DMTRDJ5WRxf/DrlOPzohzfhSuJggscLZ8EavOq9O/x8=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
Expand Down
14 changes: 14 additions & 0 deletions pkg/apis/addtoscheme_build_v1beta1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright The Shipwright Contributors
//
// SPDX-License-Identifier: Apache-2.0

package apis

import (
"github.com/shipwright-io/build/pkg/apis/build/v1beta1"
)

func init() {
// Register the types with the Scheme so the components can map objects to GroupVersionKinds and back
AddToSchemes = append(AddToSchemes, v1beta1.SchemeBuilder.AddToScheme)
}
6 changes: 5 additions & 1 deletion pkg/apis/build/v1beta1/build_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,12 @@ func (p ParamValue) convertToAlpha(dest *v1alpha1.ParamValue) {
}

if p.ConfigMapValue != nil {
dest.ConfigMapValue = &v1alpha1.ObjectKeyRef{}
dest.SingleValue = &v1alpha1.SingleValue{}
dest.ConfigMapValue = (*v1alpha1.ObjectKeyRef)(p.ConfigMapValue)
}

if p.SecretValue != nil {
dest.SingleValue = &v1alpha1.SingleValue{}
dest.SecretValue = (*v1alpha1.ObjectKeyRef)(p.SecretValue)
}

Expand Down Expand Up @@ -325,9 +327,11 @@ func convertBetaParamValue(orig v1alpha1.ParamValue) ParamValue {
}

if orig.ConfigMapValue != nil {
p.SingleValue = &SingleValue{}
p.ConfigMapValue = (*ObjectKeyRef)(orig.ConfigMapValue)
}
if orig.SecretValue != nil {
p.SingleValue = &SingleValue{}
p.SecretValue = (*ObjectKeyRef)(orig.SecretValue)
}

Expand Down
13 changes: 11 additions & 2 deletions pkg/apis/build/v1beta1/buildrun_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
runtime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/ptr"
)

// ensure v1beta1 implements the Conversion interface
Expand Down Expand Up @@ -42,8 +43,16 @@ func (src *BuildRun) ConvertTo(ctx context.Context, obj *unstructured.Unstructur
}

// BuildRunSpec ServiceAccount
alphaBuildRun.Spec.ServiceAccount = &v1alpha1.ServiceAccount{
Name: src.Spec.ServiceAccount,
// With the deprecation of serviceAccount.Generate, serviceAccount is set to ".generate" to have the SA created on fly.
if *src.Spec.ServiceAccount == ".generate" {
alphaBuildRun.Spec.ServiceAccount = &v1alpha1.ServiceAccount{
Name: &src.ObjectMeta.Name,
Generate: ptr.To[bool](true),
}
} else {
alphaBuildRun.Spec.ServiceAccount = &v1alpha1.ServiceAccount{
Name: src.Spec.ServiceAccount,
}
}

// BuildRunSpec Timeout
Expand Down
2 changes: 1 addition & 1 deletion pkg/image/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/google/go-containerregistry/pkg/v1/random"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/shipwright-io/build/pkg/image"
"github.com/shipwright-io/build/test/utils"
utils "github.com/shipwright-io/build/test/utils/v1alpha1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/build/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/shipwright-io/build/pkg/config"
"github.com/shipwright-io/build/pkg/controller/fakes"
buildController "github.com/shipwright-io/build/pkg/reconciler/build"
"github.com/shipwright-io/build/test"
test "github.com/shipwright-io/build/test/v1alpha1_samples"
)

var _ = Describe("Reconcile Build", func() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/buildrun/buildrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"github.com/shipwright-io/build/pkg/controller/fakes"
buildrunctl "github.com/shipwright-io/build/pkg/reconciler/buildrun"
"github.com/shipwright-io/build/pkg/reconciler/buildrun/resources"
"github.com/shipwright-io/build/test"
test "github.com/shipwright-io/build/test/v1alpha1_samples"
)

var _ = Describe("Reconcile BuildRun", func() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/buildrun/resources/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
build "github.com/shipwright-io/build/pkg/apis/build/v1alpha1"
"github.com/shipwright-io/build/pkg/controller/fakes"
"github.com/shipwright-io/build/pkg/reconciler/buildrun/resources"
"github.com/shipwright-io/build/test"
test "github.com/shipwright-io/build/test/v1alpha1_samples"
)

var _ = Describe("Build Resource", func() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/buildrun/resources/conditions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
build "github.com/shipwright-io/build/pkg/apis/build/v1alpha1"
"github.com/shipwright-io/build/pkg/controller/fakes"
"github.com/shipwright-io/build/pkg/reconciler/buildrun/resources"
"github.com/shipwright-io/build/test"
test "github.com/shipwright-io/build/test/v1alpha1_samples"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/buildrun/resources/image_processing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
buildv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1"
"github.com/shipwright-io/build/pkg/config"
"github.com/shipwright-io/build/pkg/reconciler/buildrun/resources"
"github.com/shipwright-io/build/test/utils"
utils "github.com/shipwright-io/build/test/utils/v1alpha1"
pipeline "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/buildrun/resources/results_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

build "github.com/shipwright-io/build/pkg/apis/build/v1alpha1"
"github.com/shipwright-io/build/pkg/reconciler/buildrun/resources"
"github.com/shipwright-io/build/test"
test "github.com/shipwright-io/build/test/v1alpha1_samples"

pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
"k8s.io/apimachinery/pkg/types"
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/buildrun/resources/service_accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
buildv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1"
"github.com/shipwright-io/build/pkg/controller/fakes"
"github.com/shipwright-io/build/pkg/reconciler/buildrun/resources"
"github.com/shipwright-io/build/test"
test "github.com/shipwright-io/build/test/v1alpha1_samples"
corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/buildrun/resources/strategies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
buildv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1"
"github.com/shipwright-io/build/pkg/controller/fakes"
"github.com/shipwright-io/build/pkg/reconciler/buildrun/resources"
"github.com/shipwright-io/build/test"
test "github.com/shipwright-io/build/test/v1alpha1_samples"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/buildrun/resources/taskrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"github.com/shipwright-io/build/pkg/config"
"github.com/shipwright-io/build/pkg/env"
"github.com/shipwright-io/build/pkg/reconciler/buildrun/resources"
"github.com/shipwright-io/build/test"
"github.com/shipwright-io/build/test/utils"
utils "github.com/shipwright-io/build/test/utils/v1alpha1"
test "github.com/shipwright-io/build/test/v1alpha1_samples"
)

var _ = Describe("GenerateTaskrun", func() {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions test/data/v1beta1/build_buildah_cr_custom_context+dockerfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
apiVersion: shipwright.io/v1beta1
kind: Build
metadata:
name: buildah-custom-context-dockerfile
spec:
source:
git:
url: https://github.com/shipwright-io/sample-nodejs
contextDir: docker-build-renamed
strategy:
name: buildah-shipwright-managed-push
kind: ClusterBuildStrategy
paramValues:
- name: dockerfile
value: RenamedDockerfile
output:
image: image-registry.openshift-image-registry.svc:5000/build-examples/renamed-dockerfile
18 changes: 18 additions & 0 deletions test/data/v1beta1/build_buildah_cr_local_source_upload.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
apiVersion: shipwright.io/v1beta1
kind: Build
metadata:
name: buildah-golang-build-local-source-upload
spec:
source:
git:
url: https://github.com/shipwright-io/sample-go
contextDir: docker-build
strategy:
name: buildah-shipwright-managed-push
kind: ClusterBuildStrategy
paramValues:
- name: dockerfile
value: Dockerfile
output:
image: image-registry.openshift-image-registry.svc:5000/build-examples/taxi-app
22 changes: 22 additions & 0 deletions test/data/v1beta1/build_buildah_cr_mutate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
apiVersion: shipwright.io/v1beta1
kind: Build
metadata:
name: buildah-golang-build-mutate
spec:
source:
git:
url: https://github.com/shipwright-io/sample-go
contextDir: docker-build
strategy:
name: buildah-shipwright-managed-push
kind: ClusterBuildStrategy
paramValues:
- name: dockerfile
value: Dockerfile
output:
image: image-registry.openshift-image-registry.svc:5000/build-examples/taxi-app
annotations:
"org.opencontainers.image.url": "https://my-company.com/images"
labels:
"maintainer": "[email protected]"
18 changes: 18 additions & 0 deletions test/data/v1beta1/build_buildah_cr_private_github.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
apiVersion: shipwright.io/v1beta1
kind: Build
metadata:
name: buildah-golang-build
spec:
source:
git:
url: [email protected]:qu1queee/newtaxi.git
cloneSecret: github-ssh-all
strategy:
name: buildah-shipwright-managed-push
kind: ClusterBuildStrategy
paramValues:
- name: dockerfile
value: Dockerfile
output:
image: image-registry.openshift-image-registry.svc:5000/build-examples/taxi-app
17 changes: 17 additions & 0 deletions test/data/v1beta1/build_buildah_cr_private_gitlab.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
apiVersion: shipwright.io/v1beta1
kind: Build
metadata:
name: buildah-golang-build
spec:
source:
git:
url: [email protected]:eduardooli/newtaxi.git
strategy:
name: buildah-shipwright-managed-push
kind: ClusterBuildStrategy
paramValues:
- name: dockerfile
value: Dockerfile
output:
image: image-registry.openshift-image-registry.svc:5000/build-examples/taxi-app
24 changes: 24 additions & 0 deletions test/data/v1beta1/build_buildkit_cr_insecure_registry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
apiVersion: shipwright.io/v1beta1
kind: Build
metadata:
name: buildkit-build
spec:
source:
git:
url: https://github.com/shipwright-io/sample-go
contextDir: docker-build
paramValues:
- name: insecure-registry
value: "true"
- name: platforms
values:
- value: linux/amd64
- value: linux/arm64
strategy:
name: buildkit
kind: ClusterBuildStrategy
retention:
atBuildDeletion: true
output:
image: image-registry.openshift-image-registry.svc:5000/build-examples/taxi-app
15 changes: 15 additions & 0 deletions test/data/v1beta1/build_buildpacks-v3_golang_cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
apiVersion: shipwright.io/v1beta1
kind: Build
metadata:
name: buildpack-golang-build
spec:
source:
git:
url: https://github.com/shipwright-io/sample-go
contextDir: source-build
strategy:
name: buildpacks-v3
kind: ClusterBuildStrategy
output:
image: image-registry.openshift-image-registry.svc:5000/build-examples/taxi-app
18 changes: 18 additions & 0 deletions test/data/v1beta1/build_buildpacks-v3_golang_cr_env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
apiVersion: shipwright.io/v1beta1
kind: Build
metadata:
name: buildpack-golang-build
spec:
source:
git:
url: https://github.com/shipwright-io/sample-go
contextDir: source-build-with-package
env:
- name: BP_GO_TARGETS
value: "main-package"
strategy:
name: buildpacks-v3
kind: ClusterBuildStrategy
output:
image: image-registry.openshift-image-registry.svc:5000/build-examples/taxi-app
17 changes: 17 additions & 0 deletions test/data/v1beta1/build_buildpacks-v3_golang_delete_cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
apiVersion: shipwright.io/v1beta1
kind: Build
metadata:
name: buildpack-golang-build
spec:
source:
git:
url: https://github.com/shipwright-io/sample-go
contextDir: source-build
strategy:
name: buildpacks-v3
kind: ClusterBuildStrategy
retention:
atBuildDeletion: true
output:
image: image-registry.openshift-image-registry.svc:5000/build-examples/taxi-app
15 changes: 15 additions & 0 deletions test/data/v1beta1/build_buildpacks-v3_java_cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
apiVersion: shipwright.io/v1beta1
kind: Build
metadata:
name: buildpack-java-build
spec:
source:
git:
url: https://github.com/shipwright-io/sample-java
contextDir: source-build
strategy:
name: buildpacks-v3
kind: ClusterBuildStrategy
output:
image: image-registry.openshift-image-registry.svc:5000/build-examples/taxi-app
Loading

0 comments on commit 80ff8f9

Please sign in to comment.