Skip to content

Commit 01a7730

Browse files
committed
Adding Github SCM integration to automated tests
1 parent 0eab1e9 commit 01a7730

7 files changed

+87
-23
lines changed

.werft/aks-installer-tests.yaml

+17-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ args:
2020
desc: "Version of gitpod to install(in the case of upgrade tests, this is the initial install version and will later get upgraded to latest"
2121
required: false
2222
default: ""
23-
- name: skipTests
24-
desc: "Set this to true to skip integration tests"
23+
- name: runTests
24+
desc: "Set this to true to run integration tests"
2525
required: false
2626
default: false
2727
- name: selfSigned
@@ -123,6 +123,21 @@ pod:
123123
secretKeyRef:
124124
name: replicated
125125
key: app
126+
- name: ROBOQUAT_TOKEN
127+
valueFrom:
128+
secretKeyRef:
129+
name: github-roboquat-automatic-changelog
130+
key: token
131+
- name: USERNAME
132+
valueFrom:
133+
secretKeyRef:
134+
name: integration-test-user
135+
key: username
136+
- name: USER_TOKEN # this is for the integration tests
137+
valueFrom:
138+
secretKeyRef:
139+
name: integration-test-user
140+
key: token
126141
command:
127142
- bash
128143
- -c

.werft/eks-installer-tests.yaml

+17-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ args:
2020
desc: "Version of gitpod to install(in the case of upgrade tests, this is the initial install version and will later get upgraded to latest"
2121
required: false
2222
default: ""
23-
- name: skipTests
24-
desc: "Set this to true to skip integration tests"
23+
- name: runTests
24+
desc: "Set this to true to run integration tests"
2525
required: false
2626
default: false
2727
- name: upgrade
@@ -118,6 +118,21 @@ pod:
118118
secretKeyRef:
119119
name: replicated
120120
key: app
121+
- name: ROBOQUAT_TOKEN
122+
valueFrom:
123+
secretKeyRef:
124+
name: github-roboquat-automatic-changelog
125+
key: token
126+
- name: USERNAME
127+
valueFrom:
128+
secretKeyRef:
129+
name: integration-test-user
130+
key: username
131+
- name: USER_TOKEN # this is for the integration tests
132+
valueFrom:
133+
secretKeyRef:
134+
name: integration-test-user
135+
key: token
121136
command:
122137
- bash
123138
- -c

.werft/gke-installer-tests.yaml

+17-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ args:
2020
desc: "Version of gitpod to install(in the case of upgrade tests, this is the initial install version and will later get upgraded to latest"
2121
required: false
2222
default: ""
23-
- name: skipTests
24-
desc: "Set this to true to skip integration tests"
23+
- name: runTests
24+
desc: "Set this to true to run integration tests"
2525
required: false
2626
default: false
2727
- name: selfSigned
@@ -105,6 +105,21 @@ pod:
105105
secretKeyRef:
106106
name: replicated
107107
key: app
108+
- name: ROBOQUAT_TOKEN
109+
valueFrom:
110+
secretKeyRef:
111+
name: github-roboquat-automatic-changelog
112+
key: token
113+
- name: USERNAME
114+
valueFrom:
115+
secretKeyRef:
116+
name: integration-test-user
117+
key: username
118+
- name: USER_TOKEN # this is for the integration tests
119+
valueFrom:
120+
secretKeyRef:
121+
name: integration-test-user
122+
key: token
108123
command:
109124
- bash
110125
- -c

.werft/installer-tests.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ const kotsApp: string = annotations.replicatedApp || "gitpod";
1818
const version: string = annotations.version || "-";
1919
const preview: string = annotations.preview || "false"; // setting to true will not destroy the setup
2020
const upgrade: string = annotations.upgrade || "false"; // setting to true will not KOTS upgrade to the latest version. Set the channel to beta or stable in this case.
21-
const skipTests: string = annotations.skipTests || "false"; // setting to true skips the integration tests
22-
const selfSigned: Boolean = annotations.selfSigned === "true";
21+
const runTests: string = annotations.runTests || "false"; // setting to true runs the integration tests
22+
const selfSigned: string = annotations.selfSigned || "false";
2323
const deps: string = annotations.deps || ""; // options: ["external", "internal"] setting to `external` will ensure that all resource dependencies(storage, db, registry) will be external. if unset, a random selection will be used
2424

