@@ -1752,9 +1752,13 @@ def test_password_rotation(self):
1752
1752
Test password rotation and removal of users due to retention policy
1753
1753
'''
1754
1754
k8s = self .k8s
1755
+ cluster_label = 'application=spilo,cluster-name=acid-minimal-cluster'
1755
1756
leader = k8s .get_cluster_leader_pod ()
1756
1757
today = date .today ()
1757
1758
1759
+ # remember number of secrets to make sure it stays the same
1760
+ secret_count = k8s .count_secrets_with_label (cluster_label )
1761
+
1758
1762
# enable password rotation for owner of foo database
1759
1763
pg_patch_rotation_single_users = {
1760
1764
"spec" : {
@@ -1859,10 +1863,24 @@ def test_password_rotation(self):
1859
1863
# check if rotation has been ignored for user from test_cross_namespace_secrets test
1860
1864
db_user_secret = k8s .get_secret (username = "test.db_user" , namespace = "test" )
1861
1865
secret_username = str (base64 .b64decode (db_user_secret .data ["username" ]), 'utf-8' )
1862
-
1863
1866
self .assertEqual ("test.db_user" , secret_username ,
1864
1867
"Unexpected username in secret of test.db_user: expected {}, got {}" .format ("test.db_user" , secret_username ))
1865
1868
1869
+ # do a cluster update which syncs secrets but not not init users
1870
+ pg_annotation_patch = {
1871
+ "metadata" : {
1872
+ "annotations" : {
1873
+ "deployment-time" : "2020-04-01 12:00:00" ,
1874
+ }
1875
+ }
1876
+ }
1877
+ k8s .api .custom_objects_api .patch_namespaced_custom_object (
1878
+ "acid.zalan.do" , "v1" , "default" , "postgresqls" , "acid-minimal-cluster" , pg_annotation_patch )
1879
+ self .eventuallyEqual (lambda : k8s .get_operator_state (), {"0" : "idle" }, "Operator does not get in sync" )
1880
+
1881
+ time .sleep (10 )
1882
+ self .eventuallyEqual (lambda : k8s .count_secrets_with_label (cluster_label ), secret_count , "Unexpected number of secrets" )
1883
+
1866
1884
# disable password rotation for all other users (foo_user)
1867
1885
# and pick smaller intervals to see if the third fake rotation user is dropped
1868
1886
enable_password_rotation = {
0 commit comments