@@ -395,13 +395,22 @@ def test_config_update(self):
395395 "spec" : {
396396 "postgresql" : {
397397 "parameters" : {
398- "max_connections" : new_max_connections_value
398+ "max_connections" : new_max_connections_value ,
399+ "wal_level" : "logical"
399400 }
400401 },
401- "patroni" : {
402+ "users" : {
403+ "test_user" : []
404+ },
405+ "databases" : {
406+ "foo" : "test_user"
407+ },
408+ "patroni" : {
402409 "slots" : {
403410 "test_slot" : {
404- "type" : "physical"
411+ "type" : "logical" ,
412+ "database" : "foo" ,
413+ "plugin" : "pgoutput"
405414 },
406415 "test_slot_2" : {
407416 "type" : "physical"
@@ -497,14 +506,22 @@ def compare_config():
497506 self .eventuallyEqual (lambda : self .query_database (replica .metadata .name , "postgres" , setting_query )[0 ], lower_max_connections_value ,
498507 "Previous max_connections setting not applied on replica" , 10 , 5 )
499508
500- # delete test_slot_2 from config
509+ # patch new slot via Patroni REST
510+ patroni_slot = "test_patroni_slot"
511+ patch_slot_command = """curl -s -XPATCH -d '{"slots": {"test_patroni_slot": {"type": "physical"}}}' http://localhost:8008/config"""
512+ k8s .exec_with_kubectl (replica .metadata .name , patch_slot_command )
513+
514+ # delete test_slot_2 from config and change the plugin type for test_slot
501515 slot_to_remove = "test_slot_2"
516+ slot_to_change = "test_slot"
502517 pg_patch_slots = {
503518 "spec" : {
504519 "patroni" : {
505520 "slots" : {
506521 "test_slot" : {
507- "type" : "physical"
522+ "type" : "logical" ,
523+ "database" : "foo" ,
524+ "plugin" : "wal2json"
508525 }
509526 }
510527 }
@@ -523,7 +540,26 @@ def compare_config():
523540 """ % (slot_to_remove )
524541
525542 self .eventuallyEqual (lambda : len (self .query_database (replica .metadata .name , "postgres" , deleted_slot_query )), 0 ,
526- "The replication slot cannot be deleted" , 10 , 5 )
543+ "The replication slot cannot be deleted" , 10 , 5 )
544+
545+ changed_slot_query = """
546+ SELECT plugin
547+ FROM pg_replication_slots
548+ WHERE slot_name = '%s';
549+ """ % (slot_to_change )
550+
551+ self .eventuallyEqual (lambda : self .query_database (replica .metadata .name , "postgres" , changed_slot_query )[0 ], "wal2json" ,
552+ "The replication slot cannot be updated" , 10 , 5 )
553+
554+ # make sure slot from Patroni didn't get deleted
555+ patroni_slot_query = """
556+ SELECT slot_name
557+ FROM pg_replication_slots
558+ WHERE slot_name = '%s';
559+ """ % (patroni_slot )
560+
561+ self .eventuallyEqual (lambda : len (self .query_database (replica .metadata .name , "postgres" , patroni_slot_query )), 1 ,
562+ "The replication slot from Patroni gets deleted" , 10 , 5 )
527563
528564 except timeout_decorator .TimeoutError :
529565 print ('Operator log: {}' .format (k8s .get_operator_log ()))
0 commit comments