9
9
import java .nio .file .Files ;
10
10
import java .nio .file .Path ;
11
11
import java .nio .file .Paths ;
12
+ import java .util .HashMap ;
12
13
import java .util .Map ;
13
14
import java .util .logging .Level ;
14
15
import oracle .kubernetes .operator .utils .Domain ;
@@ -36,6 +37,7 @@ public class ITPodsRestart extends BaseTest {
36
37
private static Operator operator1 ;
37
38
private static String domainUid = "" ;
38
39
private static String restartTmpDir = "" ;
40
+ private static String originalYaml ;
39
41
40
42
/**
41
43
* This method gets called only once before any of the test methods are executed. It does the
@@ -59,6 +61,11 @@ public static void staticPrepare() throws Exception {
59
61
Files .createDirectories (Paths .get (restartTmpDir ));
60
62
61
63
domain = createPodsRestartdomain ();
64
+ originalYaml =
65
+ BaseTest .getUserProjectsDir ()
66
+ + "/weblogic-domains/"
67
+ + domain .getDomainUid ()
68
+ + "/domain.yaml" ;
62
69
Assert .assertNotNull (domain );
63
70
}
64
71
}
@@ -319,20 +326,19 @@ public void testAdminServerRestartVersions() throws Exception {
319
326
Assume .assumeFalse (QUICKTEST );
320
327
String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
321
328
logTestBegin (testMethodName );
322
- String originalYaml =
323
- BaseTest .getUserProjectsDir ()
324
- + "/weblogic-domains/"
325
- + domain .getDomainUid ()
326
- + "/domain.yaml" ;
329
+
327
330
try {
328
331
logger .info ("Modifying the Domain CRD.." );
329
332
DomainCRD crd = new DomainCRD (originalYaml );
330
- String yaml = crd .addObjectNodeToAdminServer ("restartVersion" , "v1.1" );
331
- logger .info (yaml );
333
+ Map <String , String > admin = new HashMap ();
334
+ admin .put ("restartVersion" , "v1.1" );
335
+ crd .addObjectNodeToAdminServer (admin );
336
+ String modYaml = crd .getYamlTree ();
337
+ logger .info (modYaml );
332
338
Path path = Paths .get (restartTmpDir , "restart.admin.yaml" );
333
339
logger .log (Level .INFO , "Path of the modified domain.yaml :{0}" , path .toString ());
334
340
Charset charset = StandardCharsets .UTF_8 ;
335
- Files .write (path , yaml .getBytes (charset ));
341
+ Files .write (path , modYaml .getBytes (charset ));
336
342
logger .log (Level .INFO , "Running kubectl apply -f {0}" , path .toString ());
337
343
ExecResult exec = TestUtils .exec ("kubectl apply -f " + path .toString ());
338
344
logger .info (exec .stdout ());
@@ -347,104 +353,6 @@ public void testAdminServerRestartVersions() throws Exception {
347
353
logger .info ("SUCCESS - " + testMethodName );
348
354
}
349
355
350
- // @Test
351
- public void testClusterRestartVersions () throws Exception {
352
- Assume .assumeFalse (QUICKTEST );
353
- String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
354
- logTestBegin (testMethodName );
355
- ExecResult result ;
356
- String originalYaml =
357
- BaseTest .getUserProjectsDir ()
358
- + "/weblogic-domains/"
359
- + domain .getDomainUid ()
360
- + "/domain.yaml" ;
361
- try {
362
- result =
363
- TestUtils .exec (
364
- "kubectl get Domain "
365
- + domain .getDomainUid ()
366
- + " -n "
367
- + domain .getDomainNS ()
368
- + " --output json" );
369
- DomainCRD parser = new DomainCRD ();
370
- String yaml =
371
- parser .addRestartVersionToCluster (
372
- result .stdout (), domain .getDomainMap ().get ("clusterName" ).toString (), "v1.1" );
373
- Path path = Paths .get (restartTmpDir , "restart.cluster.yaml" );
374
- Charset charset = StandardCharsets .UTF_8 ;
375
- Files .write (path , yaml .getBytes (charset ));
376
- result = TestUtils .exec ("kubectl apply -f " + path .toString ());
377
- // TODO - verify that the pod is restarting
378
- } finally {
379
- result = TestUtils .exec ("kubectl apply -f " + originalYaml );
380
- }
381
- logger .info ("SUCCESS - " + testMethodName );
382
- }
383
-
384
- // @Test
385
- public void testMSRestartVersions () throws Exception {
386
- Assume .assumeFalse (QUICKTEST );
387
- String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
388
- logTestBegin (testMethodName );
389
- ExecResult result ;
390
- String originalYaml =
391
- BaseTest .getUserProjectsDir ()
392
- + "/weblogic-domains/"
393
- + domain .getDomainUid ()
394
- + "/domain.yaml" ;
395
- try {
396
- result =
397
- TestUtils .exec (
398
- "kubectl get Domain "
399
- + domain .getDomainUid ()
400
- + " -n "
401
- + domain .getDomainNS ()
402
- + " --output json" );
403
- DomainCRD parser = new DomainCRD ();
404
- String yaml = parser .addRestartVersionToMS (result .stdout (), "managed-server1" , "v1.1" );
405
- Path path = Paths .get (restartTmpDir , "restart.ms.yaml" );
406
- Charset charset = StandardCharsets .UTF_8 ;
407
- Files .write (path , yaml .getBytes (charset ));
408
- result = TestUtils .exec ("kubectl apply -f " + path .toString ());
409
- // TODO - verify that the pod is restarting
410
- } finally {
411
- result = TestUtils .exec ("kubectl apply -f " + originalYaml );
412
- }
413
- logger .info ("SUCCESS - " + testMethodName );
414
- }
415
-
416
- // @Test
417
- public void testDomainRestartVersions () throws Exception {
418
- Assume .assumeFalse (QUICKTEST );
419
- String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
420
- logTestBegin (testMethodName );
421
- ExecResult result ;
422
- String originalYaml =
423
- BaseTest .getUserProjectsDir ()
424
- + "/weblogic-domains/"
425
- + domain .getDomainUid ()
426
- + "/domain.yaml" ;
427
- try {
428
- result =
429
- TestUtils .exec (
430
- "kubectl get Domain "
431
- + domain .getDomainUid ()
432
- + " -n "
433
- + domain .getDomainNS ()
434
- + " --output json" );
435
- DomainCRD parser = new DomainCRD ();
436
- String yaml = parser .addRestartVersionToDomain (result .stdout (), "v1.1" );
437
- Path path = Paths .get (restartTmpDir , "restart.ms.yaml" );
438
- Charset charset = StandardCharsets .UTF_8 ;
439
- Files .write (path , yaml .getBytes (charset ));
440
- result = TestUtils .exec ("kubectl apply -f " + path .toString ());
441
- // TODO - verify that the pod is restarting
442
- } finally {
443
- result = TestUtils .exec ("kubectl apply -f " + originalYaml );
444
- }
445
- logger .info ("SUCCESS - " + testMethodName );
446
- }
447
-
448
356
private static Domain createPodsRestartdomain () throws Exception {
449
357
450
358
Map <String , Object > domainMap = TestUtils .loadYaml (DOMAINONPV_WLST_YAML );
0 commit comments