21
21
import oracle .weblogic .kubernetes .annotations .IntegrationTest ;
22
22
import oracle .weblogic .kubernetes .annotations .Namespaces ;
23
23
import oracle .weblogic .kubernetes .logging .LoggingFacade ;
24
+ import oracle .weblogic .kubernetes .utils .ExecResult ;
24
25
import org .junit .jupiter .api .BeforeAll ;
25
26
import org .junit .jupiter .api .DisplayName ;
26
27
import org .junit .jupiter .api .MethodOrderer ;
56
57
import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
57
58
import static oracle .weblogic .kubernetes .utils .DomainUtils .deleteDomainResource ;
58
59
import static oracle .weblogic .kubernetes .utils .FmwUtils .createDomainResourceSimplifyJrfPv ;
60
+ import static oracle .weblogic .kubernetes .utils .FmwUtils .restoreOpssWalletfileSecret ;
59
61
import static oracle .weblogic .kubernetes .utils .FmwUtils .saveAndRestoreOpssWalletfileSecret ;
60
62
import static oracle .weblogic .kubernetes .utils .FmwUtils .verifyDomainReady ;
61
63
import static oracle .weblogic .kubernetes .utils .ImageUtils .createBaseRepoSecret ;
65
67
import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodDoesNotExist ;
66
68
import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodLogContains ;
67
69
import static oracle .weblogic .kubernetes .utils .PodUtils .getExternalServicePodName ;
70
+ import static oracle .weblogic .kubernetes .utils .SecretUtils .createOpsswalletFileSecretWithoutFile ;
68
71
import static oracle .weblogic .kubernetes .utils .SecretUtils .createOpsswalletpasswordSecret ;
69
72
import static oracle .weblogic .kubernetes .utils .SecretUtils .createSecretWithUsernamePassword ;
70
73
import static oracle .weblogic .kubernetes .utils .ThreadSafeLogger .getLogger ;
74
+ import static org .apache .commons .io .FileUtils .delete ;
71
75
import static org .apache .commons .io .FileUtils .deleteDirectory ;
72
76
import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
73
77
import static org .junit .jupiter .api .Assertions .assertNotNull ;
78
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
74
79
75
80
/**
76
81
* Test to create a FMW domain on PV with DomainOnPvSimplification feature when user pre-creates RCU.
@@ -94,16 +99,23 @@ public class ItFmwDomainInPvUserCreateRcu {
94
99
private static LoggingFacade logger = null ;
95
100
private static String DOMAINHOMEPREFIX = null ;
96
101
private static final String domainUid1 = "jrfdomainonpv-userrcu1" ;
102
+ private static final String domainUid4 = "jrfdomainonpv-userrcu4" ;
97
103
private static final String miiAuxiliaryImage1Tag = "jrf1" + MII_BASIC_IMAGE_TAG ;
98
104
private final String adminSecretName1 = domainUid1 + "-weblogic-credentials" ;
99
105
private final String rcuaccessSecretName1 = domainUid1 + "-rcu-credentials" ;
100
106
private final String opsswalletpassSecretName1 = domainUid1 + "-opss-wallet-password-secret" ;
101
107
private final String opsswalletfileSecretName1 = domainUid1 + "-opss-wallet-file-secret" ;
108
+ private final String adminSecretName4 = domainUid4 + "-weblogic-credentials" ;
109
+ private final String rcuaccessSecretName4 = domainUid4 + "-rcu-credentials" ;
110
+ private final String opsswalletpassSecretName4 = domainUid4 + "-opss-wallet-password-secret" ;
111
+ private final String opsswalletfileSecretName4 = domainUid4 + "-opss-wallet-file-secret" ;
102
112
private static final int replicaCount = 1 ;
103
113
104
114
private final String fmwModelFilePrefix = "model-fmwdomainonpv-rcu-wdt" ;
105
115
private final String fmwModelFile = fmwModelFilePrefix + ".yaml" ;
106
116
private static DomainCreationImage domainCreationImage1 = null ;
117
+ private static List <DomainCreationImage > domainCreationImages4 = new ArrayList <>();
118
+ private static String configMapName = null ;
107
119
108
120
/**
109
121
* Assigns unique namespaces for DB, operator and domain.
@@ -273,6 +285,13 @@ void testFmwDomainOnPvUserProvideOpss() {
273
285
assertDoesNotThrow (() -> deletePod ("rcu" , dbNamespace ),
274
286
"Got exception while deleting server " + "rcu" );
275
287
checkPodDoesNotExist ("rcu" , null , dbNamespace );
288
+ //delete the wallet file ewallet.p12
289
+ try {
290
+ delete (new File ("./ewallet.p12" ));
291
+ logger .info ("Wallet file ewallet.p12 is deleted" );
292
+ } catch (IOException ioe ) {
293
+ logger .severe ("Failed to delete file ewallet.p12" , ioe );
294
+ }
276
295
277
296
}
278
297
@@ -476,7 +495,6 @@ void testFmwDomainOnPvUserCreatesRCUMultiImages() {
476
495
477
496
}
478
497
479
-
480
498
/**
481
499
* User creates RCU, Operate creates PV/PVC and FMW domain with additional WDT config map.
482
500
* Verify Pod is ready and service exists for both admin server and managed servers.
@@ -485,19 +503,16 @@ void testFmwDomainOnPvUserCreatesRCUMultiImages() {
485
503
@ Order (5 )
486
504
@ DisplayName ("Create a FMW domain on PV with additional WDT config map when user per-creates RCU" )
487
505
void testFmwDomainOnPvUserCreatesRCUwdtConfigMap () {
488
- String domainUid = "jrfdomainonpv-userrcu4" ;
489
- String adminSecretName = domainUid + "-weblogic-credentials" ;
490
- String rcuaccessSecretName = domainUid + "-rcu-credentials" ;
491
- String opsswalletpassSecretName = domainUid + "-opss-wallet-password-secret" ;
492
- final String pvName = getUniqueName (domainUid + "-pv-" );
493
- final String pvcName = getUniqueName (domainUid + "-pvc-" );
506
+
507
+ final String pvName = getUniqueName (domainUid4 + "-pv-" );
508
+ final String pvcName = getUniqueName (domainUid4 + "-pvc-" );
494
509
495
510
//create RCU schema
496
511
assertDoesNotThrow (() -> createRcuSchema (FMWINFRA_IMAGE_TO_USE_IN_SPEC , RCUSCHEMAPREFIX + "4" ,
497
512
dbUrl , dbNamespace ), "create RCU schema failed" );
498
513
499
514
// create a model property file
500
- File fmwModelPropFile = createWdtPropertyFile (domainUid , RCUSCHEMAPREFIX + "4" );
515
+ File fmwModelPropFile = createWdtPropertyFile (domainUid4 , RCUSCHEMAPREFIX + "4" );
501
516
502
517
// Create the repo secret to pull the image
503
518
// this secret is used only for non-kind cluster
@@ -506,64 +521,129 @@ void testFmwDomainOnPvUserCreatesRCUwdtConfigMap() {
506
521
// create secret for admin credentials
507
522
logger .info ("Create secret for admin credentials" );
508
523
assertDoesNotThrow (() -> createSecretWithUsernamePassword (
509
- adminSecretName ,
524
+ adminSecretName4 ,
510
525
domainNamespace ,
511
526
ADMIN_USERNAME_DEFAULT ,
512
527
ADMIN_PASSWORD_DEFAULT ),
513
- String .format ("createSecret failed for %s" , adminSecretName ));
528
+ String .format ("createSecret failed for %s" , adminSecretName4 ));
514
529
515
530
// create RCU access secret
516
531
logger .info ("Creating RCU access secret: {0}, with prefix: {1}, dbUrl: {2}, schemapassword: {3})" ,
517
- rcuaccessSecretName , RCUSCHEMAPREFIX + "4" , RCUSCHEMAPASSWORD , dbUrl );
532
+ rcuaccessSecretName4 , RCUSCHEMAPREFIX + "4" , RCUSCHEMAPASSWORD , dbUrl );
518
533
assertDoesNotThrow (() -> createRcuAccessSecret (
519
- rcuaccessSecretName ,
534
+ rcuaccessSecretName4 ,
520
535
domainNamespace ,
521
536
RCUSCHEMAPREFIX + "4" ,
522
537
RCUSCHEMAPASSWORD ,
523
538
dbUrl ),
524
- String .format ("createSecret failed for %s" , rcuaccessSecretName ));
539
+ String .format ("createSecret failed for %s" , rcuaccessSecretName4 ));
525
540
526
541
logger .info ("Create OPSS wallet password secret" );
527
542
assertDoesNotThrow (() -> createOpsswalletpasswordSecret (
528
- opsswalletpassSecretName ,
543
+ opsswalletpassSecretName4 ,
529
544
domainNamespace ,
530
545
ADMIN_PASSWORD_DEFAULT ),
531
- String .format ("createSecret failed for %s" , opsswalletpassSecretName ));
546
+ String .format ("createSecret failed for %s" , opsswalletpassSecretName4 ));
532
547
533
- DomainCreationImage domainCreationImage1 = createImage (fmwModelFile ,fmwModelPropFile ,"jrf4" );
534
- List <DomainCreationImage > domainCreationImages = new ArrayList <>();
535
- domainCreationImages .add (domainCreationImage1 );
548
+ DomainCreationImage domainCreationImage = createImage (fmwModelFile ,fmwModelPropFile ,"jrf4" );
549
+ domainCreationImages4 .add (domainCreationImage );
536
550
537
551
logger .info ("create WDT configMap with jms model" );
538
- String configMapName = "jmsconfigmap" ;
552
+ configMapName = "jmsconfigmap" ;
539
553
createConfigMapAndVerify (
540
- configMapName , domainUid , domainNamespace ,
554
+ configMapName , domainUid4 , domainNamespace ,
541
555
Arrays .asList (MODEL_DIR + "/model.jms2.yaml" ));
542
556
543
557
// create a domain custom resource configuration object
544
558
logger .info ("Creating domain custom resource with pvName: {0}" , pvName );
545
559
DomainResource domain = createDomainResourceSimplifyJrfPv (
546
- domainUid , domainNamespace , adminSecretName ,
560
+ domainUid4 , domainNamespace , adminSecretName4 ,
547
561
TEST_IMAGES_REPO_SECRET_NAME ,
548
- rcuaccessSecretName ,
549
- opsswalletpassSecretName , null ,
550
- pvName , pvcName , domainCreationImages , configMapName );
562
+ rcuaccessSecretName4 ,
563
+ opsswalletpassSecretName4 , null ,
564
+ pvName , pvcName , domainCreationImages4 , configMapName );
551
565
552
566
createDomainAndVerify (domain , domainNamespace );
553
567
554
568
// verify that all servers are ready
555
- verifyDomainReady (domainNamespace , domainUid , replicaCount , "nosuffix" );
569
+ verifyDomainReady (domainNamespace , domainUid4 , replicaCount , "nosuffix" );
556
570
557
571
//create router for admin service on OKD
558
- String adminServerPodName = domainUid + "-admin-server" ;
572
+ String adminServerPodName = domainUid4 + "-admin-server" ;
559
573
String adminSvcExtHost = createRouteForOKD (getExternalServicePodName (adminServerPodName ), domainNamespace );
560
574
logger .info ("admin svc host = {0}" , adminSvcExtHost );
561
575
562
576
// check configuration for JMS
563
577
checkConfiguredJMSresouce (domainNamespace , adminServerPodName , adminSvcExtHost );
564
578
579
+ }
580
+
581
+ /**
582
+ * The user provides opss.walletFileSecret that is empty.
583
+ * If "ewallet.p12" is an empty file, running opss-wallet.sh to restore the wallet file
584
+ * secret will fail and return "Error: Wallet file 'ewallet.p12' is empty"
585
+ * Create opss.walletFileSecret without entry with --from-file=walletFile to get an empty walletFileSecret
586
+ * The operator will not mount the secret but proceed with normal domain creation without error
587
+ */
588
+ @ Test
589
+ @ Order (6 )
590
+ @ DisplayName ("Create a FMW domain on PV when user provide OPSS wallet file is empty" )
591
+ void testFmwDomainOnPvUserProvideEmptyOpss () {
592
+
593
+ final String pvName = getUniqueName (domainUid4 + "-pv-" );
594
+ final String pvcName = getUniqueName (domainUid4 + "-pvc-" );
595
+
596
+ //create empty wallet file ewallet.p12
597
+ try {
598
+ File file = new File ("ewallet.p12" );
599
+ if (file .createNewFile ()) {
600
+ logger .info ("Empty wallet file ewallet.p12 is created: " + file .getAbsolutePath ());
601
+ } else {
602
+ logger .info ("Failed to create file ewallet.p12 " );
603
+ }
604
+ } catch (IOException ioe ) {
605
+ logger .severe ("Failed to create file ewallet.p12" , ioe );
606
+ }
607
+
608
+ ExecResult result = restoreOpssWalletfileSecret (domainNamespace , domainUid4 , opsswalletfileSecretName4 );
609
+ logger .info ("restoreOpssWalletfileSecret returns msg: " + result .stdout ());
610
+ assertTrue (result .stdout ().contains ("Error: Wallet file 'ewallet.p12' is empty" ));
611
+
612
+ //delete the empty wallet file ewallet.p12
613
+ try {
614
+ delete (new File ("./ewallet.p12" ));
615
+ logger .info ("Wallet file ewallet.p12 is deleted" );
616
+ } catch (IOException ioe ) {
617
+ logger .severe ("Failed to delete file ewallet.p12" , ioe );
618
+ }
619
+
620
+ //create empty walletFileSecret
621
+ createOpsswalletFileSecretWithoutFile (opsswalletfileSecretName4 , domainNamespace );
622
+ logger .info ("Empty walletFile secret {0} is created in the namespace {1}" ,
623
+ opsswalletfileSecretName4 , domainNamespace );
624
+
625
+ logger .info ("Deleting domain custom resource with namespace: {0}, domainUid {1}" , domainNamespace , domainUid4 );
626
+ deleteDomainResource (domainNamespace , domainUid4 );
627
+ try {
628
+ deleteDirectory (Paths .get ("/share" ).toFile ());
629
+ } catch (IOException ioe ) {
630
+ logger .severe ("Failed to cleanup directory /share" , ioe );
631
+ }
632
+ logger .info ("Creating domain custom resource with pvName: {0}" , pvName );
633
+ DomainResource domain = createDomainResourceSimplifyJrfPv (
634
+ domainUid4 , domainNamespace , adminSecretName4 ,
635
+ TEST_IMAGES_REPO_SECRET_NAME ,
636
+ rcuaccessSecretName4 ,
637
+ opsswalletpassSecretName4 , opsswalletfileSecretName4 ,
638
+ pvName , pvcName , domainCreationImages4 , configMapName );
639
+
640
+ createDomainAndVerify (domain , domainNamespace );
641
+
642
+ // verify that all servers are ready
643
+ verifyDomainReady (domainNamespace , domainUid4 , replicaCount , "nosuffix" );
644
+
565
645
// delete the domain
566
- deleteDomainResource (domainNamespace , domainUid );
646
+ deleteDomainResource (domainNamespace , domainUid4 );
567
647
//delete the rcu pod
568
648
assertDoesNotThrow (() -> deletePod ("rcu" , dbNamespace ),
569
649
"Got exception while deleting server " + "rcu" );
0 commit comments