Skip to content

Commit 7af7ae0

Browse files
redhat-appstudio-qe-botRoming22
authored andcommitted
PLNSRVCE-1090 Run AppStudio e2e tests subset on Pipeline Service PR
1 parent 8f3ebf8 commit 7af7ae0

File tree

8 files changed

+353
-5
lines changed

8 files changed

+353
-5
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
apiVersion: tekton.dev/v1beta1
3+
kind: Pipeline
4+
metadata:
5+
name: stonesoup-integeration-tests
6+
spec:
7+
timeouts:
8+
finally: "0h20m0s"
9+
params:
10+
- name: repo_url
11+
- name: revision
12+
- name: repo_owner
13+
- name: target_branch
14+
workspaces:
15+
- name: source
16+
- name: kubeconfig-dir
17+
- name: shared-workspace
18+
tasks:
19+
- name: fetch-repository
20+
taskRef:
21+
name: git-clone
22+
kind: ClusterTask
23+
workspaces:
24+
- name: output
25+
workspace: source
26+
params:
27+
- name: url
28+
value: $(params.repo_url)
29+
- name: revision
30+
value: $(params.revision)
31+
- name: produce-cluster-name
32+
runAfter:
33+
- "fetch-repository"
34+
taskRef:
35+
name: generate-cluster-name
36+
- name: deploy-cluster
37+
runAfter:
38+
- "produce-cluster-name"
39+
params:
40+
- name: image
41+
value: "quay.io/openshift-release-dev/ocp-release:4.12.2-x86_64"
42+
- name: region
43+
value: "us-east-1"
44+
- name: cluster-name
45+
value: "$(tasks.produce-cluster-name.results.cluster-name)"
46+
- name: target_branch
47+
value: $(params.target_branch)
48+
workspaces:
49+
- name: kubeconfig-dir
50+
workspace: kubeconfig-dir
51+
- name: output
52+
workspace: shared-workspace
53+
- name: source
54+
workspace: source
55+
taskRef:
56+
name: deploy-cluster
57+
- name: stonesoupe-e2e-test
58+
runAfter:
59+
- "deploy-cluster"
60+
workspaces:
61+
- name: kubeconfig-dir
62+
workspace: shared-workspace
63+
- name: source
64+
workspace: source
65+
params:
66+
- name: repo_url
67+
value: $(params.repo_url)
68+
- name: revision
69+
value: $(params.revision)
70+
- name: repo_owner
71+
value: $(params.repo_owner)
72+
- name: target_branch
73+
value: $(params.target_branch)
74+
taskRef:
75+
name: stonesoup-tests
76+
finally:
77+
- name: destroy-cluster
78+
when:
79+
- input: "$(tasks.deploy-cluster.status)"
80+
operator: notin
81+
values: ["None"]
82+
params:
83+
- name: cluster-name
84+
value: "$(tasks.produce-cluster-name.results.cluster-name)"
85+
- name: target_branch
86+
value: $(params.target_branch)
87+
workspaces:
88+
- name: kubeconfig-dir
89+
workspace: kubeconfig-dir
90+
- name: source
91+
workspace: source
92+
taskRef:
93+
name: destroy-cluster

