1212import org .junit .FixMethodOrder ;
1313import org .junit .runners .MethodSorters ;
1414
15+ import java .nio .file .Files ;
16+ import java .nio .file .Path ;
17+ import java .nio .file .Paths ;
18+ import java .nio .file .StandardCopyOption ;
1519
1620@ FixMethodOrder (MethodSorters .NAME_ASCENDING )
1721public class ITImagetool extends BaseTest {
@@ -39,6 +43,11 @@ public class ITImagetool extends BaseTest {
3943 private static final String WDT_VARIABLES = "domain.properties" ;
4044 private static final String WDT_MODEL = "simple-topology.yaml" ;
4145 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 ;
4251
4352 @ BeforeClass
4453 public static void staticPrepare () throws Exception {
@@ -51,16 +60,33 @@ public static void staticPrepare() throws Exception {
5160 setup ();
5261 // pull base OS docker image used for test
5362 pullBaseOSDockerImage ();
63+ // pull oracle db image
64+ pullOracleDBDockerImage ();
5465
5566 // download the installers for the test
5667 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+ }
5884 }
5985
6086 @ AfterClass
6187 public static void staticUnprepare () throws Exception {
6288 logger .info ("cleaning up after the test ..." );
63- cleanup ();
89+ // cleanup();
6490 }
6591
6692 /**
@@ -315,19 +341,6 @@ public void testBCreateFMWImgFullInternetAccess() throws Exception {
315341 String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
316342 logTestBegin (testMethodName );
317343
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-
331344 // add fmw installer to the cache
332345 // delete the cache entry if any
333346 deleteEntryFromCache ("fmw_" + WLS_VERSION );
@@ -341,7 +354,7 @@ public void testBCreateFMWImgFullInternetAccess() throws Exception {
341354 addInstallerToCache ("jdk" , JDK_VERSION , jdkPath );
342355
343356 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 " +
345358 httpProxy + " --httpsProxyUrl " + httpsProxy + " --type fmw" ;
346359 logger .info ("Executing command: " + command );
347360 ExecCommand .exec (command , true );
@@ -361,9 +374,6 @@ public void testCCreateFMWImgNonDefault() throws Exception {
361374 String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
362375 logTestBegin (testMethodName );
363376
364- // download the installers with non default version
365- downloadInstallers (JDK_INSTALLER_8u212 , FMW_INSTALLER_1221 , P22987840_INSTALLER );
366-
367377 // add fmw installer to the cache
368378 String fmwPath = getInstallerCacheDir () + FS + FMW_INSTALLER_1221 ;
369379 addInstallerToCache ("fmw" , WLS_VERSION_1221 , fmwPath );
@@ -397,9 +407,6 @@ public void testDCreateJRFDomainImgUsingWDT() throws Exception {
397407 String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
398408 logTestBegin (testMethodName );
399409
400- // pull oracle db image
401- pullOracleDBDockerImage ();
402-
403410 // create a db container for RCU
404411 createDBContainer ();
405412
@@ -426,19 +433,23 @@ public void testDCreateJRFDomainImgUsingWDT() throws Exception {
426433
427434 String wdtArchive = getWDTResourcePath () + FS + WDT_ARCHIVE ;
428435 String wdtModel = getWDTResourcePath () + FS + WDT_MODEL1 ;
436+ String tmpWdtModel = System .getProperty ("java.io.tmpdir" ) + FS + WDT_MODEL1 ;
429437
430438 // update wdt model file
439+ Path source = Paths .get (wdtModel );
440+ Path dest = Paths .get (tmpWdtModel );
441+ Files .copy (source , dest , StandardCopyOption .REPLACE_EXISTING );
431442 String host = System .getenv ("HOST" );
432443 if (host == null ) {
433444 throw new Exception ("There is no HOST environment variable defined" );
434445 }
435- replaceStringInFile (wdtModel , "%DB_HOST%" , host );
446+ replaceStringInFile (tmpWdtModel , "%DB_HOST%" , host );
436447
437448 String command = imagetool + " create --fromImage " +
438449 BASE_OS_IMG + ":" + BASE_OS_IMG_TAG + " --tag imagetool:" + testMethodName +
439450 " --version " + WLS_VERSION + " --wdtVersion " + WDT_VERSION +
440451 " --wdtArchive " + wdtArchive + " --wdtDomainHome /u01/domains/simple_domain --wdtModel " +
441- wdtModel + " --wdtDomainType JRF --wdtRunRCU --type fmw" ;
452+ tmpWdtModel + " --wdtDomainType JRF --wdtRunRCU --type fmw" ;
442453
443454 logger .info ("Executing command: " + command );
444455 ExecCommand .exec (command , true );
@@ -454,17 +465,10 @@ public void testDCreateJRFDomainImgUsingWDT() throws Exception {
454465 * @throws Exception - if any error occurs
455466 */
456467 @ Test
457- public void testECreateJRFDomainImgUsingWDT () throws Exception {
468+ public void testECreateRestricedJRFDomainImgUsingWDT () throws Exception {
458469 String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
459470 logTestBegin (testMethodName );
460471
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-
468472 // add WDT installer to the cache
469473 // delete the cache entry if any
470474 deleteEntryFromCache ("wdt_" + WDT_VERSION );
@@ -491,8 +495,8 @@ public void testECreateJRFDomainImgUsingWDT() throws Exception {
491495 String wdtVariables = getWDTResourcePath () + FS + WDT_VARIABLES ;
492496 String command = imagetool + " create --fromImage " +
493497 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 +
496500 " --wdtArchive " + wdtArchive + " --wdtDomainHome /u01/domains/simple_domain --wdtModel " +
497501 wdtModel + " --wdtDomainType RestrictedJRF --type fmw --wdtVariables " + wdtVariables ;
498502
@@ -504,4 +508,55 @@ public void testECreateJRFDomainImgUsingWDT() throws Exception {
504508
505509 logTestEnd (testMethodName );
506510 }
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+ }
507562}
0 commit comments