Skip to content

Commit d2d5634

Browse files
committed
Merge branch 'xc-109505' into 'main'
JRF Domain on PV: User creates RCU, operator creates PV/PVC, multiple images See merge request weblogic-cloud/weblogic-kubernetes-operator!4265
2 parents 34a424b + c417351 commit d2d5634

File tree

1 file changed

+155
-0
lines changed

1 file changed

+155
-0
lines changed

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

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.io.File;
77
import java.io.FileOutputStream;
88
import java.nio.file.Path;
9+
import java.util.ArrayList;
910
import java.util.Collections;
1011
import java.util.HashMap;
1112
import java.util.List;
@@ -68,6 +69,7 @@
6869
import static oracle.weblogic.kubernetes.TestConstants.OPERATOR_CHART_DIR;
6970
import static oracle.weblogic.kubernetes.TestConstants.OPERATOR_RELEASE_NAME;
7071
import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR;
72+
import static oracle.weblogic.kubernetes.actions.TestActions.deletePod;
7173
import static oracle.weblogic.kubernetes.utils.AuxiliaryImageUtils.createAndPushAuxiliaryImage;
7274
import static oracle.weblogic.kubernetes.utils.ClusterUtils.createClusterAndVerify;
7375
import static oracle.weblogic.kubernetes.utils.ClusterUtils.createClusterResource;
@@ -86,6 +88,7 @@
8688
import static oracle.weblogic.kubernetes.utils.PersistentVolumeUtils.createPV;
8789
import static oracle.weblogic.kubernetes.utils.PersistentVolumeUtils.createPVC;
8890
import static oracle.weblogic.kubernetes.utils.PersistentVolumeUtils.createPVHostPathDir;
91+
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodDoesNotExist;
8992
import static oracle.weblogic.kubernetes.utils.PodUtils.setPodAntiAffinity;
9093
import static oracle.weblogic.kubernetes.utils.SecretUtils.createOpsswalletpasswordSecret;
9194
import static oracle.weblogic.kubernetes.utils.SecretUtils.createSecretWithUsernamePassword;
@@ -464,6 +467,10 @@ void testUserCreatesPvPvcRcuOperatorCreatesDomain() {
464467
deleteDomainResource(domainNamespace, domainUid);
465468
// delete the cluster
466469
deleteClusterCustomResourceAndVerify(domainUid + "-" + clusterName, domainNamespace);
470+
//delete the rcu pod
471+
assertDoesNotThrow(() -> deletePod("rcu", dbNamespace),
472+
"Got exception while deleting server " + "rcu");
473+
checkPodDoesNotExist("rcu", null, dbNamespace);
467474
}
468475

