From ab863479bdb78132f8fd9defc123abf3e9a4f152 Mon Sep 17 00:00:00 2001 From: Avinal Kumar Date: Wed, 19 Apr 2023 12:07:35 +0530 Subject: [PATCH] add tekton results upstream e2e to acceptance test - Run tekton results upstream e2e test on sha update in pipeline service - Refer PLNSRVCE-1182 Signed-off-by: Avinal Kumar --- .tekton/pipeline-service-test.yaml | 14 ++++++- .tekton/pipeline/acceptance-tests.yaml | 38 +++++++++++++++++++ .tekton/tasks/tekton-results-fetch-sha.yaml | 20 ++++++++++ .../tasks/tekton-results-upstream-e2e.yaml | 24 ++++++++++++ 4 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 .tekton/tasks/tekton-results-fetch-sha.yaml create mode 100644 .tekton/tasks/tekton-results-upstream-e2e.yaml diff --git a/.tekton/pipeline-service-test.yaml b/.tekton/pipeline-service-test.yaml index b2246d499..02be91660 100644 --- a/.tekton/pipeline-service-test.yaml +++ b/.tekton/pipeline-service-test.yaml @@ -14,7 +14,9 @@ metadata: pipelinesascode.tekton.dev/task-4: "[.tekton/tasks/generate-cluster-name.yaml]" pipelinesascode.tekton.dev/task-5: "[.tekton/tasks/pipeline-service-setup.yaml]" pipelinesascode.tekton.dev/task-6: "[.tekton/tasks/pipeline-service-tests.yaml]" - pipelinesascode.tekton.dev/task-7: "[git-clone]" + pipelinesascode.tekton.dev/task-7: "[.tekton/tasks/tekton-results-fetch-sha.yaml]" + pipelinesascode.tekton.dev/task-8: "[.tekton/tasks/tekton-results-upstream-e2e.yaml]" + pipelinesascode.tekton.dev/task-9: "[git-clone]" pipelinesascode.tekton.dev/max-keep-runs: "5" spec: pipelineRef: @@ -26,6 +28,8 @@ spec: value: "{{ revision }}" - name: target_branch value: "{{ target_branch }}" + - name: results_url + value: "github.com/openshift-pipelines/tektoncd-results.git" timeouts: pipeline: "1h0m0s" workspaces: @@ -48,3 +52,11 @@ spec: resources: requests: storage: 50Mi + - name: tekton-results-source + volumeClaimTemplate: + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 3Gi diff --git a/.tekton/pipeline/acceptance-tests.yaml b/.tekton/pipeline/acceptance-tests.yaml index 70d508c59..c65136bee 100644 --- a/.tekton/pipeline/acceptance-tests.yaml +++ b/.tekton/pipeline/acceptance-tests.yaml @@ -12,6 +12,7 @@ spec: finally: "0h20m0s" workspaces: - name: source + - name: tekton-results-source - name: kubeconfig-dir - name: shared-workspace tasks: @@ -107,6 +108,43 @@ spec: workspace: shared-workspace - name: source workspace: source + - name: fetch-tekton-results-sha + taskRef: + name: tekton-results-fetch-sha + runAfter: + - "clone-pipeline-service-git" + params: + - name: target_branch + value: $(params.target_branch) + workspaces: + - name: source + workspace: source + - name: checkout-results-sha + taskRef: + name: git-clone + runAfter: + - "fetch-tekton-results-sha" + params: + - name: url + value: $(params.results_url) + - name: revision + value: $(tasks.tekton-results-fetch-sha.results.tekton-results-downstream-sha) + workspaces: + - name: output + workspace: tekton-results-source + - name: tekton-results-e2e-tests + taskRef: + name: tekton-results-upstream-e2e + runAfter: + - "checkout-results-sha" + params: + - name: target_branch + value: $(params.target_branch) + workspaces: + - name: source + workspace: tekton-results-source + - name: kubeconfig-dir + workspace: kubeconfig-dir finally: - name: destroy-cluster taskRef: diff --git a/.tekton/tasks/tekton-results-fetch-sha.yaml b/.tekton/tasks/tekton-results-fetch-sha.yaml new file mode 100644 index 000000000..c0a1d6396 --- /dev/null +++ b/.tekton/tasks/tekton-results-fetch-sha.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: tekton.dev/v1beta1 +kind: Task +metadata: + name: tekton-results-fetch-sha +spec: + workspaces: + - name: source + params: + - name: target_branch + results: + - name: tekton-results-downstream-sha + description: Tekton Results updated SHA in Pipeline Service + steps: + # access the source workspace and get sha + - name: fetch-results-sha + workingDir: $(workspaces.source.path) + image: quay.io/redhat-pipeline-service/ci-runner:$(params.target_branch) + command: + - yq '.images[0].newTag' $(workspaces.source.path)/operator/gitops/argocd/pipeline-service/tekton-results/base/kustomization.yaml | tee $(results.tekton-results-downstream-sha) diff --git a/.tekton/tasks/tekton-results-upstream-e2e.yaml b/.tekton/tasks/tekton-results-upstream-e2e.yaml new file mode 100644 index 000000000..747c3fe9c --- /dev/null +++ b/.tekton/tasks/tekton-results-upstream-e2e.yaml @@ -0,0 +1,24 @@ +--- +apiVersion: tekton.dev/v1beta1 +kind: Task +metadata: + name: tekton-results-upstream-e2e +spec: + params: + - name: target_branch + workspaces: + - name: tekton-results-source + - name: kubeconfig-dir + steps: + - name: execute-tekton-results-upstream-e2e + image: quay.io/redhat-pipeline-service/ci-runner:$(params.target_branch) + script: | + #! /usr/bin/env bash + export SA_TOKEN_PATH=${SA_TOKEN_PATH:-"/tmp/tekton-results/tokens"} + mkdir -p ${SA_TOKEN_PATH} + service_accounts=(all-namespaces-read-access single-namespace-read-access) + for service_account in "${service_accounts[@]}"; do + kubectl create token "$service_account" > "${SA_TOKEN_PATH}"/"$service_account" + done + export CGO_ENABLED=0 + go test -v -count=1 --tags=e2e $(workspaces.tekton-results-source.path)/test/e2e/...