@@ -1752,9 +1752,13 @@ def test_password_rotation(self):
17521752 Test password rotation and removal of users due to retention policy
17531753 '''
17541754 k8s = self .k8s
1755+ cluster_label = 'application=spilo,cluster-name=acid-minimal-cluster'
17551756 leader = k8s .get_cluster_leader_pod ()
17561757 today = date .today ()
17571758
1759+ # remember number of secrets to make sure it stays the same
1760+ secret_count = k8s .count_secrets_with_label (cluster_label )
1761+
17581762 # enable password rotation for owner of foo database
17591763 pg_patch_rotation_single_users = {
17601764 "spec" : {
@@ -1810,6 +1814,7 @@ def test_password_rotation(self):
18101814 enable_password_rotation = {
18111815 "data" : {
18121816 "enable_password_rotation" : "true" ,
1817+ "inherited_annotations" : "environment" ,
18131818 "password_rotation_interval" : "30" ,
18141819 "password_rotation_user_retention" : "30" , # should be set to 60
18151820 },
@@ -1856,13 +1861,29 @@ def test_password_rotation(self):
18561861 self .eventuallyEqual (lambda : len (self .query_database_with_user (leader .metadata .name , "postgres" , "SELECT 1" , "foo_user" )), 1 ,
18571862 "Could not connect to the database with rotation user {}" .format (rotation_user ), 10 , 5 )
18581863
1864+ # add annotation which triggers syncSecrets call
1865+ pg_annotation_patch = {
1866+ "metadata" : {
1867+ "annotations" : {
1868+ "environment" : "test" ,
1869+ }
1870+ }
1871+ }
1872+ k8s .api .custom_objects_api .patch_namespaced_custom_object (
1873+ "acid.zalan.do" , "v1" , "default" , "postgresqls" , "acid-minimal-cluster" , pg_annotation_patch )
1874+ self .eventuallyEqual (lambda : k8s .get_operator_state (), {"0" : "idle" }, "Operator does not get in sync" )
1875+ time .sleep (10 )
1876+ self .eventuallyEqual (lambda : k8s .count_secrets_with_label (cluster_label ), secret_count , "Unexpected number of secrets" )
1877+
18591878 # check if rotation has been ignored for user from test_cross_namespace_secrets test
18601879 db_user_secret = k8s .get_secret (username = "test.db_user" , namespace = "test" )
18611880 secret_username = str (base64 .b64decode (db_user_secret .data ["username" ]), 'utf-8' )
1862-
18631881 self .assertEqual ("test.db_user" , secret_username ,
18641882 "Unexpected username in secret of test.db_user: expected {}, got {}" .format ("test.db_user" , secret_username ))
18651883
1884+ # check if annotation for secret has been updated
1885+ self .assertTrue ("environment" in db_user_secret .metadata .annotations , "Added annotation was not propagated to secret" )
1886+
18661887 # disable password rotation for all other users (foo_user)
18671888 # and pick smaller intervals to see if the third fake rotation user is dropped
18681889 enable_password_rotation = {
@@ -2100,7 +2121,7 @@ def test_statefulset_annotation_propagation(self):
21002121 patch_sset_propagate_annotations = {
21012122 "data" : {
21022123 "downscaler_annotations" : "deployment-time,downscaler/*" ,
2103- "inherited_annotations" : "owned-by" ,
2124+ "inherited_annotations" : "environment, owned-by" ,
21042125 }
21052126 }
21062127 k8s .update_config (patch_sset_propagate_annotations )
0 commit comments