@@ -128,7 +128,7 @@ public void testDomainInitContainer() throws Exception {
128
128
129
129
// Modify the original domain yaml to include restartVersion in admin server node
130
130
DomainCrd crd = new DomainCrd (originalYaml );
131
- crd .addInitContNode ("spec" , null , null );
131
+ crd .addInitContNode ("spec" , null , null , "busybox" );
132
132
String modYaml = crd .getYamlTree ();
133
133
logger .info (modYaml );
134
134
testInitContainer (modYaml );
@@ -155,7 +155,7 @@ public void testAdminServerInitContainer() throws Exception {
155
155
156
156
// Modify the original domain yaml to include restartVersion in admin server node
157
157
DomainCrd crd = new DomainCrd (originalYaml );
158
- crd .addInitContNode ("adminServer" , null , null );
158
+ crd .addInitContNode ("adminServer" , null , null , "busybox" );
159
159
String modYaml = crd .getYamlTree ();
160
160
logger .info (modYaml );
161
161
testInitContainer (modYaml );
@@ -181,7 +181,7 @@ public void testClusterInitContainer() throws Exception {
181
181
182
182
// Modify the original domain yaml to include restartVersion in admin server node
183
183
DomainCrd crd = new DomainCrd (originalYaml );
184
- crd .addInitContNode ("clusters" , "cluster-1" , null );
184
+ crd .addInitContNode ("clusters" , "cluster-1" , null , "busybox" );
185
185
String modYaml = crd .getYamlTree ();
186
186
logger .info (modYaml );
187
187
testInitContainer (modYaml );
@@ -208,7 +208,7 @@ public void testMSInitContainer() throws Exception {
208
208
209
209
// Modify the original domain yaml to include restartVersion in admin server node
210
210
DomainCrd crd = new DomainCrd (originalYaml );
211
- crd .addInitContNode ("managedServers" , "cluster-1" , "managed-server1" );
211
+ crd .addInitContNode ("managedServers" , "cluster-1" , "managed-server1" , "busybox" );
212
212
String modYaml = crd .getYamlTree ();
213
213
logger .info (modYaml );
214
214
testInitContainer (modYaml );
@@ -218,6 +218,84 @@ public void testMSInitContainer() throws Exception {
218
218
logger .log (Level .INFO , "SUCCESS - {0}" , testMethodName );
219
219
}
220
220
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
+
221
299
/**
222
300
* Add initContainers to adminServer and verify the admin server pod goes through Init state
223
301
* before starting the admin server pod
0 commit comments