66import java .util .HashMap ;
77import java .util .List ;
88import java .util .Map ;
9+ import java .util .concurrent .Callable ;
910
1011import oracle .weblogic .kubernetes .actions .impl .UniqueName ;
1112import oracle .weblogic .kubernetes .actions .impl .primitive .Command ;
3031import static oracle .weblogic .kubernetes .TestConstants .BUSYBOX_TAG ;
3132import static oracle .weblogic .kubernetes .TestConstants .DB_IMAGE_NAME ;
3233import static oracle .weblogic .kubernetes .TestConstants .DB_IMAGE_TAG ;
34+ import static oracle .weblogic .kubernetes .TestConstants .DB_PDB_ID_DEFAULT_19C ;
3335import static oracle .weblogic .kubernetes .TestConstants .FMWINFRA_IMAGE_TAG ;
3436import static oracle .weblogic .kubernetes .TestConstants .FMWINFRA_IMAGE_TO_USE_IN_SPEC ;
3537import static oracle .weblogic .kubernetes .TestConstants .IMAGE_NAME_OPERATOR ;
4547import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_INGRESS_IMAGE_REGISTRY ;
4648import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_INGRESS_IMAGE_TAG ;
4749import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_RELEASE_NAME ;
50+ import static oracle .weblogic .kubernetes .TestConstants .WLSIMG_BUILDER ;
4851import static oracle .weblogic .kubernetes .actions .ActionConstants .WDT_DOWNLOAD_URL ;
4952import static oracle .weblogic .kubernetes .actions .ActionConstants .WIT_DOWNLOAD_URL ;
5053import static oracle .weblogic .kubernetes .actions .ActionConstants .WIT_JAVA_HOME ;
5457import static oracle .weblogic .kubernetes .utils .CommonTestUtils .backupReports ;
5558import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getUniqueName ;
5659import 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 ;
5762import static oracle .weblogic .kubernetes .utils .ImageUtils .createBaseRepoSecret ;
5863import static oracle .weblogic .kubernetes .utils .ImageUtils .createTestRepoSecret ;
5964import static oracle .weblogic .kubernetes .utils .SampleUtils .createPVHostPathAndChangePermissionInKindCluster ;
@@ -87,7 +92,7 @@ class ItFmwDomainOnPVSample {
8792 * JUnit engine parameter resolution mechanism
8893 */
8994 @ BeforeAll
90- static void initAll (@ Namespaces (4 ) List <String > namespaces ) {
95+ public static void initAll (@ Namespaces (4 ) List <String > namespaces ) {
9196 logger = getLogger ();
9297
9398 // get a new unique opNamespace
@@ -138,6 +143,7 @@ static void initAll(@Namespaces(4) List<String> namespaces) {
138143 envMap .put ("OPER_IMAGE_NAME" , TEST_IMAGES_PREFIX + IMAGE_NAME_OPERATOR );
139144 envMap .put ("DOMAIN_CREATION_IMAGE_NAME" , TEST_IMAGES_PREFIX + DOMAIN_CREATION_IMAGE_NAME );
140145 envMap .put ("DB_IMAGE_PULL_SECRET" , BASE_IMAGES_REPO_SECRET_NAME );
146+ envMap .put ("DB_PDB_ID" , DB_PDB_ID_DEFAULT_19C );
141147
142148 // kind cluster uses openjdk which is not supported by image tool
143149 if (WIT_JAVA_HOME != null ) {
@@ -176,9 +182,9 @@ static void initAll(@Namespaces(4) List<String> namespaces) {
176182 */
177183 @ Test
178184 @ Order (1 )
179- void testInstallOperator () {
185+ public void testInstallOperator () {
180186 String backupReports = backupReports (UniqueName .uniqueName (this .getClass ().getSimpleName ()));
181- execTestScriptAndAssertSuccess ("-oper" , "Failed to run -oper" );
187+ assertTrue ( execTestScriptAndAssertSuccess ("-oper" , "Failed to run -oper" ) );
182188 restoreReports (backupReports );
183189 }
184190
@@ -187,44 +193,66 @@ void testInstallOperator() {
187193 */
188194 @ Test
189195 @ 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" ));
192199 }
193200
194201 /**
195202 * Test Domain on PV sample precleandb use case.
196203 */
197204 @ Test
198205 @ 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" ));
201209 }
202210
203211 /**
204212 * Test Domain on PV sample create db use case.
205213 */
206214 @ Test
207215 @ Order (4 )
208- void testCreatedb () {
216+ public void testCreatedb () {
217+ Assumptions .assumeTrue (previousTestSuccessful );
209218 logger .info ("test case for creating a db" );
210219 if (KIND_REPO != null ) {
211220 String dbimage = DB_IMAGE_NAME + ":" + DB_IMAGE_TAG ;
212221 logger .info ("loading image {0} to kind" , dbimage );
213222 imagePush (dbimage );
214223 }
215- execTestScriptAndAssertSuccess ("-db" , "Failed to run -db" );
224+ assertTrue ( execTestScriptAndAssertSuccess ("-db" , "Failed to run -db" ) );
216225 }
217226
218227 /**
219- * Test Domain on PV sample building image for FMW domain use case .
228+ * Test Domain on PV sample - Initialize schemas in the DB .
220229 */
221230 @ Test
222231 @ 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 );
224245 logger .info ("test case for building image" );
225246 imagePull (BUSYBOX_IMAGE + ":" + BUSYBOX_TAG );
226247 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 ());
228256
229257 // load the image to kind if using kind cluster
230258 String imageCreated ;
@@ -237,8 +265,9 @@ void testInitialImage() {
237265 * Test Domain on PV sample create FMW domain use case.
238266 */
239267 @ Test
240- @ Order (6 )
241- void testInitialMain () {
268+ @ Order (7 )
269+ public void testInitialMain () {
270+ Assumptions .assumeTrue (previousTestSuccessful );
242271 logger .info ("test case for creating a FMW domain" );
243272
244273 // load the base image to kind if using kind cluster
@@ -248,18 +277,21 @@ void testInitialMain() {
248277 createPVHostPathAndChangePermissionInKindCluster ("/shared" , envMap );
249278 }
250279
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" );
252285 }
253286
254287 /**
255288 * Run script run-test.sh.
256289 * @param arg arguments to execute script
257290 * @param errString a string of detailed error
258291 */
259- private void execTestScriptAndAssertSuccess (String arg ,
292+ private boolean execTestScriptAndAssertSuccess (String arg ,
260293 String errString ) {
261294
262- Assumptions .assumeTrue (previousTestSuccessful );
263295 previousTestSuccessful = false ;
264296
265297 String command = domainOnPvSampleScript
@@ -273,27 +305,33 @@ private void execTestScriptAndAssertSuccess(String arg,
273305 .redirect (true )
274306 ).executeAndReturnResult ();
275307
276- boolean success = result != null
308+ boolean success =
309+ result != null
277310 && result .exitValue () == 0
278311 && result .stdout () != null
279312 && result .stdout ().contains ("Finished without errors" );
280313
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 " ;
283316 outStr += ", stderr=\n {\n " + (result != null ? result .stderr () : "" ) + "\n }\n " ;
284317 outStr += ", stdout=\n {\n " + (result != null ? result .stdout () : "" ) + "\n }\n " ;
285318
286319 logger .info ("output String is: {0}" , outStr );
287320
288321 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 );
290328 }
291329
292330 /**
293331 * Delete DB deployment for FMW test cases and Uninstall Traefik.
294332 */
295333 @ AfterAll
296- static void tearDownAll () {
334+ public static void tearDownAll () {
297335 logger = getLogger ();
298336
299337 // uninstall Traefik
0 commit comments