@@ -217,6 +217,15 @@ static void staticPrepare() throws Exception {
217
217
throw new Exception ("Please set environment variables ORACLE_SUPPORT_USERNAME and ORACLE_SUPPORT_PASSWORD"
218
218
+ " for Oracle Support credentials to download the patches." );
219
219
}
220
+
221
+ logger .info ("Building WDT archive ..." );
222
+ Path scriptPath = Paths .get ("src" , "test" , "resources" , "wdt" , "build-archive.sh" );
223
+ String command = "sh " + scriptPath ;
224
+ CommandResult result = executeAndVerify (command );
225
+ if (result .exitValue () != 0 ) {
226
+ logger .severe (result .stdout ());
227
+ throw new IOException ("Failed to build WDT Archive" );
228
+ }
220
229
}
221
230
222
231
@ AfterAll
@@ -266,17 +275,6 @@ private void verifyFileInImage(String imagename, String filename, String expecte
266
275
}
267
276
}
268
277
269
- private void buildWdtArchive () throws Exception {
270
- logger .info ("Building WDT archive ..." );
271
- Path scriptPath = Paths .get ("src" , "test" , "resources" , "wdt" , "build-archive.sh" );
272
- String command = "sh " + scriptPath ;
273
- CommandResult result = executeAndVerify (command );
274
- if (result .exitValue () != 0 ) {
275
- logger .severe (result .stdout ());
276
- throw new IOException ("Failed to build WDT Archive" );
277
- }
278
- }
279
-
280
278
private void createDBContainer () throws Exception {
281
279
logger .info ("Creating an Oracle db docker container ..." );
282
280
String command = "docker rm -f " + dbContainerName ;
@@ -291,7 +289,7 @@ private void createDBContainer() throws Exception {
291
289
checkCmdInLoop (command );
292
290
}
293
291
294
- private CommandResult executeAndVerify (String command ) throws Exception {
292
+ private static CommandResult executeAndVerify (String command ) throws Exception {
295
293
logger .info ("Executing command: " + command );
296
294
CommandResult result = Runner .run (command );
297
295
assertEquals (0 , result .exitValue (), "for command: " + command );
@@ -495,6 +493,33 @@ void cacheOpatch(TestInfo testInfo) throws Exception {
495
493
}
496
494
}
497
495
496
+ /**
497
+ * Add WDT installer to the cache.
498
+ * @throws IOException if getting a file to write the command output fails
499
+ * @throws InterruptedException if running the Java command fails
500
+ */
501
+ @ Test
502
+ @ Order (7 )
503
+ @ Tag ("gate" )
504
+ @ Tag ("cache" )
505
+ @ DisplayName ("Add WDT installer to cache" )
506
+ void cacheAddInstallerWdt (TestInfo testInfo ) throws IOException , InterruptedException {
507
+ // add WDT installer to the cache
508
+ Path wdtPath = Paths .get (STAGING_DIR , WDT_INSTALLER );
509
+ String addCommand = new CacheCommand ()
510
+ .addInstaller (true )
511
+ .type ("wdt" )
512
+ .version (WDT_VERSION )
513
+ .path (wdtPath )
514
+ .build ();
515
+
516
+ try (PrintWriter out = getTestMethodWriter (testInfo )) {
517
+ CommandResult addResult = Runner .run (addCommand , out , logger );
518
+ // the process return code for addInstaller should be 0
519
+ assertEquals (0 , addResult .exitValue (), "for command: " + addCommand );
520
+ }
521
+ }
522
+
498
523
/**
499
524
* create a WLS image with default WLS version.
500
525
*
@@ -559,22 +584,8 @@ void updateWlsImg(TestInfo testInfo) throws Exception {
559
584
@ Tag ("gate" )
560
585
@ DisplayName ("Create WLS image with WDT domain" )
561
586
void createWlsImgUsingWdt (TestInfo testInfo ) throws Exception {
562
- // add WDT installer to the cache
563
- Path wdtPath = Paths .get (STAGING_DIR , WDT_INSTALLER );
564
- String addCommand = new CacheCommand ()
565
- .addInstaller (true )
566
- .type ("wdt" )
567
- .version (WDT_VERSION )
568
- .path (wdtPath )
569
- .build ();
570
587
571
588
try (PrintWriter out = getTestMethodWriter (testInfo )) {
572
- CommandResult addResult = Runner .run (addCommand , out , logger );
573
- // the process return code for addInstaller should be 0
574
- assertEquals (0 , addResult .exitValue (), "for command: " + addCommand );
575
-
576
- // build the wdt archive
577
- buildWdtArchive ();
578
589
579
590
String tagName = build_tag + ":" + getMethodName (testInfo );
580
591
// create a WLS image with a domain
@@ -702,9 +713,6 @@ void createJrfDomainImgUsingWdt(TestInfo testInfo) throws Exception {
702
713
703
714
// test assumes that the default JDK version 8u202 is already in the cache
704
715
705
- // build the wdt archive
706
- buildWdtArchive ();
707
-
708
716
Path tmpWdtModel = Paths .get (wlsImgBldDir , WDT_MODEL1 );
709
717
710
718
// update wdt model file
@@ -755,9 +763,6 @@ void createRestrictedJrfDomainImgUsingWdt(TestInfo testInfo) throws Exception {
755
763
756
764
// test assumes that the default JDK version 8u202 is already in the cache
757
765
758
- // build the wdt archive
759
- buildWdtArchive ();
760
-
761
766
String tagName = build_tag + ":" + getMethodName (testInfo );
762
767
String command = new CreateCommand ()
763
768
.tag (tagName )
@@ -800,9 +805,6 @@ void createWlsImgUsingMultiModels(TestInfo testInfo) throws Exception {
800
805
801
806
// test assumes that the WDT installer is already in the cache
802
807
803
- // build the wdt archive
804
- buildWdtArchive ();
805
-
806
808
String tagName = build_tag + ":" + getMethodName (testInfo );
807
809
String command = new CreateCommand ()
808
810
.tag (tagName )
@@ -923,13 +925,13 @@ void updateImageWithServerJRE(TestInfo testInfo) throws Exception {
923
925
}
924
926
925
927
/**
926
- * Create an image with WDT Model only on OL 8-slim
928
+ * Create an image with WDT Model on OL 8-slim
927
929
*
928
930
* @throws Exception - if any error occurs
929
931
*/
930
932
@ Test
931
- @ Order (28 )
932
- @ Tag ("nightly " )
933
+ @ Order (14 )
934
+ @ Tag ("gate " )
933
935
@ DisplayName ("Create Model in Image with OL 8-slim" )
934
936
void createMiiOl8slim (TestInfo testInfo ) throws Exception {
935
937
// test assumes that WDT installer is already in the cache from previous test
@@ -938,8 +940,6 @@ void createMiiOl8slim(TestInfo testInfo) throws Exception {
938
940
939
941
// test assumes that the default JDK version 8u202 is already in the cache
940
942
941
- // test assumes that the WDT archive was already constructed
942
-
943
943
Path tmpWdtModel = Paths .get (wlsImgBldDir , WDT_MODEL1 );
944
944
945
945
// update wdt model file
@@ -964,6 +964,31 @@ void createMiiOl8slim(TestInfo testInfo) throws Exception {
964
964
// verify the docker image is created
965
965
String imageId = Runner .run ("docker images -q " + tagName , out , logger ).stdout ().trim ();
966
966
assertFalse (imageId .isEmpty (), "Image was not created: " + tagName );
967
+
968
+ validateDirectoryPermissions ("/u01/domains" , "drwxrwxr-x" , tagName , out );
969
+ validateDirectoryPermissions ("/u01/wdt" , "drwxrwxr-x" , tagName , out );
970
+ validateDirectoryPermissions ("/u01/wdt/models" , "drwxrwxr-x" , tagName , out );
971
+ validateDirectoryPermissions ("/u01/wdt/weblogic-deploy" , "drwxr-x---" , tagName , out );
972
+ validateDirectoryPermissions ("/u01/oracle" , "drwxr-xr-x" , tagName , out );
967
973
}
968
974
}
975
+
976
+ /**
977
+ * Verify file permissions for a specified path on the given image.
978
+ * @param directory Directory name to check for permissions value.
979
+ * @param expected Expected permission string, such as "drwxrwxr-x"
980
+ * @param tagName Tag name or image ID of the image to inspect
981
+ * @param out The printwriter where the docker run command will send stdout/stderr
982
+ * @throws IOException if process start fails
983
+ * @throws InterruptedException if the wait is interrupted before the process completes
984
+ */
985
+ private void validateDirectoryPermissions (String directory , String expected , String tagName , PrintWriter out )
986
+ throws IOException , InterruptedException {
987
+ String command = String .format (" docker run -t %s ls -ld %s" , tagName , directory );
988
+ String actual = Runner .run (command , out , logger ).stdout ().trim ();
989
+ String [] tokens = actual .split (" " , 2 );
990
+ assertEquals (2 , tokens .length , "Unable to get directory permissions for " + directory );
991
+ // When running on an SELinux host, the permissions shown by ls will end with a "."
992
+ assertTrue (tokens [0 ].startsWith (expected ), "Incorrect directory permissions for " + directory );
993
+ }
969
994
}
0 commit comments