Skip to content

Commit

Permalink
Add a Task to run the e2e tests
Browse files Browse the repository at this point in the history
The task uses functions from the library.sh to run the e2e tests.
Update the pipeline and docs to run the tests.
  • Loading branch information
afrittoli committed Oct 1, 2019
1 parent c19e8c7 commit b0087b1
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 14 deletions.
4 changes: 2 additions & 2 deletions scripts/library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ fi
# Useful environment variables
[[ -n "${PROW_JOB_ID:-}" ]] && IS_PROW=1 || IS_PROW=0
readonly IS_PROW
readonly REPO_ROOT_DIR="$(git rev-parse --show-toplevel)"
readonly REPO_NAME="$(basename ${REPO_ROOT_DIR})"
readonly REPO_ROOT_DIR="${REPO_ROOT_DIR:-$(git rev-parse --show-toplevel 2> /dev/null)}"
readonly REPO_NAME="${REPO_NAME:-$(basename ${REPO_ROOT_DIR} 2> /dev/null)}"

# Set ARTIFACTS to an empty temp dir if unset
if [[ -z "${ARTIFACTS:-}" ]]; then
Expand Down
56 changes: 47 additions & 9 deletions tekton/README
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,32 @@ spec:

### Verify Release

The `verify-deploy-log-tekton-release` is an example pipeline to verify the
release assets for a Tekton project. The test part of the pipeline depends on
tasks defined in the specific repo, at least until we have more powerful ways to
invoke tasks in a pipeline, so the complete pipeline must be also defined in the
specific repos.
The `verify-deploy-test-tekton-release` is a pipeline to verify the release
assets for a Tekton project.

This pipeline performs the following steps:
* validate the release YAML from the bucket against that in GitHub
* deploy the release against a test k8s cluster
* wait for all the deployments and pods to be up and running
* log the version of tools in the test running image
* Not included: run E2E tests and validate results
* run the e2e tests
* cleanup resources
* repeat deploy-to-log
* run the YAML tests (if available)
* check the overall results and log success or failure

Inputs are:
Params are:
- Param `projectName`: the name of the project (pipeline, trigger,
dashboard, experimental)
- Param `version`: the version to be installed, e.g. "v0.7.0"
- A storage resource, that should point to the release bucket. The release file

Resources are:
- A ro storage resource, that should point to the release bucket. The release file
is expected to be at `<bucket>/<projectName>/previous/<version>/release.yaml`
- A cluster resource, that points to the credentials for the target cluster
- A git resource for the plumbing repo
- A git resource for the repo that holds the tests
- A rw storage resource where the test results and logs are written

The cluster resource pulls the token and cadata from a kubernetes secret like the
following:
Expand Down Expand Up @@ -125,7 +131,7 @@ spec:
secretName: $CLUSTER_SECRET_NAME
```

The bucket resource can be read-only:
The read-only release bucket resource:
```
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
Expand Down Expand Up @@ -157,6 +163,38 @@ spec:
value: https://github.com/tektoncd/plumbing
```

The test git resource:
```
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: pipeline-git-v0-7-0
spec:
type: git
params:
- name: revision
value: v0.7.0
- name: url
value: https://github.com/tektoncd/pipeline
```

The read-write results bucket resource:
```
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: tekton-results-bucket
spec:
type: storage
params:
- name: type
value: gcs
- name: location
value: gs://tekton-test-results
- name: dir
value: "y"
```

The pipeline can be executed using the `tkn` client:
```
tkn pipeline start \
Expand Down
21 changes: 20 additions & 1 deletion tekton/install_and_test_tekton_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
name: verify-deploy-log-tekton-release
name: verify-deploy-test-tekton-release
spec:
params:
- name: projectName
Expand All @@ -31,6 +31,10 @@ spec:
type: cluster
- name: plumbing
type: git
- name: tests
type: git
- name: results-bucket
type: storage
tasks:
- name: verify
taskRef:
Expand Down Expand Up @@ -71,3 +75,18 @@ spec:
inputs:
- name: plumbing-library
resource: plumbing
- name: e2e-test
runAfter: [log]
taskRef:
name: e2e-tests
resources:
inputs:
- name: plumbing-library
resource: plumbing
- name: tests
resource: tests
- name: test-cluster
resource: test-cluster
outputs:
- name: results-bucket
resource: results-bucket
2 changes: 0 additions & 2 deletions tekton/install_tekton_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ spec:
env:
- name: KUBECONFIG
value: /workspace/$(inputs.resources.k8s-cluster.name)/kubeconfig
- name: REPO_NAME
value: tektoncd/$(inputs.params.projectName)
---
apiVersion: tekton.dev/v1alpha1
kind: Task
Expand Down
47 changes: 47 additions & 0 deletions tekton/test_tekton_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,50 @@ spec:
git version
echo ">> bazel version"
bazel version 2> /dev/null
---
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: e2e-tests
spec:
inputs:
params:
- name: tests-path
description: path to the tests within "tests" git resource
default: ./test
- name: timeout
description: timeout for the go test runner
default: 20m
resources:
- name: plumbing-library
type: git
- name: tests
type: git
- name: test-cluster
type: cluster
outputs:
resources:
- name: results-bucket
type: storage
steps:
- name: run-e2e-tests
image: gcr.io/tekton-releases/tests/test-runner@sha256:a4a64b2b70f85a618bbbcc6c0b713b313b2e410504dee24c9f90ec6fe3ebf63f
env:
- name: REPO_ROOT_DIR
value: $(inputs.resources.tests.path)
- name: ARTIFACTS
value: $(outputs.resources.results-bucket.path)
- name: KUBECONFIG
value: /workspace/$(inputs.resources.test-cluster.name)/kubeconfig
command:
- /bin/bash
args:
- -ce
- |
source $(inputs.resources.plumbing-library.path)/scripts/library.sh
e2e_failed=0
header "Running Go e2e tests"
cd $(inputs.resources.tests.path)
report_go_test -v -count=1 -tags=e2e -timeout=$(input.params.timeout) $(input.params.tests-path) || e2e_failed=1
echo ${e2e_failed} > ${ARTIFACTS}/e2e.result

0 comments on commit b0087b1

Please sign in to comment.