Skip to content

Commit aa240d8

Browse files
danishedbjbattiatomnencia
authored
ci(k3d): add support to run e2e tests using k3d (cloudnative-pg#9912)
Add k3d as a new CI engine for running E2E tests via workflow_dispatch. Rename the "local" engine to "kind" throughout and enable portable tests to also run on k3d. Closes cloudnative-pg#9871 Signed-off-by: danishedb <danish.khan@enterprisedb.com> Signed-off-by: Jonathan Battiato <jonathan.battiato@enterprisedb.com> Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com> Co-authored-by: Jonathan Battiato <jonathan.battiato@enterprisedb.com> Co-authored-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
1 parent 09b91e5 commit aa240d8

18 files changed

+372
-104
lines changed

.github/e2e-matrix-generator.py

Lines changed: 62 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
GKE_VERSIONS_FILE = ".github/gke_versions.json"
3434
OPENSHIFT_VERSIONS_FILE = ".github/openshift_versions.json"
3535
KIND_VERSIONS_FILE = ".github/kind_versions.json"
36+
K3D_VERSIONS_FILE = ".github/k3d_versions.json"
3637
VERSION_SCOPE_FILE = ".github/k8s_versions_scope.json"
3738
E2E_TEST_TIMEOUT = ".github/e2e_test_timeout.json"
3839

@@ -114,6 +115,16 @@ def filter_version(versions_list, version_range):
114115
print(f"Failed opening file: {KIND_VERSIONS_FILE}")
115116
exit(1)
116117

118+
# Kubernetes versions on k3d to use during the tests
119+
try:
120+
with open(K3D_VERSIONS_FILE) as json_file:
121+
version_list = json.load(json_file)
122+
k3d_versions = filter_version(version_list, SUPPORT_K8S_VERSION["K3D"])
123+
K3D_K8S = VersionList(k3d_versions)
124+
except:
125+
print(f"Failed opening file: {K3D_VERSIONS_FILE}")
126+
exit(1)
127+
117128
# Kubernetes versions on EKS to use during the tests
118129
try:
119130
with open(EKS_VERSIONS_FILE) as json_file:
@@ -177,7 +188,7 @@ class E2EJob(dict):
177188
def __init__(self, k8s_version, postgres_version_list, flavor):
178189
postgres_version = postgres_version_list.latest
179190
postgres_version_pre = postgres_version_list.oldest
180-
short_postgres_version = postgres_version.split('-')[0]
191+
short_postgres_version = postgres_version.split("-")[0]
181192

182193
if flavor == "pg":
183194
name = f"{k8s_version}-PostgreSQL-{short_postgres_version}"
@@ -199,17 +210,17 @@ def __hash__(self):
199210
return hash(self["id"])
200211

201212

202-
def build_push_include_local():
213+
def build_push_include_kind():
203214
"""Build the list of tests running on push"""
204215
return {
205216
E2EJob(KIND_K8S.latest, POSTGRES.latest, "pg"),
206217
E2EJob(KIND_K8S.oldest, POSTGRES.oldest, "pg"),
207218
}
208219

209220

210-
def build_pull_request_include_local():
221+
def build_pull_request_include_kind():
211222
"""Build the list of tests running on pull request"""
212-
result = build_push_include_local()
223+
result = build_push_include_kind()
213224

214225
# Iterate over K8S versions
215226
for k8s_version in KIND_K8S:
@@ -224,9 +235,9 @@ def build_pull_request_include_local():
224235
return result
225236

226237

227-
def build_main_include_local():
238+
def build_main_include_kind():
228239
"""Build the list tests running on main"""
229-
result = build_pull_request_include_local()
240+
result = build_pull_request_include_kind()
230241

231242
# Iterate over K8S versions
232243
for k8s_version in KIND_K8S:
@@ -241,29 +252,29 @@ def build_main_include_local():
241252
return result
242253

243254

244-
def build_schedule_include_local():
255+
def build_schedule_include_kind():
245256
"""Build the list of tests running on schedule"""
246257
# For the moment scheduled tests are identical to main
247-
return build_main_include_local()
258+
return build_main_include_kind()
248259

249260

250-
def build_push_include_cloud(engine_version_list):
261+
def build_push_include_default(engine_version_list):
251262
return {}
252263

253264

254-
def build_pull_request_include_cloud(engine_version_list):
265+
def build_pull_request_include_default(engine_version_list):
255266
return {
256267
E2EJob(engine_version_list.latest, POSTGRES.latest, "pg"),
257268
}
258269

259270

260-
def build_main_include_cloud(engine_version_list):
271+
def build_main_include_default(engine_version_list):
261272
return {
262273
E2EJob(engine_version_list.latest, POSTGRES.latest, "pg"),
263274
}
264275

265276

266-
def build_schedule_include_cloud(engine_version_list):
277+
def build_schedule_include_default(engine_version_list):
267278
"""Build the list of tests running on schedule"""
268279
result = set()
269280
# Iterate over K8S versions
@@ -276,45 +287,53 @@ def build_schedule_include_cloud(engine_version_list):
276287

277288

278289
ENGINE_MODES = {
279-
"local": {
280-
"push": build_push_include_local,
281-
"pull_request": build_pull_request_include_local,
282-
"issue_comment": build_pull_request_include_local,
283-
"workflow_dispatch": build_pull_request_include_local,
284-
"main": build_main_include_local,
285-
"schedule": build_schedule_include_local,
290+
"kind": {
291+
"push": build_push_include_kind,
292+
"pull_request": build_pull_request_include_kind,
293+
"issue_comment": build_pull_request_include_kind,
294+
"workflow_dispatch": build_pull_request_include_kind,
295+
"main": build_main_include_kind,
296+
"schedule": build_schedule_include_kind,
297+
},
298+
"k3d": {
299+
"push": lambda: build_push_include_default(K3D_K8S),
300+
"pull_request": lambda: build_pull_request_include_default(K3D_K8S),
301+
"issue_comment": lambda: build_pull_request_include_default(K3D_K8S),
302+
"workflow_dispatch": lambda: build_pull_request_include_default(K3D_K8S),
303+
"main": lambda: build_main_include_default(K3D_K8S),
304+
"schedule": lambda: build_schedule_include_default(K3D_K8S),
286305
},
287306
"eks": {
288-
"push": lambda: build_push_include_cloud(EKS_K8S),
289-
"pull_request": lambda: build_pull_request_include_cloud(EKS_K8S),
290-
"issue_comment": lambda: build_pull_request_include_cloud(EKS_K8S),
291-
"workflow_dispatch": lambda: build_pull_request_include_cloud(EKS_K8S),
292-
"main": lambda: build_main_include_cloud(EKS_K8S),
293-
"schedule": lambda: build_schedule_include_cloud(EKS_K8S),
307+
"push": lambda: build_push_include_default(EKS_K8S),
308+
"pull_request": lambda: build_pull_request_include_default(EKS_K8S),
309+
"issue_comment": lambda: build_pull_request_include_default(EKS_K8S),
310+
"workflow_dispatch": lambda: build_pull_request_include_default(EKS_K8S),
311+
"main": lambda: build_main_include_default(EKS_K8S),
312+
"schedule": lambda: build_schedule_include_default(EKS_K8S),
294313
},
295314
"aks": {
296-
"push": lambda: build_push_include_cloud(AKS_K8S),
297-
"pull_request": lambda: build_pull_request_include_cloud(AKS_K8S),
298-
"issue_comment": lambda: build_pull_request_include_cloud(AKS_K8S),
299-
"workflow_dispatch": lambda: build_pull_request_include_cloud(AKS_K8S),
300-
"main": lambda: build_main_include_cloud(AKS_K8S),
301-
"schedule": lambda: build_schedule_include_cloud(AKS_K8S),
315+
"push": lambda: build_push_include_default(AKS_K8S),
316+
"pull_request": lambda: build_pull_request_include_default(AKS_K8S),
317+
"issue_comment": lambda: build_pull_request_include_default(AKS_K8S),
318+
"workflow_dispatch": lambda: build_pull_request_include_default(AKS_K8S),
319+
"main": lambda: build_main_include_default(AKS_K8S),
320+
"schedule": lambda: build_schedule_include_default(AKS_K8S),
302321
},
303322
"gke": {
304-
"push": lambda: build_push_include_cloud(GKE_K8S),
305-
"pull_request": lambda: build_pull_request_include_cloud(GKE_K8S),
306-
"issue_comment": lambda: build_pull_request_include_cloud(GKE_K8S),
307-
"workflow_dispatch": lambda: build_pull_request_include_cloud(GKE_K8S),
308-
"main": lambda: build_main_include_cloud(GKE_K8S),
309-
"schedule": lambda: build_schedule_include_cloud(GKE_K8S),
323+
"push": lambda: build_push_include_default(GKE_K8S),
324+
"pull_request": lambda: build_pull_request_include_default(GKE_K8S),
325+
"issue_comment": lambda: build_pull_request_include_default(GKE_K8S),
326+
"workflow_dispatch": lambda: build_pull_request_include_default(GKE_K8S),
327+
"main": lambda: build_main_include_default(GKE_K8S),
328+
"schedule": lambda: build_schedule_include_default(GKE_K8S),
310329
},
311330
"openshift": {
312-
"push": lambda: build_push_include_cloud(OPENSHIFT_K8S),
313-
"pull_request": lambda: build_pull_request_include_cloud(OPENSHIFT_K8S),
314-
"issue_comment": lambda: build_pull_request_include_cloud(OPENSHIFT_K8S),
315-
"workflow_dispatch": lambda: build_pull_request_include_cloud(OPENSHIFT_K8S),
316-
"main": lambda: build_main_include_cloud(OPENSHIFT_K8S),
317-
"schedule": lambda: build_schedule_include_cloud(OPENSHIFT_K8S),
331+
"push": lambda: build_push_include_default(OPENSHIFT_K8S),
332+
"pull_request": lambda: build_pull_request_include_default(OPENSHIFT_K8S),
333+
"issue_comment": lambda: build_pull_request_include_default(OPENSHIFT_K8S),
334+
"workflow_dispatch": lambda: build_pull_request_include_default(OPENSHIFT_K8S),
335+
"main": lambda: build_main_include_default(OPENSHIFT_K8S),
336+
"schedule": lambda: build_schedule_include_default(OPENSHIFT_K8S),
318337
},
319338
}
320339

.github/e2e_test_timeout.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
{
2-
"local": {
2+
"kind": {
3+
"failover": 240,
4+
"namespaceCreation": 30,
5+
"clusterIsReady": 600,
6+
"clusterIsReadyQuick": 300,
7+
"clusterIsReadySlow": 800,
8+
"newPrimaryAfterSwitchover": 45,
9+
"newPrimaryAfterFailover": 30,
10+
"newTargetOnFailover": 120,
11+
"operatorIsReady": 120,
12+
"largeObject": 300,
13+
"walsInMinio": 60,
14+
"minioInstallation": 300,
15+
"backupIsReady": 180,
16+
"drainNode": 900,
17+
"short": 5
18+
},
19+
"k3d": {
320
"failover": 240,
421
"namespaceCreation": 30,
522
"clusterIsReady": 600,

.github/k3d_versions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[
2+
"v1.35.0",
3+
"v1.34.3",
4+
"v1.33.7"
5+
]

.github/k8s_versions_scope.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"e2e_test": {
33
"KIND": {"min": "1.29", "max": ""},
4+
"K3D": {"min": "1.29", "max": ""},
45
"AKS": {"min": "1.29", "max": ""},
56
"EKS": {"min": "1.29", "max": ""},
67
"GKE": {"min": "1.29", "max": ""},

0 commit comments

Comments
 (0)