@@ -133,10 +133,10 @@ void givenAnUpdateWithPatroniInitialConfigWithCallbacksChanged_shouldPass() thro
133133 final StackGresClusterReview review = getUpdateReview ();
134134 review .getRequest ().getOldObject ().getSpec ().getConfigurations ()
135135 .getPatroni ().getInitialConfig ().put (
136- "postgresql" , Map .of ("callbacks" , Map .of ("on_role_change" , "sh -c 'echo \" on_role_change: $* \" ' " )));
136+ "postgresql" , Map .of ("callbacks" , Map .of ("on_role_change" , "/usr/local/bin/ on_role_change" )));
137137 review .getRequest ().getObject ().getSpec ().getConfigurations ()
138138 .getPatroni ().getInitialConfig ().put (
139- "postgresql" , Map .of ("callbacks" , Map .of ("on_start" , "sh -c 'echo \" on_start: $* \" ' " )));
139+ "postgresql" , Map .of ("callbacks" , Map .of ("on_start" , "/usr/local/bin/ on_start" )));
140140
141141 validator .validate (review );
142142 }
@@ -146,7 +146,7 @@ void givenAnUpdateWithPatroniInitialConfigWithCallbacksAdded_shouldPass() throws
146146 final StackGresClusterReview review = getUpdateReview ();
147147 review .getRequest ().getObject ().getSpec ().getConfigurations ()
148148 .getPatroni ().getInitialConfig ().put (
149- "postgresql" , Map .of ("callbacks" , Map .of ("on_start" , "sh -c 'echo \" on_start: $* \" ' " )));
149+ "postgresql" , Map .of ("callbacks" , Map .of ("on_start" , "/usr/local/bin/ on_start" )));
150150
151151 validator .validate (review );
152152 }
@@ -159,7 +159,7 @@ void givenAnUpdateWithPatroniInitialConfigWithCallbacksAddedFromScratch_shouldPa
159159 .setInitialConfig (new StackGresClusterPatroniConfig ());
160160 review .getRequest ().getObject ().getSpec ().getConfigurations ()
161161 .getPatroni ().getInitialConfig ().put (
162- "postgresql" , Map .of ("callbacks" , Map .of ("on_start" , "sh -c 'echo \" on_start: $* \" ' " )));
162+ "postgresql" , Map .of ("callbacks" , Map .of ("on_start" , "/usr/local/bin/ on_start" )));
163163
164164 validator .validate (review );
165165 }
@@ -169,7 +169,89 @@ void givenAnUpdateWithPatroniInitialConfigWithCallbacksRemoved_shouldPass() thro
169169 final StackGresClusterReview review = getUpdateReview ();
170170 review .getRequest ().getOldObject ().getSpec ().getConfigurations ()
171171 .getPatroni ().getInitialConfig ().put (
172- "postgresql" , Map .of ("callbacks" , Map .of ("on_role_change" , "sh -c 'echo \" on_role_change: $*\" '" )));
172+ "postgresql" , Map .of ("callbacks" , Map .of ("on_role_change" , "/usr/local/bin/on_role_change" )));
173+
174+ validator .validate (review );
175+ }
176+
177+ @ Test
178+ void givenAnUpdateWithPatroniInitialConfigWithPrePromoteChanged_shouldPass () throws ValidationFailed {
179+ final StackGresClusterReview review = getUpdateReview ();
180+ review .getRequest ().getOldObject ().getSpec ().getConfigurations ()
181+ .getPatroni ().getInitialConfig ().put ("postgresql" , Map .of ("pre_promote" , "/usr/local/bin/pre_promote" ));
182+ review .getRequest ().getObject ().getSpec ().getConfigurations ()
183+ .getPatroni ().getInitialConfig ().put ("postgresql" , Map .of ("pre_promote" , "/usr/local/bin/pre_promote_2" ));
184+
185+ validator .validate (review );
186+ }
187+
188+ @ Test
189+ void givenAnUpdateWithPatroniInitialConfigWithPrePromoteAdded_shouldPass () throws ValidationFailed {
190+ final StackGresClusterReview review = getUpdateReview ();
191+ review .getRequest ().getObject ().getSpec ().getConfigurations ()
192+ .getPatroni ().getInitialConfig ().put ("postgresql" , Map .of ("pre_promote" , "/usr/local/bin/pre_promote_2" ));
193+
194+ validator .validate (review );
195+ }
196+
197+ @ Test
198+ void givenAnUpdateWithPatroniInitialConfigWithPrePromoteAddedFromScratch_shouldPass () throws ValidationFailed {
199+ final StackGresClusterReview review = getUpdateReview ();
200+ review .getRequest ().getOldObject ().getSpec ().getConfigurations ().getPatroni ().setInitialConfig (null );
201+ review .getRequest ().getObject ().getSpec ().getConfigurations ().getPatroni ()
202+ .setInitialConfig (new StackGresClusterPatroniConfig ());
203+ review .getRequest ().getObject ().getSpec ().getConfigurations ()
204+ .getPatroni ().getInitialConfig ().put ("postgresql" , Map .of ("pre_promote" , "/usr/local/bin/pre_promote_2" ));
205+
206+ validator .validate (review );
207+ }
208+
209+ @ Test
210+ void givenAnUpdateWithPatroniInitialConfigWithPrePromoteRemoved_shouldPass () throws ValidationFailed {
211+ final StackGresClusterReview review = getUpdateReview ();
212+ review .getRequest ().getOldObject ().getSpec ().getConfigurations ()
213+ .getPatroni ().getInitialConfig ().put ("postgresql" , Map .of ("pre_promote" , "/usr/local/bin/pre_promote" ));
214+
215+ validator .validate (review );
216+ }
217+
218+ @ Test
219+ void givenAnUpdateWithPatroniInitialConfigWithBeforeStopChanged_shouldPass () throws ValidationFailed {
220+ final StackGresClusterReview review = getUpdateReview ();
221+ review .getRequest ().getOldObject ().getSpec ().getConfigurations ()
222+ .getPatroni ().getInitialConfig ().put ("postgresql" , Map .of ("before_stop" , "/usr/local/bin/before_stop" ));
223+ review .getRequest ().getObject ().getSpec ().getConfigurations ()
224+ .getPatroni ().getInitialConfig ().put ("postgresql" , Map .of ("before_stop" , "/usr/local/bin/before_stop_2" ));
225+
226+ validator .validate (review );
227+ }
228+
229+ @ Test
230+ void givenAnUpdateWithPatroniInitialConfigWithBeforeStopAdded_shouldPass () throws ValidationFailed {
231+ final StackGresClusterReview review = getUpdateReview ();
232+ review .getRequest ().getObject ().getSpec ().getConfigurations ()
233+ .getPatroni ().getInitialConfig ().put ("postgresql" , Map .of ("before_stop" , "/usr/local/bin/before_stop_2" ));
234+
235+ validator .validate (review );
236+ }
237+
238+ @ Test
239+ void givenAnUpdateWithPatroniInitialConfigWithBeforeStopAddedFromScratch_shouldPass () throws ValidationFailed {
240+ final StackGresClusterReview review = getUpdateReview ();
241+ review .getRequest ().getOldObject ().getSpec ().getConfigurations ().getPatroni ().setInitialConfig (null );
242+ review .getRequest ().getObject ().getSpec ().getConfigurations ().getPatroni ()
243+ .setInitialConfig (new StackGresClusterPatroniConfig ());
244+ review .getRequest ().getObject ().getSpec ().getConfigurations ()
245+ .getPatroni ().getInitialConfig ().put ("postgresql" , Map .of ("before_stop" , "/usr/local/bin/before_stop_2" ));
246+
247+ validator .validate (review );
248+ }
249+
250+ @ Test
251+ void givenAnUpdateWithPatroniInitialConfigWithBeforeStopRemoved_shouldPass () throws ValidationFailed {
252+ final StackGresClusterReview review = getUpdateReview ();
253+ review .getRequest ().getOldObject ().getSpec ().getConfigurations ()
254+ .getPatroni ().getInitialConfig ().put ("postgresql" , Map .of ("before_stop" , "/usr/local/bin/before_stop" ));
173255
174256 validator .validate (review );
175257 }
0 commit comments