Skip to content

Commit fa6dadd

Browse files
Update e2e test to patch topologySpreadConstraints into the postgresqls manifest.
1 parent bb676f5 commit fa6dadd

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

e2e/tests/test_e2e.py

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2410,9 +2410,23 @@ def test_topology_spread_constraints(self):
24102410
k8s.api.core_v1.patch_node(master_nodes[0], patch_node_label)
24112411
k8s.api.core_v1.patch_node(replica_nodes[0], patch_node_label)
24122412

2413-
# Scale-out postgresql pods
2414-
k8s.api.custom_objects_api.patch_namespaced_custom_object("acid.zalan.do", "v1", "default", "postgresqls", "acid-minimal-cluster",
2415-
{"spec": {"numberOfInstances": 6}})
2413+
# Patch topologySpreadConstraint and scale-out postgresql pods to postgresqls manifest.
2414+
patch_topologySpreadConstraint_config = {
2415+
"spec": {
2416+
"numberOfInstances": 6,
2417+
"topologySpreadConstraint": [
2418+
{
2419+
"maxskew": 1,
2420+
"topologyKey": "topology.kubernetes.io/zone",
2421+
"whenUnsatisfiable": "DoNotSchedule"
2422+
}
2423+
]
2424+
}
2425+
}
2426+
k8s.api.custom_objects_api.patch_namespaced_custom_object(
2427+
"acid.zalan.do", "v1", "default",
2428+
"postgresqls", "acid-minimal-cluster",
2429+
patch_topologySpreadConstraint_config)
24162430
self.eventuallyEqual(lambda: k8s.get_operator_state(), {"0": "idle"}, "Operator does not get in sync")
24172431
self.eventuallyEqual(lambda: k8s.count_pods_with_label(cluster_labels), 6, "Postgresql StatefulSet are scale to 6")
24182432
self.eventuallyEqual(lambda: k8s.count_running_pods(), 6, "All pods are running")
@@ -2430,9 +2444,17 @@ def test_topology_spread_constraints(self):
24302444
self.assertEqual(worker_node_1, 3)
24312445
self.assertEqual(worker_node_2, 3)
24322446

2433-
# Scale-it postgresql pods to previous replicas
2434-
k8s.api.custom_objects_api.patch_namespaced_custom_object("acid.zalan.do", "v1", "default", "postgresqls", "acid-minimal-cluster",
2435-
{"spec": {"numberOfInstances": 2}})
2447+
# Reset configurations
2448+
patch_topologySpreadConstraint_config = {
2449+
"spec": {
2450+
"numberOfInstances": 2,
2451+
"topologySpreadConstraint": []
2452+
}
2453+
}
2454+
k8s.api.custom_objects_api.patch_namespaced_custom_object(
2455+
"acid.zalan.do", "v1", "default",
2456+
"postgresqls", "acid-minimal-cluster",
2457+
patch_topologySpreadConstraint_config)
24362458

24372459
@timeout_decorator.timeout(TEST_TIMEOUT_SEC)
24382460
def test_zz_cluster_deletion(self):

0 commit comments

Comments
 (0)