@@ -1187,7 +1187,7 @@ def test_major_version_upgrade(self):
11871187 Test major version upgrade: with full upgrade, maintenance window, and annotation
11881188 """
11891189 def check_version ():
1190- p = k8s .patroni_rest ("acid-upgrade-test-0" , "" )
1190+ p = k8s .patroni_rest ("acid-upgrade-test-0" , "" ) or {}
11911191 version = p .get ("server_version" , 0 ) // 10000
11921192 return version
11931193
@@ -1237,7 +1237,7 @@ def get_annotations():
12371237 # should not upgrade because current time is not in maintenanceWindow
12381238 current_time = datetime .now ()
12391239 maintenance_window_future = f"{ (current_time + timedelta (minutes = 60 )).strftime ('%H:%M' )} -{ (current_time + timedelta (minutes = 120 )).strftime ('%H:%M' )} "
1240- pg_patch_version_15 = {
1240+ pg_patch_version_15_outside_mw = {
12411241 "spec" : {
12421242 "postgresql" : {
12431243 "version" : "15"
@@ -1248,7 +1248,7 @@ def get_annotations():
12481248 }
12491249 }
12501250 k8s .api .custom_objects_api .patch_namespaced_custom_object (
1251- "acid.zalan.do" , "v1" , "default" , "postgresqls" , "acid-upgrade-test" , pg_patch_version_15 )
1251+ "acid.zalan.do" , "v1" , "default" , "postgresqls" , "acid-upgrade-test" , pg_patch_version_15_outside_mw )
12521252 self .eventuallyEqual (lambda : k8s .get_operator_state (), {"0" : "idle" }, "Operator does not get in sync" )
12531253
12541254 # no pod replacement outside of the maintenance window
@@ -1259,12 +1259,12 @@ def get_annotations():
12591259 second_annotations = get_annotations ()
12601260 self .assertIsNone (second_annotations .get ("last-major-upgrade-failure" ), "Annotation for last upgrade's failure should not be set" )
12611261
1262- # change the version again to trigger operator sync
1262+ # change maintenanceWindows to current
12631263 maintenance_window_current = f"{ (current_time - timedelta (minutes = 30 )).strftime ('%H:%M' )} -{ (current_time + timedelta (minutes = 30 )).strftime ('%H:%M' )} "
1264- pg_patch_version_16 = {
1264+ pg_patch_version_15_in_mw = {
12651265 "spec" : {
12661266 "postgresql" : {
1267- "version" : "16 "
1267+ "version" : "15 "
12681268 },
12691269 "maintenanceWindows" : [
12701270 maintenance_window_current
@@ -1273,13 +1273,13 @@ def get_annotations():
12731273 }
12741274
12751275 k8s .api .custom_objects_api .patch_namespaced_custom_object (
1276- "acid.zalan.do" , "v1" , "default" , "postgresqls" , "acid-upgrade-test" , pg_patch_version_16 )
1276+ "acid.zalan.do" , "v1" , "default" , "postgresqls" , "acid-upgrade-test" , pg_patch_version_15_in_mw )
12771277 self .eventuallyEqual (lambda : k8s .get_operator_state (), {"0" : "idle" }, "Operator does not get in sync" )
12781278
12791279 k8s .wait_for_pod_failover (master_nodes , 'spilo-role=master,' + cluster_label )
12801280 k8s .wait_for_pod_start ('spilo-role=master,' + cluster_label )
12811281 k8s .wait_for_pod_start ('spilo-role=replica,' + cluster_label )
1282- self .eventuallyEqual (check_version , 16 , "Version should be upgraded from 14 to 16 " )
1282+ self .eventuallyEqual (check_version , 15 , "Version should be upgraded from 14 to 15 " )
12831283
12841284 # check if annotation for last upgrade's success is updated after second upgrade
12851285 third_annotations = get_annotations ()
@@ -1306,16 +1306,17 @@ def get_annotations():
13061306 k8s .wait_for_pod_failover (master_nodes , 'spilo-role=replica,' + cluster_label )
13071307 k8s .wait_for_pod_start ('spilo-role=master,' + cluster_label )
13081308 k8s .wait_for_pod_start ('spilo-role=replica,' + cluster_label )
1309- self .eventuallyEqual (check_version , 16 , "Version should not be upgraded because annotation for last upgrade's failure is set" )
1309+ self .eventuallyEqual (check_version , 15 , "Version should not be upgraded because annotation for last upgrade's failure is set" )
13101310
13111311 # change the version back to 15 and should remove failure annotation
13121312 k8s .api .custom_objects_api .patch_namespaced_custom_object (
1313- "acid.zalan.do" , "v1" , "default" , "postgresqls" , "acid-upgrade-test" , pg_patch_version_15 )
1313+ "acid.zalan.do" , "v1" , "default" , "postgresqls" , "acid-upgrade-test" , pg_patch_version_15_in_mw )
13141314 self .eventuallyEqual (lambda : k8s .get_operator_state (), {"0" : "idle" }, "Operator does not get in sync" )
13151315
13161316 k8s .wait_for_pod_start ('spilo-role=master,' + cluster_label )
13171317 k8s .wait_for_pod_start ('spilo-role=replica,' + cluster_label )
13181318
1319+ self .eventuallyEqual (check_version , 15 , "Version should not be upgraded from 15" )
13191320 fourth_annotations = get_annotations ()
13201321 self .assertIsNone (fourth_annotations .get ("last-major-upgrade-failure" ), "Annotation for last upgrade's failure is not removed" )
13211322
0 commit comments