@@ -217,6 +217,15 @@ static void staticPrepare() throws Exception {
217217 throw new Exception ("Please set environment variables ORACLE_SUPPORT_USERNAME and ORACLE_SUPPORT_PASSWORD"
218218 + " for Oracle Support credentials to download the patches." );
219219 }
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+ }
220229 }
221230
222231 @ AfterAll
@@ -266,17 +275,6 @@ private void verifyFileInImage(String imagename, String filename, String expecte
266275 }
267276 }
268277
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-
280278 private void createDBContainer () throws Exception {
281279 logger .info ("Creating an Oracle db docker container ..." );
282280 String command = "docker rm -f " + dbContainerName ;
@@ -291,7 +289,7 @@ private void createDBContainer() throws Exception {
291289 checkCmdInLoop (command );
292290 }
293291
294- private CommandResult executeAndVerify (String command ) throws Exception {
292+ private static CommandResult executeAndVerify (String command ) throws Exception {
295293 logger .info ("Executing command: " + command );
296294 CommandResult result = Runner .run (command );
297295 assertEquals (0 , result .exitValue (), "for command: " + command );
@@ -495,6 +493,33 @@ void cacheOpatch(TestInfo testInfo) throws Exception {
495493 }
496494 }
497495
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+
498523 /**
499524 * create a WLS image with default WLS version.
500525 *
@@ -559,22 +584,8 @@ void updateWlsImg(TestInfo testInfo) throws Exception {
559584 @ Tag ("gate" )
560585 @ DisplayName ("Create WLS image with WDT domain" )
561586 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 ();
570587
571588 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 ();
578589
579590 String tagName = build_tag + ":" + getMethodName (testInfo );
580591 // create a WLS image with a domain
@@ -702,9 +713,6 @@ void createJrfDomainImgUsingWdt(TestInfo testInfo) throws Exception {
702713
703714 // test assumes that the default JDK version 8u202 is already in the cache
704715
705- // build the wdt archive
706- buildWdtArchive ();
707-
708716 Path tmpWdtModel = Paths .get (wlsImgBldDir , WDT_MODEL1 );
709717
710718 // update wdt model file
@@ -755,9 +763,6 @@ void createRestrictedJrfDomainImgUsingWdt(TestInfo testInfo) throws Exception {
755763
756764 // test assumes that the default JDK version 8u202 is already in the cache
757765
758- // build the wdt archive
759- buildWdtArchive ();
760-
761766 String tagName = build_tag + ":" + getMethodName (testInfo );
762767 String command = new CreateCommand ()
763768 .tag (tagName )
@@ -800,9 +805,6 @@ void createWlsImgUsingMultiModels(TestInfo testInfo) throws Exception {
800805
801806 // test assumes that the WDT installer is already in the cache
802807
803- // build the wdt archive
804- buildWdtArchive ();
805-
806808 String tagName = build_tag + ":" + getMethodName (testInfo );
807809 String command = new CreateCommand ()
808810 .tag (tagName )
@@ -923,13 +925,13 @@ void updateImageWithServerJRE(TestInfo testInfo) throws Exception {
923925 }
924926
925927 /**
926- * Create an image with WDT Model only on OL 8-slim
928+ * Create an image with WDT Model on OL 8-slim
927929 *
928930 * @throws Exception - if any error occurs
929931 */
930932 @ Test
931- @ Order (28 )
932- @ Tag ("nightly " )
933+ @ Order (14 )
934+ @ Tag ("gate " )
933935 @ DisplayName ("Create Model in Image with OL 8-slim" )
934936 void createMiiOl8slim (TestInfo testInfo ) throws Exception {
935937 // test assumes that WDT installer is already in the cache from previous test
@@ -938,8 +940,6 @@ void createMiiOl8slim(TestInfo testInfo) throws Exception {
938940
939941 // test assumes that the default JDK version 8u202 is already in the cache
940942
941- // test assumes that the WDT archive was already constructed
942-
943943 Path tmpWdtModel = Paths .get (wlsImgBldDir , WDT_MODEL1 );
944944
945945 // update wdt model file
@@ -964,6 +964,31 @@ void createMiiOl8slim(TestInfo testInfo) throws Exception {
964964 // verify the docker image is created
965965 String imageId = Runner .run ("docker images -q " + tagName , out , logger ).stdout ().trim ();
966966 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 );
967973 }
968974 }
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+ }
969994}
0 commit comments