Skip to content

Commit 2057ad8

Browse files
authored
reorder e2e tests to follow alphabetical sorting (zalando#1567)
* reorder e2e tests to follow alphabetical sorting * e2e: finish waiting for pod failover only if all pods were replaced * wait for sync in rolling update timeout test
1 parent 58bab07 commit 2057ad8

File tree

5 files changed

+635
-605
lines changed

5 files changed

+635
-605
lines changed

charts/postgres-operator/crds/postgresqls.yaml

Lines changed: 91 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,97 @@ spec:
223223
items:
224224
type: string
225225
pattern: '^\ *((Mon|Tue|Wed|Thu|Fri|Sat|Sun):(2[0-3]|[01]?\d):([0-5]?\d)|(2[0-3]|[01]?\d):([0-5]?\d))-((Mon|Tue|Wed|Thu|Fri|Sat|Sun):(2[0-3]|[01]?\d):([0-5]?\d)|(2[0-3]|[01]?\d):([0-5]?\d))\ *$'
226+
nodeAffinity:
227+
type: object
228+
properties:
229+
preferredDuringSchedulingIgnoredDuringExecution:
230+
type: array
231+
items:
232+
type: object
233+
required:
234+
- weight
235+
- preference
236+
properties:
237+
preference:
238+
type: object
239+
properties:
240+
matchExpressions:
241+
type: array
242+
items:
243+
type: object
244+
required:
245+
- key
246+
- operator
247+
properties:
248+
key:
249+
type: string
250+
operator:
251+
type: string
252+
values:
253+
type: array
254+
items:
255+
type: string
256+
matchFields:
257+
type: array
258+
items:
259+
type: object
260+
required:
261+
- key
262+
- operator
263+
properties:
264+
key:
265+
type: string
266+
operator:
267+
type: string
268+
values:
269+
type: array
270+
items:
271+
type: string
272+
weight:
273+
format: int32
274+
type: integer
275+
requiredDuringSchedulingIgnoredDuringExecution:
276+
type: object
277+
required:
278+
- nodeSelectorTerms
279+
properties:
280+
nodeSelectorTerms:
281+
type: array
282+
items:
283+
type: object
284+
properties:
285+
matchExpressions:
286+
type: array
287+
items:
288+
type: object
289+
required:
290+
- key
291+
- operator
292+
properties:
293+
key:
294+
type: string
295+
operator:
296+
type: string
297+
values:
298+
type: array
299+
items:
300+
type: string
301+
matchFields:
302+
type: array
303+
items:
304+
type: object
305+
required:
306+
- key
307+
- operator
308+
properties:
309+
key:
310+
type: string
311+
operator:
312+
type: string
313+
values:
314+
type: array
315+
items:
316+
type: string
226317
numberOfInstances:
227318
type: integer
228319
minimum: 0
@@ -396,97 +487,6 @@ spec:
396487
type: string
397488
caSecretName:
398489
type: string
399-
nodeAffinity:
400-
type: object
401-
properties:
402-
preferredDuringSchedulingIgnoredDuringExecution:
403-
type: array
404-
items:
405-
type: object
406-
required:
407-
- weight
408-
- preference
409-
properties:
410-
preference:
411-
type: object
412-
properties:
413-
matchExpressions:
414-
type: array
415-
items:
416-
type: object
417-
required:
418-
- key
419-
- operator
420-
properties:
421-
key:
422-
type: string
423-
operator:
424-
type: string
425-
values:
426-
type: array
427-
items:
428-
type: string
429-
matchFields:
430-
type: array
431-
items:
432-
type: object
433-
required:
434-
- key
435-
- operator
436-
properties:
437-
key:
438-
type: string
439-
operator:
440-
type: string
441-
values:
442-
type: array
443-
items:
444-
type: string
445-
weight:
446-
format: int32
447-
type: integer
448-
requiredDuringSchedulingIgnoredDuringExecution:
449-
type: object
450-
required:
451-
- nodeSelectorTerms
452-
properties:
453-
nodeSelectorTerms:
454-
type: array
455-
items:
456-
type: object
457-
properties:
458-
matchExpressions:
459-
type: array
460-
items:
461-
type: object
462-
required:
463-
- key
464-
- operator
465-
properties:
466-
key:
467-
type: string
468-
operator:
469-
type: string
470-
values:
471-
type: array
472-
items:
473-
type: string
474-
matchFields:
475-
type: array
476-
items:
477-
type: object
478-
required:
479-
- key
480-
- operator
481-
properties:
482-
key:
483-
type: string
484-
operator:
485-
type: string
486-
values:
487-
type: array
488-
items:
489-
type: string
490490
tolerations:
491491
type: array
492492
items:

e2e/tests/k8s_api.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ def get_services():
156156
while not get_services():
157157
time.sleep(self.RETRY_TIMEOUT_SEC)
158158

159+
def count_pods_with_rolling_update_flag(self, labels, namespace='default'):
160+
pods = self.api.core_v1.list_namespaced_pod(namespace, label_selector=labels).items
161+
return len(list(filter(lambda x: "zalando-postgres-operator-rolling-update-required" in x.metadata.annotations, pods)))
162+
159163
def count_pods_with_label(self, labels, namespace='default'):
160164
return len(self.api.core_v1.list_namespaced_pod(namespace, label_selector=labels).items)
161165

@@ -189,13 +193,18 @@ def count_pods_with_container_capabilities(self, capabilities, labels, namespace
189193
def wait_for_pod_failover(self, failover_targets, labels, namespace='default'):
190194
pod_phase = 'Failing over'
191195
new_pod_node = ''
196+
pods_with_update_flag = self.count_pods_with_rolling_update_flag(labels, namespace)
192197

193198
while (pod_phase != 'Running') or (new_pod_node not in failover_targets):
194199
pods = self.api.core_v1.list_namespaced_pod(namespace, label_selector=labels).items
195200
if pods:
196201
new_pod_node = pods[0].spec.node_name
197202
pod_phase = pods[0].status.phase
198203
time.sleep(self.RETRY_TIMEOUT_SEC)
204+
205+
while pods_with_update_flag != 0:
206+
pods_with_update_flag = self.count_pods_with_rolling_update_flag(labels, namespace)
207+
time.sleep(self.RETRY_TIMEOUT_SEC)
199208

200209
def wait_for_namespace_creation(self, namespace='default'):
201210
ns_found = False
@@ -423,6 +432,10 @@ def get_services():
423432
while not get_services():
424433
time.sleep(self.RETRY_TIMEOUT_SEC)
425434

435+
def count_pods_with_rolling_update_flag(self, labels, namespace='default'):
436+
pods = self.api.core_v1.list_namespaced_pod(namespace, label_selector=labels).items
437+
return len(list(filter(lambda x: "zalando-postgres-operator-rolling-update-required" in x.metadata.annotations, pods)))
438+
426439
def count_pods_with_label(self, labels, namespace='default'):
427440
return len(self.api.core_v1.list_namespaced_pod(namespace, label_selector=labels).items)
428441

@@ -456,6 +469,7 @@ def count_pods_with_container_capabilities(self, capabilities, labels, namespace
456469
def wait_for_pod_failover(self, failover_targets, labels, namespace='default'):
457470
pod_phase = 'Failing over'
458471
new_pod_node = ''
472+
pods_with_update_flag = self.count_pods_with_rolling_update_flag(labels, namespace)
459473

460474
while (pod_phase != 'Running') or (new_pod_node not in failover_targets):
461475
pods = self.api.core_v1.list_namespaced_pod(namespace, label_selector=labels).items
@@ -464,6 +478,10 @@ def wait_for_pod_failover(self, failover_targets, labels, namespace='default'):
464478
pod_phase = pods[0].status.phase
465479
time.sleep(self.RETRY_TIMEOUT_SEC)
466480

481+
while pods_with_update_flag != 0:
482+
pods_with_update_flag = self.count_pods_with_rolling_update_flag(labels, namespace)
483+
time.sleep(self.RETRY_TIMEOUT_SEC)
484+
467485
def get_logical_backup_job(self, namespace='default'):
468486
return self.api.batch_v1_beta1.list_namespaced_cron_job(namespace, label_selector="application=spilo")
469487

0 commit comments

Comments
 (0)