@@ -128,7 +128,7 @@ public void testDomainInitContainer() throws Exception {
128128
129129 // Modify the original domain yaml to include restartVersion in admin server node
130130 DomainCrd crd = new DomainCrd (originalYaml );
131- crd .addInitContNode ("spec" , null , null );
131+ crd .addInitContNode ("spec" , null , null , "busybox" );
132132 String modYaml = crd .getYamlTree ();
133133 logger .info (modYaml );
134134 testInitContainer (modYaml );
@@ -155,7 +155,7 @@ public void testAdminServerInitContainer() throws Exception {
155155
156156 // Modify the original domain yaml to include restartVersion in admin server node
157157 DomainCrd crd = new DomainCrd (originalYaml );
158- crd .addInitContNode ("adminServer" , null , null );
158+ crd .addInitContNode ("adminServer" , null , null , "busybox" );
159159 String modYaml = crd .getYamlTree ();
160160 logger .info (modYaml );
161161 testInitContainer (modYaml );
@@ -181,7 +181,7 @@ public void testClusterInitContainer() throws Exception {
181181
182182 // Modify the original domain yaml to include restartVersion in admin server node
183183 DomainCrd crd = new DomainCrd (originalYaml );
184- crd .addInitContNode ("clusters" , "cluster-1" , null );
184+ crd .addInitContNode ("clusters" , "cluster-1" , null , "busybox" );
185185 String modYaml = crd .getYamlTree ();
186186 logger .info (modYaml );
187187 testInitContainer (modYaml );
@@ -208,7 +208,7 @@ public void testMSInitContainer() throws Exception {
208208
209209 // Modify the original domain yaml to include restartVersion in admin server node
210210 DomainCrd crd = new DomainCrd (originalYaml );
211- crd .addInitContNode ("managedServers" , "cluster-1" , "managed-server1" );
211+ crd .addInitContNode ("managedServers" , "cluster-1" , "managed-server1" , "busybox" );
212212 String modYaml = crd .getYamlTree ();
213213 logger .info (modYaml );
214214 testInitContainer (modYaml );
@@ -218,6 +218,84 @@ public void testMSInitContainer() throws Exception {
218218 logger .log (Level .INFO , "SUCCESS - {0}" , testMethodName );
219219 }
220220
221+ /**
222+ * Add initContainers which fails to run to completion and verify the weblogic server pods are not
223+ * started as result of it.
224+ *
225+ * @throws Exception when domain.yaml cannot be read or modified to include the initContainers or
226+ * weblogic server pod doesn't go through initialization and ready state
227+ */
228+ @ Test
229+ public void testDomainInitContainerNegative () throws Exception {
230+ Assume .assumeFalse (QUICKTEST );
231+ String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
232+ logTestBegin (testMethodName );
233+ String pods [] = {domainUid + "-" + domain .getAdminServerName (), domainUid + "-managed-server1" };
234+
235+ // Modify the original domain yaml to include restartVersion in admin server node
236+ DomainCrd crd = new DomainCrd (originalYaml );
237+ crd .addInitContNode ("spec" , null , null , "busybox" );
238+ String modYaml = crd .getYamlTree ();
239+ modYaml = modYaml .replaceAll ("sleep" , "foo" );
240+ logger .info (modYaml );
241+ testInitContainer (modYaml );
242+ TestUtils .checkPodInitializing (pods [0 ], domain .getDomainNs ());
243+ TestUtils .checkPodReady (pods [0 ], domain .getDomainNs ());
244+ logger .log (Level .INFO , "SUCCESS - {0}" , testMethodName );
245+ }
246+
247+ /**
248+ * Add initContainers at domain and adminserver level and verify init containers are run at both
249+ * level
250+ *
251+ * @throws Exception when domain.yaml cannot be read or modified to include the initContainers or
252+ * weblogic server pod doesn't go through initialization and ready state
253+ */
254+ @ Test
255+ public void testInitContainerDiffLevel () throws Exception {
256+ Assume .assumeFalse (QUICKTEST );
257+ String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
258+ logTestBegin (testMethodName );
259+ String pods [] = {domainUid + "-" + domain .getAdminServerName (), domainUid + "-managed-server1" };
260+
261+ // Modify the original domain yaml to include restartVersion in admin server node
262+ DomainCrd crd = new DomainCrd (originalYaml );
263+ crd .addInitContNode ("spec" , null , null , "busybox" );
264+ crd .addInitContNode ("adminServer" , null , null , "busybox1" );
265+ String modYaml = crd .getYamlTree ();
266+ logger .info (modYaml );
267+ testInitContainer (modYaml );
268+ TestUtils .checkPodInitializing (pods [0 ], domain .getDomainNs ());
269+ TestUtils .checkPodReady (pods [0 ], domain .getDomainNs ());
270+ logger .log (Level .INFO , "SUCCESS - {0}" , testMethodName );
271+ }
272+
273+ /**
274+ * Add initContainers at domain and adminserver level and verify init containers are run at both
275+ * level
276+ *
277+ * @throws Exception when domain.yaml cannot be read or modified to include the initContainers or
278+ * weblogic server pod doesn't go through initialization and ready state
279+ */
280+ @ Test
281+ public void testInitContainerMultiple () throws Exception {
282+ Assume .assumeFalse (QUICKTEST );
283+ String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
284+ logTestBegin (testMethodName );
285+ String pods [] = {domainUid + "-" + domain .getAdminServerName (), domainUid + "-managed-server1" };
286+
287+ // Modify the original domain yaml to include restartVersion in admin server node
288+ DomainCrd crd = new DomainCrd (originalYaml );
289+ crd .addInitContNode ("spec" , null , null , "busybox1" );
290+ crd .addInitContNode ("spec" , null , null , "busybox2" );
291+ String modYaml = crd .getYamlTree ();
292+ logger .info (modYaml );
293+ testInitContainer (modYaml );
294+ TestUtils .checkPodInitializing (pods [0 ], domain .getDomainNs ());
295+ TestUtils .checkPodReady (pods [0 ], domain .getDomainNs ());
296+ logger .log (Level .INFO , "SUCCESS - {0}" , testMethodName );
297+ }
298+
221299 /**
222300 * Add initContainers to adminServer and verify the admin server pod goes through Init state
223301 * before starting the admin server pod
0 commit comments