Skip to content

Commit

Permalink
Merge branch 'xc-122451' into 'main'
Browse files Browse the repository at this point in the history
backport MR 4823 to main branch

See merge request weblogic-cloud/weblogic-kubernetes-operator!4832
  • Loading branch information
rjeberhard committed Oct 8, 2024
2 parents ccf6763 + f1dcbd0 commit 47a40b3
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainResourceOnPv;
import static oracle.weblogic.kubernetes.utils.ExecCommand.exec;
import static oracle.weblogic.kubernetes.utils.FileUtils.createWdtPropertyFile;
import static oracle.weblogic.kubernetes.utils.FileUtils.replaceStringInFile;
import static oracle.weblogic.kubernetes.utils.FmwUtils.getConfiguration;
import static oracle.weblogic.kubernetes.utils.ImageUtils.createBaseRepoSecret;
Expand Down Expand Up @@ -981,7 +982,7 @@ private void createDomain() {
final String wlsModelFilePrefix = "model-dci-introspect";
final String wlsModelFile = wlsModelFilePrefix + ".yaml";
t3ChannelPort = getNextFreePort();
File wlsModelPropFile = ItIntrospectVersion.createWdtPropertyFile(wlsModelFilePrefix,
File wlsModelPropFile = createWdtPropertyFile(wlsModelFilePrefix,
K8S_NODEPORT_HOST, t3ChannelPort);
// create domainCreationImage
String domainCreationImageName = DOMAIN_IMAGES_PREFIX + "configdist-domain-on-pv-image";
Expand Down Expand Up @@ -1010,7 +1011,7 @@ private void createDomain() {
configuration = getConfiguration(pvcName, pvcRequest, "oci-fss");
} else {
configuration = getConfiguration(pvName, pvcName, pvCapacity, pvcRequest, storageClassName,
ItIntrospectVersion.class.getName());
ItConfigDistributionStrategy.class.getSimpleName());
}
configuration.getInitializeDomainOnPV().domain(new DomainOnPV()
.createMode(CreateIfNotExists.DOMAIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainResourceOnPv;
import static oracle.weblogic.kubernetes.utils.DomainUtils.verifyDomainStatusConditionTypeDoesNotExist;
import static oracle.weblogic.kubernetes.utils.FileUtils.createWdtPropertyFile;
import static oracle.weblogic.kubernetes.utils.FmwUtils.getConfiguration;
import static oracle.weblogic.kubernetes.utils.ImageUtils.createMiiImageAndVerify;
import static oracle.weblogic.kubernetes.utils.ImageUtils.createTestRepoSecret;
Expand Down Expand Up @@ -1554,26 +1555,4 @@ private void updateIngressBackendServicePort(int newAdminPort) throws ApiExcepti
fail("Ingress is null, failed to update ingress");
}
}

public static File createWdtPropertyFile(String wlsModelFilePrefix, String nodePortHost, int t3Port) {

// create property file used with domain model file
Properties p = new Properties();
p.setProperty("WebLogicAdminUserName", ADMIN_USERNAME_DEFAULT);
p.setProperty("WebLogicAdminPassword", ADMIN_PASSWORD_DEFAULT);
p.setProperty("K8S_NODEPORT_HOST", nodePortHost);
p.setProperty("T3_CHANNEL_PORT", Integer.toString(t3Port));

// create a model property file
File domainPropertiesFile = assertDoesNotThrow(() ->
File.createTempFile(wlsModelFilePrefix, ".properties", new File(RESULTS_TEMPFILE)),
"Failed to create WLS model properties file");

// create the property file
assertDoesNotThrow(() ->
p.store(new FileOutputStream(domainPropertiesFile), "WLS properties file"),
"Failed to write WLS properties file");

return domainPropertiesFile;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
import static oracle.weblogic.kubernetes.utils.DomainUtils.deleteDomainResource;
import static oracle.weblogic.kubernetes.utils.DomainUtils.removeClusterInDomainResource;
import static oracle.weblogic.kubernetes.utils.DomainUtils.verifyDomainStatusConditionTypeDoesNotExist;
import static oracle.weblogic.kubernetes.utils.FileUtils.createWdtPropertyFile;
import static oracle.weblogic.kubernetes.utils.FmwUtils.getConfiguration;
import static oracle.weblogic.kubernetes.utils.ImageUtils.createBaseRepoSecret;
import static oracle.weblogic.kubernetes.utils.JobUtils.getIntrospectJobName;
Expand Down Expand Up @@ -771,7 +772,7 @@ private static DomainResource createDomain(String domainNamespace, String domain
final String wlsModelFilePrefix = "model-dci-introspect";
final String wlsModelFile = wlsModelFilePrefix + ".yaml";
int t3ChannelPort = getNextFreePort();
File wlsModelPropFile = ItIntrospectVersion.createWdtPropertyFile(wlsModelFilePrefix,
File wlsModelPropFile = createWdtPropertyFile(wlsModelFilePrefix,
K8S_NODEPORT_HOST, t3ChannelPort);

// create domainCreationImage
Expand Down Expand Up @@ -801,7 +802,7 @@ private static DomainResource createDomain(String domainNamespace, String domain
configuration = getConfiguration(pvcName, pvcRequest, "oci-fss");
} else {
configuration = getConfiguration(pvName, pvcName, pvCapacity, pvcRequest, storageClassName,
ItIntrospectVersion.class.getName());
ItKubernetesDomainEvents.class.getSimpleName());
}
configuration.getInitializeDomainOnPV().domain(new DomainOnPV()
.createMode(CreateIfNotExists.DOMAIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
import static oracle.weblogic.kubernetes.utils.ConfigMapUtils.createConfigMapFromFiles;
import static oracle.weblogic.kubernetes.utils.DeployUtil.deployUsingWlst;
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
import static oracle.weblogic.kubernetes.utils.FileUtils.createWdtPropertyFile;
import static oracle.weblogic.kubernetes.utils.FmwUtils.getConfiguration;
import static oracle.weblogic.kubernetes.utils.ImageUtils.createBaseRepoSecret;
import static oracle.weblogic.kubernetes.utils.JobUtils.createDomainJob;
Expand Down Expand Up @@ -393,7 +394,7 @@ private void createDomain() {
final String wlsModelFilePrefix = "sitconfig-dci-model";
final String wlsModelFile = wlsModelFilePrefix + ".yaml";
t3ChannelPort = getNextFreePort();
File wlsModelPropFile = ItIntrospectVersion.createWdtPropertyFile(wlsModelFilePrefix,
File wlsModelPropFile = createWdtPropertyFile(wlsModelFilePrefix,
K8S_NODEPORT_HOST, t3ChannelPort);

// create domainCreationImage
Expand Down Expand Up @@ -423,7 +424,7 @@ private void createDomain() {
configuration = getConfiguration(pvcName, pvcRequest, "oci-fss");
} else {
configuration = getConfiguration(pvName, pvcName, pvCapacity, pvcRequest, storageClassName,
ItIntrospectVersion.class.getName());
ItSystemResOverrides.class.getSimpleName());
}
configuration.getInitializeDomainOnPV().domain(new DomainOnPV()
.createMode(CreateIfNotExists.DOMAIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
import static oracle.weblogic.kubernetes.utils.DeployUtil.deployUsingWlst;
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
import static oracle.weblogic.kubernetes.utils.FileUtils.createWdtPropertyFile;
import static oracle.weblogic.kubernetes.utils.FmwUtils.getConfiguration;
import static oracle.weblogic.kubernetes.utils.ImageUtils.createBaseRepoSecret;
import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
Expand Down Expand Up @@ -174,7 +175,7 @@ void testAdminServerT3Channel() {

final String wlsModelFilePrefix = "model-dci-introspect";
final String wlsModelFile = wlsModelFilePrefix + ".yaml";
File wlsModelPropFile = ItIntrospectVersion.createWdtPropertyFile(wlsModelFilePrefix,
File wlsModelPropFile = createWdtPropertyFile(wlsModelFilePrefix,
K8S_NODEPORT_HOST, t3ChannelPort);

// create domainCreationImage
Expand Down Expand Up @@ -204,7 +205,7 @@ void testAdminServerT3Channel() {
configuration = getConfiguration(pvcName, pvcRequest, "oci-fss");
} else {
configuration = getConfiguration(pvName, pvcName, pvCapacity, pvcRequest, storageClassName,
ItIntrospectVersion.class.getName());
ItT3Channel.class.getSimpleName());
}
configuration.getInitializeDomainOnPV().domain(new DomainOnPV()
.createMode(CreateIfNotExists.DOMAIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.nio.file.attribute.BasicFileAttributes;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand All @@ -31,8 +32,11 @@
import oracle.weblogic.kubernetes.logging.LoggingFacade;

import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_DEFAULT;
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
import static oracle.weblogic.kubernetes.TestConstants.KUBERNETES_CLI;
import static oracle.weblogic.kubernetes.TestConstants.RESULTS_ROOT;
import static oracle.weblogic.kubernetes.TestConstants.RESULTS_TEMPFILE;
import static oracle.weblogic.kubernetes.TestConstants.WLSIMG_BUILDER;
import static oracle.weblogic.kubernetes.actions.ActionConstants.DOWNLOAD_DIR;
import static oracle.weblogic.kubernetes.actions.ActionConstants.WDT_DOWNLOAD_FILENAME_DEFAULT;
Expand Down Expand Up @@ -616,4 +620,33 @@ public static boolean searchStringInFile(String fileName, String searchString) t
logger.info("Failed to find string {0} in the file {1}", searchString, fileName);
return false;
}

/**
* Create WDT property file.
* @param wlsModelFilePrefix the model file prefix
* @param nodePortHost the K8S node port host name
* @param t3Port T3_CHANNEL_PORT
* @return WDT property file
*/
public static File createWdtPropertyFile(String wlsModelFilePrefix, String nodePortHost, int t3Port) {

// create property file used with domain model file
Properties p = new Properties();
p.setProperty("WebLogicAdminUserName", ADMIN_USERNAME_DEFAULT);
p.setProperty("WebLogicAdminPassword", ADMIN_PASSWORD_DEFAULT);
p.setProperty("K8S_NODEPORT_HOST", nodePortHost);
p.setProperty("T3_CHANNEL_PORT", Integer.toString(t3Port));

// create a model property file
File domainPropertiesFile = assertDoesNotThrow(() ->
File.createTempFile(wlsModelFilePrefix, ".properties", new File(RESULTS_TEMPFILE)),
"Failed to create WLS model properties file");

// create the property file
assertDoesNotThrow(() ->
p.store(new FileOutputStream(domainPropertiesFile), "WLS properties file"),
"Failed to write WLS properties file");

return domainPropertiesFile;
}
}

0 comments on commit 47a40b3

Please sign in to comment.