Skip to content

Commit

Permalink
Use kubectl create instead of apply
Browse files Browse the repository at this point in the history
When running YAML E2E tests, use kubectl create instead of apply,
so that example can use generateName, which is a best practice
for run objects (TaskRun/PipelineRun).

Using "create" also exposed name conflicts for several resources
all named the same. Luckily the content of those secret was the
same, so we had no race condition in the past, but it's best
to avoid side effects between tests as much as possible and
keep resource names uniques across examples.

With this change we start running taskrun tests again, and it
turns out the gitlab test is broken because of a broken gitlab URL.
Introduce a subfolder for examples that are valid but that we
don't want to run in CI because they need some access to a
resource which is not available.

Fixes #1397
  • Loading branch information
afrittoli committed Oct 9, 2019
1 parent ef8a6b2 commit 9ee8282
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 35 deletions.
4 changes: 2 additions & 2 deletions examples/pipelineruns/output-pipelinerun.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: skaffold-git
name: skaffold-git-output-pipelinerun
spec:
type: git
params:
Expand Down Expand Up @@ -102,4 +102,4 @@ spec:
resources:
- name: source-repo
resourceRef:
name: skaffold-git
name: skaffold-git-output-pipelinerun
10 changes: 5 additions & 5 deletions examples/pipelineruns/pipelinerun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: default-cluster-admin
generateName: default-cluster-admin-
subjects:
- kind: ServiceAccount
name: default
Expand All @@ -29,7 +29,7 @@ roleRef:
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: skaffold-image-leeroy-web
name: skaffold-image-leeroy-web-pipelinerun
spec:
type: image
params:
Expand All @@ -39,7 +39,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: skaffold-git
name: skaffold-git-pipelinerun
spec:
type: git
params:
Expand Down Expand Up @@ -250,10 +250,10 @@ spec:
resources:
- name: source-repo
resourceRef:
name: skaffold-git
name: skaffold-git-pipelinerun
- name: web-image
resourceRef:
name: skaffold-image-leeroy-web
name: skaffold-image-leeroy-web-pipelinerun
- name: app-image
resourceRef:
name: skaffold-image-leeroy-app
10 changes: 5 additions & 5 deletions examples/taskruns/build-push-kaniko.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: skaffold-image-leeroy-web
name: skaffold-image-leeroy-web-build-push-kaniko
spec:
type: image
params:
Expand All @@ -14,7 +14,7 @@ spec:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: default-cluster-admin
generateName: default-cluster-admin-
subjects:
- kind: ServiceAccount
name: default
Expand All @@ -27,7 +27,7 @@ roleRef:
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: skaffold-git
name: skaffold-git-build-push-kaniko
spec:
type: git
params:
Expand Down Expand Up @@ -82,7 +82,7 @@ spec:
resources:
- name: workspace
resourceRef:
name: skaffold-git
name: skaffold-git-build-push-kaniko
params:
- name: pathToDockerFile
value: Dockerfile
Expand All @@ -92,4 +92,4 @@ spec:
resources:
- name: builtImage
resourceRef:
name: skaffold-image-leeroy-web
name: skaffold-image-leeroy-web-build-push-kaniko
6 changes: 3 additions & 3 deletions examples/taskruns/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: config-for-testing
name: config-for-testing-configmaps
data:
test.data: tasks are my jam
---
Expand All @@ -22,12 +22,12 @@ spec:
- name: TEST_DATA
valueFrom:
configMapKeyRef:
name: config-for-testing
name: config-for-testing-configmaps
key: test.data
volumeMounts:
- name: config-volume
mountPath: /config
volumes:
- name: config-volume
configMap:
name: config-for-testing
name: config-for-testing-configmaps
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/taskruns/secret-env.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind: Secret
apiVersion: v1
metadata:
name: secret-password
name: secret-env-password
stringData:
ninja: SECRET_PASSWORD
---
Expand All @@ -22,5 +22,5 @@ spec:
- name: SECRET_PASSWORD
valueFrom:
secretKeyRef:
name: secret-password
name: secret-env-password
key: ninja
5 changes: 3 additions & 2 deletions examples/taskruns/secret-volume-params.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind: Secret
apiVersion: v1
metadata:
name: secret-password
name: secret-vol-param-password
stringData:
ninja: SECRET_PASSWORD
---
Expand All @@ -15,6 +15,7 @@ spec:
params:
- name: SCNAME
description: Name of secret
type: string
steps:
- image: ubuntu
command:
Expand All @@ -33,4 +34,4 @@ spec:
inputs:
params:
- name: SCNAME
value: secret-password
value: secret-vol-param-password
4 changes: 2 additions & 2 deletions examples/taskruns/secret-volume.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind: Secret
apiVersion: v1
metadata:
name: secret-password
name: secret-vol-password
stringData:
ninja: SECRET_PASSWORD
---
Expand All @@ -25,4 +25,4 @@ spec:
volumes:
- name: secret-volume
secret:
secretName: secret-password
secretName: secret-vol-password
3 changes: 3 additions & 0 deletions examples/taskruns/steptemplate-env-merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ spec:
params:
- name: FOO
description: FOO variable
type: string
- name: BAR
description: BAR variable
type: string
- name: FOOBAR
description: FOOBAR variable
default: foobar
type: string
steps:
# Test the environment variables are set in the task
- name: foo
Expand Down
8 changes: 4 additions & 4 deletions examples/taskruns/task-multiple-output-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: default-cluster-admin
generateName: default-cluster-admin-
subjects:
- kind: ServiceAccount
name: default
Expand All @@ -37,7 +37,7 @@ roleRef:
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: skaffold-git
name: skaffold-git-multiple-output-image
spec:
type: git
params:
Expand All @@ -46,7 +46,7 @@ spec:
- name: url
value: https://github.com/GoogleContainerTools/skaffold
---
# This task is currently hardcoding a index.json file instead of
# This task is currently hardcoding a index.json file instead of
# building an image since kaniko and other easy to use tools don't
# support exporting this file yet
apiVersion: tekton.dev/v1alpha1
Expand Down Expand Up @@ -117,7 +117,7 @@ spec:
resources:
- name: sourcerepo
resourceRef:
name: skaffold-git
name: skaffold-git-multiple-output-image
outputs:
resources:
- name: builtImage1
Expand Down
12 changes: 6 additions & 6 deletions examples/taskruns/task-output-image.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: skaffold-image-leeroy-web
name: skaffold-image-leeroy-web-output-image
spec:
type: image
params:
Expand All @@ -14,7 +14,7 @@ spec:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: default-cluster-admin
generateName: default-cluster-admin-
subjects:
- kind: ServiceAccount
name: default
Expand All @@ -27,7 +27,7 @@ roleRef:
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: skaffold-git
name: skaffold-git-output-image
spec:
type: git
params:
Expand All @@ -36,7 +36,7 @@ spec:
- name: url
value: https://github.com/GoogleContainerTools/skaffold
---
# This task is currently hardcoding a index.json file instead of
# This task is currently hardcoding a index.json file instead of
# building an image since kaniko and other easy to use tools don't
# support exporting this file yet
apiVersion: tekton.dev/v1alpha1
Expand Down Expand Up @@ -95,9 +95,9 @@ spec:
resources:
- name: sourcerepo
resourceRef:
name: skaffold-git
name: skaffold-git-output-image
outputs:
resources:
- name: builtImage
resourceRef:
name: skaffold-image-leeroy-web
name: skaffold-image-leeroy-web-output-image
5 changes: 3 additions & 2 deletions examples/taskruns/task-volume-args.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: config-for-testing
name: config-for-testing-volume-args
data:
test.data: tasks are my jam
---
Expand All @@ -15,6 +15,7 @@ spec:
params:
- name: CFGNAME
description: Name of config map
type: string
steps:
- name: read
image: ubuntu
Expand All @@ -30,4 +31,4 @@ spec:
inputs:
params:
- name: CFGNAME
value: config-for-testing
value: config-for-testing-volume-args
4 changes: 2 additions & 2 deletions test/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ function create_resources() {
echo ">> Creating resources ${resource}"

# Applying the resources, either *taskruns or * *pipelineruns
for file in $(find ${REPO_ROOT_DIR}/examples/${resource}s/ -name *.yaml | sort); do
perl -p -e 's/gcr.io\/christiewilson-catfactory/$ENV{KO_DOCKER_REPO}/g' ${file} | ko apply -f - || return 1
for file in $(find ${REPO_ROOT_DIR}/examples/${resource}s/ -name *.yaml -not -path "${REPO_ROOT_DIR}/examples/${resource}s/no-ci/*" | sort); do
perl -p -e 's/gcr.io\/christiewilson-catfactory/$ENV{KO_DOCKER_REPO}/g' ${file} | ko create -f - || return 1
done
}

Expand Down

0 comments on commit 9ee8282

Please sign in to comment.