Skip to content

Commit cf256e0

Browse files
committed
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 <[email protected]>
1 parent 12862f6 commit cf256e0

File tree

4 files changed

+120
-1
lines changed

4 files changed

+120
-1
lines changed

.tekton/pipeline-service-test.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ metadata:
1414
pipelinesascode.tekton.dev/task-4: "[.tekton/tasks/generate-cluster-name.yaml]"
1515
pipelinesascode.tekton.dev/task-5: "[.tekton/tasks/pipeline-service-setup.yaml]"
1616
pipelinesascode.tekton.dev/task-6: "[.tekton/tasks/pipeline-service-tests.yaml]"
17-
pipelinesascode.tekton.dev/task-7: "[git-clone]"
17+
pipelinesascode.tekton.dev/task-7: "[.tekton/tasks/tekton-results-fetch-sha.yaml]"
18+
pipelinesascode.tekton.dev/task-8: "[.tekton/tasks/tekton-results-upstream-e2e.yaml]"
19+
pipelinesascode.tekton.dev/task-9: "[git-clone]"
1820
pipelinesascode.tekton.dev/max-keep-runs: "5"
1921
spec:
2022
pipelineRef:
@@ -30,6 +32,8 @@ spec:
3032
value: "{{ revision }}"
3133
- name: target_branch
3234
value: "{{ target_branch }}"
35+
- name: results_url
36+
value: "https://github.com/openshift-pipelines/tektoncd-results"
3337
timeouts:
3438
pipeline: "1h0m0s"
3539
workspaces:
@@ -49,3 +53,11 @@ spec:
4953
resources:
5054
requests:
5155
storage: 50Mi
56+
- name: tekton-results-source
57+
volumeClaimTemplate:
58+
spec:
59+
accessModes:
60+
- ReadWriteOnce
61+
resources:
62+
requests:
63+
storage: 3Gi

.tekton/pipeline/acceptance-tests.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ spec:
1010
- name: revision
1111
- name: target_branch
1212
- name: ocp_version
13+
- name: results_url
1314
timeouts:
1415
finally: "0h20m0s"
1516
workspaces:
1617
- name: source
18+
- name: tekton-results-source
19+
- name: kubeconfig-dir
1720
- name: shared-workspace
1821
tasks:
1922
- name: generate-cluster-name
@@ -106,6 +109,35 @@ spec:
106109
workspace: shared-workspace
107110
- name: source
108111
workspace: source
112+
- name: tekton-results-fetch-sha
113+
taskRef:
114+
name: tekton-results-fetch-sha
115+
runAfter:
116+
- "clone-pipeline-service-git"
117+
params:
118+
- name: target_branch
119+
value: $(params.target_branch)
120+
workspaces:
121+
- name: source
122+
workspace: source
123+
- name: tekton-results-upstream-e2e
124+
taskRef:
125+
name: tekton-results-upstream-e2e
126+
runAfter:
127+
- "tekton-results-fetch-sha"
128+
- "plnsvc-setup"
129+
params:
130+
- name: target_branch
131+
value: $(params.target_branch)
132+
- name: repo_url
133+
value: "$(params.results_url)"
134+
- name: revision
135+
value: "$(tasks.tekton-results-fetch-sha.results.tekton-results-downstream-sha)"
136+
workspaces:
137+
- name: source
138+
workspace: tekton-results-source
139+
- name: kubeconfig-dir
140+
workspace: shared-workspace
109141
finally:
110142
- name: destroy-cluster
111143
taskRef:
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
apiVersion: tekton.dev/v1beta1
3+
kind: Task
4+
metadata:
5+
name: tekton-results-fetch-sha
6+
spec:
7+
workspaces:
8+
- name: source
9+
params:
10+
- name: target_branch
11+
results:
12+
- name: tekton-results-downstream-sha
13+
description: Tekton Results updated SHA in Pipeline Service
14+
steps:
15+
- name: fetch-results-sha
16+
workingDir: $(workspaces.source.path)
17+
image: quay.io/openshift-pipeline/ci:latest
18+
script: |
19+
#! /usr/bin/env bash
20+
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)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
apiVersion: tekton.dev/v1beta1
3+
kind: Task
4+
metadata:
5+
name: tekton-results-upstream-e2e
6+
spec:
7+
params:
8+
- name: target_branch
9+
- name: repo_url
10+
- name: revision
11+
workspaces:
12+
- name: source
13+
- name: kubeconfig-dir
14+
steps:
15+
- name: execute-tekton-results-upstream-e2e
16+
image: quay.io/redhat-pipeline-service/ci-runner:$(params.target_branch)
17+
workingDir: $(workspaces.source.path)
18+
env:
19+
- name: KUBECONFIG
20+
value: "$(workspaces.kubeconfig-dir.path)/kubeconfig"
21+
script: |
22+
#! /usr/bin/env bash
23+
cd $(workspaces.source.path)
24+
git clone --no-checkout $(params.repo_url)
25+
cd tektoncd-results
26+
git config remote.origin.fetch '+refs/heads/downstream*:refs/remotes/origin/downstream*'
27+
git fetch origin $(params.revision)
28+
git checkout $(params.revision)
29+
export SA_TOKEN_PATH=${SA_TOKEN_PATH:-"/tmp/tekton-results/tokens"}
30+
export SSL_CERT_PATH=${SSL_CERT_PATH:="/tmp/tekton-results/ssl"}
31+
mkdir -p ${SA_TOKEN_PATH} ${SSL_CERT_PATH}
32+
kubectl get secrets tekton-results-tls -n tekton-results --template='{{index .data "tls.crt"}}' | base64 -d > ${SSL_CERT_PATH}/tekton-results-cert.pem
33+
kubectl get secrets tekton-results-tls -n tekton-results --template='{{index .data "tls.key"}}' | base64 -d > ${SSL_CERT_PATH}/tekton-results-key.pem
34+
kubectl apply -f ./test/e2e/kustomize/rbac.yaml
35+
service_accounts=(all-namespaces-read-access single-namespace-read-access)
36+
for service_account in "${service_accounts[@]}"; do
37+
kubectl create token "$service_account" > "${SA_TOKEN_PATH}"/"$service_account"
38+
done
39+
RESULT_ROUTE=$(kubectl get route tekton-results -n tekton-results --template='{{.spec.host}}')
40+
cat <<EOF > patch-test-config.patch
41+
diff --git a/test/e2e/grpc_client.go b/test/e2e/grpc_client.go
42+
--- a/test/e2e/grpc_client.go
43+
+++ b/test/e2e/grpc_client.go
44+
@@ -36,4 +36,4 @@ const (
45+
certFile = "tekton-results-cert.pem"
46+
- apiServerName = "tekton-results-api-service.tekton-pipelines.svc.cluster.local"
47+
- apiServerAddress = "localhost:50051"
48+
+ apiServerName = "tekton-results-api-service.tekton-results.svc.cluster.local"
49+
+ apiServerAddress = "$RESULT_ROUTE"
50+
defCertFolder = "/tmp/tekton-results/ssl"
51+
52+
EOF
53+
git apply patch-test-config.patch
54+
export CGO_ENABLED=0
55+
go test -v -count=1 --tags=e2e ./test/e2e/...

0 commit comments

Comments
 (0)