Skip to content

Commit

Permalink
Add a simple e2e test for the task
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Demeester <[email protected]>
  • Loading branch information
vdemeester committed Nov 21, 2023
1 parent 172a793 commit 883ad60
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
# settings to reach it during testing
- uses: openshift-pipelines/setup-tektoncd@v1
with:
pipeline_version: v0.41.3
pipeline_version: v0.53.2

# running end-to-end test target
- name: test-e2e
run: make test-e2e
run: make test-e2e
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ BATS_FLAGS ?= --print-output-on-failure --show-output-of-passing-tests --verbose

# path to the bats test files, overwite the variables below to tweak the test scope
E2E_TESTS ?= ./test/e2e/*.bats
E2E_OPENSHIFT_PARAMS_SCRIPT ?= "oc version"

# generic arguments employed on most of the targets
ARGS ?=
Expand Down Expand Up @@ -45,4 +46,4 @@ test-e2e: install
# and end-to-end) to avoid running the release workflow accidently
act: ARGS = --workflows=./.github/workflows/test.yaml
act:
act $(ARGS)
act $(ARGS)
2 changes: 1 addition & 1 deletion templates/task-openshift-client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
optional: true
description: >-
The workspace which contains the the kubeconfig file if in case we want to run the oc command on another cluster.
params:
- name: SCRIPT
description: The OpenShift CLI arguments to run
Expand Down
24 changes: 24 additions & 0 deletions test/e2e/e2e.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bats

source ./test/helper/helper.sh

# E2E tests parameters for the test pipeline

# Testing the maven task,
@test "[e2e] openshift task" {
[ -n "${E2E_OPENSHIFT_PARAMS_SCRIPT}" ]

run tkn task start openshift-client \
--param="SCRIPT=${E2E_OPENSHIFT_PARAMS_SCRIPT}" \
--param="VERBOSE=true" \
--use-param-defaults \
--skip-optional-workspace \
--showlog
assert_success

# waiting a few seconds before asserting results
sleep 30

# assering the taskrun status, making sure all steps have been successful
assert_tekton_resource "taskrun"
}
5 changes: 1 addition & 4 deletions test/helper/helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ function assert_tekton_resource () {
{{- printf "%s\n" .message -}}
{{- end -}}
{{- end }}
{{- range .status.taskResults }}
{{- printf "%s=%s\n" .name .value -}}
{{- end -}}
{{- range .status.results }}
{{- printf "%s=%s\n" .name .value -}}
{{- end -}}
Expand All @@ -46,4 +43,4 @@ EOS
shift
assert_success
assert_output ${*}
}
}

0 comments on commit 883ad60

Please sign in to comment.