Skip to content

Commit 8c0c0ca

Browse files
committed
use leader instead replica to query slots
1 parent 86dfc8c commit 8c0c0ca

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

e2e/tests/test_e2e.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -511,12 +511,15 @@ def compare_config():
511511

512512
# patch new slot via Patroni REST
513513
patroni_slot = "test_patroni_slot"
514-
patch_slot_command = """curl -s -XPATCH -d '{"slots": {"test_patroni_slot": {"type": "physical"}}}' http://localhost:8008/config"""
515-
k8s.exec_with_kubectl(replica.metadata.name, patch_slot_command)
514+
patch_slot_command = """curl -s -XPATCH -d '{"slots": {"test_patroni_slot": {"type": "physical"}}}' localhost:8008/config"""
515+
k8s.exec_with_kubectl(leader.metadata.name, patch_slot_command)
516+
517+
self.eventuallyEqual(lambda: k8s.get_operator_state(), {"0": "idle"}, "Operator does not get in sync")
518+
self.eventuallyTrue(compare_config, "Postgres config not applied")
516519

517520
# delete test_slot_2 from config and change the plugin type for test_slot
518-
slot_to_remove = "test_slot_2"
519521
slot_to_change = "test_slot"
522+
slot_to_remove = "test_slot_2"
520523
pg_patch_slots = {
521524
"spec": {
522525
"patroni": {
@@ -535,14 +538,15 @@ def compare_config():
535538
"acid.zalan.do", "v1", "default", "postgresqls", "acid-minimal-cluster", pg_patch_slots)
536539

537540
self.eventuallyEqual(lambda: k8s.get_operator_state(), {"0": "idle"}, "Operator does not get in sync")
541+
self.eventuallyTrue(compare_config, "Postgres config not applied")
538542

539543
deleted_slot_query = """
540544
SELECT slot_name
541545
FROM pg_replication_slots
542546
WHERE slot_name = '%s';
543547
""" % (slot_to_remove)
544-
545-
self.eventuallyEqual(lambda: len(self.query_database(replica.metadata.name, "postgres", deleted_slot_query)), 0,
548+
549+
self.eventuallyEqual(lambda: len(self.query_database(leader.metadata.name, "postgres", deleted_slot_query)), 0,
546550
"The replication slot cannot be deleted", 10, 5)
547551

548552
changed_slot_query = """
@@ -551,7 +555,7 @@ def compare_config():
551555
WHERE slot_name = '%s';
552556
""" % (slot_to_change)
553557

554-
self.eventuallyEqual(lambda: self.query_database(replica.metadata.name, "postgres", changed_slot_query)[0], "wal2json",
558+
self.eventuallyEqual(lambda: self.query_database(leader.metadata.name, "postgres", changed_slot_query)[0], "wal2json",
555559
"The replication slot cannot be updated", 10, 5)
556560

557561
# make sure slot from Patroni didn't get deleted
@@ -561,7 +565,7 @@ def compare_config():
561565
WHERE slot_name = '%s';
562566
""" % (patroni_slot)
563567

564-
self.eventuallyEqual(lambda: len(self.query_database(replica.metadata.name, "postgres", patroni_slot_query)), 1,
568+
self.eventuallyEqual(lambda: len(self.query_database(leader.metadata.name, "postgres", patroni_slot_query)), 1,
565569
"The replication slot from Patroni gets deleted", 10, 5)
566570

567571
except timeout_decorator.TimeoutError:

0 commit comments

Comments
 (0)