42
42
import static oracle .weblogic .kubernetes .TestConstants .TEST_IMAGES_REPO_SECRET_NAME ;
43
43
import static oracle .weblogic .kubernetes .actions .ActionConstants .MODEL_DIR ;
44
44
import static oracle .weblogic .kubernetes .actions .TestActions .deletePod ;
45
+ import static oracle .weblogic .kubernetes .actions .TestActions .getOperatorPodName ;
45
46
import static oracle .weblogic .kubernetes .utils .AuxiliaryImageUtils .createAndPushAuxiliaryImage ;
46
47
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .addSccToDBSvcAccount ;
47
48
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getNextFreePort ;
48
49
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getUniqueName ;
50
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
49
51
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .verifyConfiguredSystemResource ;
50
52
import static oracle .weblogic .kubernetes .utils .ConfigMapUtils .createConfigMapAndVerify ;
51
53
import static oracle .weblogic .kubernetes .utils .DbUtils .createRcuAccessSecret ;
61
63
import static oracle .weblogic .kubernetes .utils .OKDUtils .createRouteForOKD ;
62
64
import static oracle .weblogic .kubernetes .utils .OperatorUtils .installAndVerifyOperator ;
63
65
import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodDoesNotExist ;
66
+ import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodLogContains ;
64
67
import static oracle .weblogic .kubernetes .utils .PodUtils .getExternalServicePodName ;
65
68
import static oracle .weblogic .kubernetes .utils .SecretUtils .createOpsswalletpasswordSecret ;
66
69
import static oracle .weblogic .kubernetes .utils .SecretUtils .createSecretWithUsernamePassword ;
@@ -224,7 +227,6 @@ void testFmwDomainOnPvUserCreatesRCU() {
224
227
opsswalletpassSecretName1 , null ,
225
228
pvName , pvcName , Collections .singletonList (domainCreationImage1 ), null );
226
229
227
- // create a domain custom resource and verify domain is created
228
230
createDomainAndVerify (domain , domainNamespace );
229
231
230
232
// verify that all servers are ready
@@ -259,7 +261,7 @@ void testFmwDomainOnPvUserProvideOpss() {
259
261
rcuaccessSecretName1 ,
260
262
opsswalletpassSecretName1 , opsswalletfileSecretName1 ,
261
263
pvName , pvcName , Collections .singletonList (domainCreationImage1 ), null );
262
- // create a domain custom resource and verify domain is created
264
+
263
265
createDomainAndVerify (domain , domainNamespace );
264
266
265
267
// verify that all servers are ready and EM console is accessible
@@ -274,12 +276,108 @@ void testFmwDomainOnPvUserProvideOpss() {
274
276
275
277
}
276
278
279
+ /**
280
+ * The user provides opss.walletFileSecret that does not exist.
281
+ * In this case the domain will not be created and operator will log message like
282
+ * "Domain xxx is not valid: OpssWalletFile secret 'xxx' not found in namespace xxx"
283
+ */
284
+ @ Test
285
+ @ Order (3 )
286
+ @ DisplayName ("Create a FMW domain on PV when user provide OPSS wallet file secret that does not exist" )
287
+ void testFmwDomainOnPvUserProvideOpssNotexist () {
288
+ String domainUid = "jrfdomainonpv-userrcu2" ;
289
+ String adminSecretName = domainUid + "-weblogic-credentials" ;
290
+ String rcuaccessSecretName = domainUid + "-rcu-credentials" ;
291
+ String opsswalletpassSecretName = domainUid + "-opss-wallet-password-secret" ;
292
+ String opsswalletfileSecretName = domainUid + "-opss-wallet-file-secret" ;
293
+ final String pvName = getUniqueName (domainUid1 + "-pv-" );
294
+ final String pvcName = getUniqueName (domainUid1 + "-pvc-" );
295
+
296
+ //create RCU schema
297
+ assertDoesNotThrow (() -> createRcuSchema (FMWINFRA_IMAGE_TO_USE_IN_SPEC , RCUSCHEMAPREFIX + "2" ,
298
+ dbUrl , dbNamespace ),"create RCU schema failed" );
299
+
300
+ // create a model property file
301
+ File fmwModelPropFile = createWdtPropertyFile (domainUid , RCUSCHEMAPREFIX + "2" );
302
+
303
+ // Create the repo secret to pull the image
304
+ // this secret is used only for non-kind cluster
305
+ createTestRepoSecret (domainNamespace );
306
+
307
+ // create secret for admin credentials
308
+ logger .info ("Create secret for admin credentials" );
309
+ assertDoesNotThrow (() -> createSecretWithUsernamePassword (
310
+ adminSecretName ,
311
+ domainNamespace ,
312
+ ADMIN_USERNAME_DEFAULT ,
313
+ ADMIN_PASSWORD_DEFAULT ),
314
+ String .format ("createSecret failed for %s" , adminSecretName ));
315
+
316
+ // create RCU access secret
317
+ logger .info ("Creating RCU access secret: {0}, with prefix: {1}, dbUrl: {2}, schemapassword: {3})" ,
318
+ rcuaccessSecretName , RCUSCHEMAPREFIX + "2" , RCUSCHEMAPASSWORD , dbUrl );
319
+ assertDoesNotThrow (() -> createRcuAccessSecret (
320
+ rcuaccessSecretName ,
321
+ domainNamespace ,
322
+ RCUSCHEMAPREFIX + "2" ,
323
+ RCUSCHEMAPASSWORD ,
324
+ dbUrl ),
325
+ String .format ("createSecret failed for %s" , rcuaccessSecretName ));
326
+
327
+ logger .info ("Create OPSS wallet password secret" );
328
+ assertDoesNotThrow (() -> createOpsswalletpasswordSecret (
329
+ opsswalletpassSecretName ,
330
+ domainNamespace ,
331
+ ADMIN_PASSWORD_DEFAULT ),
332
+ String .format ("createSecret failed for %s" , opsswalletpassSecretName ));
333
+
334
+ List <String > modelList = new ArrayList <>();
335
+ modelList .add (MODEL_DIR + "/" + fmwModelFile );
336
+ List <String > modelProList = new ArrayList <>();
337
+ modelProList .add (fmwModelPropFile .toPath ().toString ());
338
+ String miiAuxiliaryImageTag = "jrf2" + MII_BASIC_IMAGE_TAG ;
339
+ WitParams witParams =
340
+ new WitParams ()
341
+ .modelImageName (MII_AUXILIARY_IMAGE_NAME )
342
+ .modelImageTag (miiAuxiliaryImageTag )
343
+ .modelFiles (modelList )
344
+ .modelVariableFiles (modelProList );
345
+ createAndPushAuxiliaryImage (MII_AUXILIARY_IMAGE_NAME , miiAuxiliaryImageTag , witParams );
346
+ DomainCreationImage domainCreationImage =
347
+ new DomainCreationImage ().image (MII_AUXILIARY_IMAGE_NAME + ":" + miiAuxiliaryImageTag );
348
+
349
+ // create a domain custom resource configuration object
350
+ logger .info ("Creating domain custom resource with pvName: {0}" , pvName );
351
+ DomainResource domain = createDomainResourceSimplifyJrfPv (
352
+ domainUid , domainNamespace , adminSecretName ,
353
+ TEST_IMAGES_REPO_SECRET_NAME ,
354
+ rcuaccessSecretName ,
355
+ opsswalletpassSecretName , opsswalletfileSecretName ,
356
+ pvName , pvcName , Collections .singletonList (domainCreationImage ), null );
357
+
358
+ createDomainAndVerify (domain , domainNamespace );
359
+
360
+ String expectedErrorMsg = String .format ("Domain %s is not valid: OpssWalletFile secret '%s'"
361
+ + " not found in namespace '%s'" , domainUid , opsswalletfileSecretName , domainNamespace );
362
+ String operatorPodName =
363
+ assertDoesNotThrow (() -> getOperatorPodName (OPERATOR_RELEASE_NAME , opNamespace ));
364
+ verifyPodWithExpectedErrorMsg (expectedErrorMsg , operatorPodName , opNamespace );
365
+
366
+ // delete the domain
367
+ deleteDomainResource (domainNamespace , domainUid );
368
+ //delete the rcu pod
369
+ assertDoesNotThrow (() -> deletePod ("rcu" , dbNamespace ),
370
+ "Got exception while deleting server " + "rcu" );
371
+ checkPodDoesNotExist ("rcu" , null , dbNamespace );
372
+
373
+ }
374
+
277
375
/**
278
376
* User creates RCU, Operate creates PV/PVC and FMW domain with multiple images
279
377
* Verify Pod is ready and service exists for both admin server and managed servers.
280
378
*/
281
379
@ Test
282
- @ Order (3 )
380
+ @ Order (4 )
283
381
@ DisplayName ("Create a FMW domain on PV with multiple images when user per-creates RCU" )
284
382
void testFmwDomainOnPvUserCreatesRCUMultiImages () {
285
383
String domainUid = "jrfdomainonpv-userrcu3" ;
@@ -356,7 +454,6 @@ void testFmwDomainOnPvUserCreatesRCUMultiImages() {
356
454
opsswalletpassSecretName , null ,
357
455
pvName , pvcName , domainCreationImages , null );
358
456
359
- // create a domain custom resource and verify domain is created
360
457
createDomainAndVerify (domain , domainNamespace );
361
458
362
459
// verify that all servers are ready
@@ -385,8 +482,8 @@ void testFmwDomainOnPvUserCreatesRCUMultiImages() {
385
482
* Verify Pod is ready and service exists for both admin server and managed servers.
386
483
*/
387
484
@ Test
388
- @ Order (4 )
389
- @ DisplayName ("Create a FMW domain on PV with multiple images when user per-creates RCU" )
485
+ @ Order (5 )
486
+ @ DisplayName ("Create a FMW domain on PV with additional WDT config map when user per-creates RCU" )
390
487
void testFmwDomainOnPvUserCreatesRCUwdtConfigMap () {
391
488
String domainUid = "jrfdomainonpv-userrcu4" ;
392
489
String adminSecretName = domainUid + "-weblogic-credentials" ;
@@ -452,7 +549,6 @@ void testFmwDomainOnPvUserCreatesRCUwdtConfigMap() {
452
549
opsswalletpassSecretName , null ,
453
550
pvName , pvcName , domainCreationImages , configMapName );
454
551
455
- // create a domain custom resource and verify domain is created
456
552
createDomainAndVerify (domain , domainNamespace );
457
553
458
554
// verify that all servers are ready
@@ -553,5 +649,17 @@ private static void checkConfiguredJMSresouce(String domainNamespace, String adm
553
649
verifyConfiguredSystemResource (domainNamespace , adminServerPodName , adminSvcExtHost ,
554
650
"JMSSystemResources" , "TestClusterJmsModule2" , "200" );
555
651
}
652
+
653
+ private void verifyPodWithExpectedErrorMsg (String expectedErrorMsg , String podName , String nameSpace ) {
654
+
655
+ logger .info ("Verifying operator pod log for error messages" );
656
+ testUntil (
657
+ () -> assertDoesNotThrow (() -> checkPodLogContains (expectedErrorMsg , podName , nameSpace ),
658
+ String .format ("Checking operator pod %s log failed for namespace %s, expectErrorMsg %s" , podName ,
659
+ nameSpace , expectedErrorMsg )),
660
+ logger ,
661
+ "Checking operator log containing the expected error msg {0}:" ,
662
+ expectedErrorMsg );
663
+ }
556
664
557
665
}
0 commit comments