forked from replicatedhq/kots
-
Notifications
You must be signed in to change notification settings - Fork 0
275 lines (269 loc) · 11.5 KB
/
regression.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
name: regression
on:
workflow_call:
inputs:
version_tag_old:
description: 'The initial install version to use for upgrade scenarios'
required: true
type: string
version_tag_new:
description: 'The new version to use as the upgrade in upgrade scenarios and the initial version for fresh installs.'
required: true
type: string
addon_package_url:
description: 'The URL to the kURL add-on package to use as an override.'
required: false
type: string
id:
description: 'An arbitrary value used to identify the testing infrastructure. Using the same value twice will destroy the old infrastructure before creating.'
required: false
type: string
secrets:
TESTIM_ACCESS_TOKEN:
required: true
E2E_TESTIM_AWS_ACCESS_KEY_ID:
required: true
E2E_TESTIM_AWS_SECRET_ACCESS_KEY:
required: true
E2E_GH_PAT:
required: true
KOTS_BUILD_STATUS_SLACK_WEBHOOK_URL:
required: true
workflow_dispatch:
inputs:
version_tag_old:
description: 'The initial install version to use for upgrade scenarios'
required: true
type: string
version_tag_new:
description: 'The new version to use as the upgrade in upgrade scenarios and the initial version for fresh installs.'
required: true
type: string
addon_package_url:
description: 'The URL to the kURL add-on package to use as an override.'
required: false
type: string
id:
description: 'An arbitrary value used to identify the testing infrastructure. Using the same value twice will destroy the old infrastructure before creating.'
required: false
type: string
env:
AWS_DEFAULT_REGION: us-east-1
AWS_ACCESS_KEY_ID: ${{ secrets.E2E_TESTIM_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.E2E_TESTIM_AWS_SECRET_ACCESS_KEY }}
TF_VAR_testim_token: ${{ secrets.TESTIM_ACCESS_TOKEN }}
WORKSPACE: automation-${{ github.event.inputs.id || inputs.id }}
jobs:
jumpbox:
runs-on: ubuntu-20.04
container:
image: hashicorp/terraform:1.0.11
steps:
- name: Checkout
uses: actions/checkout@v3
with:
repository: replicatedhq/kots-regression-automation
token: ${{ secrets.E2E_GH_PAT }}
path: automation
ref: main
- name: Download go_api artifact
uses: actions/download-artifact@v3
with:
name: go_api
path: ./automation/jumpbox/bin
- name: Download kotsadm image
uses: actions/download-artifact@v3
with:
name: kotsadm-image
path: ./automation/jumpbox/docker-archive
- name: Download migrations
uses: actions/download-artifact@v3
with:
name: migrations-image
path: ./automation/jumpbox/docker-archive
- name: Make kotsadm airgap archive with minio image
working-directory: automation/jumpbox
run: tar czf ./kotsadm.tar.gz -C ./ ./docker-archive
- name: Initialize terraform
if: always()
working-directory: automation/jumpbox
run: |
terraform init
terraform workspace new "$WORKSPACE" || true
terraform workspace select "$WORKSPACE"
- name: Create Jumpbox Environment
if: always()
working-directory: automation/jumpbox
run: terraform apply --auto-approve
- name: Notify Slack
if: failure() && github.ref_name == 'main'
uses: 8398a7/action-slack@v3
with:
status: custom
fields: repo,ref,workflow
custom_payload: |
{
attachments: [{
color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning',
text: `Create jumpbox: ${{ job.status }}. Workflow: ${process.env.AS_WORKFLOW}. Repo: ${process.env.AS_REPO}.\nRef: ${process.env.AS_REF}`,
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.KOTS_BUILD_STATUS_SLACK_WEBHOOK_URL }}
tests:
needs: jumpbox
runs-on: ubuntu-20.04
container:
image: hashicorp/terraform:1.0.11
strategy:
fail-fast: false
matrix:
test: [
{
name: "type=embedded cluster, env=airgapped, phase=upgraded install, rbac=cluster admin",
backend_config: "embedded-airgapped-upgrade-backend-config.tfvars",
terraform_script: "embedded-airgapped-upgrade.sh",
is_upgrade: "1"
},
{
name: "type=embedded cluster, env=airgapped, phase=new install, rbac=cluster admin",
backend_config: "embedded-airgapped-install-backend-config.tfvars",
terraform_script: "embedded-airgapped-install.sh"
},
{
name: "type=embedded cluster, env=online, phase=new install, rbac=cluster admin",
backend_config: "embedded-online-install-backend-config.tfvars",
terraform_script: "embedded-online-install.sh"
},
{
name: "type=embedded cluster, env=online, phase=upgraded install, rbac=cluster admin",
backend_config: "embedded-online-upgrade-backend-config.tfvars",
terraform_script: "embedded-online-upgrade.sh",
is_upgrade: "1"
},
{
name: "type=existing cluster, env=airgapped, phase=new install, rbac=cluster admin",
backend_config: "existing-airgapped-install-admin-backend-config.tfvars",
terraform_script: "existing-airgapped-install-admin.sh"
},
{
name: "type=existing cluster, env=airgapped, phase=new install, rbac=minimal rbac",
backend_config: "existing-airgapped-install-minimum-backend-config.tfvars",
terraform_script: "existing-airgapped-install-minimum.sh"
},
{
name: "type=existing cluster, env=online, phase=upgraded install, rbac=cluster admin",
backend_config: "existing-online-upgrade-admin-backend-config.tfvars",
terraform_script: "existing-online-upgrade-admin.sh",
is_upgrade: "1"
},
{
name: "type=existing cluster, env=online, phase=upgraded install, rbac=minimal rbac",
backend_config: "existing-online-upgrade-minimum-backend-config.tfvars",
terraform_script: "existing-online-upgrade-minimum.sh",
is_upgrade: "1"
},
{
name: "type=existing cluster, env=online, phase=new install, rbac=cluster admin",
backend_config: "existing-online-install-admin-backend-config.tfvars",
terraform_script: "existing-online-install-admin.sh"
},
{
name: "type=existing cluster, env=online, phase=new install, rbac=minimal rbac",
backend_config: "existing-online-install-minimum-backend-config.tfvars",
terraform_script: "existing-online-install-minimum.sh"
},
{
name: "type=existing cluster, env=airgapped, phase=upgraded install, rbac=cluster admin",
backend_config: "existing-airgapped-upgrade-admin-backend-config.tfvars",
terraform_script: "existing-airgapped-upgrade-admin.sh",
is_upgrade: "1"
},
{
name: "type=existing cluster, env=airgapped, phase=upgraded install, rbac=minimal rbac",
backend_config: "existing-airgapped-upgrade-minimum-backend-config.tfvars",
terraform_script: "existing-airgapped-upgrade-minimum.sh",
is_upgrade: "1"
},
{
name: "type=helmvm cluster, env=online, phase=new install, rbac=cluster admin",
backend_config: "helmvm-online-install-backend-config.tfvars",
terraform_script: "helmvm-online-install.sh"
}
]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
repository: replicatedhq/kots-regression-automation
token: ${{ secrets.E2E_GH_PAT }}
path: automation
ref: main
- name: Initialize terraform
if: always()
working-directory: automation/cluster
run: |
terraform init -backend-config ${{ matrix.test.backend_config }}
terraform workspace new "$WORKSPACE" || true
terraform workspace select "$WORKSPACE"
- name: Destroy test environment before re-run
if: always() && github.run_attempt > 1
working-directory: automation/cluster
run: ./${{ matrix.test.terraform_script }} destroy
- name: Create test environment
if: always()
working-directory: automation/cluster
run: |
export CURRENT_TAG="${{ github.event.inputs.version_tag_old || inputs.version_tag_old }}"
export NEXT_TAG="${{ github.event.inputs.version_tag_new || inputs.version_tag_new }}"
if [ -n "${{ matrix.test.is_upgrade }}" ]; then
export TF_VAR_kots_version_initial="${CURRENT_TAG:1}"
export TF_VAR_kots_version_upgrade="${NEXT_TAG:1}"
else
export TF_VAR_kots_version_initial="${NEXT_TAG:1}"
fi
export TF_VAR_kots_addon_package_url="${{ github.event.inputs.addon_package_url || inputs.addon_package_url }}"
export TF_VAR_testim_branch="master"
./${{ matrix.test.terraform_script }} apply
- name: Wait for instance to be ready
working-directory: automation/cluster
run: |
apk update && apk add aws-cli jq
terraform output -raw control_plane_instance_id
until [ -n "$(aws ec2 describe-instance-status --instance-ids "$(terraform output -raw control_plane_instance_id)" --filter Name=instance-status.reachability,Values=passed | jq -r '.InstanceStatuses[].InstanceStatus.Details[].Status')" ]
do
echo "waiting for instance to become ready" && sleep 1
done
- name: Run the test
working-directory: automation/cluster
run: |
terraform output -raw jumpbox_private_key > ssh.pem
chmod 600 ssh.pem
ssh -i ssh.pem "ubuntu@$(terraform output -raw jumpbox_public_ip)" -oStrictHostKeyChecking=no -oServerAliveInterval=60 -oServerAliveCountMax=10 "ssh -tt ubuntu@$(terraform output -raw control_plane_private_ip) -oServerAliveInterval=60 -oServerAliveCountMax=10 -oConnectionAttempts=30 \"sudo /tmp/start.sh\""
- name: Notify Slack
if: always() && github.ref_name == 'main'
uses: 8398a7/action-slack@v3
with:
status: custom
fields: repo,ref,workflow,commit
custom_payload: |
{
attachments: [{
color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning',
text: `Test name: ${{ matrix.test.name }}.\nStatus: ${{ job.status }}. Workflow: ${process.env.AS_WORKFLOW}. Repo: ${process.env.AS_REPO}. Ref: ${process.env.AS_REF}\nCommit: ${process.env.AS_COMMIT}`,
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.KOTS_BUILD_STATUS_SLACK_WEBHOOK_URL }}
MATRIX_CONTEXT: ${{ toJson(matrix) }}
cleanup:
needs: tests
runs-on: ubuntu-20.04
steps:
- name: Trigger workspace cleanup
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.E2E_GH_PAT }}
repository: replicatedhq/kots
event-type: e2e-workspace-cleanup
client-payload: '{"workspace": "automation-${{ github.event.inputs.id || inputs.id }}"}'