469476
/**
@@ -569,6 +576,154 @@ void testOperatorCreatesPvPvcWlsDomain() {
569576
deleteClusterCustomResourceAndVerify(domainUid + "-" + clusterName, domainNamespace);
570577
}
571578

579+
/**
580+
* Create a basic FMW domain on PV using simplified feature.
581+
* User creates RCU schema, Operator creates PV/PVC and JRF domain
582+
* The user creates multiple domain initialization images
583+
* Verify Pod is ready and service exists for both admin server and managed servers.
584+
*/
585+
@Test
586+
@DisplayName("Create a FMW domain on PV. User creates RCU and operator creates PV/PVC and domain, "
587+
+ "User creates multiple domain initialization images")
588+
void testUserCreatesRcuOperatorCreatesPvPvcDomainMultipleImages() {
589+
String domainUid = "jrfonpv-simplified4";
590+
final String pvName = getUniqueName(domainUid + "-pv-");
591+
final String pvcName = getUniqueName(domainUid + "-pvc-");
592+
final int t3ChannelPort = getNextFreePort();
593+
final String wlSecretName = domainUid + "-weblogic-credentials";
594+
final String fmwModelFile = fmwModelFilePrefix + ".yaml";
595+
596+
// create FMW domain credential secret
597+
createSecretWithUsernamePassword(wlSecretName, domainNamespace,
598+
ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT);
599+
600+
// create RCU schema
601+
assertDoesNotThrow(() -> createRcuSchema(FMWINFRA_IMAGE_TO_USE_IN_SPEC, RCUSCHEMAPREFIX + "4", dbUrl,
602+
dbNamespace), "create rcu schema failed");
603+
604+
// create RCU access secret
605+
String rcuAccessSecretName = domainUid + "-rcu-credentials";
606+
logger.info("Creating RCU access secret: {0}, with prefix: {1}, dbUrl: {2}, schemapassword: {3})",
607+
rcuAccessSecretName, RCUSCHEMAPREFIX + "4", RCUSCHEMAPASSWORD, dbUrl);
608+
assertDoesNotThrow(() -> createRcuAccessSecret(
609+
rcuAccessSecretName,
610+
domainNamespace,
611+
RCUSCHEMAPREFIX + "4",
612+
RCUSCHEMAPASSWORD,
613+
dbUrl),
614+
String.format("createSecret failed for %s", rcuAccessSecretName));
615+
616+
// create a model property file
617+
File fmwModelPropFile = createWdtPropertyFile(domainUid, RCUSCHEMAPREFIX + "4");
618+
619+
// create domainCreationImage
620+
String domainCreationImageName1 = DOMAIN_IMAGES_REPO + "jrf-domain-on-pv-image41";
621+
// create image with model and wdt installation files
622+
WitParams witParams =
623+
new WitParams()
624+
.modelImageName(domainCreationImageName1)
625+
.modelImageTag(MII_BASIC_IMAGE_TAG)
626+
.modelFiles(Collections.singletonList(MODEL_DIR + "/" + fmwModelFile))
627+
.modelVariableFiles(Collections.singletonList(fmwModelPropFile.getAbsolutePath()));
628+
createAndPushAuxiliaryImage(domainCreationImageName1, MII_BASIC_IMAGE_TAG, witParams);
629+
630+
DomainCreationImage domainCreationImage1 =
631+
new DomainCreationImage().image(domainCreationImageName1 + ":" + MII_BASIC_IMAGE_TAG);
632+
633+
// create second image
634+
String domainCreationImageName2 = DOMAIN_IMAGES_REPO + "jrf-domain-on-pv-image42";
635+
// create image with model and wdt installation files
636+
witParams =
637+
new WitParams()
638+
.modelImageName(domainCreationImageName2)
639+
.modelImageTag(MII_BASIC_IMAGE_TAG)
640+
.modelFiles(Collections.singletonList(MODEL_DIR + "/model.jms2.yaml"))
641+
.modelVariableFiles(Collections.singletonList(fmwModelPropFile.getAbsolutePath()));
642+
createAndPushAuxiliaryImage(domainCreationImageName2, MII_BASIC_IMAGE_TAG, witParams);
643+
644+
DomainCreationImage domainCreationImage2 =
645+
new DomainCreationImage()
646+
.image(domainCreationImageName2 + ":" + MII_BASIC_IMAGE_TAG)
647+
.sourceWDTInstallHome("None");
648+
649+
List<DomainCreationImage> domainCreationImages = new ArrayList<>();
650+
domainCreationImages.add(domainCreationImage1);
651+
domainCreationImages.add(domainCreationImage2);
652+
653+
// create opss wallet password secret
654+
String opsswalletpassSecretName = domainUid + "-opss-wallet-password-secret";
655+
logger.info("Create OPSS wallet password secret");
656+
assertDoesNotThrow(() -> createOpsswalletpasswordSecret(
657+
opsswalletpassSecretName,
658+
domainNamespace,
659+
ADMIN_PASSWORD_DEFAULT),
660+
String.format("createSecret failed for %s", opsswalletpassSecretName));
661+
662+
// create a domain resource
663+
logger.info("Creating domain custom resource");
664+
Map<String, Quantity> pvCapacity = new HashMap<>();
665+
pvCapacity.put("storage", new Quantity("2Gi"));
666+
667+
Map<String, Quantity> pvcRequest = new HashMap<>();
668+
pvcRequest.put("storage", new Quantity("2Gi"));
669+
670+
Configuration configuration = new Configuration()
671+
.addSecretsItem(rcuAccessSecretName)
672+
.initializeDomainOnPV(new InitializeDomainOnPV()
673+
.persistentVolume(new PersistentVolume()
674+
.metadata(new V1ObjectMeta()
675+
.name(pvName))
676+
.spec(new PersistentVolumeSpec()
677+
.storageClassName(storageClassName)
678+
.capacity(pvCapacity)
679+
.persistentVolumeReclaimPolicy("Retain")
680+
.hostPath(new V1HostPathVolumeSource()
681+
.path(getHostPath(pvName, this.getClass().getSimpleName())))))
682+
.persistentVolumeClaim(new PersistentVolumeClaim()
683+
.metadata(new V1ObjectMeta()
684+
.name(pvcName))
685+
.spec(new PersistentVolumeClaimSpec()
686+
.storageClassName(storageClassName)
687+
.resources(new V1ResourceRequirements()
688+
.requests(pvcRequest))))
689+
.domain(new DomainOnPV()
690+
.createMode(CreateIfNotExists.DOMAIN)
691+
.domainCreationImages(domainCreationImages)
692+
.domainType(DomainOnPVType.JRF)
693+
.opss(new Opss()
694+
.walletPasswordSecret(opsswalletpassSecretName))));
695+
696+
DomainResource domain = createDomainResourceOnPv(
697+
domainUid,
698+
domainNamespace,
699+
wlSecretName,
700+
clusterName,
701+
pvName,
702+
pvcName,
703+
DOMAINHOMEPREFIX,
704+
replicaCount,
705+
t3ChannelPort,
706+
configuration);
707+
708+
// Set the inter-pod anti-affinity for the domain custom resource
709+
setPodAntiAffinity(domain);
710+
711+
// create a domain custom resource and verify domain is created
712+
createDomainAndVerify(domain, domainNamespace);
713+
714+
// verify that all servers are ready
715+
verifyDomainReady(domainNamespace, domainUid, replicaCount, "nosuffix");
716+
717+
// delete the domain
718+
deleteDomainResource(domainNamespace, domainUid);
719+
// delete the cluster
720+
deleteClusterCustomResourceAndVerify(domainUid + "-" + clusterName, domainNamespace);
721+
//delete the rcu pod
722+
assertDoesNotThrow(() -> deletePod("rcu", dbNamespace),
723+
"Got exception while deleting server " + "rcu");
724+
checkPodDoesNotExist("rcu", null, dbNamespace);
725+
}
726+
572727
private File createWdtPropertyFile(String domainName, String rcuSchemaPrefix) {
573728

574729
// create property file used with domain model file

0 commit comments

Comments
 (0)