12
12
import org .junit .FixMethodOrder ;
13
13
import org .junit .runners .MethodSorters ;
14
14
15
+ import java .nio .file .Files ;
16
+ import java .nio .file .Path ;
17
+ import java .nio .file .Paths ;
18
+ import java .nio .file .StandardCopyOption ;
15
19
16
20
@ FixMethodOrder (MethodSorters .NAME_ASCENDING )
17
21
public class ITImagetool extends BaseTest {
@@ -39,6 +43,11 @@ public class ITImagetool extends BaseTest {
39
43
private static final String WDT_VARIABLES = "domain.properties" ;
40
44
private static final String WDT_MODEL = "simple-topology.yaml" ;
41
45
private static final String WDT_MODEL1 = "simple-topology1.yaml" ;
46
+ private static final String WDT_MODEL2 = "simple-topology2.yaml" ;
47
+ private static String oracleSupportUsername ;
48
+ private static String oracleSupportPassword ;
49
+ private static String httpProxy ;
50
+ private static String httpsProxy ;
42
51
43
52
@ BeforeClass
44
53
public static void staticPrepare () throws Exception {
@@ -51,16 +60,33 @@ public static void staticPrepare() throws Exception {
51
60
setup ();
52
61
// pull base OS docker image used for test
53
62
pullBaseOSDockerImage ();
63
+ // pull oracle db image
64
+ pullOracleDBDockerImage ();
54
65
55
66
// download the installers for the test
56
67
downloadInstallers (JDK_INSTALLER , WLS_INSTALLER , WDT_INSTALLER , P27342434_INSTALLER , P28186730_INSTALLER ,
57
- FMW_INSTALLER );
68
+ FMW_INSTALLER , JDK_INSTALLER_8u212 , FMW_INSTALLER_1221 , P22987840_INSTALLER );
69
+
70
+ // get Oracle support credentials
71
+ oracleSupportUsername = System .getenv ("ORACLE_SUPPORT_USERNAME" );
72
+ oracleSupportPassword = System .getenv ("ORACLE_SUPPORT_PASSWORD" );
73
+ if (oracleSupportUsername == null || oracleSupportPassword == null ) {
74
+ throw new Exception ("Please set environment variables ORACLE_SUPPORT_USERNAME and ORACLE_SUPPORT_PASSWORD" +
75
+ " for Oracle Support credentials to download the patches." );
76
+ }
77
+
78
+ // get http proxy
79
+ httpProxy = System .getenv ("HTTP_PROXY" );
80
+ httpsProxy = System .getenv ("HTTPS_PROXY" );
81
+ if (httpProxy == null || httpsProxy == null ) {
82
+ throw new Exception ("Please set environment variable HTTP_PROXY and HTTPS_PROXY" );
83
+ }
58
84
}
59
85
60
86
@ AfterClass
61
87
public static void staticUnprepare () throws Exception {
62
88
logger .info ("cleaning up after the test ..." );
63
- cleanup ();
89
+ // cleanup();
64
90
}
65
91
66
92
/**
@@ -315,19 +341,6 @@ public void testBCreateFMWImgFullInternetAccess() throws Exception {
315
341
String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
316
342
logTestBegin (testMethodName );
317
343
318
- String user = System .getenv ("ORACLE_SUPPORT_USERNAME" );
319
- String password = System .getenv ("ORACLE_SUPPORT_PASSWORD" );
320
- if (user == null || password == null ) {
321
- throw new Exception ("Please set environment variables ORACLE_SUPPORT_USERNAME and ORACLE_SUPPORT_PASSWORD" +
322
- " for Oracle Support credentials to download the patches." );
323
- }
324
-
325
- String httpProxy = System .getenv ("HTTP_PROXY" );
326
- String httpsProxy = System .getenv ("HTTPS_PROXY" );
327
- if (httpProxy == null || httpsProxy == null ) {
328
- throw new Exception ("Please set environment variable HTTP_PROXY and HTTPS_PROXY" );
329
- }
330
-
331
344
// add fmw installer to the cache
332
345
// delete the cache entry if any
333
346
deleteEntryFromCache ("fmw_" + WLS_VERSION );
@@ -341,7 +354,7 @@ public void testBCreateFMWImgFullInternetAccess() throws Exception {
341
354
addInstallerToCache ("jdk" , JDK_VERSION , jdkPath );
342
355
343
356
String command = imagetool + " create --version=" + WLS_VERSION + " --tag imagetool:" + testMethodName +
344
- " --latestPSU --user " + user + " --passwordEnv ORACLE_SUPPORT_PASSWORD --httpProxyUrl " +
357
+ " --latestPSU --user " + oracleSupportUsername + " --passwordEnv ORACLE_SUPPORT_PASSWORD --httpProxyUrl " +
345
358
httpProxy + " --httpsProxyUrl " + httpsProxy + " --type fmw" ;
346
359
logger .info ("Executing command: " + command );
347
360
ExecCommand .exec (command , true );
@@ -361,9 +374,6 @@ public void testCCreateFMWImgNonDefault() throws Exception {
361
374
String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
362
375
logTestBegin (testMethodName );
363
376
364
- // download the installers with non default version
365
- downloadInstallers (JDK_INSTALLER_8u212 , FMW_INSTALLER_1221 , P22987840_INSTALLER );
366
-
367
377
// add fmw installer to the cache
368
378
String fmwPath = getInstallerCacheDir () + FS + FMW_INSTALLER_1221 ;
369
379
addInstallerToCache ("fmw" , WLS_VERSION_1221 , fmwPath );
@@ -397,9 +407,6 @@ public void testDCreateJRFDomainImgUsingWDT() throws Exception {
397
407
String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
398
408
logTestBegin (testMethodName );
399
409
400
- // pull oracle db image
401
- pullOracleDBDockerImage ();
402
-
403
410
// create a db container for RCU
404
411
createDBContainer ();
405
412
@@ -426,19 +433,23 @@ public void testDCreateJRFDomainImgUsingWDT() throws Exception {
426
433
427
434
String wdtArchive = getWDTResourcePath () + FS + WDT_ARCHIVE ;
428
435
String wdtModel = getWDTResourcePath () + FS + WDT_MODEL1 ;
436
+ String tmpWdtModel = System .getProperty ("java.io.tmpdir" ) + FS + WDT_MODEL1 ;
429
437
430
438
// update wdt model file
439
+ Path source = Paths .get (wdtModel );
440
+ Path dest = Paths .get (tmpWdtModel );
441
+ Files .copy (source , dest , StandardCopyOption .REPLACE_EXISTING );
431
442
String host = System .getenv ("HOST" );
432
443
if (host == null ) {
433
444
throw new Exception ("There is no HOST environment variable defined" );
434
445
}
435
- replaceStringInFile (wdtModel , "%DB_HOST%" , host );
446
+ replaceStringInFile (tmpWdtModel , "%DB_HOST%" , host );
436
447
437
448
String command = imagetool + " create --fromImage " +
438
449
BASE_OS_IMG + ":" + BASE_OS_IMG_TAG + " --tag imagetool:" + testMethodName +
439
450
" --version " + WLS_VERSION + " --wdtVersion " + WDT_VERSION +
440
451
" --wdtArchive " + wdtArchive + " --wdtDomainHome /u01/domains/simple_domain --wdtModel " +
441
- wdtModel + " --wdtDomainType JRF --wdtRunRCU --type fmw" ;
452
+ tmpWdtModel + " --wdtDomainType JRF --wdtRunRCU --type fmw" ;
442
453
443
454
logger .info ("Executing command: " + command );
444
455
ExecCommand .exec (command , true );
@@ -454,17 +465,10 @@ public void testDCreateJRFDomainImgUsingWDT() throws Exception {
454
465
* @throws Exception - if any error occurs
455
466
*/
456
467
@ Test
457
- public void testECreateJRFDomainImgUsingWDT () throws Exception {
468
+ public void testECreateRestricedJRFDomainImgUsingWDT () throws Exception {
458
469
String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
459
470
logTestBegin (testMethodName );
460
471
461
- String user = System .getenv ("ORACLE_SUPPORT_USERNAME" );
462
- String password = System .getenv ("ORACLE_SUPPORT_PASSWORD" );
463
- if (user == null || password == null ) {
464
- throw new Exception ("Please set environment variables ORACLE_SUPPORT_USERNAME and ORACLE_SUPPORT_PASSWORD" +
465
- " for Oracle Support credentials to download the patches." );
466
- }
467
-
468
472
// add WDT installer to the cache
469
473
// delete the cache entry if any
470
474
deleteEntryFromCache ("wdt_" + WDT_VERSION );
@@ -491,8 +495,8 @@ public void testECreateJRFDomainImgUsingWDT() throws Exception {
491
495
String wdtVariables = getWDTResourcePath () + FS + WDT_VARIABLES ;
492
496
String command = imagetool + " create --fromImage " +
493
497
BASE_OS_IMG + ":" + BASE_OS_IMG_TAG + " --tag imagetool:" + testMethodName +
494
- " --version " + WLS_VERSION + " --latestPSU --user " + user +
495
- " --passwordEnv ORACLE_SUPPORT_PASSWORD " + " --wdtVersion " + WDT_VERSION +
498
+ " --version " + WLS_VERSION + " --latestPSU --user " + oracleSupportUsername +
499
+ " --password " + oracleSupportPassword + " --wdtVersion " + WDT_VERSION +
496
500
" --wdtArchive " + wdtArchive + " --wdtDomainHome /u01/domains/simple_domain --wdtModel " +
497
501
wdtModel + " --wdtDomainType RestrictedJRF --type fmw --wdtVariables " + wdtVariables ;
498
502
@@ -504,4 +508,55 @@ public void testECreateJRFDomainImgUsingWDT() throws Exception {
504
508
505
509
logTestEnd (testMethodName );
506
510
}
511
+
512
+ @ Test
513
+ public void testFCreateWLSImgUsingMultiModels () throws Exception {
514
+ String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
515
+ logTestBegin (testMethodName );
516
+
517
+ // add WDT installer to the cache
518
+ // delete the cache entry first
519
+ deleteEntryFromCache ("wdt_" + WDT_VERSION );
520
+ String wdtPath = getInstallerCacheDir () + FS + WDT_INSTALLER ;
521
+ addInstallerToCache ("wdt" , WDT_VERSION , wdtPath );
522
+
523
+ // add WLS installer to the cache
524
+ // delete the cache entry first
525
+ deleteEntryFromCache ("wls_" + WLS_VERSION );
526
+ String wlsPath = getInstallerCacheDir () + FS + WLS_INSTALLER ;
527
+ addInstallerToCache ("wls" , WLS_VERSION , wlsPath );
528
+
529
+ // add jdk installer to the cache
530
+ // delete the cache entry first
531
+ deleteEntryFromCache ("jdk_" + JDK_VERSION );
532
+ String jdkPath = getInstallerCacheDir () + FS + JDK_INSTALLER ;
533
+ addInstallerToCache ("jdk" , JDK_VERSION , jdkPath );
534
+
535
+ // need to add the required patches 28186730 for Opatch before create wls images
536
+ // delete the cache entry first
537
+ deleteEntryFromCache (P28186730_ID + "_opatch" );
538
+ String patchPath = getInstallerCacheDir () + FS + P28186730_INSTALLER ;
539
+ addPatchToCache ("wls" , P28186730_ID , OPATCH_VERSION , patchPath );
540
+
541
+ // build the wdt archive
542
+ buildWDTArchive ();
543
+
544
+ String wdtArchive = getWDTResourcePath () + FS + WDT_ARCHIVE ;
545
+ String wdtModel = getWDTResourcePath () + FS + WDT_MODEL ;
546
+ String wdtModel2 = getWDTResourcePath () + FS + WDT_MODEL2 ;
547
+ String wdtVariables = getWDTResourcePath () + FS + WDT_VARIABLES ;
548
+ String command = imagetool + " create --fromImage " +
549
+ BASE_OS_IMG + ":" + BASE_OS_IMG_TAG + " --tag imagetool:" + testMethodName +
550
+ " --version " + WLS_VERSION + " --wdtVersion " + WDT_VERSION +
551
+ " --wdtArchive " + wdtArchive + " --wdtDomainHome /u01/domains/simple_domain --wdtModel " +
552
+ wdtModel + "," + wdtModel2 + " --wdtVariables " + wdtVariables ;
553
+
554
+ logger .info ("Executing command: " + command );
555
+ ExecCommand .exec (command , true );
556
+
557
+ // verify the docker image is created
558
+ verifyDockerImages (testMethodName );
559
+
560
+ logTestEnd (testMethodName );
561
+ }
507
562
}
0 commit comments