Skip to content

Commit e2377e9

Browse files
committed
Merge branch 'jrf_newopss' into 'main'
Create JRF domain and RCU with CreateIfNotExists.DOMAIN_AND_RCU and provided OPSS file secret See merge request weblogic-cloud/weblogic-kubernetes-operator!4314
2 parents 5c40123 + 14fe94f commit e2377e9

File tree

2 files changed

+262
-110
lines changed

2 files changed

+262
-110
lines changed

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItFmwDomainInPvUserCreateRcu.java

Lines changed: 157 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
5858
import static oracle.weblogic.kubernetes.utils.DomainUtils.deleteDomainResource;
5959
import static oracle.weblogic.kubernetes.utils.FmwUtils.createDomainResourceSimplifyJrfPv;
60+
import static oracle.weblogic.kubernetes.utils.FmwUtils.createSimplifyJrfPvDomainAndRCU;
6061
import static oracle.weblogic.kubernetes.utils.FmwUtils.restoreOpssWalletfileSecret;
6162
import static oracle.weblogic.kubernetes.utils.FmwUtils.saveAndRestoreOpssWalletfileSecret;
6263
import static oracle.weblogic.kubernetes.utils.FmwUtils.verifyDomainReady;
@@ -99,21 +100,27 @@ public class ItFmwDomainInPvUserCreateRcu {
99100
private static LoggingFacade logger = null;
100101
private static String DOMAINHOMEPREFIX = null;
101102
private static final String domainUid1 = "jrfdomainonpv-userrcu1";
103+
private static final String domainUid3 = "jrfdomainonpv-userrcu3";
102104
private static final String domainUid4 = "jrfdomainonpv-userrcu4";
103105
private static final String miiAuxiliaryImage1Tag = "jrf1" + MII_BASIC_IMAGE_TAG;
104106
private final String adminSecretName1 = domainUid1 + "-weblogic-credentials";
105-
private final String rcuaccessSecretName1 = domainUid1 + "-rcu-credentials";
106-
private final String opsswalletpassSecretName1 = domainUid1 + "-opss-wallet-password-secret";
107-
private final String opsswalletfileSecretName1 = domainUid1 + "-opss-wallet-file-secret";
107+
private final String adminSecretName3 = domainUid3 + "-weblogic-credentials";
108108
private final String adminSecretName4 = domainUid4 + "-weblogic-credentials";
109+
private final String rcuaccessSecretName1 = domainUid1 + "-rcu-credentials";
110+
private final String rcuaccessSecretName3 = domainUid3 + "-rcu-credentials";
109111
private final String rcuaccessSecretName4 = domainUid4 + "-rcu-credentials";
112+
private final String opsswalletpassSecretName1 = domainUid1 + "-opss-wallet-password-secret";
113+
private final String opsswalletpassSecretName3 = domainUid3 + "-opss-wallet-password-secret";
110114
private final String opsswalletpassSecretName4 = domainUid4 + "-opss-wallet-password-secret";
115+
private final String opsswalletfileSecretName1 = domainUid1 + "-opss-wallet-file-secret";
116+
private final String opsswalletfileSecretName3 = domainUid3 + "-opss-wallet-file-secret";
111117
private final String opsswalletfileSecretName4 = domainUid4 + "-opss-wallet-file-secret";
112118
private static final int replicaCount = 1;
113119

114120
private final String fmwModelFilePrefix = "model-fmwdomainonpv-rcu-wdt";
115121
private final String fmwModelFile = fmwModelFilePrefix + ".yaml";
116122
private static DomainCreationImage domainCreationImage1 = null;
123+
private static List<DomainCreationImage> domainCreationImages3 = new ArrayList<>();
117124
private static List<DomainCreationImage> domainCreationImages4 = new ArrayList<>();
118125
private static String configMapName = null;
119126

@@ -390,117 +397,13 @@ void testFmwDomainOnPvUserProvideOpssNotexist() {
390397
checkPodDoesNotExist("rcu", null, dbNamespace);
391398

392399
}
393-
394-
/**
395-
* User creates RCU, Operate creates PV/PVC and FMW domain with multiple images
396-
* Verify Pod is ready and service exists for both admin server and managed servers.
397-
*/
398-
@Test
399-
@Order(4)
400-
@DisplayName("Create a FMW domain on PV with multiple images when user per-creates RCU")
401-
void testFmwDomainOnPvUserCreatesRCUMultiImages() {
402-
String domainUid = "jrfdomainonpv-userrcu3";
403-
String adminSecretName = domainUid + "-weblogic-credentials";
404-
String rcuaccessSecretName = domainUid + "-rcu-credentials";
405-
String opsswalletpassSecretName = domainUid + "-opss-wallet-password-secret";
406-
final String pvName = getUniqueName(domainUid + "-pv-");
407-
final String pvcName = getUniqueName(domainUid + "-pvc-");
408-
409-
//create RCU schema
410-
assertDoesNotThrow(() -> createRcuSchema(FMWINFRA_IMAGE_TO_USE_IN_SPEC, RCUSCHEMAPREFIX + "3",
411-
dbUrl, dbNamespace), "create RCU schema failed");
412-
413-
// create a model property file
414-
File fmwModelPropFile = createWdtPropertyFile(domainUid, RCUSCHEMAPREFIX + "3");
415-
416-
// Create the repo secret to pull the image
417-
// this secret is used only for non-kind cluster
418-
createTestRepoSecret(domainNamespace);
419-
420-
// create secret for admin credentials
421-
logger.info("Create secret for admin credentials");
422-
assertDoesNotThrow(() -> createSecretWithUsernamePassword(
423-
adminSecretName,
424-
domainNamespace,
425-
ADMIN_USERNAME_DEFAULT,
426-
ADMIN_PASSWORD_DEFAULT),
427-
String.format("createSecret failed for %s", adminSecretName));
428-
429-
// create RCU access secret
430-
logger.info("Creating RCU access secret: {0}, with prefix: {1}, dbUrl: {2}, schemapassword: {3})",
431-
rcuaccessSecretName, RCUSCHEMAPREFIX + "3", RCUSCHEMAPASSWORD, dbUrl);
432-
assertDoesNotThrow(() -> createRcuAccessSecret(
433-
rcuaccessSecretName,
434-
domainNamespace,
435-
RCUSCHEMAPREFIX + "3",
436-
RCUSCHEMAPASSWORD,
437-
dbUrl),
438-
String.format("createSecret failed for %s", rcuaccessSecretName));
439-
440-
logger.info("Create OPSS wallet password secret");
441-
assertDoesNotThrow(() -> createOpsswalletpasswordSecret(
442-
opsswalletpassSecretName,
443-
domainNamespace,
444-
ADMIN_PASSWORD_DEFAULT),
445-
String.format("createSecret failed for %s", opsswalletpassSecretName));
446-
447-
DomainCreationImage domainCreationImage1 = createImage(fmwModelFile,fmwModelPropFile,"jrf3");
448-
449-
// image2 with model files for jms config
450-
List modelList = new ArrayList<>();
451-
modelList.add(MODEL_DIR + "/model.jms2.yaml");
452-
String miiAuxiliaryImageTag = "jrf3jms" + MII_BASIC_IMAGE_TAG;
453-
WitParams witParams =
454-
new WitParams()
455-
.modelImageName(MII_AUXILIARY_IMAGE_NAME)
456-
.modelImageTag(miiAuxiliaryImageTag)
457-
.wdtModelOnly(true)
458-
.modelFiles(modelList)
459-
.wdtVersion("NONE");
460-
createAndPushAuxiliaryImage(MII_AUXILIARY_IMAGE_NAME, miiAuxiliaryImageTag, witParams);
461-
DomainCreationImage domainCreationImage2 = new DomainCreationImage().image(MII_AUXILIARY_IMAGE_NAME
462-
+ ":" + miiAuxiliaryImageTag);
463-
List<DomainCreationImage> domainCreationImages = new ArrayList<>();
464-
domainCreationImages.add(domainCreationImage1);
465-
domainCreationImages.add(domainCreationImage2);
466-
467-
// create a domain custom resource configuration object
468-
logger.info("Creating domain custom resource with pvName: {0}", pvName);
469-
DomainResource domain = createDomainResourceSimplifyJrfPv(
470-
domainUid, domainNamespace, adminSecretName,
471-
TEST_IMAGES_REPO_SECRET_NAME,
472-
rcuaccessSecretName,
473-
opsswalletpassSecretName, null,
474-
pvName, pvcName, domainCreationImages, null);
475-
476-
createDomainAndVerify(domain, domainNamespace);
477-
478-
// verify that all servers are ready
479-
verifyDomainReady(domainNamespace, domainUid, replicaCount, "nosuffix");
480-
481-
//create router for admin service on OKD
482-
String adminServerPodName = domainUid + "-admin-server";
483-
String adminSvcExtHost = createRouteForOKD(getExternalServicePodName(adminServerPodName), domainNamespace);
484-
logger.info("admin svc host = {0}", adminSvcExtHost);
485-
486-
// check configuration for JMS
487-
checkConfiguredJMSresouce(domainNamespace, adminServerPodName, adminSvcExtHost);
488-
489-
// delete the domain
490-
deleteDomainResource(domainNamespace, domainUid);
491-
//delete the rcu pod
492-
assertDoesNotThrow(() -> deletePod("rcu", dbNamespace),
493-
"Got exception while deleting server " + "rcu");
494-
checkPodDoesNotExist("rcu", null, dbNamespace);
495-
496-
}
497-
400+
498401
/**
499402
* User creates RCU, Operate creates PV/PVC and FMW domain with additional WDT config map.
500403
* Verify Pod is ready and service exists for both admin server and managed servers.
501404
*/
502405
@Test
503-
@Order(5)
406+
@Order(4)
504407
@DisplayName("Create a FMW domain on PV with additional WDT config map when user per-creates RCU")
505408
void testFmwDomainOnPvUserCreatesRCUwdtConfigMap() {
506409

@@ -586,7 +489,7 @@ void testFmwDomainOnPvUserCreatesRCUwdtConfigMap() {
586489
* The operator will not mount the secret but proceed with normal domain creation without error
587490
*/
588491
@Test
589-
@Order(6)
492+
@Order(5)
590493
@DisplayName("Create a FMW domain on PV when user provide OPSS wallet file is empty")
591494
void testFmwDomainOnPvUserProvideEmptyOpss() {
592495

@@ -651,6 +554,150 @@ void testFmwDomainOnPvUserProvideEmptyOpss() {
651554

652555
}
653556

557+
/**
558+
* User creates RCU, Operate creates PV/PVC and FMW domain with multiple images
559+
* Verify Pod is ready and service exists for both admin server and managed servers.
560+
*/
561+
@Test
562+
@Order(6)
563+
@DisplayName("Create a FMW domain on PV with multiple images when user per-creates RCU")
564+
void testFmwDomainOnPvUserCreatesRCUMultiImages() {
565+
566+
final String pvName = getUniqueName(domainUid3 + "-pv-");
567+
final String pvcName = getUniqueName(domainUid3 + "-pvc-");
568+
569+
//create RCU schema
570+
assertDoesNotThrow(() -> createRcuSchema(FMWINFRA_IMAGE_TO_USE_IN_SPEC, RCUSCHEMAPREFIX + "3",
571+
dbUrl, dbNamespace), "create RCU schema failed");
572+
573+
// create a model property file
574+
File fmwModelPropFile = createWdtPropertyFile(domainUid3, RCUSCHEMAPREFIX + "3");
575+
576+
// Create the repo secret to pull the image
577+
// this secret is used only for non-kind cluster
578+
createTestRepoSecret(domainNamespace);
579+
580+
// create secret for admin credentials
581+
logger.info("Create secret for admin credentials");
582+
assertDoesNotThrow(() -> createSecretWithUsernamePassword(
583+
adminSecretName3,
584+
domainNamespace,
585+
ADMIN_USERNAME_DEFAULT,
586+
ADMIN_PASSWORD_DEFAULT),
587+
String.format("createSecret failed for %s", adminSecretName3));
588+
589+
// create RCU access secret
590+
logger.info("Creating RCU access secret: {0}, with prefix: {1}, dbUrl: {2}, schemapassword: {3})",
591+
rcuaccessSecretName3, RCUSCHEMAPREFIX + "3", RCUSCHEMAPASSWORD, dbUrl);
592+
assertDoesNotThrow(() -> createRcuAccessSecret(
593+
rcuaccessSecretName3,
594+
domainNamespace,
595+
RCUSCHEMAPREFIX + "3",
596+
RCUSCHEMAPASSWORD,
597+
dbUrl),
598+
String.format("createSecret failed for %s", rcuaccessSecretName3));
599+
600+
logger.info("Create OPSS wallet password secret");
601+
assertDoesNotThrow(() -> createOpsswalletpasswordSecret(
602+
opsswalletpassSecretName3,
603+
domainNamespace,
604+
ADMIN_PASSWORD_DEFAULT),
605+
String.format("createSecret failed for %s", opsswalletpassSecretName3));
606+
607+
DomainCreationImage domainCreationImage1 = createImage(fmwModelFile,fmwModelPropFile,"jrf3");
608+
609+
// image2 with model files for jms config
610+
List modelList = new ArrayList<>();
611+
modelList.add(MODEL_DIR + "/model.jms2.yaml");
612+
String miiAuxiliaryImageTag = "jrf3jms" + MII_BASIC_IMAGE_TAG;
613+
WitParams witParams =
614+
new WitParams()
615+
.modelImageName(MII_AUXILIARY_IMAGE_NAME)
616+
.modelImageTag(miiAuxiliaryImageTag)
617+
.wdtModelOnly(true)
618+
.modelFiles(modelList)
619+
.wdtVersion("NONE");
620+
createAndPushAuxiliaryImage(MII_AUXILIARY_IMAGE_NAME, miiAuxiliaryImageTag, witParams);
621+
DomainCreationImage domainCreationImage2 = new DomainCreationImage().image(MII_AUXILIARY_IMAGE_NAME
622+
+ ":" + miiAuxiliaryImageTag);
623+
domainCreationImages3.add(domainCreationImage1);
624+
domainCreationImages3.add(domainCreationImage2);
625+
626+
// create a domain custom resource configuration object
627+
logger.info("Creating domain custom resource with pvName: {0}", pvName);
628+
DomainResource domain = createDomainResourceSimplifyJrfPv(
629+
domainUid3, domainNamespace, adminSecretName3,
630+
TEST_IMAGES_REPO_SECRET_NAME,
631+
rcuaccessSecretName3,
632+
opsswalletpassSecretName3, null,
633+
pvName, pvcName, domainCreationImages3, null);
634+
635+
createDomainAndVerify(domain, domainNamespace);
636+
637+
// verify that all servers are ready
638+
verifyDomainReady(domainNamespace, domainUid3, replicaCount, "nosuffix");
639+
640+
//create router for admin service on OKD
641+
String adminServerPodName = domainUid3 + "-admin-server";
642+
String adminSvcExtHost = createRouteForOKD(getExternalServicePodName(adminServerPodName), domainNamespace);
643+
logger.info("admin svc host = {0}", adminSvcExtHost);
644+
645+
// check configuration for JMS
646+
checkConfiguredJMSresouce(domainNamespace, adminServerPodName, adminSvcExtHost);
647+
648+
}
649+
650+
/**
651+
* Export the OPSS wallet file secret of Fmw domain from the previous run
652+
* CrateIfNotExists set to domainAndRCU
653+
* Use this OPSS wallet file secret to create Fmw domain on PV to connect to the same database
654+
* Verify Pod is ready and service exists for both admin server and managed servers.
655+
*/
656+
@Test
657+
@Order(7)
658+
@DisplayName("Create a FMW domain on PV with provided OPSS wallet file secret")
659+
void testFmwDomainOnPVwithProvidedOpss() {
660+
661+
final String pvName = getUniqueName(domainUid3 + "-pv-");
662+
final String pvcName = getUniqueName(domainUid3 + "-pvc-");
663+
664+
saveAndRestoreOpssWalletfileSecret(domainNamespace, domainUid3, opsswalletfileSecretName3);
665+
logger.info("Deleting domain custom resource with namespace: {0}, domainUid {1}", domainNamespace, domainUid3);
666+
deleteDomainResource(domainNamespace, domainUid3);
667+
try {
668+
deleteDirectory(Paths.get("/share").toFile());
669+
} catch (IOException ioe) {
670+
logger.severe("Failed to cleanup directory /share", ioe);
671+
}
672+
logger.info("Creating domain custom resource with pvName: {0}", pvName);
673+
DomainResource domain = createSimplifyJrfPvDomainAndRCU(
674+
domainUid3, domainNamespace, adminSecretName3,
675+
TEST_IMAGES_REPO_SECRET_NAME,
676+
rcuaccessSecretName3,
677+
opsswalletpassSecretName3, opsswalletfileSecretName3,
678+
pvName, pvcName, domainCreationImages3, null);
679+
680+
createDomainAndVerify(domain, domainNamespace);
681+
682+
// verify that all servers are ready
683+
verifyDomainReady(domainNamespace, domainUid3, replicaCount, "nosuffix");
684+
685+
// delete the domain
686+
deleteDomainResource(domainNamespace, domainUid3);
687+
//delete the rcu pod
688+
assertDoesNotThrow(() -> deletePod("rcu", dbNamespace),
689+
"Got exception while deleting server " + "rcu");
690+
checkPodDoesNotExist("rcu", null, dbNamespace);
691+
//delete the wallet file ewallet.p12
692+
try {
693+
delete(new File("./ewallet.p12"));
694+
logger.info("Wallet file ewallet.p12 is deleted");
695+
} catch (IOException ioe) {
696+
logger.severe("Failed to delete file ewallet.p12", ioe);
697+
}
698+
}
699+
700+
654701
private DomainCreationImage createImage(String fmwModelFile, File fmwModelPropFile, String imageTagPrefix) {
655702

656703
List<String> modelList = new ArrayList<>();

0 commit comments

Comments
 (0)