2525
const baseDomain: string = annotations.domain || "tests.gitpod-self-hosted.com";
@@ -155,12 +155,12 @@ const INFRA_PHASES: { [name: string]: InfraConfig } = {
155155
},
156156
GENERATE_KOTS_CONFIG: {
157157
phase: "generate-kots-config",
158-
makeTarget: `generate-kots-config storage=${randDeps()} registry=${randDeps()} db=${randDeps()}`,
158+
makeTarget: `generate-kots-config storage=${randDeps()} registry=${randDeps()} db=${randDeps()} runTests=${runTests} self_signed=${selfSigned}`,
159159
description: `Generate KOTS Config file`,
160160
},
161161
CLUSTER_ISSUER: {
162162
phase: "setup-cluster-issuer",
163-
makeTarget: `cluster-issuer`,
163+
makeTarget: `cluster-issuer self_signed=${selfSigned}`,
164164
description: `Deploys ClusterIssuer for ${cloud}`,
165165
},
166166
EXTERNALDNS: {
@@ -319,7 +319,7 @@ export async function installerTests(config: TestConfig) {
319319
}
320320
}
321321

322-
if (skipTests === "true") {
322+
if (runTests === "false") {
323323
console.log("Skipping integration tests");
324324
} else {
325325
runIntegrationTests();
@@ -551,7 +551,7 @@ export function sendFailureSlackAlert(phase: string, err: Error, hook: string):
551551
{
552552
hostname: "hooks.slack.com",
553553
port: 443,
554-
path: process.env.SH_SLACK_NOTIFICATION_PATH.trim(),
554+
path: hook,
555555
method: "POST",
556556
headers: {
557557
"Content-Type": "application/json",

.werft/jobs/build/self-hosted-upgrade-tests.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export async function triggerSelfHostedPreview(werft: Werft, config: JobConfig,
114114

115115
exec(`git config --global user.name "${username}"`);
116116

117-
annotation = `${annotation} -a channel=${replicatedChannel} -a preview=true -a skipTests=true -a deps=external`;
117+
annotation = `${annotation} -a channel=${replicatedChannel} -a preview=true -a deps=external`;
118118

119119
werft.phase("self-hosted-preview", `Create self-hosted preview in ${cluster}`);
120120

.werft/k3s-installer-tests.yaml

+20-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ args:
2020
desc: "Version of gitpod to install(in the case of upgrade tests, this is the initial install version and will later get upgraded to latest"
2121
required: false
2222
default: ""
23-
- name: skipTests
24-
desc: "Set this to true to skip integration tests"
23+
- name: runTests
24+
desc: "Set this to true to run integration tests"
2525
required: false
2626
default: false
2727
- name: selfSigned
@@ -59,6 +59,9 @@ pod:
5959
- name: sh-playground-dns-perm
6060
secret:
6161
secretName: sh-playground-dns-perm
62+
- name: self-hosted-github-oauth
63+
secret:
64+
secretName: self-hosted-github-oauth
6265
containers:
6366
- name: nightly-test
6467
image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:mads-update-leeway.0
@@ -69,17 +72,31 @@ pod:
6972
mountPath: /mnt/secrets/sh-playground-sa-perm
7073
- name: sh-playground-dns-perm # this sa is used for the DNS management
7174
mountPath: /mnt/secrets/sh-playground-dns-perm
75+
- name: self-hosted-github-oauth
76+
mountPath: "/mnt/secrets/github-oauth"
7277
env:
7378
- name: GOOGLE_APPLICATION_CREDENTIALS
7479
value: "/mnt/secrets/sh-playground-sa-perm/sh-sa.json"
7580
- name: TF_VAR_sa_creds
7681
value: "/mnt/secrets/sh-playground-sa-perm/sh-sa.json"
7782
- name: TF_VAR_dns_sa_creds
7883
value: "/mnt/secrets/sh-playground-dns-perm/sh-dns-sa.json"
84+
- name: GITHUB_SCM_OAUTH
85+
value: "/mnt/secrets/github-oauth/provider"
7986
- name: NODENAME
8087
valueFrom:
8188
fieldRef:
8289
fieldPath: spec.nodeName
90+
- name: ROBOQUAT_TOKEN
91+
valueFrom:
92+
secretKeyRef:
93+
name: github-roboquat-automatic-changelog
94+
key: token
95+
- name: USERNAME
96+
valueFrom:
97+
secretKeyRef:
98+
name: integration-test-user
99+
key: username
83100
- name: USER_TOKEN # this is for the integration tests
84101
valueFrom:
85102
secretKeyRef:
@@ -130,7 +147,7 @@ pod:
130147
export domain="{{ .Annotations.subdomain }}"
131148
132149
if [[ "$domain" == "<no value>" ]]; then
133-
export TF_VAR_TEST_ID="$(echo $RANDOM | md5sum | head -c 5; echo)-k3s"
150+
export TF_VAR_TEST_ID="p$(echo $RANDOM | md5sum | head -c 5; echo)-k3s"
134151
else
135152
export TF_VAR_TEST_ID="$domain"
136153
fi

install/tests/Makefile

+9-7
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,11 @@ add-ns-record: check-env-cloud
146146
terraform apply -target=module.$(cloud)-add-dns-record -var kubeconfig=${KUBECONFIG} --auto-approve
147147
@echo "Done adding NS record"
148148

149+
self_signed ?= "false"
149150
.PHONY:
150151
## cluster-issuer: Creates a cluster issuer for the correspondign provider
151152
cluster-issuer: check-env-cloud
152-
ifneq ($(self_signed),)
153+
ifneq ($(self_signed), "false")
153154
@echo "Skipped creating cluster issuer"
154155
else
155156
terraform init --upgrade && \
@@ -206,8 +207,8 @@ get-kubeconfig:
206207
get-github-config:
207208
ifneq ($(GITHUB_SCM_OAUTH),)
208209
export SCM_OAUTH=./manifests/github-oauth.yaml && \
209-
cat $$GITHUB_SCM_OAUTH/provider > $$SCM_OAUTH && \
210-
yq w -i $$SCM_OAUTH 'oauth.callBackUrl' http://${TF_VAR_TEST_ID}.${TF_VAR_domain}/auth/github.com/callback && \
210+
cat $$GITHUB_SCM_OAUTH > $$SCM_OAUTH && \
211+
yq w -i $$SCM_OAUTH 'oauth.callBackUrl' https://scm.${DOMAIN}/auth/github.com/callback?state=${TF_VAR_TEST_ID} && \
211212
kubectl --kubeconfig=${KUBECONFIG} create namespace gitpod || echo "Gitpod namespace already exist" && \
212213
kubectl --kubeconfig=${KUBECONFIG} delete secret github-oauth -n gitpod || echo "gitpod-oauth secret needs to be created" && \
213214
kubectl --kubeconfig=${KUBECONFIG} create secret generic "github-oauth" --namespace gitpod --from-literal=provider="$$(cat $$SCM_OAUTH)" && \
@@ -218,7 +219,7 @@ endif
218219

219220
KOTS_KONFIG := "./manifests/kots-config.yaml"
220221

221-
get-base-config: get-github-config
222+
get-base-config:
222223
export CONFIG_PATCH=./manifests/config-patch.yaml && \
223224
export DOMAIN=${TF_VAR_domain} && \
224225
export PATCH=$$(cat $$CONFIG_PATCH | base64 -w 0) || export PATCH="" && \
@@ -329,6 +330,8 @@ endif
329330
storage ?= incluster
330331
registry ?= incluster
331332
db ?= incluster
333+
runTests ?= "false"
334+
self_signed ?= "false"
332335
.PHONY:
333336
generate-kots-config: cloud_storage = $(if $(findstring external,$(storage)),$(cloud),incluster)
334337
generate-kots-config: cloud_registry = $(if $(findstring external,$(registry)),$(cloud),incluster)
@@ -338,9 +341,8 @@ generate-kots-config: select-workspace check-env-cloud get-base-config check-env
338341
$(MAKE) storage-config-${cloud_storage}
339342
$(MAKE) db-config-${cloud_db}
340343
$(MAKE) registry-config-${cloud_registry}
341-
ifneq ($(self_signed),)
342-
$(MAKE) self-signed-config
343-
endif
344+
if [[ $$self_signed == "true" ]]; then $(MAKE) self-signed-config; fi
345+
if [[ $$runTests == "true" ]]; then $(MAKE) get-github-config; fi
344346

345347
license_community_beta := "../licenses/Community (Beta).yaml"
346348
license_community_stable := "../licenses/Community.yaml"

0 commit comments

Comments
 (0)