-
Notifications
You must be signed in to change notification settings - Fork 38
243 lines (236 loc) · 8.88 KB
/
e2e-tests.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
name: E2E Tests
on:
workflow_call:
inputs:
environment:
required: true
type: string
ref:
required: true
type: string
concurrency:
group: e2e-cluster-${{ inputs.environment }}
env:
IMAGE_NAME: "s3-csi-driver"
BENCHMARK_ARTIFACTS_FOLDER: ".github/artifacts"
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
KOPS_STATE_FILE: "s3://${{ vars.KOPS_STATE_FILE }}"
BENCHMARK_BUCKET: "s3://${{ vars.BENCHMARK_BUCKET }}"
TAG_UNTESTED: "untested_${{ inputs.ref }}"
TAG_PASSED: "test_passed_${{ inputs.ref }}"
jobs:
build_matrix:
name: Build Matrix
uses: ./.github/workflows/build_matrix.yaml
build:
runs-on: ubuntu-22.04 # FIXME - https://github.com/actions/runner-images/issues/11471
environment: ${{ inputs.environment }}
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@master
with:
role-to-assume: ${{ vars.IAM_ROLE }}
aws-region: ${{ vars.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag, and push docker image to Amazon ECR Private Repository
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
PLATFORM: "linux/amd64,linux/arm64"
TAG: "${{ env.TAG_UNTESTED }}"
run: |
make -j `nproc` all-push-skip-if-present
test:
needs: ["build", "build_matrix"]
strategy:
# Failing fast causes some resources created during the test to leak,
# so we disable it to ensure all resources created during test are properly cleaned up.
fail-fast: false
matrix: ${{ fromJson(needs.build_matrix.outputs.matrix) }}
runs-on: ubuntu-22.04 # FIXME - https://github.com/actions/runner-images/issues/11471
environment: ${{ inputs.environment }}
permissions:
id-token: write
contents: read
env:
AWS_REGION: "${{ vars.AWS_REGION }}"
CLUSTER_TYPE: "${{ matrix.cluster-type }}"
ARCH: "${{ matrix.arch }}"
AMI_FAMILY: "${{ matrix.family }}"
TAG: "untested_${{ inputs.ref }}"
# envtest doesn't support all versions, here K8S_VERSION is a full version like 1.28.13,
# and in order to get latest supported version by envtest we convert it to 1.28.
K8S_VERSION: "${{ matrix.kubernetes-version }}"
ENVTEST_K8S_VERSION: "${K8S_VERSION%.*}"
SELINUX_MODE: "${{ matrix.selinux-mode }}"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.IAM_ROLE }}
aws-region: ${{ vars.AWS_REGION }}
role-duration-seconds: 7200
- name: Install tools
env:
ACTION: "install_tools"
run: |
tests/e2e-kubernetes/scripts/run.sh
- name: Run Controller Tests
run: |
make e2e-controller
- name: Create cluster
env:
ACTION: "create_cluster"
run: |
tests/e2e-kubernetes/scripts/run.sh
- name: Update kubeconfig
env:
ACTION: "update_kubeconfig"
run: |
tests/e2e-kubernetes/scripts/run.sh
# Test SystemdMounter
# SystemdMounter tests are skipped if SELinux is enabled as SystemdMounter won't work with SELinux.
- name: Install the driver (SystemdMounter)
if: matrix.selinux-mode != 'enforcing'
env:
ACTION: "install_driver"
run: |
tests/e2e-kubernetes/scripts/run.sh
- name: Run E2E Tests (SystemdMounter)
if: matrix.selinux-mode != 'enforcing'
env:
ACTION: "run_tests"
run: |
tests/e2e-kubernetes/scripts/run.sh
- name: Run Performance Tests
if: (env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'bench') && matrix.cluster-type == 'kops' && matrix.arch == 'x86'
env:
ACTION: "run_perf"
run: |
tests/e2e-kubernetes/scripts/run.sh
- name: Download previous benchmark results
if: (env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'bench') && matrix.cluster-type == 'kops' && matrix.arch == 'x86'
run: |
mkdir -p ${{ env.BENCHMARK_ARTIFACTS_FOLDER }}
aws s3 cp --region ${{ vars.BENCHMARK_RESULTS_REGION }} ${{ vars.BENCHMARK_BUCKET }}/benchmark-data.json ${{ env.BENCHMARK_ARTIFACTS_FOLDER }}/benchmark-data.json || true
- name: Update benchmark result file
if: (env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'bench') && matrix.cluster-type == 'kops' && matrix.arch == 'x86'
uses: benchmark-action/github-action-benchmark@v1
with:
tool: "customBiggerIsBetter"
output-file-path: tests/e2e-kubernetes/csi-test-artifacts/output.json
alert-threshold: "200%"
fail-on-alert: true
external-data-json-path: ${{ env.BENCHMARK_ARTIFACTS_FOLDER }}/benchmark-data.json
max-items-in-chart: 20
- name: Store benchmark result
if: (env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'bench') && matrix.cluster-type == 'kops' && matrix.arch == 'x86'
run: |
tests/e2e-kubernetes/scripts/format_benchmark_data.py ${{ env.BENCHMARK_ARTIFACTS_FOLDER }}/benchmark-data.json ${{ env.BENCHMARK_ARTIFACTS_FOLDER }}/quicksight-data.json
aws s3 cp ${{ env.BENCHMARK_ARTIFACTS_FOLDER }} ${{ env.BENCHMARK_BUCKET }} --recursive
- name: Post e2e cleanup (SystemdMounter)
if: matrix.selinux-mode != 'enforcing' && always()
env:
ACTION: "e2e_cleanup"
run: |
tests/e2e-kubernetes/scripts/run.sh
- name: Uninstall the driver (SystemdMounter)
if: matrix.selinux-mode != 'enforcing' && always()
env:
ACTION: "uninstall_driver"
run: |
tests/e2e-kubernetes/scripts/run.sh
# Test PodMounter
- name: Install the driver (PodMounter)
env:
ACTION: "install_driver"
MOUNTER_KIND: "pod"
run: |
tests/e2e-kubernetes/scripts/run.sh
- name: Run E2E Tests (PodMounter)
env:
ACTION: "run_tests"
run: |
tests/e2e-kubernetes/scripts/run.sh
- name: Post e2e cleanup (PodMounter)
if: always()
env:
ACTION: "e2e_cleanup"
run: |
tests/e2e-kubernetes/scripts/run.sh
- name: Uninstall the driver (PodMounter)
if: always()
env:
ACTION: "uninstall_driver"
run: |
tests/e2e-kubernetes/scripts/run.sh
# Everything is tested, delete the cluster
- name: Delete cluster
if: always()
env:
ACTION: "delete_cluster"
run: |
tests/e2e-kubernetes/scripts/run.sh
post_test:
needs: test
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
permissions:
id-token: write
contents: read
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.IAM_ROLE }}
aws-region: ${{ vars.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Mark tests as passed
env:
AWS_REGION: "${{ vars.AWS_REGION }}"
REPOSITORY: "${{ steps.login-ecr.outputs.registry }}/${{ env.IMAGE_NAME }}"
REPOSITORY_NAME: "${{ env.IMAGE_NAME }}"
run: |
docker buildx imagetools create --tag ${REPOSITORY}:${TAG_PASSED} ${REPOSITORY}:${TAG_UNTESTED}
for ARCH in amd64 arm64; do
MANIFEST=$(aws ecr batch-get-image --repository-name ${REPOSITORY_NAME} \
--image-ids imageTag=${TAG_UNTESTED}-linux-${ARCH}-amazon \
--region ${AWS_REGION} --query 'images[].imageManifest' --output text)
aws ecr put-image \
--repository-name ${REPOSITORY_NAME} \
--image-tag ${TAG_PASSED}-linux-${ARCH}-amazon \
--image-manifest "$MANIFEST" \
--region ${AWS_REGION} 2>&1 | grep -q "ImageAlreadyExistsException" || \
{ err=$?; [ $err -eq 1 ] || exit $err; }
done