Skip to content

Commit f50f00e

Browse files
hzhao-githubrjeberhard
authored andcommitted
OKE: Update Integration tests with Admin NodePort to run on internal Jenkin
1 parent 790948d commit f50f00e

File tree

3 files changed

+270
-133
lines changed

3 files changed

+270
-133
lines changed

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

Lines changed: 157 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import static oracle.weblogic.kubernetes.TestConstants.KUBERNETES_CLI;
5555
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_NAME;
5656
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_TAG;
57+
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER;
5758
import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_SECRET_NAME;
5859
import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR;
5960
import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR;
@@ -71,6 +72,7 @@
7172
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.verifyUpdateWebLogicCredential;
7273
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
7374
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists;
75+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.exeAppInServerPod;
7476
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort;
7577
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
7678
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getUniqueName;
@@ -100,6 +102,7 @@
100102
import static org.junit.jupiter.api.Assertions.assertNotNull;
101103
import static org.junit.jupiter.api.Assertions.assertTrue;
102104

105+
103106
/**
104107
* This test class verifies dynamic changes to domain resource and configuration
105108
* by modifying the associated configmap with a model-in-image domain.
@@ -111,10 +114,10 @@
111114
@DisplayName("Test logHome on PV, add SystemResources, Clusters to model in image domain")
112115
@IntegrationTest
113116
@Tag("olcne-mrg")
114-
@Tag("oke-parallel")
115117
@Tag("kind-parallel")
116118
@Tag("toolkits-srg")
117119
@Tag("okd-wls-srg")
120+
@Tag("oke-gate")
118121
class ItMiiUpdateDomainConfig {
119122

120123
private static String opNamespace = null;
@@ -124,7 +127,6 @@ class ItMiiUpdateDomainConfig {
124127
private static final String pvName = getUniqueName(domainUid + "-pv-");
125128
private static final String pvcName = getUniqueName(domainUid + "-pvc-");
126129
private StringBuffer curlString = null;
127-
private StringBuffer checkCluster = null;
128130
private V1Patch patch = null;
129131
private final String adminServerPodName = domainUid + "-admin-server";
130132
private final String managedServerPrefix = domainUid + "-managed-server";
@@ -264,17 +266,25 @@ void testMiiCustomEnv() {
264266
int adminServiceNodePort
265267
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
266268

269+
String hostAndPort =
270+
OKE_CLUSTER ? adminServerPodName + ":7001" : getHostAndPort(adminSvcExtHost, adminServiceNodePort);
271+
267272
String curlString = new StringBuffer()
268273
.append("curl --user ")
269274
.append(ADMIN_USERNAME_DEFAULT)
270275
.append(":")
271276
.append(ADMIN_PASSWORD_DEFAULT)
272277
.append(" ")
273-
.append("\"http://" + getHostAndPort(adminSvcExtHost, adminServiceNodePort))
278+
.append("\"http://" + hostAndPort)
274279
.append("/management/weblogic/latest/domainConfig")
275280
.append("/JMSServers/TestClusterJmsServer")
276281
.append("?fields=notes&links=none\"")
277282
.append(" --silent ").toString();
283+
284+
if (OKE_CLUSTER) {
285+
curlString = KUBERNETES_CLI + " exec -n " + domainNamespace + " " + adminServerPodName + " -- " + curlString;
286+
}
287+
278288
logger.info("checkJmsServerConfig: curl command {0}", curlString);
279289
verifyCommandResultContainsMsg(curlString, "${DOMAIN_UID}~##!'%*$(ls)");
280290
}
@@ -341,21 +351,51 @@ void testMiiCheckSystemResources() {
341351
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
342352
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
343353

344-
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
345-
"JDBCSystemResources", "TestDataSource", "200");
346-
logger.info("Found the JDBCSystemResource configuration");
347-
348-
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
349-
"JMSSystemResources", "TestClusterJmsModule", "200");
350-
logger.info("Found the JMSSystemResource configuration");
351-
352-
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
353-
"WLDFSystemResources", "TestWldfModule", "200");
354-
logger.info("Found the WLDFSystemResource configuration");
355-
356-
verifyJdbcRuntime("TestDataSource", "jdbc:oracle:thin:localhost");
357-
verifyJdbcRuntime("TestDataSource", "scott");
358-
logger.info("Found the JDBCSystemResource configuration");
354+
if (OKE_CLUSTER) {
355+
String resourcePath = "/management/weblogic/latest/domainConfig/JDBCSystemResources/TestDataSource";
356+
ExecResult result = exeAppInServerPod(domainNamespace, adminServerPodName,7001, resourcePath);
357+
assertEquals(0, result.exitValue(), "Failed to find the JDBCSystemResource configuration");
358+
assertTrue(result.toString().contains("JDBCSystemResources"),
359+
"Failed to find the JDBCSystemResource configuration");
360+
logger.info("Found the JDBCSystemResource configuration");
361+
362+
resourcePath = "/management/weblogic/latest/domainConfig/JMSSystemResources/TestClusterJmsModule";
363+
result = exeAppInServerPod(domainNamespace, adminServerPodName,7001, resourcePath);
364+
assertEquals(0, result.exitValue(), "Failed to find the JMSSystemResources configuration");
365+
assertTrue(result.toString().contains("JMSSystemResources"),
366+
"Failed to find the JMSSystemResources configuration");
367+
logger.info("Found the JMSSystemResource configuration");
368+
369+
resourcePath = "/management/weblogic/latest/domainConfig/WLDFSystemResources/TestWldfModule";
370+
result = exeAppInServerPod(domainNamespace, adminServerPodName,7001, resourcePath);
371+
assertEquals(0, result.exitValue(), "Failed to find the WLDFSystemResources configuration");
372+
assertTrue(result.toString().contains("WLDFSystemResources"),
373+
"Failed to find the WLDFSystemResources configuration");
374+
logger.info("Found the WLDFSystemResources configuration");
375+
376+
resourcePath = "/management/wls/latest/datasources/id/TestDataSource";
377+
result = exeAppInServerPod(domainNamespace, adminServerPodName,7001, resourcePath);
378+
assertEquals(0, result.exitValue(), "Failed to find the JDBCSystemResource configuration");
379+
assertTrue(result.toString().contains("scott"),
380+
"Failed to find the JDBCSystemResource configuration");
381+
logger.info("Found the JDBCSystemResource configuration");
382+
} else {
383+
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
384+
"JDBCSystemResources", "TestDataSource", "200");
385+
logger.info("Found the JDBCSystemResource configuration");
386+
387+
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
388+
"JMSSystemResources", "TestClusterJmsModule", "200");
389+
logger.info("Found the JMSSystemResource configuration");
390+
391+
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
392+
"WLDFSystemResources", "TestWldfModule", "200");
393+
logger.info("Found the WLDFSystemResource configuration");
394+
395+
verifyJdbcRuntime("TestDataSource", "jdbc:oracle:thin:localhost");
396+
verifyJdbcRuntime("TestDataSource", "scott");
397+
logger.info("Found the JDBCSystemResource configuration");
398+
}
359399
}
360400

361401
/**
@@ -416,13 +456,27 @@ void testMiiDeleteSystemResources() {
416456
checkServiceExists(managedServerPrefix + i, domainNamespace);
417457
}
418458

419-
int adminServiceNodePort
420-
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
421-
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
422-
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
423-
"JDBCSystemResources", "TestDataSource", "404");
424-
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
425-
"JMSSystemResources", "TestClusterJmsModule", "404");
459+
if (OKE_CLUSTER) {
460+
String resourcePath = "/management/weblogic/latest/domainConfig/JDBCSystemResources/TestDataSource";
461+
ExecResult result = exeAppInServerPod(domainNamespace, adminServerPodName, 7001, resourcePath);
462+
assertEquals(0, result.exitValue(), "Failed to delete the JDBCSystemResource configuration");
463+
assertTrue(result.toString().contains("404"), "Failed to delete the JDBCSystemResource configuration");
464+
logger.info("The JDBCSystemResource configuration is deleted");
465+
466+
resourcePath = "/management/weblogic/latest/domainConfig/JMSSystemResources/TestClusterJmsModule";
467+
result = exeAppInServerPod(domainNamespace, adminServerPodName, 7001, resourcePath);
468+
assertEquals(0, result.exitValue(), "Failed to delete the JMSSystemResources configuration");
469+
assertTrue(result.toString().contains("404"), "Failed to delete the JMSSystemResources configuration");
470+
logger.info("The JMSSystemResource configuration is deleted");
471+
} else {
472+
int adminServiceNodePort
473+
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
474+
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
475+
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
476+
"JDBCSystemResources", "TestDataSource", "404");
477+
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
478+
"JMSSystemResources", "TestClusterJmsModule", "404");
479+
}
426480
}
427481

428482
/**
@@ -482,17 +536,33 @@ void testMiiAddSystemResources() {
482536
checkServiceExists(managedServerPrefix + i, domainNamespace);
483537
}
484538

485-
int adminServiceNodePort
486-
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
487-
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
488-
489-
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
490-
"JDBCSystemResources", "TestDataSource2", "200");
491-
logger.info("Found the JDBCSystemResource configuration");
492-
493-
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
494-
"JMSSystemResources", "TestClusterJmsModule2", "200");
495-
logger.info("Found the JMSSystemResource configuration");
539+
if (OKE_CLUSTER) {
540+
String resourcePath = "/management/weblogic/latest/domainConfig/JDBCSystemResources/TestDataSource2";
541+
ExecResult result = exeAppInServerPod(domainNamespace, adminServerPodName, 7001, resourcePath);
542+
assertEquals(0, result.exitValue(), "Failed to find the JDBCSystemResource configuration");
543+
assertTrue(result.toString().contains("JDBCSystemResources"),
544+
"Failed to find the JDBCSystemResource configuration");
545+
logger.info("Found the JDBCSystemResource configuration");
546+
547+
resourcePath = "/management/weblogic/latest/domainConfig/JMSSystemResources/TestClusterJmsModule2";
548+
result = exeAppInServerPod(domainNamespace, adminServerPodName, 7001, resourcePath);
549+
assertEquals(0, result.exitValue(), "Failed to find the JMSSystemResources configuration");
550+
assertTrue(result.toString().contains("JMSSystemResources"),
551+
"Failed to find the JMSSystemResources configuration");
552+
logger.info("Found the JMSSystemResource configuration");
553+
} else {
554+
int adminServiceNodePort
555+
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
556+
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
557+
558+
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
559+
"JDBCSystemResources", "TestDataSource2", "200");
560+
logger.info("Found the JDBCSystemResource configuration");
561+
562+
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
563+
"JMSSystemResources", "TestClusterJmsModule2", "200");
564+
logger.info("Found the JMSSystemResource configuration");
565+
}
496566

497567
// check JMS logs are written on PV
498568
checkLogsOnPV("ls -ltr /shared/" + domainNamespace + "/logs/*jms_messages.log", managedServerPrefix + "1");
@@ -559,13 +629,11 @@ void testMiiAddDynamicCluster() {
559629

560630
// Check if the admin server pod has been restarted
561631
// by comparing the PodCreationTime before and after rolling restart
562-
563632
assertTrue(verifyRollingRestartOccurred(pods, 1, domainNamespace),
564633
"Rolling restart failed");
565634

566635
// The ServerNamePrefix for the new dynamic cluster is dynamic-server
567636
// Make sure the managed server from the new cluster is running
568-
569637
String newServerPodName = domainUid + "-dynamic-server1";
570638
checkPodReady(newServerPodName, domainUid, domainNamespace);
571639
checkServiceExists(newServerPodName, domainNamespace);
@@ -803,13 +871,27 @@ void testMiiDeleteSystemResourcesByEmptyConfigMap() {
803871
checkServiceExists(managedServerPrefix + i, domainNamespace);
804872
}
805873

806-
int adminServiceNodePort
807-
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
808-
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
809-
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
810-
"JDBCSystemResources", "TestDataSource", "404");
811-
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
812-
"JMSSystemResources", "TestClusterJmsModule", "404");
874+
if (OKE_CLUSTER) {
875+
String resourcePath = "/management/weblogic/latest/domainConfig/JDBCSystemResources/TestDataSource";
876+
ExecResult result = exeAppInServerPod(domainNamespace, adminServerPodName, 7001, resourcePath);
877+
assertEquals(0, result.exitValue(), "Failed to delete the JDBCSystemResource configuration");
878+
assertTrue(result.toString().contains("404"), "Failed to delete the JDBCSystemResource configuration");
879+
logger.info("The JDBCSystemResource configuration is deleted");
880+
881+
resourcePath = "/management/weblogic/latest/domainConfig/JMSSystemResources/TestClusterJmsModule";
882+
result = exeAppInServerPod(domainNamespace, adminServerPodName, 7001, resourcePath);
883+
assertEquals(0, result.exitValue(), "Failed to delete the JMSSystemResources configuration");
884+
assertTrue(result.toString().contains("404"), "Failed to delete the JMSSystemResources configuration");
885+
logger.info("The JMSSystemResource configuration is deleted");
886+
} else {
887+
int adminServiceNodePort
888+
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
889+
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
890+
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
891+
"JDBCSystemResources", "TestDataSource", "404");
892+
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
893+
"JMSSystemResources", "TestClusterJmsModule", "404");
894+
}
813895
}
814896

815897
// Run standalone JMS Client in the pod using wlthint3client.jar in classpath.
@@ -918,26 +1000,41 @@ private static DomainResource createDomainResource(
9181000
}
9191001

9201002
private void verifyManagedServerConfiguration(String managedServer) {
921-
9221003
int adminServiceNodePort
9231004
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
924-
925-
checkCluster = new StringBuffer("status=$(curl --user ");
926-
checkCluster.append(ADMIN_USERNAME_DEFAULT)
927-
.append(":")
928-
.append(ADMIN_PASSWORD_DEFAULT)
929-
.append(" ")
930-
.append("http://" + getHostAndPort(adminSvcExtHost, adminServiceNodePort))
931-
.append("/management/tenant-monitoring/servers/")
932-
.append(managedServer)
933-
.append(" --silent --show-error ")
934-
.append(" -o /dev/null")
935-
.append(" -w %{http_code});")
1005+
String hostAndPort =
1006+
OKE_CLUSTER ? adminServerPodName + ":7001" : getHostAndPort(adminSvcExtHost, adminServiceNodePort);
1007+
1008+
StringBuffer checkClusterBaseCmd = new StringBuffer("curl --user ")
1009+
.append(ADMIN_USERNAME_DEFAULT)
1010+
.append(":")
1011+
.append(ADMIN_PASSWORD_DEFAULT)
1012+
.append(" ")
1013+
.append("http://" + hostAndPort)
1014+
.append("/management/tenant-monitoring/servers/")
1015+
.append(managedServer)
1016+
.append(" --silent --show-error -o /dev/null -w %{http_code}");
1017+
1018+
StringBuffer checkCluster = new StringBuffer();
1019+
1020+
if (OKE_CLUSTER) {
1021+
checkCluster = new StringBuffer(KUBERNETES_CLI)
1022+
.append(" exec -n ")
1023+
.append(domainNamespace)
1024+
.append(" ")
1025+
.append(adminServerPodName)
1026+
.append(" -- ")
1027+
.append(checkClusterBaseCmd);
1028+
} else {
1029+
checkCluster = new StringBuffer("status=$(");
1030+
checkCluster.append(checkClusterBaseCmd)
1031+
.append(");")
9361032
.append("echo ${status}");
937-
logger.info("checkManagedServerConfiguration: curl command {0}", new String(checkCluster));
1033+
}
9381034

1035+
logger.info("checkManagedServerConfiguration: curl command {0}", new String(checkCluster));
9391036
verifyCommandResultContainsMsg(new String(checkCluster), "200");
940-
1037+
logger.info("Command to check managedServer configuration: {0} succeeded", new String(checkCluster));
9411038
}
9421039

9431040
// Crate a ConfigMap with a model file to add a new WebLogic cluster
@@ -1005,7 +1102,5 @@ private void checkLogsOnPV(String commandToExecuteInsidePod, String podName) {
10051102
assertFalse(result.exitValue() != 0 && result.stderr() != null && !result.stderr().isEmpty(),
10061103
String.format("Command %s failed with exit value %s, stderr %s, stdout %s",
10071104
commandToExecuteInsidePod, result.exitValue(), result.stderr(), result.stdout()));
1008-
10091105
}
1010-
10111106
}

0 commit comments

Comments
 (0)