-
Notifications
You must be signed in to change notification settings - Fork 8
271 lines (241 loc) · 8.63 KB
/
reusable-e2e.yml
File metadata and controls
271 lines (241 loc) · 8.63 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
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
on:
workflow_call:
inputs:
postgres_img:
description: "URL of the Postgres image to test"
required: true
type: string
major_version:
description: "PostgreSQL major version"
required: true
type: string
cnpg_branch:
description: "Name of the branch/tag used to build & load the operator"
required: false
type: string
default: "main"
test_depth:
description: 'E2E test level: 0(highest) to 4(lowest)'
required: false
type: string
default: "4"
feature_type:
description: 'E2E feature type filter'
required: false
type: string
default: ""
# set up environment variables to be used across all the jobs
env:
KIND_VERSION: "v0.31.0"
K8S_VERSION: "v1.35.1"
REGISTRY: "ghcr.io/${{ github.repository_owner }}/postgresql-trunk"
defaults:
run:
# default failure handling for shell scripts in 'run' steps
shell: 'bash -Eeuo pipefail -x {0}'
permissions: {}
jobs:
e2e-local:
name: Run E2E on local executors
runs-on: ${{ github.repository_owner == 'cloudnative-pg' && 'ubuntu-latest-16-cores' || 'ubuntu-24.04' }}
permissions:
packages: write
env:
TEST_DEPTH: ${{ inputs.test_depth }}
FEATURE_TYPE: ${{ inputs.feature_type }}
POSTGRES_VERSION: ${{ inputs.major_version }}
POSTGRES_IMG: ${{ inputs.postgres_img }}
POSTGRES_KIND: "PostgreSQL"
POSTGRES_MAJOR_UPGRADE_IMAGE_REGISTRY: "ghcr.io/${{ github.repository_owner }}/postgresql-trunk"
POSTGRES_MAJOR_UPGRADE_SKIP_ARCHIVE_SCENARIO: true
DOCKER_SERVER: ghcr.io
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
ID: "local"
TEST_UPGRADE_TO_V1: false
DEBUG: "true"
BUILD_IMAGE: "true"
E2E_DEFAULT_STORAGE_CLASS: standard
E2E_CSI_STORAGE_CLASS: csi-hostpath-sc
E2E_DEFAULT_VOLUMESNAPSHOT_CLASS: csi-hostpath-snapclass
LOG_DIR: ${{ github.workspace }}/kind-logs/
DOCKER_REGISTRY_MIRROR: https://mirror.gcr.io
TEST_CLOUD_VENDOR: "local"
steps:
- name: Cleanup Disk
uses: jlumbroso/free-disk-space@main
with:
android: true
dotnet: true
haskell: true
tool-cache: true
large-packages: false
swap-storage: false
- name: Cleanup docker cache
run: |
echo "-------------Disk info before cleanup----------------"
df -h
echo "-----------------------------------------------------"
docker system prune -a -f
echo "-------------Disk info after cleanup----------------"
df -h
echo "-----------------------------------------------------"
- name: Checkout
uses: actions/checkout@v6
with:
repository: cloudnative-pg/cloudnative-pg
ref: ${{ inputs.cnpg_branch }}
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
check-latest: true
- name: Set GoReleaser environment
run: |
echo GOPATH=$(go env GOPATH) >> $GITHUB_ENV
echo PWD=$(pwd) >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Install Kind
uses: helm/kind-action@v1.14.0
with:
install_only: true
version: ${{ env.KIND_VERSION }}
kubectl_version: ${{ env.K8S_VERSION }}
- name: Log in to the GitHub Container registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# The version of operator to upgrade FROM, in the rolling upgrade E2E test
- name: Retag the image to create E2E_PRE_ROLLING_UPDATE_IMG
env:
INPUT_MAJOR_VERSION: ${{ inputs.major_version }}
INPUT_POSTGRES_IMG: ${{ inputs.postgres_img }}
run: |
E2E_PRE_ROLLING_UPDATE_IMG="${REGISTRY}:${INPUT_MAJOR_VERSION}-rolling-upgrade-e2e-${GITHUB_RUN_NUMBER}"
docker pull "${INPUT_POSTGRES_IMG}"
docker tag "${INPUT_POSTGRES_IMG}" $E2E_PRE_ROLLING_UPDATE_IMG
docker push $E2E_PRE_ROLLING_UPDATE_IMG
echo "E2E_PRE_ROLLING_UPDATE_IMG=$E2E_PRE_ROLLING_UPDATE_IMG" >> $GITHUB_ENV
- name: Setting up defaults
run: |
# Exlude backup/recovery and image-volume tests
if [ -z "${FEATURE_TYPE}" ]; then
echo "FEATURE_TYPE=!(backup-restore || image-volume-extensions)" >> $GITHUB_ENV
else
echo "FEATURE_TYPE=!(backup-restore || image-volume-extensions) && ${FEATURE_TYPE}" >> $GITHUB_ENV
fi
- name: Run Kind End-to-End tests
run: make e2e-test-kind
# Summarize the failed E2E test cases if there are any
- name: Report failed E2E tests
if: failure()
run: |
set +x
chmod +x .github/report-failed-test.sh
./.github/report-failed-test.sh
# Create an individual artifact for each E2E test, which will be used to
# generate E2E test summary in the follow-up job 'summarize-e2e-tests'
- name: Create individual artifact for each E2E test
if: (always() && !cancelled())
env:
RUNNER: "${{ env.ID }}"
POSTGRES_VERSION: "${{ env.PG_MAJOR }}"
RUN_ID: "${{ github.run_id }}"
MATRIX: "${{ env.ID }}-${{ env.POSTGRES_KIND }}-${{ env.PG_MAJOR }}"
REPOSITORY: "${{ github.repository }}"
BRANCH_NAME: "${GITHUB_REF#refs/heads/}"
GIT_REF: "${{ github.ref_name }}"
run: |
set +x
python .github/generate-test-artifacts.py \
-o "testartifacts-${ID}" \
-f tests/e2e/out/report.json \
--environment=true
if [ -f tests/e2e/out/upgrade_report.json ]; then
python .github/generate-test-artifacts.py \
-o "testartifacts-${ID}" \
-f tests/e2e/out/upgrade_report.json \
--environment=true
fi
- name: Archive test artifacts
if: (always() && !cancelled())
uses: actions/upload-artifact@v7
with:
name: testartifacts-local
path: testartifacts-${{ env.ID }}/
retention-days: 7
- name: Cleanup test artifacts
if: always()
run:
rm -rf testartifacts-${{ env.ID }}/
# Delete report.json after the analysis. File should always exist.
# Delete upgrade_report.json. It may not exist depending on test level.
- name: Cleanup ginkgo JSON report
if: always()
run: |
if [ -f tests/e2e/out/upgrade_report.json ]; then
rm tests/e2e/out/upgrade_report.json
fi
if [ -f tests/e2e/out/report.json ]; then
rm tests/e2e/out/report.json
fi
# Archive logs for failed test cases if there are any
- name: Archive Kind logs
if: failure()
uses: actions/upload-artifact@v7
with:
name: kind-logs-${{ env.ID }}
path: kind-logs/
retention-days: 7
- name: Archive e2e failure contexts
if: failure()
uses: actions/upload-artifact@v7
with:
name: test-failure-contexts-${{ env.ID }}
path: |
tests/*/out/
retention-days: 7
if-no-files-found: ignore
# Archive Cluster logs
- name: Archive e2e logs
if: failure()
uses: actions/upload-artifact@v7
with:
name: cluster-logs-${{ env.ID }}
path: |
tests/e2e/cluster_logs/**
retention-days: 7
if-no-files-found: ignore
# Summarize E2E test results, display in the GitHub 'summary' view
summarize-e2e-tests:
name: E2E test suite
needs:
- e2e-local
if: |
always() && !cancelled() &&
(
needs.e2e-local.result == 'success' ||
needs.e2e-local.result == 'failure'
)
runs-on: ubuntu-24.04
steps:
- name: Create a directory for the artifacts
run: mkdir test-artifacts
- name: Download all artifacts to the directory
uses: actions/download-artifact@v8
with:
path: test-artifacts
pattern: testartifacts-*
merge-multiple: true
- name: Display the structure of the artifact folder
run: ls -R test-artifacts
- name: Compute the E2E test summary
uses: cloudnative-pg/ciclops@v1.3.2
with:
artifact_directory: test-artifacts
- name: Delete the downloaded files
run: rm -rf test-artifacts