-
Notifications
You must be signed in to change notification settings - Fork 77
215 lines (209 loc) · 7.13 KB
/
e2e-tests.yaml
File metadata and controls
215 lines (209 loc) · 7.13 KB
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
name: E2E Tests
on:
workflow_call:
inputs:
environment:
required: true
type: string
ref:
required: true
type: string
concurrency:
group: e2e-cluster-${{ inputs.environment }}
queue: max
env:
IMAGE_NAME: "s3-csi-driver"
BENCHMARK_ARTIFACTS_FOLDER: ".github/artifacts"
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
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
permissions:
contents: read
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@v6
with:
ref: ${{ inputs.ref }}
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: "go.mod"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- 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 }}"
K8S_VERSION: "${{ matrix.kubernetes-version }}"
SELINUX_MODE: "${{ matrix.selinux-mode }}"
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.ref }}
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: "go.mod"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v6
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: Create cluster
id: 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: 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"
MOUNTER_KIND: "pod"
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)
# Skip uninstall if cluster creation did not succeed - no cluster to communicate with
if: ${{ always() && steps.create_cluster.conclusion == 'success' }}
env:
ACTION: "uninstall_driver"
run: |
tests/e2e-kubernetes/scripts/run.sh
- name: Delete cluster
if: always()
env:
ACTION: "delete_cluster"
run: |
tests/e2e-kubernetes/scripts/run.sh
post_test:
if: always()
needs:
- test
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
permissions:
id-token: write
contents: read
steps:
- name: Verify jobs succeeded
run: echo '${{ toJSON(needs) }}' | jq -e 'to_entries | all(.value.result == "success")'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v6
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