@@ -245,14 +245,46 @@ public void testDomainInitContainerNegative() throws Exception {
245245 }
246246
247247 /**
248- * Add initContainers at domain and admin server level and verify init container run only at
249- * domain level
248+ * Add initContainers at domain and admin server level and verify init container runs at both
249+ * level when the names are different
250250 *
251251 * @throws Exception when domain.yaml cannot be read or modified to include the initContainers or
252252 * weblogic server pod doesn't go through initialization and ready state
253253 */
254254 @ Test
255- public void testInitContainerDiffLevel () throws Exception {
255+ public void testInitContainerDiffLevelDiffName () 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-server2" };
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 , "busybox1" , "sleep" );
264+ crd .addInitContNode ("adminServer" , null , null , "busybox2" , "sleep" );
265+ String modYaml = crd .getYamlTree ();
266+ logger .info (modYaml );
267+ testInitContainer (modYaml );
268+ String cmd = "kubectl get pod " + pods [0 ] + " -n " + domain .getDomainNs ();
269+
270+ TestUtils .checkCmdInLoop (cmd , "Init:0/2" , pods [0 ]);
271+ TestUtils .checkCmdInLoop (cmd , "Init:1/2" , pods [0 ]);
272+ TestUtils .checkPodReady (pods [0 ], domain .getDomainNs ());
273+
274+ logger .info ("Verifying if the pods are recreated with initialization" );
275+ verifyPodInitialized (pods [1 ]);
276+ logger .log (Level .INFO , "SUCCESS - {0}" , testMethodName );
277+ }
278+
279+ /**
280+ * Add initContainers at domain and admin server level and verify init container is not run at
281+ * both level when the names are same
282+ *
283+ * @throws Exception when domain.yaml cannot be read or modified to include the initContainers or
284+ * weblogic server pod doesn't go through initialization and ready state
285+ */
286+ @ Test
287+ public void testInitContainerDiffLevelSameName () throws Exception {
256288 Assume .assumeFalse (QUICKTEST );
257289 String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
258290 logTestBegin (testMethodName );
@@ -261,7 +293,7 @@ public void testInitContainerDiffLevel() throws Exception {
261293 // Modify the original domain yaml to include restartVersion in admin server node
262294 DomainCrd crd = new DomainCrd (originalYaml );
263295 crd .addInitContNode ("spec" , null , null , "busybox" , "sleep" );
264- crd .addInitContNode ("adminServer" , null , null , "busybox1 " , "foo" );
296+ crd .addInitContNode ("adminServer" , null , null , "busybox " , "foo" );
265297 String modYaml = crd .getYamlTree ();
266298 logger .info (modYaml );
267299 testInitContainer (modYaml );
@@ -271,7 +303,6 @@ public void testInitContainerDiffLevel() throws Exception {
271303 }
272304 logger .log (Level .INFO , "SUCCESS - {0}" , testMethodName );
273305 }
274-
275306 /**
276307 * Add multiple initContainers at domain level and verify all of the init containers are run
277308 *
0 commit comments