Skip to content

Commit

Permalink
Merge branch 'move-to-oke-admin' into 'main'
Browse files Browse the repository at this point in the history
OKE: Update Integration tests with Admin NodePort to run on internal Jenkin

See merge request weblogic-cloud/weblogic-kubernetes-operator!4487
  • Loading branch information
rjeberhard committed Nov 6, 2023
2 parents 5b0685a + f50f00e commit a293f99
Show file tree
Hide file tree
Showing 3 changed files with 270 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import static oracle.weblogic.kubernetes.TestConstants.KUBERNETES_CLI;
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_NAME;
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_TAG;
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER;
import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_SECRET_NAME;
import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR;
import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR;
Expand All @@ -71,6 +72,7 @@
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.verifyUpdateWebLogicCredential;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.exeAppInServerPod;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getUniqueName;
Expand Down Expand Up @@ -100,6 +102,7 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;


/**
* This test class verifies dynamic changes to domain resource and configuration
* by modifying the associated configmap with a model-in-image domain.
Expand All @@ -111,10 +114,10 @@
@DisplayName("Test logHome on PV, add SystemResources, Clusters to model in image domain")
@IntegrationTest
@Tag("olcne-mrg")
@Tag("oke-parallel")
@Tag("kind-parallel")
@Tag("toolkits-srg")
@Tag("okd-wls-srg")
@Tag("oke-gate")
class ItMiiUpdateDomainConfig {

private static String opNamespace = null;
Expand All @@ -124,7 +127,6 @@ class ItMiiUpdateDomainConfig {
private static final String pvName = getUniqueName(domainUid + "-pv-");
private static final String pvcName = getUniqueName(domainUid + "-pvc-");
private StringBuffer curlString = null;
private StringBuffer checkCluster = null;
private V1Patch patch = null;
private final String adminServerPodName = domainUid + "-admin-server";
private final String managedServerPrefix = domainUid + "-managed-server";
Expand Down Expand Up @@ -264,17 +266,25 @@ void testMiiCustomEnv() {
int adminServiceNodePort
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");

String hostAndPort =
OKE_CLUSTER ? adminServerPodName + ":7001" : getHostAndPort(adminSvcExtHost, adminServiceNodePort);

String curlString = new StringBuffer()
.append("curl --user ")
.append(ADMIN_USERNAME_DEFAULT)
.append(":")
.append(ADMIN_PASSWORD_DEFAULT)
.append(" ")
.append("\"http://" + getHostAndPort(adminSvcExtHost, adminServiceNodePort))
.append("\"http://" + hostAndPort)
.append("/management/weblogic/latest/domainConfig")
.append("/JMSServers/TestClusterJmsServer")
.append("?fields=notes&links=none\"")
.append(" --silent ").toString();

if (OKE_CLUSTER) {
curlString = KUBERNETES_CLI + " exec -n " + domainNamespace + " " + adminServerPodName + " -- " + curlString;
}

logger.info("checkJmsServerConfig: curl command {0}", curlString);
verifyCommandResultContainsMsg(curlString, "${DOMAIN_UID}~##!'%*$(ls)");
}
Expand Down Expand Up @@ -341,21 +351,51 @@ void testMiiCheckSystemResources() {
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");

verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
"JDBCSystemResources", "TestDataSource", "200");
logger.info("Found the JDBCSystemResource configuration");

verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
"JMSSystemResources", "TestClusterJmsModule", "200");
logger.info("Found the JMSSystemResource configuration");

verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
"WLDFSystemResources", "TestWldfModule", "200");
logger.info("Found the WLDFSystemResource configuration");

verifyJdbcRuntime("TestDataSource", "jdbc:oracle:thin:localhost");
verifyJdbcRuntime("TestDataSource", "scott");
logger.info("Found the JDBCSystemResource configuration");
if (OKE_CLUSTER) {
String resourcePath = "/management/weblogic/latest/domainConfig/JDBCSystemResources/TestDataSource";
ExecResult result = exeAppInServerPod(domainNamespace, adminServerPodName,7001, resourcePath);
assertEquals(0, result.exitValue(), "Failed to find the JDBCSystemResource configuration");
assertTrue(result.toString().contains("JDBCSystemResources"),
"Failed to find the JDBCSystemResource configuration");
logger.info("Found the JDBCSystemResource configuration");

resourcePath = "/management/weblogic/latest/domainConfig/JMSSystemResources/TestClusterJmsModule";
result = exeAppInServerPod(domainNamespace, adminServerPodName,7001, resourcePath);
assertEquals(0, result.exitValue(), "Failed to find the JMSSystemResources configuration");
assertTrue(result.toString().contains("JMSSystemResources"),
"Failed to find the JMSSystemResources configuration");
logger.info("Found the JMSSystemResource configuration");

resourcePath = "/management/weblogic/latest/domainConfig/WLDFSystemResources/TestWldfModule";
result = exeAppInServerPod(domainNamespace, adminServerPodName,7001, resourcePath);
assertEquals(0, result.exitValue(), "Failed to find the WLDFSystemResources configuration");
assertTrue(result.toString().contains("WLDFSystemResources"),
"Failed to find the WLDFSystemResources configuration");
logger.info("Found the WLDFSystemResources configuration");

resourcePath = "/management/wls/latest/datasources/id/TestDataSource";
result = exeAppInServerPod(domainNamespace, adminServerPodName,7001, resourcePath);
assertEquals(0, result.exitValue(), "Failed to find the JDBCSystemResource configuration");
assertTrue(result.toString().contains("scott"),
"Failed to find the JDBCSystemResource configuration");
logger.info("Found the JDBCSystemResource configuration");
} else {
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
"JDBCSystemResources", "TestDataSource", "200");
logger.info("Found the JDBCSystemResource configuration");

verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
"JMSSystemResources", "TestClusterJmsModule", "200");
logger.info("Found the JMSSystemResource configuration");

verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
"WLDFSystemResources", "TestWldfModule", "200");
logger.info("Found the WLDFSystemResource configuration");

verifyJdbcRuntime("TestDataSource", "jdbc:oracle:thin:localhost");
verifyJdbcRuntime("TestDataSource", "scott");
logger.info("Found the JDBCSystemResource configuration");
}
}

/**
Expand Down Expand Up @@ -416,13 +456,27 @@ void testMiiDeleteSystemResources() {
checkServiceExists(managedServerPrefix + i, domainNamespace);
}

int adminServiceNodePort
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
"JDBCSystemResources", "TestDataSource", "404");
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
"JMSSystemResources", "TestClusterJmsModule", "404");
if (OKE_CLUSTER) {
String resourcePath = "/management/weblogic/latest/domainConfig/JDBCSystemResources/TestDataSource";
ExecResult result = exeAppInServerPod(domainNamespace, adminServerPodName, 7001, resourcePath);
assertEquals(0, result.exitValue(), "Failed to delete the JDBCSystemResource configuration");
assertTrue(result.toString().contains("404"), "Failed to delete the JDBCSystemResource configuration");
logger.info("The JDBCSystemResource configuration is deleted");

resourcePath = "/management/weblogic/latest/domainConfig/JMSSystemResources/TestClusterJmsModule";
result = exeAppInServerPod(domainNamespace, adminServerPodName, 7001, resourcePath);
assertEquals(0, result.exitValue(), "Failed to delete the JMSSystemResources configuration");
assertTrue(result.toString().contains("404"), "Failed to delete the JMSSystemResources configuration");
logger.info("The JMSSystemResource configuration is deleted");
} else {
int adminServiceNodePort
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
"JDBCSystemResources", "TestDataSource", "404");
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
"JMSSystemResources", "TestClusterJmsModule", "404");
}
}

/**
Expand Down Expand Up @@ -482,17 +536,33 @@ void testMiiAddSystemResources() {
checkServiceExists(managedServerPrefix + i, domainNamespace);
}

int adminServiceNodePort
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");

verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
"JDBCSystemResources", "TestDataSource2", "200");
logger.info("Found the JDBCSystemResource configuration");

verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
"JMSSystemResources", "TestClusterJmsModule2", "200");
logger.info("Found the JMSSystemResource configuration");
if (OKE_CLUSTER) {
String resourcePath = "/management/weblogic/latest/domainConfig/JDBCSystemResources/TestDataSource2";
ExecResult result = exeAppInServerPod(domainNamespace, adminServerPodName, 7001, resourcePath);
assertEquals(0, result.exitValue(), "Failed to find the JDBCSystemResource configuration");
assertTrue(result.toString().contains("JDBCSystemResources"),
"Failed to find the JDBCSystemResource configuration");
logger.info("Found the JDBCSystemResource configuration");

resourcePath = "/management/weblogic/latest/domainConfig/JMSSystemResources/TestClusterJmsModule2";
result = exeAppInServerPod(domainNamespace, adminServerPodName, 7001, resourcePath);
assertEquals(0, result.exitValue(), "Failed to find the JMSSystemResources configuration");
assertTrue(result.toString().contains("JMSSystemResources"),
"Failed to find the JMSSystemResources configuration");
logger.info("Found the JMSSystemResource configuration");
} else {
int adminServiceNodePort
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");

verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
"JDBCSystemResources", "TestDataSource2", "200");
logger.info("Found the JDBCSystemResource configuration");

verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
"JMSSystemResources", "TestClusterJmsModule2", "200");
logger.info("Found the JMSSystemResource configuration");
}

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

// Check if the admin server pod has been restarted
// by comparing the PodCreationTime before and after rolling restart

assertTrue(verifyRollingRestartOccurred(pods, 1, domainNamespace),
"Rolling restart failed");

// The ServerNamePrefix for the new dynamic cluster is dynamic-server
// Make sure the managed server from the new cluster is running

String newServerPodName = domainUid + "-dynamic-server1";
checkPodReady(newServerPodName, domainUid, domainNamespace);
checkServiceExists(newServerPodName, domainNamespace);
Expand Down Expand Up @@ -803,13 +871,27 @@ void testMiiDeleteSystemResourcesByEmptyConfigMap() {
checkServiceExists(managedServerPrefix + i, domainNamespace);
}

int adminServiceNodePort
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
"JDBCSystemResources", "TestDataSource", "404");
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
"JMSSystemResources", "TestClusterJmsModule", "404");
if (OKE_CLUSTER) {
String resourcePath = "/management/weblogic/latest/domainConfig/JDBCSystemResources/TestDataSource";
ExecResult result = exeAppInServerPod(domainNamespace, adminServerPodName, 7001, resourcePath);
assertEquals(0, result.exitValue(), "Failed to delete the JDBCSystemResource configuration");
assertTrue(result.toString().contains("404"), "Failed to delete the JDBCSystemResource configuration");
logger.info("The JDBCSystemResource configuration is deleted");

resourcePath = "/management/weblogic/latest/domainConfig/JMSSystemResources/TestClusterJmsModule";
result = exeAppInServerPod(domainNamespace, adminServerPodName, 7001, resourcePath);
assertEquals(0, result.exitValue(), "Failed to delete the JMSSystemResources configuration");
assertTrue(result.toString().contains("404"), "Failed to delete the JMSSystemResources configuration");
logger.info("The JMSSystemResource configuration is deleted");
} else {
int adminServiceNodePort
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
"JDBCSystemResources", "TestDataSource", "404");
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
"JMSSystemResources", "TestClusterJmsModule", "404");
}
}

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

private void verifyManagedServerConfiguration(String managedServer) {

int adminServiceNodePort
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");

checkCluster = new StringBuffer("status=$(curl --user ");
checkCluster.append(ADMIN_USERNAME_DEFAULT)
.append(":")
.append(ADMIN_PASSWORD_DEFAULT)
.append(" ")
.append("http://" + getHostAndPort(adminSvcExtHost, adminServiceNodePort))
.append("/management/tenant-monitoring/servers/")
.append(managedServer)
.append(" --silent --show-error ")
.append(" -o /dev/null")
.append(" -w %{http_code});")
String hostAndPort =
OKE_CLUSTER ? adminServerPodName + ":7001" : getHostAndPort(adminSvcExtHost, adminServiceNodePort);

StringBuffer checkClusterBaseCmd = new StringBuffer("curl --user ")
.append(ADMIN_USERNAME_DEFAULT)
.append(":")
.append(ADMIN_PASSWORD_DEFAULT)
.append(" ")
.append("http://" + hostAndPort)
.append("/management/tenant-monitoring/servers/")
.append(managedServer)
.append(" --silent --show-error -o /dev/null -w %{http_code}");

StringBuffer checkCluster = new StringBuffer();

if (OKE_CLUSTER) {
checkCluster = new StringBuffer(KUBERNETES_CLI)
.append(" exec -n ")
.append(domainNamespace)
.append(" ")
.append(adminServerPodName)
.append(" -- ")
.append(checkClusterBaseCmd);
} else {
checkCluster = new StringBuffer("status=$(");
checkCluster.append(checkClusterBaseCmd)
.append(");")
.append("echo ${status}");
logger.info("checkManagedServerConfiguration: curl command {0}", new String(checkCluster));
}

logger.info("checkManagedServerConfiguration: curl command {0}", new String(checkCluster));
verifyCommandResultContainsMsg(new String(checkCluster), "200");

logger.info("Command to check managedServer configuration: {0} succeeded", new String(checkCluster));
}

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

}

}
Loading

0 comments on commit a293f99

Please sign in to comment.