@@ -264,6 +264,28 @@ private static String getMethodName(TestInfo testInfo) {
264
264
265
265
}
266
266
267
+ private static CommandResult executeAndVerify (String command ) throws Exception {
268
+ logger .info ("Executing command: " + command );
269
+ CommandResult result = Runner .run (command );
270
+ assertEquals (0 , result .exitValue (), "for command: " + command );
271
+ logger .info (result .stdout ());
272
+ return result ;
273
+ }
274
+
275
+ /**
276
+ * Determine if a Docker image exists on the local system.
277
+ */
278
+ private static boolean imageExists (String imageTag ) throws IOException , InterruptedException {
279
+ return !getImageId (imageTag ).isEmpty ();
280
+ }
281
+
282
+ /**
283
+ * Get the docker identifier for this image tag.
284
+ */
285
+ private static String getImageId (String imageTag ) throws IOException , InterruptedException {
286
+ return Runner .run ("docker images -q " + imageTag ).stdout ().trim ();
287
+ }
288
+
267
289
private void verifyFileInImage (String imagename , String filename , String expectedContent ) throws Exception {
268
290
logger .info ("verifying the file content in image" );
269
291
String command = "docker run --rm " + imagename + " bash -c 'cat " + filename + "'" ;
@@ -289,14 +311,6 @@ private void createDBContainer() throws Exception {
289
311
checkCmdInLoop (command );
290
312
}
291
313
292
- private static CommandResult executeAndVerify (String command ) throws Exception {
293
- logger .info ("Executing command: " + command );
294
- CommandResult result = Runner .run (command );
295
- assertEquals (0 , result .exitValue (), "for command: " + command );
296
- logger .info (result .stdout ());
297
- return result ;
298
- }
299
-
300
314
/**
301
315
* Test caching of an installer of type JDK.
302
316
*
@@ -538,8 +552,8 @@ void createWlsImg(TestInfo testInfo) throws Exception {
538
552
assertEquals (0 , result .exitValue (), "for command: " + command );
539
553
540
554
// verify the docker image is created
541
- String imageId = Runner . run ( "docker images -q " + tagName , out , logger ). stdout (). trim ( );
542
- assertFalse ( imageId . isEmpty (), "Image was not created: " + tagName );
555
+ assertTrue ( imageExists ( tagName ), "Image was not created: " + tagName );
556
+
543
557
wlsImgBuilt = true ;
544
558
}
545
559
}
@@ -568,8 +582,8 @@ void updateWlsImg(TestInfo testInfo) throws Exception {
568
582
assertEquals (0 , result .exitValue (), "for command: " + command );
569
583
570
584
// verify the docker image is created
571
- String imageId = Runner . run ( "docker images -q " + tagName , out , logger ). stdout (). trim ( );
572
- assertFalse ( imageId . isEmpty (), "Image was not created: " + tagName );
585
+ assertTrue ( imageExists ( tagName ), "Image was not created: " + tagName );
586
+
573
587
// TODO should check that patch and OPatch were applied
574
588
}
575
589
}
@@ -603,8 +617,8 @@ void createWlsImgUsingWdt(TestInfo testInfo) throws Exception {
603
617
assertEquals (0 , result .exitValue (), "for command: " + command );
604
618
605
619
// verify the docker image is created
606
- String imageId = Runner . run ( "docker images -q " + tagName , out , logger ). stdout (). trim ( );
607
- assertFalse ( imageId . isEmpty (), "Image was not created: " + tagName );
620
+ assertTrue ( imageExists ( tagName ), "Image was not created: " + tagName );
621
+
608
622
domainImgBuilt = true ;
609
623
}
610
624
}
@@ -633,8 +647,7 @@ void rebaseWlsImg(TestInfo testInfo) throws Exception {
633
647
assertEquals (0 , result .exitValue (), "for command: " + command );
634
648
635
649
// verify the docker image is created
636
- String imageId = Runner .run ("docker images -q " + tagName , out , logger ).stdout ().trim ();
637
- assertFalse (imageId .isEmpty (), "Image was not created: " + tagName );
650
+ assertTrue (imageExists (tagName ), "Image was not created: " + tagName );
638
651
}
639
652
}
640
653
@@ -688,8 +701,7 @@ void createFmwImgFullInternetAccess(TestInfo testInfo) throws Exception {
688
701
assertEquals (0 , result .exitValue (), "for command: " + command );
689
702
690
703
// verify the docker image is created
691
- String imageId = Runner .run ("docker images -q " + tagName , out , logger ).stdout ().trim ();
692
- assertFalse (imageId .isEmpty (), "Image was not created: " + tagName );
704
+ assertTrue (imageExists (tagName ), "Image was not created: " + tagName );
693
705
}
694
706
}
695
707
@@ -744,8 +756,7 @@ void createJrfDomainImgUsingWdt(TestInfo testInfo) throws Exception {
744
756
assertEquals (0 , result .exitValue (), "for command: " + command );
745
757
746
758
// verify the docker image is created
747
- String imageId = Runner .run ("docker images -q " + tagName , out , logger ).stdout ().trim ();
748
- assertFalse (imageId .isEmpty (), "Image was not created: " + tagName );
759
+ assertTrue (imageExists (tagName ), "Image was not created: " + tagName );
749
760
}
750
761
}
751
762
@@ -784,8 +795,7 @@ void createRestrictedJrfDomainImgUsingWdt(TestInfo testInfo) throws Exception {
784
795
assertEquals (0 , result .exitValue (), "for command: " + command );
785
796
786
797
// verify the docker image is created
787
- String imageId = Runner .run ("docker images -q " + tagName , out , logger ).stdout ().trim ();
788
- assertFalse (imageId .isEmpty (), "Image was not created: " + tagName );
798
+ assertTrue (imageExists (tagName ), "Image was not created: " + tagName );
789
799
}
790
800
}
791
801
@@ -821,8 +831,7 @@ void createWlsImgUsingMultiModels(TestInfo testInfo) throws Exception {
821
831
assertEquals (0 , result .exitValue (), "for command: " + command );
822
832
823
833
// verify the docker image is created
824
- String imageId = Runner .run ("docker images -q " + tagName , out , logger ).stdout ().trim ();
825
- assertFalse (imageId .isEmpty (), "Image was not created: " + tagName );
834
+ assertTrue (imageExists (tagName ), "Image was not created: " + tagName );
826
835
}
827
836
}
828
837
@@ -851,8 +860,7 @@ void createWlsImgWithAdditionalBuildCommands(TestInfo testInfo) throws Exception
851
860
assertEquals (0 , result .exitValue (), "for command: " + command );
852
861
853
862
// verify the docker image is created
854
- String imageId = Runner .run ("docker images -q " + tagName , out , logger ).stdout ().trim ();
855
- assertFalse (imageId .isEmpty (), "Image was not created: " + tagName );
863
+ assertTrue (imageExists (tagName ), "Image was not created: " + tagName );
856
864
}
857
865
858
866
// verify the file created in [before-jdk-install] section
@@ -891,8 +899,7 @@ void createImageWithServerJRE(TestInfo testInfo) throws Exception {
891
899
assertEquals (0 , result .exitValue (), "for command: " + command );
892
900
893
901
// verify the docker image is created
894
- String imageId = Runner .run ("docker images -q " + tagName , out , logger ).stdout ().trim ();
895
- assertFalse (imageId .isEmpty (), "Image was not created: " + tagName );
902
+ assertTrue (imageExists (tagName ), "Image was not created: " + tagName );
896
903
}
897
904
}
898
905
@@ -919,8 +926,7 @@ void updateImageWithServerJRE(TestInfo testInfo) throws Exception {
919
926
assertEquals (0 , result .exitValue (), "for command: " + command );
920
927
921
928
// verify the docker image is created
922
- String imageId = Runner .run ("docker images -q " + tagName , out , logger ).stdout ().trim ();
923
- assertFalse (imageId .isEmpty (), "Image was not created: " + tagName );
929
+ assertTrue (imageExists (tagName ), "Image was not created: " + tagName );
924
930
}
925
931
}
926
932
@@ -962,8 +968,7 @@ void createMiiOl8slim(TestInfo testInfo) throws Exception {
962
968
assertEquals (0 , result .exitValue (), "for command: " + command );
963
969
964
970
// verify the docker image is created
965
- String imageId = Runner .run ("docker images -q " + tagName , out , logger ).stdout ().trim ();
966
- assertFalse (imageId .isEmpty (), "Image was not created: " + tagName );
971
+ assertTrue (imageExists (tagName ), "Image was not created: " + tagName );
967
972
968
973
validateDirectoryPermissions ("/u01/domains" , "drwxrwxr-x" , tagName , out );
969
974
validateDirectoryPermissions ("/u01/wdt" , "drwxrwxr-x" , tagName , out );
@@ -991,4 +996,68 @@ private void validateDirectoryPermissions(String directory, String expected, Str
991
996
// When running on an SELinux host, the permissions shown by ls will end with a "."
992
997
assertTrue (tokens [0 ].startsWith (expected ), "Incorrect directory permissions for " + directory );
993
998
}
999
+
1000
+ /**
1001
+ * update a WLS image with a model.
1002
+ *
1003
+ * @throws Exception - if any error occurs
1004
+ */
1005
+ @ Test
1006
+ @ Order (28 )
1007
+ @ Tag ("nightly" )
1008
+ @ DisplayName ("Use Update to add a WDT model to createWlsImg" )
1009
+ void updateAddModel (TestInfo testInfo ) throws Exception {
1010
+ assumeTrue (wlsImgBuilt );
1011
+
1012
+ String tagName = build_tag + ":" + getMethodName (testInfo );
1013
+ String command = new UpdateCommand ()
1014
+ .fromImage (build_tag + ":createWlsImg" ) //from step 10, createWlsImg()
1015
+ .tag (tagName )
1016
+ .wdtVersion (WDT_VERSION )
1017
+ .wdtModel (WDT_MODEL )
1018
+ .wdtVariables (WDT_VARIABLES )
1019
+ .wdtArchive (WDT_ARCHIVE )
1020
+ .wdtModelOnly (true )
1021
+ .build ();
1022
+
1023
+ try (PrintWriter out = getTestMethodWriter (testInfo )) {
1024
+ CommandResult result = Runner .run (command , out , logger );
1025
+ assertEquals (0 , result .exitValue (), "for command: " + command );
1026
+
1027
+ // verify the docker image is created
1028
+ assertTrue (imageExists (tagName ), "Image was not created: " + tagName );
1029
+ }
1030
+ }
1031
+
1032
+ /**
1033
+ * update a WLS image with another model.
1034
+ *
1035
+ * @throws Exception - if any error occurs
1036
+ */
1037
+ @ Test
1038
+ @ Order (29 )
1039
+ @ Tag ("nightly" )
1040
+ @ DisplayName ("Use Update to add a second WDT model to createWlsImg" )
1041
+ void updateAddSecondModel (TestInfo testInfo ) throws Exception {
1042
+ String testFromImage = build_tag + ":updateAddModel" ;
1043
+ // skip this test if updateAddModel() failed to create an image
1044
+ assumeTrue (imageExists (testFromImage ));
1045
+
1046
+ String tagName = build_tag + ":" + getMethodName (testInfo );
1047
+ String command = new UpdateCommand ()
1048
+ .fromImage (testFromImage )
1049
+ .tag (tagName )
1050
+ .wdtVersion (WDT_VERSION )
1051
+ .wdtModel (WDT_MODEL2 )
1052
+ .wdtModelOnly (true )
1053
+ .build ();
1054
+
1055
+ try (PrintWriter out = getTestMethodWriter (testInfo )) {
1056
+ CommandResult result = Runner .run (command , out , logger );
1057
+ assertEquals (0 , result .exitValue (), "for command: " + command );
1058
+
1059
+ // verify the docker image is created
1060
+ assertTrue (imageExists (tagName ), "Image was not created: " + tagName );
1061
+ }
1062
+ }
994
1063
}
0 commit comments