1616@ FixMethodOrder (MethodSorters .NAME_ASCENDING )
1717public class ITImagetool extends BaseTest {
1818
19- private static final String JDK_INSTALLER = "jdk-8u212 -linux-x64.tar.gz" ;
19+ private static final String JDK_INSTALLER = "jdk-8u202 -linux-x64.tar.gz" ;
2020 private static final String WLS_INSTALLER = "fmw_12.2.1.3.0_wls_Disk1_1of1.zip" ;
2121 private static final String P27342434_INSTALLER = "p27342434_122130_Generic.zip" ;
2222 private static final String P28186730_INSTALLER = "p28186730_139400_Generic.zip" ;
23+ private static final String WDT_INSTALLER = "weblogic-deploy.zip" ;
2324 private static final String TEST_ENTRY_KEY = "mytestEntryKey" ;
2425 private static final String P27342434_ID = "27342434" ;
2526 private static final String P28186730_ID = "28186730" ;
2627 private static final String WLS_VERSION = "12.2.1.3.0" ;
27- private static final String JDK_VERSION = "8u212" ;
28+ private static final String OPATCH_VERSION = "13.9.4.0.0" ;
29+ private static final String JDK_VERSION = "8u202" ;
30+ private static final String WDT_VERSION = "1.1.1" ;
31+ private static final String WDT_ARCHIVE = "archive.zip" ;
32+ private static final String WDT_VARIABLES = "domain.properties" ;
33+ private static final String WDT_MODEL = "simple-topology.yaml" ;
2834
2935 @ BeforeClass
3036 public static void staticPrepare () throws Exception {
3137 logger .info ("prepare for image tool test ..." );
38+
3239 initialize ();
40+ // clean up the env first
41+ cleanup ();
42+
3343 setup ();
3444 // pull base OS docker image used for test
3545 pullDockerImage ();
@@ -38,6 +48,7 @@ public static void staticPrepare() throws Exception {
3848 @ AfterClass
3949 public static void staticUnprepare () throws Exception {
4050 logger .info ("cleaning up after the test ..." );
51+ cleanup ();
4152 }
4253
4354 @ Test
@@ -94,11 +105,7 @@ public void test4CreateWLSImg() throws Exception {
94105 ExecCommand .exec (command , true );
95106
96107 // verify the docker image is created
97- ExecResult result = ExecCommand .exec ("docker images | grep imagetool | grep " + testMethodName +
98- "| wc -l" );
99- if (Integer .parseInt (result .stdout ()) != 1 ) {
100- throw new Exception ("wls docker image is not created as expected" );
101- }
108+ verifyDockerImages (testMethodName );
102109
103110 logTestEnd (testMethodName );
104111 }
@@ -109,7 +116,8 @@ public void test5CacheAddPatch() throws Exception {
109116 logTestBegin (testMethodName );
110117
111118 String patchPath = getProjectRoot () + FS + ".." + FS + "caches" + FS + P27342434_INSTALLER ;
112- addPatchToCache ("wls" , "p" + P27342434_ID , WLS_VERSION , patchPath );
119+ deleteEntryFromCache (P27342434_ID + "_" + WLS_VERSION );
120+ addPatchToCache ("wls" , P27342434_ID , WLS_VERSION , patchPath );
113121
114122 // verify the result
115123 ExecResult result = listItemsInCache ();
@@ -158,20 +166,16 @@ public void test8CreateWLSImgUseCache() throws Exception {
158166
159167 // need to add the required patches 28186730 for Opatch before create wls images
160168 String patchPath = getProjectRoot () + FS + ".." + FS + "caches" + FS + P28186730_INSTALLER ;
161- addPatchToCache ("wls" , "p" + P28186730_ID , WLS_VERSION , patchPath );
169+ addPatchToCache ("wls" , P28186730_ID , OPATCH_VERSION , patchPath );
162170
163171 String command = imagetool + " create --jdkVersion " + JDK_VERSION + " --fromImage " +
164172 BASE_OS_IMG + ":" + BASE_OS_IMG_TAG + " --tag imagetool:" + testMethodName +
165- " --version " + WLS_VERSION + " --useCache always" ;
173+ " --version " + WLS_VERSION ;
166174 logger .info ("Executing command: " + command );
167175 ExecCommand .exec (command , true );
168176
169177 // verify the docker image is created
170- ExecResult result = ExecCommand .exec ("docker images | grep imagetool | grep " + testMethodName +
171- "| wc -l" );
172- if (Integer .parseInt (result .stdout ()) != 1 ) {
173- throw new Exception ("wls docker image is not created as expected" );
174- }
178+ verifyDockerImages (testMethodName );
175179
176180 logTestEnd (testMethodName );
177181 }
@@ -182,16 +186,60 @@ public void test9UpdateWLSImg() throws Exception {
182186 logTestBegin (testMethodName );
183187
184188 String command = imagetool + " update --fromImage imagetool:test8CreateWLSImgUseCache --tag imagetool:" +
185- testMethodName + " --patches " + P27342434_ID + " --useCache always" ;
189+ testMethodName + " --patches " + P27342434_ID ;
186190 logger .info ("Executing command: " + command );
187191 ExecCommand .exec (command , true );
188192
189193 // verify the docker image is created
190- ExecResult result = ExecCommand .exec ("docker images | grep imagetool | grep " + testMethodName +
191- "| wc -l" );
192- if (Integer .parseInt (result .stdout ()) != 1 ) {
193- throw new Exception ("wls docker image is not created as expected" );
194- }
194+ verifyDockerImages (testMethodName );
195+
196+ logTestEnd (testMethodName );
197+ }
198+
199+ @ Test
200+ public void testACreateWLSImgUsingWDT () throws Exception {
201+
202+ String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
203+ logTestBegin (testMethodName );
204+
205+ // add WDT installer to the cache
206+ String wdtPath = getProjectRoot () + FS + ".." + FS + "caches" + FS + WDT_INSTALLER ;
207+ addInstallerToCache ("wdt" , WDT_VERSION , wdtPath );
208+
209+ // add WLS installer to the cache
210+ String wlsPath = getProjectRoot () + FS + ".." + FS + "caches" + FS + WLS_INSTALLER ;
211+ addInstallerToCache ("wls" , WLS_VERSION , wlsPath );
212+
213+ // add jdk installer to the cache
214+ String jdkPath = getProjectRoot () + FS + ".." + FS + "caches" + FS + JDK_INSTALLER ;
215+ addInstallerToCache ("jdk" , JDK_VERSION , jdkPath );
216+
217+ // need to add the required patches 28186730 for Opatch before create wls images
218+ // delete the cache entry first
219+ deleteEntryFromCache (P28186730_ID + "_opatch" );
220+ String patchPath = getProjectRoot () + FS + ".." + FS + "caches" + FS + P28186730_INSTALLER ;
221+ addPatchToCache ("wls" , P28186730_ID , OPATCH_VERSION , patchPath );
222+
223+ // add the patch to the cache
224+ deleteEntryFromCache (P27342434_ID + "_" + WLS_VERSION );
225+ patchPath = getProjectRoot () + FS + ".." + FS + "caches" + FS + P27342434_INSTALLER ;
226+ addPatchToCache ("wls" , P27342434_ID , WLS_VERSION , patchPath );
227+
228+ String wdtResourcePath = getProjectRoot () + FS + "src" + FS + "test" + FS + "resources" + FS + "wdt" + FS ;
229+ String wdtArchive = wdtResourcePath + WDT_ARCHIVE ;
230+ String wdtModel = wdtResourcePath + WDT_MODEL ;
231+ String wdtVariables = wdtResourcePath + WDT_VARIABLES ;
232+ String command = imagetool + " create --fromImage " +
233+ BASE_OS_IMG + ":" + BASE_OS_IMG_TAG + " --tag imagetool:" + testMethodName +
234+ " --version " + WLS_VERSION + " --patches " + P27342434_ID + " --wdtVersion " + WDT_VERSION +
235+ " --wdtArchive " + wdtArchive + " --wdtDomainHome /u01/domains/simple_domain --wdtModel " +
236+ wdtModel + " --wdtVariables " + wdtVariables ;
237+
238+ logger .info ("Executing command: " + command );
239+ ExecCommand .exec (command , true );
240+
241+ // verify the docker image is created
242+ verifyDockerImages (testMethodName );
195243
196244 logTestEnd (testMethodName );
197245 }
0 commit comments