From f2ecc6c746852101db67a9f965cf0712b1c07f0c Mon Sep 17 00:00:00 2001 From: Avinal Kumar Date: Wed, 19 Apr 2023 12:07:35 +0530 Subject: [PATCH 1/2] 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 | 32 +++++++++++ .tekton/tasks/tekton-results-fetch-sha.yaml | 20 +++++++ .../tasks/tekton-results-upstream-e2e.yaml | 55 +++++++++++++++++++ 4 files changed, 120 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 05c55f9ba..9d210903d 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: @@ -30,6 +32,8 @@ spec: value: "{{ revision }}" - name: target_branch value: "{{ target_branch }}" + - name: results_url + value: "https://github.com/openshift-pipelines/tektoncd-results" timeouts: pipeline: "1h30m0s" workspaces: @@ -49,3 +53,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 93444d692..3ed62d22c 100644 --- a/.tekton/pipeline/acceptance-tests.yaml +++ b/.tekton/pipeline/acceptance-tests.yaml @@ -10,10 +10,13 @@ spec: - name: revision - name: target_branch - name: ocp_version + - name: results_url timeouts: finally: "0h30m0s" workspaces: - name: source + - name: tekton-results-source + - name: kubeconfig-dir - name: shared-workspace tasks: - name: generate-cluster-name @@ -106,6 +109,35 @@ spec: workspace: shared-workspace - name: source workspace: source + - name: tekton-results-fetch-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: tekton-results-upstream-e2e + taskRef: + name: tekton-results-upstream-e2e + runAfter: + - "tekton-results-fetch-sha" + - "plnsvc-setup" + params: + - name: target_branch + value: $(params.target_branch) + - name: repo_url + value: "$(params.results_url)" + - name: revision + value: "$(tasks.tekton-results-fetch-sha.results.tekton-results-downstream-sha)" + workspaces: + - name: source + workspace: tekton-results-source + - name: kubeconfig-dir + workspace: shared-workspace 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..c3875af3e --- /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: + - name: fetch-results-sha + workingDir: $(workspaces.source.path) + image: quay.io/openshift-pipeline/ci:latest + script: | + #! /usr/bin/env bash + echo -n "$(yq '.images[0].newTag' $(workspaces.source.path)/operator/gitops/argocd/pipeline-service/tekton-results/base/kustomization.yaml)" | tee $(results.tekton-results-downstream-sha.path) diff --git a/.tekton/tasks/tekton-results-upstream-e2e.yaml b/.tekton/tasks/tekton-results-upstream-e2e.yaml new file mode 100644 index 000000000..33eb49020 --- /dev/null +++ b/.tekton/tasks/tekton-results-upstream-e2e.yaml @@ -0,0 +1,55 @@ +--- +apiVersion: tekton.dev/v1beta1 +kind: Task +metadata: + name: tekton-results-upstream-e2e +spec: + params: + - name: target_branch + - name: repo_url + - name: revision + workspaces: + - name: source + - name: kubeconfig-dir + steps: + - name: execute-tekton-results-upstream-e2e + image: quay.io/redhat-pipeline-service/ci-runner:$(params.target_branch) + workingDir: $(workspaces.source.path) + env: + - name: KUBECONFIG + value: "$(workspaces.kubeconfig-dir.path)/kubeconfig" + script: | + #! /usr/bin/env bash + cd $(workspaces.source.path) + git clone --no-checkout $(params.repo_url) + cd tektoncd-results + git config remote.origin.fetch '+refs/heads/downstream*:refs/remotes/origin/downstream*' + git fetch origin $(params.revision) + git checkout $(params.revision) + export SA_TOKEN_PATH=${SA_TOKEN_PATH:-"/tmp/tekton-results/tokens"} + export SSL_CERT_PATH=${SSL_CERT_PATH:="/tmp/tekton-results/ssl"} + mkdir -p ${SA_TOKEN_PATH} ${SSL_CERT_PATH} + kubectl get secrets tekton-results-tls -n tekton-results --template='{{index .data "tls.crt"}}' | base64 -d > ${SSL_CERT_PATH}/tekton-results-cert.pem + kubectl get secrets tekton-results-tls -n tekton-results --template='{{index .data "tls.key"}}' | base64 -d > ${SSL_CERT_PATH}/tekton-results-key.pem + kubectl apply -f ./test/e2e/kustomize/rbac.yaml + 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 + RESULT_ROUTE=$(kubectl get route tekton-results -n tekton-results --template='{{.spec.host}}') + cat < patch-test-config.patch + diff --git a/test/e2e/grpc_client.go b/test/e2e/grpc_client.go + --- a/test/e2e/grpc_client.go + +++ b/test/e2e/grpc_client.go + @@ -36,4 +36,4 @@ const ( + certFile = "tekton-results-cert.pem" + - apiServerName = "tekton-results-api-service.tekton-pipelines.svc.cluster.local" + - apiServerAddress = "localhost:50051" + + apiServerName = "tekton-results-api-service.tekton-results.svc.cluster.local" + + apiServerAddress = "$RESULT_ROUTE" + defCertFolder = "/tmp/tekton-results/ssl" + + EOF + git apply patch-test-config.patch + export CGO_ENABLED=0 + go test -v -count=1 --tags=e2e ./test/e2e/... From 8043769ec28a2500398db764ef4416f77871c569 Mon Sep 17 00:00:00 2001 From: Avinal Kumar Date: Tue, 6 Jun 2023 14:51:32 +0530 Subject: [PATCH 2/2] test forward update --- .tekton/pipeline/acceptance-tests.yaml | 1 - .tekton/tasks/tekton-results-fetch-sha.yaml | 2 +- .../tasks/tekton-results-upstream-e2e.yaml | 20 ++++--------------- .../ci-runner/hack/bin/deploy-cluster.sh | 1 + 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/.tekton/pipeline/acceptance-tests.yaml b/.tekton/pipeline/acceptance-tests.yaml index 3ed62d22c..7e347e1bd 100644 --- a/.tekton/pipeline/acceptance-tests.yaml +++ b/.tekton/pipeline/acceptance-tests.yaml @@ -16,7 +16,6 @@ spec: workspaces: - name: source - name: tekton-results-source - - name: kubeconfig-dir - name: shared-workspace tasks: - name: generate-cluster-name diff --git a/.tekton/tasks/tekton-results-fetch-sha.yaml b/.tekton/tasks/tekton-results-fetch-sha.yaml index c3875af3e..4e28fbd5b 100644 --- a/.tekton/tasks/tekton-results-fetch-sha.yaml +++ b/.tekton/tasks/tekton-results-fetch-sha.yaml @@ -17,4 +17,4 @@ spec: image: quay.io/openshift-pipeline/ci:latest script: | #! /usr/bin/env bash - echo -n "$(yq '.images[0].newTag' $(workspaces.source.path)/operator/gitops/argocd/pipeline-service/tekton-results/base/kustomization.yaml)" | tee $(results.tekton-results-downstream-sha.path) + echo -n "$(yq '.images[0].newTag' $(workspaces.source.path)/operator/gitops/argocd/pipeline-service/tekton-results/kustomization.yaml)" | tee $(results.tekton-results-downstream-sha.path) diff --git a/.tekton/tasks/tekton-results-upstream-e2e.yaml b/.tekton/tasks/tekton-results-upstream-e2e.yaml index 33eb49020..15a2508fb 100644 --- a/.tekton/tasks/tekton-results-upstream-e2e.yaml +++ b/.tekton/tasks/tekton-results-upstream-e2e.yaml @@ -36,20 +36,8 @@ spec: for service_account in "${service_accounts[@]}"; do kubectl create token "$service_account" > "${SA_TOKEN_PATH}"/"$service_account" done - RESULT_ROUTE=$(kubectl get route tekton-results -n tekton-results --template='{{.spec.host}}') - cat < patch-test-config.patch - diff --git a/test/e2e/grpc_client.go b/test/e2e/grpc_client.go - --- a/test/e2e/grpc_client.go - +++ b/test/e2e/grpc_client.go - @@ -36,4 +36,4 @@ const ( - certFile = "tekton-results-cert.pem" - - apiServerName = "tekton-results-api-service.tekton-pipelines.svc.cluster.local" - - apiServerAddress = "localhost:50051" - + apiServerName = "tekton-results-api-service.tekton-results.svc.cluster.local" - + apiServerAddress = "$RESULT_ROUTE" - defCertFolder = "/tmp/tekton-results/ssl" - - EOF - git apply patch-test-config.patch + export API_SERVER_NAME="tekton-results-api-service.tekton-results.svc.cluster.local" + export API_SERVER_ADDR="https://$(kubectl get route tekton-results -n tekton-results --template='{{.spec.host}}'):443" + echo $API_SERVER_ADDR export CGO_ENABLED=0 - go test -v -count=1 --tags=e2e ./test/e2e/... + go test -v -count=1 --tags=e2e $(go list --tags=e2e ./test/e2e/... | grep -v /client) diff --git a/ci/images/ci-runner/hack/bin/deploy-cluster.sh b/ci/images/ci-runner/hack/bin/deploy-cluster.sh index 402085e06..bd38962af 100755 --- a/ci/images/ci-runner/hack/bin/deploy-cluster.sh +++ b/ci/images/ci-runner/hack/bin/deploy-cluster.sh @@ -97,6 +97,7 @@ deploy_cluster() { exit 1 fi check_clusteroperators + oc annotate ingresses.config/cluster ingress.operator.openshift.io/default-enable-http2=true } deploy_cluster \ No newline at end of file