.tekton/stonesoup-e2e-test.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
apiVersion: tekton.dev/v1beta1
3+
kind: PipelineRun
4+
metadata:
5+
name: stonesoup-e2e-test
6+
annotations:
7+
pipelinesascode.tekton.dev/on-event: "[push]"
8+
pipelinesascode.tekton.dev/on-target-branch: "main"
9+
pipelinesascode.tekton.dev/pipeline: "[.tekton/pipeline/stonesoup-integeration-tests.yaml]"
10+
pipelinesascode.tekton.dev/task-1: "[.tekton/tasks/deploy-cluster.yaml]"
11+
pipelinesascode.tekton.dev/task-2: "[.tekton/tasks/destroy-cluster.yaml]"
12+
pipelinesascode.tekton.dev/task-3: "[.tekton/tasks/generate-cluster-name.yaml]"
13+
pipelinesascode.tekton.dev/task-4: "[.tekton/tasks/stonesoup-tests.yaml]"
14+
pipelinesascode.tekton.dev/task-5: "[git-clone]"
15+
pipelinesascode.tekton.dev/max-keep-runs: "5"
16+
spec:
17+
pipelineRef:
18+
name: stonesoup-integeration-tests
19+
params:
20+
- name: repo_url
21+
value: "{{ repo_url }}"
22+
- name: revision
23+
value: "{{ revision }}"
24+
- name: repo_owner
25+
value: "{{ repo_owner }}"
26+
- name: target_branch
27+
value: "{{ target_branch }}"
28+
timeouts:
29+
pipeline: "1h30m0s"
30+
workspaces:
31+
- name: kubeconfig-dir
32+
configMap:
33+
name: newkubeconfig
34+
- name: source
35+
volumeClaimTemplate:
36+
spec:
37+
accessModes:
38+
- ReadWriteOnce
39+
resources:
40+
requests:
41+
storage: 3Gi
42+
- name: shared-workspace
43+
volumeClaimTemplate:
44+
spec:
45+
accessModes:
46+
- ReadWriteOnce
47+
resources:
48+
requests:
49+
storage: 50Mi

.tekton/tasks/stonesoup-tests.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
apiVersion: tekton.dev/v1beta1
3+
kind: Task
4+
metadata:
5+
name: stonesoup-tests
6+
spec:
7+
workspaces:
8+
- name: kubeconfig-dir
9+
- name: source
10+
params:
11+
- name: repo_url
12+
- name: revision
13+
- name: repo_owner
14+
- name: target_branch
15+
kind: ClusterTask
16+
steps:
17+
- name: run-e2e-test
18+
image: quay.io/redhat-pipeline-service/e2e-test-runner:$(params.target_branch)
19+
resources:
20+
limits:
21+
memory: 4Gi
22+
requests:
23+
memory: 500Mi
24+
cpu: 300m
25+
workingDir: "$(workspaces.source.path)"
26+
env:
27+
- name: KUBECONFIG
28+
value: "$(workspaces.kubeconfig-dir.path)/kubeconfig"
29+
- name: PIPELINE_PR_OWNER
30+
value: $(params.repo_owner)
31+
- name: PIPELINE_PR_SHA
32+
value: $(params.revision)
33+
- name: BW_CLIENTID
34+
valueFrom:
35+
secretKeyRef:
36+
name: hypershift-bitwarden
37+
key: "BW_CLIENTID"
38+
- name: BW_CLIENTSECRET
39+
valueFrom:
40+
secretKeyRef:
41+
name: hypershift-bitwarden
42+
key: "BW_CLIENTSECRET"
43+
- name: BW_PASSWORD
44+
valueFrom:
45+
secretKeyRef:
46+
name: hypershift-bitwarden
47+
key: "BW_PASSWORD"
48+
command:
49+
- ci/images/e2e-test-runner/run-e2e-test.sh

