4
4
5
5
package oracle .kubernetes .operator ;
6
6
7
+ import java .nio .charset .Charset ;
8
+ import java .nio .charset .StandardCharsets ;
7
9
import java .nio .file .Files ;
10
+ import java .nio .file .Path ;
8
11
import java .nio .file .Paths ;
9
12
import java .util .Map ;
10
13
import oracle .kubernetes .operator .utils .Domain ;
14
+ import oracle .kubernetes .operator .utils .DomainCRD ;
15
+ import oracle .kubernetes .operator .utils .ExecResult ;
11
16
import oracle .kubernetes .operator .utils .Operator ;
12
17
import oracle .kubernetes .operator .utils .TestUtils ;
13
18
import org .junit .AfterClass ;
@@ -29,6 +34,7 @@ public class ITPodsRestart extends BaseTest {
29
34
private static Domain domain = null ;
30
35
private static Operator operator1 ;
31
36
private static String domainUid = "" ;
37
+ private static String restartTmpDir = "" ;
32
38
33
39
/**
34
40
* This method gets called only once before any of the test methods are executed. It does the
@@ -48,6 +54,8 @@ public static void staticPrepare() throws Exception {
48
54
if (operator1 == null ) {
49
55
operator1 = TestUtils .createOperator (OPERATOR1_YAML );
50
56
}
57
+ restartTmpDir = BaseTest .getResultDir () + "/restarttemp" ;
58
+ Files .createDirectories (Paths .get (restartTmpDir ));
51
59
52
60
domain = createPodsRestartdomain ();
53
61
Assert .assertNotNull (domain );
@@ -305,6 +313,138 @@ public void testServerPodsRestartByChangingResource() throws Exception {
305
313
logger .info ("SUCCESS - " + testMethodName );
306
314
}
307
315
316
+ @ Test
317
+ public void testAdminServerRestartVersions () throws Exception {
318
+ Assume .assumeFalse (QUICKTEST );
319
+ String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
320
+ logTestBegin (testMethodName );
321
+ String originalYaml =
322
+ BaseTest .getUserProjectsDir ()
323
+ + "/weblogic-domains/"
324
+ + domain .getDomainUid ()
325
+ + "/domain.yaml" ;
326
+ try {
327
+ DomainCRD crd = new DomainCRD ();
328
+ String yaml =
329
+ crd .addRestartVersionToAdminServer (
330
+ TestUtils .exec (
331
+ "kubectl get Domain "
332
+ + domain .getDomainUid ()
333
+ + " -n "
334
+ + domain .getDomainNS ()
335
+ + " --output json" )
336
+ .stdout (),
337
+ "v1.1" );
338
+ Path path = Paths .get (restartTmpDir , "restart.admin.yaml" );
339
+ Charset charset = StandardCharsets .UTF_8 ;
340
+ Files .write (path , yaml .getBytes (charset ));
341
+ logger .info (TestUtils .exec ("kubectl apply -f " + path .toString ()).stdout ());
342
+ domain .verifyAdminServerRestarted ();
343
+ } finally {
344
+ TestUtils .exec ("kubectl apply -f " + originalYaml );
345
+ domain .verifyAdminServerRestarted ();
346
+ }
347
+ logger .info ("SUCCESS - " + testMethodName );
348
+ }
349
+
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
+
308
448
private static Domain createPodsRestartdomain () throws Exception {
309
449
310
450
Map <String , Object > domainMap = TestUtils .loadYaml (DOMAINONPV_WLST_YAML );
0 commit comments