@@ -194,161 +194,108 @@ public void testServerPodsRestartByChangingZImage() throws Exception {
194
194
/**
195
195
* Modify/Add the containerSecurityContext section at ServerPod Level using kubectl apply -f
196
196
* cont.security.context.domain.yaml. Verify all the pods re-started. The property tested is:
197
- * serverPod: containerSecurityContext: runAsUser: 1000 fsGroup: 2000
197
+ * serverPod: containerSecurityContext: runAsUser: 1000 fsGroup: 1000.
198
198
*
199
- * @throws Exception
199
+ * @throws Exception - assertion fails due to unmatched value or errors occurred if tested servers
200
+ * are not restarted or after restart the server yaml file doesn't include the new added
201
+ * property
200
202
*/
201
203
@ Test
202
204
public void testServerPodsRestartByChangingContSecurityContext () throws Exception {
203
205
Assume .assumeFalse (QUICKTEST );
204
206
String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
205
207
logTestBegin (testMethodName );
206
208
209
+ // firstly ensure that original domain.yaml doesn't include the property-to-be-added
210
+ String domainFileName =
211
+ BaseTest .getUserProjectsDir () + "/weblogic-domains/" + domainUid + "/domain.yaml" ;
212
+ boolean result = TestUtils .checkFileIncludeProperty ("fsGroup: 1000" , domainFileName );
213
+ Assert .assertFalse (result );
214
+
207
215
// domainYaml: the yaml file name with changed property under resources dir
208
216
String domainYaml = "cont.security.context.domain.yaml" ;
209
- try {
210
- logger .info (
211
- "About to testDomainServerPodRestart for Domain: "
212
- + domain .getDomainUid ()
213
- + " change container securityContext:\n "
214
- + " runAsUser: 1000\n "
215
- + " fsGroup: 2000 " );
216
- domain .testDomainServerPodRestart (domainYaml );
217
- domain .findServerPropertyChange ("runAsUser: 1000" , "admin-server" );
218
- domain .findServerPropertyChange ("runAsUser: 1000" , "managed-server1" );
219
- } finally {
220
- // bring back the domain into previous state
221
- restoreDomain ();
222
- }
217
+ logger .info (
218
+ "About to testDomainServerPodRestart for Domain: "
219
+ + domain .getDomainUid ()
220
+ + " change container securityContext:\n "
221
+ + " runAsUser: 1000\n "
222
+ + " fsGroup: 1000 " );
223
+ domain .testDomainServerPodRestart (domainYaml );
224
+ domain .findServerPropertyChange ("securityContext" , "admin-server" );
225
+ domain .findServerPropertyChange ("securityContext" , "managed-server1" );
223
226
224
227
logger .info ("SUCCESS - " + testMethodName );
225
228
}
226
229
227
230
/**
228
231
* Modify/Add the podSecurityContext section at ServerPod level using kubectl apply -f
229
232
* pod.security.context.domain.yaml. Verify all the pods re-started. The property tested is:
230
- * podSecurityContext: runAsUser: 1000 fsGroup: 2000
233
+ * podSecurityContext: runAsUser: 1000 fsGroup: 2000.
231
234
*
232
- * @throws Exception
235
+ * @throws Exception - assertion fails due to unmatched value or errors occurred if tested servers
236
+ * are not restarted or after restart the server yaml file doesn't include the new added
237
+ * property
233
238
*/
234
239
@ Test
235
240
public void testServerPodsRestartByChangingPodSecurityContext () throws Exception {
236
241
Assume .assumeFalse (QUICKTEST );
237
242
String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
238
243
logTestBegin (testMethodName );
239
244
245
+ // firstly ensure that original domain.yaml doesn't include the property-to-be-added
246
+ String domainFileName =
247
+ BaseTest .getUserProjectsDir () + "/weblogic-domains/" + domainUid + "/domain.yaml" ;
248
+ boolean result = TestUtils .checkFileIncludeProperty ("fsGroup: 2000" , domainFileName );
249
+ Assert .assertFalse (result );
250
+
240
251
// domainYaml: the yaml file name with changed property under resources dir
241
252
String domainYaml = "pod.security.context.domain.yaml" ;
242
- try {
243
- logger .info (
244
- "About to testDomainServerPodRestart for Domain: "
245
- + domain .getDomainUid ()
246
- + " change securityContext:\n "
247
- + " runAsUser: 1000\n "
248
- + " fsGroup: 2000 " );
249
- domain .testDomainServerPodRestart (domainYaml );
250
- domain .findServerPropertyChange ("fsGroup: 2000" , "admin-server" );
251
- domain .findServerPropertyChange ("fsGroup: 2000" , "managed-server1" );
252
- } finally {
253
- // bring back the domain into previous State
254
- restoreDomain ();
255
- }
256
253
257
- logger .info ("SUCCESS - " + testMethodName );
258
- }
259
-
260
- /**
261
- * Modify/Add imagePullSecrets section at Domain Level using kubectl apply -f secret.domain.yaml.
262
- * Verify all pods re-started. The property tested is: imagePullSecrets:- name: imagePullSecr
263
- * value: myImagePullSecret
264
- *
265
- * @throws Exception
266
- */
267
- @ Test
268
- public void testServerPodsRestartByChangingImagePullSecrets () throws Exception {
269
- Assume .assumeFalse (QUICKTEST );
270
- String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
271
- logTestBegin (testMethodName );
272
-
273
- // domainYaml: the yaml file name with changed property under resources dir
274
- String domainYaml = "secret.domain.yaml" ;
275
- try {
276
- logger .info (
277
- "About to testDomainServerPodRestart for Domain: "
278
- + domain .getDomainUid ()
279
- + " change imagePullSecrets:\n "
280
- + " name: imagePullSecret\n "
281
- + " value: myImagePullSecret " );
282
- domain .testDomainServerPodRestart (domainYaml );
283
- domain .findServerPropertyChange ("myImagePullSecret" , "admin-server" );
284
- domain .findServerPropertyChange ("myImagePullSecret" , "managed-server1" );
285
- } finally {
286
- // bring back the domain into previous state
287
- restoreDomain ();
288
- }
254
+ logger .info (
255
+ "About to testDomainServerPodRestart for Domain: "
256
+ + domain .getDomainUid ()
257
+ + " change securityContext:\n "
258
+ + " runAsUser: 1000\n "
259
+ + " fsGroup: 2000 " );
260
+ domain .testDomainServerPodRestart (domainYaml );
261
+ domain .findServerPropertyChange ("fsGroup: 2000" , "admin-server" );
262
+ domain .findServerPropertyChange ("fsGroup: 2000" , "managed-server1" );
289
263
290
264
logger .info ("SUCCESS - " + testMethodName );
291
265
}
292
266
293
267
/**
294
- * Modify/Add resources at ServerPod level using kubectl apply -f resource. domain.yaml. Verify all
295
- * pods re-started. The property tested is: resources: limits: cpu: "1" requests: cpu: "0.5" args:
296
- * - - cpus - "2"
268
+ * Modify/Add resources at ServerPod level using kubectl apply -f domain.yaml. Verify all pods
269
+ * re-started. The property tested is: resources: limits: cpu: "1" requests: cpu: "0.5" args: -
270
+ * -cpus - "2".
297
271
*
298
- * @throws Exception
272
+ * @throws Exception - assertion fails due to unmatched value or errors occurred if tested servers
273
+ * are not restarted or after restart the server yaml file doesn't include the new added
274
+ * property
299
275
*/
300
276
@ Test
301
277
public void testServerPodsRestartByChangingResource () throws Exception {
302
278
Assume .assumeFalse (QUICKTEST );
303
279
String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
304
280
logTestBegin (testMethodName );
305
281
306
- // domainYaml: the yaml file name with changed property under resources dir
307
- String domainYaml = "resource.domain.yaml" ;
308
- try {
309
- logger .info (
310
- "About to testDomainServerPodRestart for Domain: "
311
- + domain .getDomainUid ()
312
- + " change resource:\n "
313
- + " cpu: 500m" );
314
- domain .testDomainServerPodRestart (domainYaml );
315
- domain .findServerPropertyChange ("cpu: 500m" , "admin-server" );
316
- domain .findServerPropertyChange ("cpu: 500m" , "managed-server1" );
317
- } finally {
318
- // bring back the domain into previous state
319
- restoreDomain ();
320
- }
321
-
322
- logger .info ("SUCCESS - " + testMethodName );
323
- }
324
-
325
- /**
326
- * Modify the annotations at ServerPod level using kubectl apply -f annotation.domain.yaml. Verify
327
- * all pods re-started. The property tested is: annotations: "TSTAMP" --> "DATETIME"
328
- *
329
- * @throws Exception
330
- */
331
- @ Test
332
- public void testServerPodsRestartByChangingAnnotation () throws Exception {
333
- Assume .assumeFalse (QUICKTEST );
334
- String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
335
- logTestBegin (testMethodName );
282
+ // firstly ensure that original domain.yaml doesn't include the property-to-be-addeded
283
+ String domainFileName =
284
+ BaseTest .getUserProjectsDir () + "/weblogic-domains/" + domainUid + "/domain.yaml" ;
285
+ boolean result = TestUtils .checkFileIncludeProperty ("cpu: 500m" , domainFileName );
286
+ Assert .assertFalse (result );
336
287
337
288
// domainYaml: the yaml file name with changed property under resources dir
338
- String domainYaml = "annotation.domain.yaml" ;
339
- try {
340
- logger .info (
341
- "About to testDomainServerPodRestart for Domain: "
342
- + domain .getDomainUid ()
343
- + " change annotation"
344
- + " annotations:\n "
345
- + " custom: \" DATETIME\" " );
346
- domain .testDomainServerPodRestart (domainYaml );
289
+ String domainYaml = "resource.domain.yaml" ;
347
290
348
- } finally {
349
- // bring back the domain into previous state
350
- restoreDomain ();
351
- }
291
+ logger .info (
292
+ "About to testDomainServerPodRestart for Domain: "
293
+ + domain .getDomainUid ()
294
+ + " change resource:\n "
295
+ + " cpu: 500m" );
296
+ domain .testDomainServerPodRestart (domainYaml );
297
+ domain .findServerPropertyChange ("cpu: 500m" , "admin-server" );
298
+ domain .findServerPropertyChange ("cpu: 500m" , "managed-server1" );
352
299
353
300
logger .info ("SUCCESS - " + testMethodName );
354
301
}
@@ -373,12 +320,4 @@ private static void destroyPodsRestartdomain() throws Exception {
373
320
domain .destroy ();
374
321
}
375
322
}
376
-
377
- private static void restoreDomain () throws Exception {
378
- String yamlFile =
379
- BaseTest .getUserProjectsDir () + "/weblogic-domains/" + domainUid + "/domain.yaml" ;
380
- TestUtils .kubectlapply (yamlFile );
381
- domain .verifyAdminServerRestarted ();
382
- domain .verifyManagedServersRestarted ();
383
- }
384
323
}
0 commit comments