Skip to content

Commit 7c3e486

Browse files
authored
Fix for Openshift certification, 12.2.1.3 mySql driver, and Istio related changes (#4069)
* Fix for OpenShift certification, 12.2.1.3 MySQL driver, and Istio related changes
1 parent 6431d1e commit 7c3e486

File tree

5 files changed

+40
-27
lines changed

5 files changed

+40
-27
lines changed

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import java.io.FileOutputStream;
88
import java.io.IOException;
99
import java.net.http.HttpResponse;
10-
import java.nio.charset.StandardCharsets;
1110
import java.nio.file.Files;
1211
import java.nio.file.Path;
1312
import java.nio.file.Paths;
@@ -65,6 +64,7 @@
6564
import static oracle.weblogic.kubernetes.TestConstants.IMAGE_PULL_POLICY;
6665
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST;
6766
import static oracle.weblogic.kubernetes.TestConstants.OKD;
67+
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_12213;
6868
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TO_USE_IN_SPEC;
6969
import static oracle.weblogic.kubernetes.actions.ActionConstants.APP_DIR;
7070
import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR;
@@ -95,6 +95,7 @@
9595
import static oracle.weblogic.kubernetes.utils.DeployUtil.deployUsingWlst;
9696
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
9797
import static oracle.weblogic.kubernetes.utils.ExecCommand.exec;
98+
import static oracle.weblogic.kubernetes.utils.FileUtils.replaceStringInFile;
9899
import static oracle.weblogic.kubernetes.utils.ImageUtils.createBaseRepoSecret;
99100
import static oracle.weblogic.kubernetes.utils.JobUtils.createDomainJob;
100101
import static oracle.weblogic.kubernetes.utils.JobUtils.getIntrospectJobName;
@@ -561,10 +562,13 @@ void testOnRestartOverride() {
561562
//copy the template datasource file for override after replacing JDBC_URL with new datasource url
562563
Path srcDsOverrideFile = Paths.get(RESOURCE_DIR, "configfiles/configoverridesset1/jdbc-JdbcTestDataSource-1.xml");
563564
Path dstDsOverrideFile = Paths.get(WORK_DIR, "jdbc-JdbcTestDataSource-1.xml");
564-
String tempString = assertDoesNotThrow(()
565-
-> Files.readString(srcDsOverrideFile).replaceAll("JDBC_URL", dsUrl2));
566-
assertDoesNotThrow(()
567-
-> Files.write(dstDsOverrideFile, tempString.getBytes(StandardCharsets.UTF_8)));
565+
assertDoesNotThrow(() -> {
566+
Files.copy(srcDsOverrideFile, dstDsOverrideFile, StandardCopyOption.REPLACE_EXISTING);
567+
replaceStringInFile(dstDsOverrideFile.toString(), "JDBC_URL", dsUrl2);
568+
if (WEBLOGIC_12213) {
569+
replaceStringInFile(dstDsOverrideFile.toString(), "com.mysql.cj.jdbc.Driver", "com.mysql.jdbc.Driver");
570+
}
571+
});
568572

569573
List<Path> overrideFiles = new ArrayList<>();
570574
overrideFiles.add(dstDsOverrideFile);
@@ -1083,6 +1087,9 @@ private void createJdbcDataSource(String dsName, String user, String password,
10831087
logger.info("hostAndPort = {0} ", hostAndPort);
10841088
String jdbcDsUrl = "jdbc:mysql://" + hostAndPort;
10851089

1090+
// based on WebLogic image, change the mysql driver to
1091+
// 12.2.1.3 - com.mysql.jdbc.Driver
1092+
// 12.2.1.4 and above - com.mysql.cj.jdbc.Driver
10861093
// create a temporary WebLogic domain property file
10871094
File domainPropertiesFile = File.createTempFile("domain", "properties");
10881095
Properties p = new Properties();
@@ -1092,7 +1099,11 @@ private void createJdbcDataSource(String dsName, String user, String password,
10921099
p.setProperty("admin_password", ADMIN_PASSWORD_DEFAULT);
10931100
p.setProperty("dsName", dsName);
10941101
p.setProperty("dsUrl", jdbcDsUrl);
1095-
p.setProperty("dsDriver", "com.mysql.cj.jdbc.Driver");
1102+
if (WEBLOGIC_12213) {
1103+
p.setProperty("dsDriver", "com.mysql.jdbc.Driver");
1104+
} else {
1105+
p.setProperty("dsDriver", "com.mysql.cj.jdbc.Driver");
1106+
}
10961107
p.setProperty("dsUser", user);
10971108
p.setProperty("dsPassword", password);
10981109
p.setProperty("dsTarget", clusterName);

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,14 @@ void testIstioModelInImageDomain() {
213213
managedServerPrefix + i, domainNamespace);
214214
checkPodReadyAndServiceExists(managedServerPrefix + i, domainUid, domainNamespace);
215215
}
216+
217+
218+
// delete the mTLS mode
219+
ExecResult result = assertDoesNotThrow(() -> ExecCommand.exec(KUBERNETES_CLI + " delete -f "
220+
+ Paths.get(WORK_DIR, "istio-tls-mode.yaml").toString(), true));
221+
assertEquals(0, result.exitValue(), "Got expected exit value");
222+
logger.info(result.stdout());
223+
logger.info(result.stderr());
216224

217225
String clusterService = domainUid + "-cluster-" + clusterName + "." + domainNamespace + ".svc.cluster.local";
218226

@@ -243,17 +251,6 @@ void testIstioModelInImageDomain() {
243251
int istioIngressPort = getIstioHttpIngressPort();
244252
logger.info("Istio Ingress Port is {0}", istioIngressPort);
245253

246-
String curlCmd = "curl -j -sk --show-error --noproxy '*' "
247-
+ " -H 'Host: " + domainNamespace + ".org'"
248-
+ " --url http://" + K8S_NODEPORT_HOST + ":" + istioIngressPort + "/console/login/LoginForm.jsp";
249-
ExecResult result;
250-
logger.info("curl command {0}", curlCmd);
251-
result = assertDoesNotThrow(() -> exec(curlCmd, true));
252-
assertEquals(0, result.exitValue(), "Got expected exit value");
253-
result = assertDoesNotThrow(() -> ExecCommand.exec(KUBERNETES_CLI + " delete -f "
254-
+ Paths.get(WORK_DIR, "istio-tls-mode.yaml").toString(), true));
255-
assertEquals(0, result.exitValue(), "Got expected exit value");
256-
257254
// We can not verify Rest Management console thru Adminstration NodePort
258255
// in istio, as we can not enable Adminstration NodePort
259256
if (!WEBLOGIC_SLIM) {
@@ -379,14 +376,17 @@ private DomainResource createDomainResource(String domainUid, String domNamespac
379376
}
380377

381378
private static void enableStrictMode(String namespace) {
382-
assertDoesNotThrow(() -> copyFile(Paths.get(RESOURCE_DIR, "istio", "istio-tls-mode.yaml").toFile(),
383-
Paths.get(WORK_DIR, "istio-tls-mode.yaml").toFile()));
384-
assertDoesNotThrow(() -> replaceStringInFile(Paths.get(WORK_DIR, "istio-tls-mode.yaml").toString(),
385-
"NAMESPACE", namespace));
386-
387-
ExecResult result = assertDoesNotThrow(() -> ExecCommand.exec(KUBERNETES_CLI + " apply -f "
388-
+ Paths.get(WORK_DIR, "istio-tls-mode.yaml").toString(), true));
389-
logger.info(result.stdout());
390-
logger.info(result.stderr());
379+
Path srcFile = Paths.get(RESOURCE_DIR, "istio", "istio-tls-mode.yaml");
380+
Path dstFile = Paths.get(WORK_DIR, "istio-tls-mode.yaml");
381+
logger.info("Enabling STRICT mTLS mode in istio in namesapce {0}", namespace);
382+
assertDoesNotThrow(() -> {
383+
copyFile(srcFile.toFile(), dstFile.toFile());
384+
replaceStringInFile(dstFile.toString(), "NAMESPACE", namespace);
385+
ExecResult result = ExecCommand.exec(KUBERNETES_CLI + " apply -f "
386+
+ Paths.get(WORK_DIR, "istio-tls-mode.yaml").toString(), true);
387+
assertEquals(0, result.exitValue(), "Failed to enable mTLS strict mode");
388+
logger.info(result.stdout());
389+
logger.info(result.stderr());
390+
});
391391
}
392392
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ private DomainResource createDomainResource(String domainUid, String domNamespac
295295
.webLogicCredentialsSecret(new V1LocalObjectReference()
296296
.name(adminSecretName))
297297
.includeServerOutInPodLog(true)
298-
.serverStartPolicy("IF_NEEDED")
298+
.serverStartPolicy("IfNeeded")
299299
.serverPod(new ServerPod()
300300
.putAnnotationsItem("sidecar.istio.io/inject", "true")
301301
.addEnvItem(new V1EnvVar()

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/OperatorUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,8 @@ public static OperatorParams installAndVerifyOperator(String opNamespace,
622622

623623
if (domainNamespaceSelectionStrategy != null) {
624624
opParams.domainNamespaceSelectionStrategy(domainNamespaceSelectionStrategy);
625+
} else if (domainNamespace.length > 0) {
626+
opParams.domainNamespaceSelectionStrategy("List");
625627
}
626628

627629
// use default image in chart when repoUrl is set, otherwise use latest/current branch operator image

0 commit comments

Comments
 (0)