@@ -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"
@@ -500,14 +509,22 @@ def compare_config():
500509 self .eventuallyEqual (lambda : self .query_database (replica .metadata .name , "postgres" , setting_query )[0 ], lower_max_connections_value ,
501510 "Previous max_connections setting not applied on replica" , 10 , 5 )
502511
503- # delete test_slot_2 from config
512+ # patch new slot via Patroni REST
513+ 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 )
516+
517+ # delete test_slot_2 from config and change the plugin type for test_slot
504518 slot_to_remove = "test_slot_2"
519+ slot_to_change = "test_slot"
505520 pg_patch_slots = {
506521 "spec" : {
507522 "patroni" : {
508523 "slots" : {
509524 "test_slot" : {
510- "type" : "physical"
525+ "type" : "logical" ,
526+ "database" : "foo" ,
527+ "plugin" : "wal2json"
511528 }
512529 }
513530 }
@@ -526,7 +543,26 @@ def compare_config():
526543 """ % (slot_to_remove )
527544
528545 self .eventuallyEqual (lambda : len (self .query_database (replica .metadata .name , "postgres" , deleted_slot_query )), 0 ,
529- "The replication slot cannot be deleted" , 10 , 5 )
546+ "The replication slot cannot be deleted" , 10 , 5 )
547+
548+ changed_slot_query = """
549+ SELECT plugin
550+ FROM pg_replication_slots
551+ WHERE slot_name = '%s';
552+ """ % (slot_to_change )
553+
554+ self .eventuallyEqual (lambda : self .query_database (replica .metadata .name , "postgres" , changed_slot_query )[0 ], "wal2json" ,
555+ "The replication slot cannot be updated" , 10 , 5 )
556+
557+ # make sure slot from Patroni didn't get deleted
558+ patroni_slot_query = """
559+ SELECT slot_name
560+ FROM pg_replication_slots
561+ WHERE slot_name = '%s';
562+ """ % (patroni_slot )
563+
564+ self .eventuallyEqual (lambda : len (self .query_database (replica .metadata .name , "postgres" , patroni_slot_query )), 1 ,
565+ "The replication slot from Patroni gets deleted" , 10 , 5 )
530566
531567 except timeout_decorator .TimeoutError :
532568 print ('Operator log: {}' .format (k8s .get_operator_log ()))
0 commit comments