6
6
import java .util .HashMap ;
7
7
import java .util .List ;
8
8
import java .util .Map ;
9
+ import java .util .concurrent .Callable ;
9
10
10
11
import oracle .weblogic .kubernetes .actions .impl .UniqueName ;
11
12
import oracle .weblogic .kubernetes .actions .impl .primitive .Command ;
30
31
import static oracle .weblogic .kubernetes .TestConstants .BUSYBOX_TAG ;
31
32
import static oracle .weblogic .kubernetes .TestConstants .DB_IMAGE_NAME ;
32
33
import static oracle .weblogic .kubernetes .TestConstants .DB_IMAGE_TAG ;
34
+ import static oracle .weblogic .kubernetes .TestConstants .DB_PDB_ID_DEFAULT_19C ;
33
35
import static oracle .weblogic .kubernetes .TestConstants .FMWINFRA_IMAGE_TAG ;
34
36
import static oracle .weblogic .kubernetes .TestConstants .FMWINFRA_IMAGE_TO_USE_IN_SPEC ;
35
37
import static oracle .weblogic .kubernetes .TestConstants .IMAGE_NAME_OPERATOR ;
45
47
import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_INGRESS_IMAGE_REGISTRY ;
46
48
import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_INGRESS_IMAGE_TAG ;
47
49
import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_RELEASE_NAME ;
50
+ import static oracle .weblogic .kubernetes .TestConstants .WLSIMG_BUILDER ;
48
51
import static oracle .weblogic .kubernetes .actions .ActionConstants .WDT_DOWNLOAD_URL ;
49
52
import static oracle .weblogic .kubernetes .actions .ActionConstants .WIT_DOWNLOAD_URL ;
50
53
import static oracle .weblogic .kubernetes .actions .ActionConstants .WIT_JAVA_HOME ;
54
57
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .backupReports ;
55
58
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getUniqueName ;
56
59
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .restoreReports ;
60
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
61
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .withLongRetryPolicy ;
57
62
import static oracle .weblogic .kubernetes .utils .ImageUtils .createBaseRepoSecret ;
58
63
import static oracle .weblogic .kubernetes .utils .ImageUtils .createTestRepoSecret ;
59
64
import static oracle .weblogic .kubernetes .utils .SampleUtils .createPVHostPathAndChangePermissionInKindCluster ;
@@ -87,7 +92,7 @@ class ItFmwDomainOnPVSample {
87
92
* JUnit engine parameter resolution mechanism
88
93
*/
89
94
@ BeforeAll
90
- static void initAll (@ Namespaces (4 ) List <String > namespaces ) {
95
+ public static void initAll (@ Namespaces (4 ) List <String > namespaces ) {
91
96
logger = getLogger ();
92
97
93
98
// get a new unique opNamespace
@@ -138,6 +143,7 @@ static void initAll(@Namespaces(4) List<String> namespaces) {
138
143
envMap .put ("OPER_IMAGE_NAME" , TEST_IMAGES_PREFIX + IMAGE_NAME_OPERATOR );
139
144
envMap .put ("DOMAIN_CREATION_IMAGE_NAME" , TEST_IMAGES_PREFIX + DOMAIN_CREATION_IMAGE_NAME );
140
145
envMap .put ("DB_IMAGE_PULL_SECRET" , BASE_IMAGES_REPO_SECRET_NAME );
146
+ envMap .put ("DB_PDB_ID" , DB_PDB_ID_DEFAULT_19C );
141
147
142
148
// kind cluster uses openjdk which is not supported by image tool
143
149
if (WIT_JAVA_HOME != null ) {
@@ -176,9 +182,9 @@ static void initAll(@Namespaces(4) List<String> namespaces) {
176
182
*/
177
183
@ Test
178
184
@ Order (1 )
179
- void testInstallOperator () {
185
+ public void testInstallOperator () {
180
186
String backupReports = backupReports (UniqueName .uniqueName (this .getClass ().getSimpleName ()));
181
- execTestScriptAndAssertSuccess ("-oper" , "Failed to run -oper" );
187
+ assertTrue ( execTestScriptAndAssertSuccess ("-oper" , "Failed to run -oper" ) );
182
188
restoreReports (backupReports );
183
189
}
184
190
@@ -187,44 +193,66 @@ void testInstallOperator() {
187
193
*/
188
194
@ Test
189
195
@ Order (2 )
190
- void testInstallTraefik () {
191
- execTestScriptAndAssertSuccess ("-traefik" , "Failed to run -traefik" );
196
+ public void testInstallTraefik () {
197
+ Assumptions .assumeTrue (previousTestSuccessful );
198
+ assertTrue (execTestScriptAndAssertSuccess ("-traefik" , "Failed to run -traefik" ));
192
199
}
193
200
194
201
/**
195
202
* Test Domain on PV sample precleandb use case.
196
203
*/
197
204
@ Test
198
205
@ Order (3 )
199
- void testPrecleandb () {
200
- execTestScriptAndAssertSuccess ("-precleandb" , "Failed to run -precleandb" );
206
+ public void testPrecleandb () {
207
+ Assumptions .assumeTrue (previousTestSuccessful );
208
+ assertTrue (execTestScriptAndAssertSuccess ("-precleandb" , "Failed to run -precleandb" ));
201
209
}
202
210
203
211
/**
204
212
* Test Domain on PV sample create db use case.
205
213
*/
206
214
@ Test
207
215
@ Order (4 )
208
- void testCreatedb () {
216
+ public void testCreatedb () {
217
+ Assumptions .assumeTrue (previousTestSuccessful );
209
218
logger .info ("test case for creating a db" );
210
219
if (KIND_REPO != null ) {
211
220
String dbimage = DB_IMAGE_NAME + ":" + DB_IMAGE_TAG ;
212
221
logger .info ("loading image {0} to kind" , dbimage );
213
222
imagePush (dbimage );
214
223
}
215
- execTestScriptAndAssertSuccess ("-db" , "Failed to run -db" );
224
+ assertTrue ( execTestScriptAndAssertSuccess ("-db" , "Failed to run -db" ) );
216
225
}
217
226
218
227
/**
219
- * Test Domain on PV sample building image for FMW domain use case .
228
+ * Test Domain on PV sample - Initialize schemas in the DB .
220
229
*/
221
230
@ Test
222
231
@ Order (5 )
223
- void testInitialImage () {
232
+ public void testCreateRCU () {
233
+ Assumptions .assumeTrue (previousTestSuccessful );
234
+ logger .info ("test case for initializing schemas in the DB" );
235
+ assertTrue (execTestScriptAndAssertSuccess ("-rcu" , "Failed to run -rcu" ));
236
+ }
237
+
238
+ /**
239
+ * Test Domain on PV sample building image for FMW domain use case.
240
+ */
241
+ @ Test
242
+ @ Order (6 )
243
+ public void testInitialImage () {
244
+ Assumptions .assumeTrue (previousTestSuccessful );
224
245
logger .info ("test case for building image" );
225
246
imagePull (BUSYBOX_IMAGE + ":" + BUSYBOX_TAG );
226
247
imageTag (BUSYBOX_IMAGE + ":" + BUSYBOX_TAG , "busybox" );
227
- execTestScriptAndAssertSuccess ("-initial-image" , "Failed to run -initial-image" );
248
+ assertTrue (execTestScriptAndAssertSuccess ("-initial-image" , "Failed to run -initial-image" ));
249
+ ExecResult result = Command .withParams (
250
+ new CommandParams ()
251
+ .command (WLSIMG_BUILDER + " images" )
252
+ .env (envMap )
253
+ .redirect (true )
254
+ ).executeAndReturnResult ();
255
+ logger .info (result .stdout ());
228
256
229
257
// load the image to kind if using kind cluster
230
258
String imageCreated ;
@@ -237,8 +265,9 @@ void testInitialImage() {
237
265
* Test Domain on PV sample create FMW domain use case.
238
266
*/
239
267
@ Test
240
- @ Order (6 )
241
- void testInitialMain () {
268
+ @ Order (7 )
269
+ public void testInitialMain () {
270
+ Assumptions .assumeTrue (previousTestSuccessful );
242
271
logger .info ("test case for creating a FMW domain" );
243
272
244
273
// load the base image to kind if using kind cluster
@@ -248,18 +277,21 @@ void testInitialMain() {
248
277
createPVHostPathAndChangePermissionInKindCluster ("/shared" , envMap );
249
278
}
250
279
251
- execTestScriptAndAssertSuccess ("-initial-main" , "Failed to run -initial-main" );
280
+ testUntil (
281
+ withLongRetryPolicy ,
282
+ checkTestScriptAndAssertSuccess ("-initial-main" , "Failed to run -initial-main" ),
283
+ logger ,
284
+ "creating FMW domain" );
252
285
}
253
286
254
287
/**
255
288
* Run script run-test.sh.
256
289
* @param arg arguments to execute script
257
290
* @param errString a string of detailed error
258
291
*/
259
- private void execTestScriptAndAssertSuccess (String arg ,
292
+ private boolean execTestScriptAndAssertSuccess (String arg ,
260
293
String errString ) {
261
294
262
- Assumptions .assumeTrue (previousTestSuccessful );
263
295
previousTestSuccessful = false ;
264
296
265
297
String command = domainOnPvSampleScript
@@ -273,27 +305,33 @@ private void execTestScriptAndAssertSuccess(String arg,
273
305
.redirect (true )
274
306
).executeAndReturnResult ();
275
307
276
- boolean success = result != null
308
+ boolean success =
309
+ result != null
277
310
&& result .exitValue () == 0
278
311
&& result .stdout () != null
279
312
&& result .stdout ().contains ("Finished without errors" );
280
313
281
- String outStr = errString ;
282
- outStr += ", command=\n {\n " + command + "\n }\n " ;
314
+ String outStr = success ? "Running test script succeeds: " : errString + ":" ;
315
+ outStr += " command=\n {\n " + command + "\n }\n " ;
283
316
outStr += ", stderr=\n {\n " + (result != null ? result .stderr () : "" ) + "\n }\n " ;
284
317
outStr += ", stdout=\n {\n " + (result != null ? result .stdout () : "" ) + "\n }\n " ;
285
318
286
319
logger .info ("output String is: {0}" , outStr );
287
320
288
321
previousTestSuccessful = success ;
289
- assertTrue (success , "running test script " + arg + " failed" );
322
+
323
+ return success ;
324
+ }
325
+
326
+ private Callable <Boolean > checkTestScriptAndAssertSuccess (String arg , String errString ) {
327
+ return () -> execTestScriptAndAssertSuccess (arg , errString );
290
328
}
291
329
292
330
/**
293
331
* Delete DB deployment for FMW test cases and Uninstall Traefik.
294
332
*/
295
333
@ AfterAll
296
- static void tearDownAll () {
334
+ public static void tearDownAll () {
297
335
logger = getLogger ();
298
336
299
337
// uninstall Traefik
0 commit comments