ci/images/ci-runner/hack/bin/deploy-cluster.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fetch_bitwarden_secrets() {
2121

2222
deploy_cluster() {
2323
setx_off
24-
hypershift create cluster aws --pull-secret "$PULL_SECRET" --aws-creds "$AWS_CREDENTIALS" --name "$CLUSTER_NAME" --node-pool-replicas=2 --base-domain "$BASE_DOMAIN" --region="$REGION" --release-image="$IMAGE" --root-volume-type=gp3 --root-volume-size=60 --instance-type=m5.2xlarge
24+
hypershift create cluster aws --pull-secret "$PULL_SECRET" --aws-creds "$AWS_CREDENTIALS" --name "$CLUSTER_NAME" --node-pool-replicas=2 --base-domain "$BASE_DOMAIN" --region="$REGION" --release-image="$IMAGE" --root-volume-type=gp3 --root-volume-size=120 --instance-type=m5.2xlarge
2525
setx_on
2626

2727
echo "Wait until hypershift hosted cluster is ready..."

ci/images/ci-runner/hack/bin/utils.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,67 @@ get_pull_secret() {
8686
get_password "97960272-52cd-43bd-a1df-af8d003b4efb"
8787
cat <<< "${password}" | base64 -d > "$PULL_SECRET"
8888
}
89+
90+
get_github_user() {
91+
get_password "49988640-d47c-4cac-861e-afaa00721e18"
92+
setx_off
93+
GITHUB_USER="${password}"
94+
export GITHUB_USER
95+
setx_on
96+
}
97+
98+
get_github_token() {
99+
get_password "5c9597fb-083c-4321-9452-afaa00760c99"
100+
setx_off
101+
GITHUB_TOKEN="${password}"
102+
export GITHUB_TOKEN
103+
setx_on
104+
}
105+
106+
get_quay_token() {
107+
get_password "50c61ee9-82ad-4316-95fd-afaa0076a17d"
108+
setx_off
109+
QUAY_TOKEN="${password}"
110+
export QUAY_TOKEN
111+
setx_on
112+
}
113+
114+
get_quay_oauth_user() {
115+
get_password "fee70791-4bdc-4ddf-bd78-afaa0076fb6a"
116+
setx_off
117+
QUAY_OAUTH_USER="${password}"
118+
export QUAY_OAUTH_USER
119+
setx_on
120+
}
121+
122+
get_quay_oauth_token() {
123+
get_password "7c494bb5-75ec-4b80-8085-afaa00774d83"
124+
setx_off
125+
QUAY_OAUTH_TOKEN="${password}"
126+
export QUAY_OAUTH_TOKEN
127+
setx_on
128+
}
129+
130+
get_quay_oauth_token_release_source() {
131+
get_password "28b147c0-2988-4d7d-b359-afaa0077e626"
132+
setx_off
133+
QUAY_OAUTH_TOKEN_RELEASE_SOURCE="${password}"
134+
export QUAY_OAUTH_TOKEN_RELEASE_SOURCE
135+
setx_on
136+
}
137+
138+
get_quay_oauth_token_release_destination() {
139+
get_password "0e8b59e3-6ac2-47d6-98a4-afaa00782b9c"
140+
setx_off
141+
QUAY_OAUTH_TOKEN_RELEASE_DESTINATION="${password}"
142+
export QUAY_OAUTH_TOKEN_RELEASE_DESTINATION
143+
setx_on
144+
}
145+
146+
get_github_accounts() {
147+
get_password "bb32321b-601c-4c92-8605-afc40050d9e4"
148+
setx_off
149+
IFS=',' read -r -a GITHUB_ACCOUNTS_ARRAY <<< "${password}"
150+
export GITHUB_ACCOUNTS_ARRAY
151+
setx_on
152+
}

ci/images/e2e-test-runner/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#@FROM registry.access.redhat.com/ubi9/ubi-minimal
2+
FROM registry.access.redhat.com/ubi9/ubi-minimal@sha256:085c5049f5bd0b3cb33c322306a528373f79dc6f1098ff8f5a5b28f2685c53f8
3+
RUN set -x \
4+
&& mkdir ~/.kube \
5+
&& mkdir -p /tmp/image-build \
6+
&& microdnf install -y \
7+
httpd-tools \
8+
git-2.31.1 \
9+
make-1:4.3 \
10+
openssl-3.0.1 \
11+
tar-2:1.34 \
12+
unzip-6.0 \
13+
which-2.21 \
14+
&& microdnf clean all
15+
COPY shared /tmp/image-build/shared
16+
RUN /tmp/image-build/shared/hack/install.sh --debug --bin bitwarden,go,jq,kubectl,oc,yq \
17+
&& rm -rf /tmp/image-build
18+
19+
WORKDIR "/source"
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
set -o errexit
3+
set -o nounset
4+
set -o pipefail
5+
set -x
6+
7+
SCRIPT_DIR="$(
8+
cd "$(dirname "$0")" >/dev/null
9+
pwd
10+
)"
11+
12+
PROJECT_DIR="$(
13+
cd "$SCRIPT_DIR/../../.." >/dev/null || exit 1
14+
pwd
15+
)"
16+
17+
# shellcheck source=ci/images/ci-runner/hack/bin/utils.sh
18+
source "$PROJECT_DIR/ci/images/ci-runner/hack/bin/utils.sh"
19+
20+
export GITHUB_USER GITHUB_TOKEN QUAY_TOKEN QUAY_OAUTH_USER QUAY_OAUTH_TOKEN QUAY_OAUTH_TOKEN_RELEASE_SOURCE QUAY_OAUTH_TOKEN_RELEASE_DESTINATION \
21+
GITHUB_ACCOUNTS_ARRAY PREVIOUS_RATE_REMAINING GITHUB_USERNAME_ARRAY GH_RATE_REMAINING
22+
23+
printf "Fetch secrets from bitwarden server\n" | indent 2
24+
open_bitwarden_session
25+
get_github_user
26+
get_github_token
27+
get_quay_token
28+
get_quay_oauth_user
29+
get_quay_oauth_token
30+
get_quay_oauth_token_release_source
31+
get_quay_oauth_token_release_destination
32+
get_github_accounts
33+
34+
35+
PREVIOUS_RATE_REMAINING=0
36+
37+
# user stored: username:token,username:token
38+
for account in "${GITHUB_ACCOUNTS_ARRAY[@]}"
39+
do :
40+
IFS=':' read -r -a GITHUB_USERNAME_ARRAY <<< "$account"
41+
42+
GH_RATE_REMAINING=$(curl -s \
43+
-H "Accept: application/vnd.github+json" \
44+
-H "Authorization: Bearer ${GITHUB_USERNAME_ARRAY[1]}"\
45+
https://api.github.com/rate_limit | jq ".rate.remaining")
46+
47+
echo -e "[INFO ] user: ${GITHUB_USERNAME_ARRAY[0]} with rate limit remaining $GH_RATE_REMAINING"
48+
if [[ "${GH_RATE_REMAINING}" -ge "${PREVIOUS_RATE_REMAINING}" ]];then
49+
GITHUB_USER="${GITHUB_USERNAME_ARRAY[0]}"
50+
GITHUB_TOKEN="${GITHUB_USERNAME_ARRAY[1]}"
51+
fi
52+
PREVIOUS_RATE_REMAINING="${GH_RATE_REMAINING}"
53+
done
54+
55+
echo -e "[INFO] Start tests with user: ${GITHUB_USER}"
56+
57+
##git config
58+
git config --global user.name "redhat-appstudio-qe-bot"
59+
git config --global user.email [email protected]
60+
61+
mkdir -p "${HOME}/creds"
62+
GIT_CREDS_PATH="${HOME}/creds/file"
63+
git config --global credential.helper "store --file ${GIT_CREDS_PATH}"
64+
echo "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com" > "${GIT_CREDS_PATH}"
65+
66+
67+
cd "$(mktemp -d)"
68+
69+
git clone --branch main "https://${GITHUB_TOKEN}@github.com/redhat-appstudio/e2e-tests.git" .
70+
## Deploy StoneSoup
71+
make local/cluster/prepare
72+
73+
## Launch partial StoneSoup e2e tests
74+
go mod tidy
75+
go mod vendor
76+
make build
77+
./bin/e2e-appstudio --ginkgo.label-filter "pipeline" --ginkgo.vv

shared/hack/install.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,7 @@ install_checkov() {
148148
install_go() {
149149
curl "${CURL_OPTS[@]}" -o "$TMPDIR/go.tgz" "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz"
150150
tar -C /usr/local -xzf "$TMPDIR/go.tgz"
151-
PATH="$PATH:/usr/local/go/bin"
152-
echo "export PATH=$PATH" >"/etc/profile"
153-
# shellcheck disable=SC1091
154-
source "/etc/profile"
151+
ln -s /usr/local/go/bin/go /usr/bin/go
155152
go version
156153
}
157154

0 commit comments

Comments
 (0)