1
+ // Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2
+ // Licensed under the Universal Permissive License v 1.0 as shown at
3
+ // http://oss.oracle.com/licenses/upl.
4
+
1
5
package com .oracle .weblogic .imagetool .integration ;
2
6
3
7
import com .oracle .weblogic .imagetool .integration .utils .ExecCommand ;
12
16
@ FixMethodOrder (MethodSorters .NAME_ASCENDING )
13
17
public class ITImagetool extends BaseTest {
14
18
15
-
19
+ private static final String JDK_INSTALLER = "jdk-8u212-linux-x64.tar.gz" ;
20
+ private static final String WLS_INSTALLER = "fmw_12.2.1.3.0_wls_Disk1_1of1.zip" ;
21
+ private static final String P27342434_INSTALLER = "p27342434_122130_Generic.zip" ;
22
+ private static final String P28186730_INSTALLER = "p28186730_139400_Generic.zip" ;
23
+ private static final String TEST_ENTRY_KEY = "mytestEntryKey" ;
24
+ private static final String P27342434_ID = "27342434" ;
25
+ private static final String P28186730_ID = "28186730" ;
26
+ private static final String WLS_VERSION = "12.2.1.3.0" ;
27
+ private static final String JDK_VERSION = "8u212" ;
16
28
17
29
@ BeforeClass
18
30
public static void staticPrepare () throws Exception {
19
31
logger .info ("prepare for image tool test ..." );
20
32
initialize ();
21
33
setup ();
34
+ // pull base OS docker image used for test
35
+ pullDockerImage ();
22
36
}
23
37
24
38
@ AfterClass
@@ -45,14 +59,140 @@ public void test2CacheAddInstallerJDK() throws Exception {
45
59
String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
46
60
logTestBegin (testMethodName );
47
61
48
- String jdkPath = getProjectRoot () + FS + ".." + FS + "caches" + FS + "jdk-8u212-linux-x64.tar.gz" ;
49
- ExecResult result = addInstallerToCache ("jdk" , "8u212" , jdkPath );
50
- logger .info (result .stderr ());
62
+ String jdkPath = getProjectRoot () + FS + ".." + FS + "caches" + FS + JDK_INSTALLER ;
63
+ addInstallerToCache ("jdk" , JDK_VERSION , jdkPath );
64
+
65
+ ExecResult result = listItemsInCache ();
66
+ String expectedString = "jdk_" + JDK_VERSION + "=" + jdkPath ;
67
+ verifyResult (result , expectedString );
68
+
69
+ logTestEnd (testMethodName );
70
+ }
71
+
72
+ @ Test
73
+ public void test3CacheAddInstallerWLS () throws Exception {
74
+ String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
75
+ logTestBegin (testMethodName );
76
+
77
+ String wlsPath = getProjectRoot () + FS + ".." + FS + "caches" + FS + WLS_INSTALLER ;
78
+ addInstallerToCache ("wls" , WLS_VERSION , wlsPath );
79
+
80
+ ExecResult result = listItemsInCache ();
81
+ String expectedString = "wls_" + WLS_VERSION + "=" + wlsPath ;
82
+ verifyResult (result , expectedString );
83
+
84
+ logTestEnd (testMethodName );
85
+ }
86
+
87
+ @ Test
88
+ public void test4CreateWLSImg () throws Exception {
89
+ String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
90
+ logTestBegin (testMethodName );
91
+
92
+ String command = imagetool + " create --jdkVersion=" + JDK_VERSION + " --tag imagetool:" + testMethodName ;
93
+ logger .info ("Executing command: " + command );
94
+ ExecCommand .exec (command , true );
95
+
96
+ // 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
+ }
102
+
103
+ logTestEnd (testMethodName );
104
+ }
105
+
106
+ @ Test
107
+ public void test5CacheAddPatch () throws Exception {
108
+ String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
109
+ logTestBegin (testMethodName );
110
+
111
+ String patchPath = getProjectRoot () + FS + ".." + FS + "caches" + FS + P27342434_INSTALLER ;
112
+ addPatchToCache ("wls" , "p" + P27342434_ID , WLS_VERSION , patchPath );
113
+
114
+ // verify the result
115
+ ExecResult result = listItemsInCache ();
116
+ String expectedString = P27342434_ID + "_" + WLS_VERSION + "=" + patchPath ;
117
+ verifyResult (result , expectedString );
118
+
119
+ logTestEnd (testMethodName );
120
+ }
121
+
122
+ @ Test
123
+ public void test6CacheAddEntry () throws Exception {
124
+ String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
125
+ logTestBegin (testMethodName );
126
+
127
+ String mytestEntryValue = getProjectRoot () + FS + ".." + FS + "caches" + FS + P27342434_INSTALLER ;
128
+ addEntryToCache (TEST_ENTRY_KEY , mytestEntryValue );
51
129
52
- result = listItemsInCache ();
53
- String expectedString = "jdk_8u212=" + jdkPath ;
130
+ // verify the result
131
+ ExecResult result = listItemsInCache ();
132
+ String expectedString = TEST_ENTRY_KEY .toLowerCase () + "=" + mytestEntryValue ;
54
133
verifyResult (result , expectedString );
55
134
56
135
logTestEnd (testMethodName );
57
136
}
137
+
138
+ @ Test
139
+ public void test7CacheDeleteEntry () throws Exception {
140
+ String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
141
+ logTestBegin (testMethodName );
142
+
143
+ deleteEntryFromCache (TEST_ENTRY_KEY );
144
+
145
+ // verify the result
146
+ ExecResult result = listItemsInCache ();
147
+ if (result .exitValue () != 0 || result .stdout ().contains (TEST_ENTRY_KEY )) {
148
+ throw new Exception ("The entry key is not deleted from the cache" );
149
+ }
150
+
151
+ logTestEnd (testMethodName );
152
+ }
153
+
154
+ @ Test
155
+ public void test8CreateWLSImgUseCache () throws Exception {
156
+ String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
157
+ logTestBegin (testMethodName );
158
+
159
+ // need to add the required patches 28186730 for Opatch before create wls images
160
+ String patchPath = getProjectRoot () + FS + ".." + FS + "caches" + FS + P28186730_INSTALLER ;
161
+ addPatchToCache ("wls" , "p" + P28186730_ID , WLS_VERSION , patchPath );
162
+
163
+ String command = imagetool + " create --jdkVersion " + JDK_VERSION + " --fromImage " +
164
+ BASE_OS_IMG + ":" + BASE_OS_IMG_TAG + " --tag imagetool:" + testMethodName +
165
+ " --version " + WLS_VERSION + " --useCache always" ;
166
+ logger .info ("Executing command: " + command );
167
+ ExecCommand .exec (command , true );
168
+
169
+ // 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
+ }
175
+
176
+ logTestEnd (testMethodName );
177
+ }
178
+
179
+ @ Test
180
+ public void test9UpdateWLSImg () throws Exception {
181
+ String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
182
+ logTestBegin (testMethodName );
183
+
184
+ String command = imagetool + " update --fromImage imagetool:test8CreateWLSImgUseCache --tag imagetool:" +
185
+ testMethodName + " --patches " + P27342434_ID + " --useCache always" ;
186
+ logger .info ("Executing command: " + command );
187
+ ExecCommand .exec (command , true );
188
+
189
+ // 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
+ }
195
+
196
+ logTestEnd (testMethodName );
197
+ }
58
198
}
0 commit comments