Skip to content

Commit 7d88eb4

Browse files
hzhao-githubrjeberhard
authored andcommitted
OKE: Update OKE Integration tests to run on internal Jenkin
1 parent c8c0be7 commit 7d88eb4

File tree

5 files changed

+155
-28
lines changed

5 files changed

+155
-28
lines changed

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222

2323
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_DEFAULT;
2424
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
25+
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER;
2526
import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR;
2627
import static oracle.weblogic.kubernetes.actions.TestActions.getNextIntrospectVersion;
2728
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
2829
import static oracle.weblogic.kubernetes.actions.TestActions.getServicePort;
2930
import static oracle.weblogic.kubernetes.actions.impl.Domain.patchDomainCustomResource;
3031
import static oracle.weblogic.kubernetes.assertions.TestAssertions.adminNodePortAccessible;
3132
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
33+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.isAppInServerPodReady;
3234
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
3335
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainOnPvUsingWdt;
3436
import static oracle.weblogic.kubernetes.utils.OKDUtils.createRouteForOKD;
@@ -47,9 +49,9 @@
4749
*/
4850
@DisplayName("Verify that server in newly added dynamic cluster is started successfully")
4951
@IntegrationTest
50-
@Tag("oke-parallel")
5152
@Tag("kind-parallel")
5253
@Tag("olcne-mrg")
54+
@Tag("oke-gate")
5355
class ItAddNewDynamicClusterUsingWlst {
5456

5557
// domain constants
@@ -111,20 +113,26 @@ void testDynamicClusterNotAsConfigCluster() {
111113

112114
// In OKD cluster, we need to get the routeHost for the external admin service
113115
String routeHost = createRouteForOKD(getExternalServicePodName(adminServerPodName), domainNamespace);
114-
116+
115117
logger.info("Validating WebLogic admin server access by login to console");
116-
testUntil(
117-
assertDoesNotThrow(() -> {
118-
return adminNodePortAccessible(serviceNodePort, ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT, routeHost);
119-
}, "Access to admin server node port failed"),
120-
logger,
121-
"Console login validation");
118+
if (OKE_CLUSTER) {
119+
testUntil(isAppInServerPodReady(domainNamespace,
120+
adminServerPodName, 7001, "/console/login/LoginForm.jsp", "Copyright"),
121+
logger, "Validating WebLogic admin server access by login to console");
122+
} else {
123+
testUntil(
124+
assertDoesNotThrow(() -> {
125+
return adminNodePortAccessible(serviceNodePort,
126+
ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT, routeHost);
127+
}, "Access to admin server node port failed"), logger, "Console login validation");
128+
}
122129

123130
// create a new dynamic cluster using an online WLST script
124131
createNewDynamicCluster();
125132

126133
// verify the managed server pod in newly added dynamic cluster comes up
127134
checkPodReadyAndServiceExists(newManagedServerPodPrefix + 1, domainUid, domainNamespace);
135+
128136
}
129137

130138
private void createNewDynamicCluster() {

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@
3535
import static oracle.weblogic.kubernetes.TestConstants.FMWINFRA_IMAGE_TO_USE_IN_SPEC;
3636
import static oracle.weblogic.kubernetes.TestConstants.IMAGE_PULL_POLICY;
3737
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_APP_NAME;
38+
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER;
3839
import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_SECRET_NAME;
3940
import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR;
4041
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
42+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.isAppInServerPodReady;
43+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
4144
import static oracle.weblogic.kubernetes.utils.DbUtils.createRcuAccessSecret;
4245
import static oracle.weblogic.kubernetes.utils.DbUtils.setupDBandRCUschema;
4346
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
@@ -61,9 +64,9 @@
6164
@DisplayName("Test to Create a FMW Dynamic Domain with Dynamic Cluster using model in image")
6265
@IntegrationTest
6366
@Tag("olcne-mrg")
64-
@Tag("oke-parallel")
6567
@Tag("kind-parallel")
6668
@Tag("okd-fmw-cert")
69+
@Tag("oke-gate")
6770
class ItFmwDynamicClusterMiiDomain {
6871

6972
private static String dbNamespace = null;
@@ -143,11 +146,22 @@ void testFmwDynamicClusterDomainInModelInImage() {
143146
// create FMW dynamic domain and verify
144147
createFmwDomainAndVerify();
145148
verifyDomainReady(domainNamespace, domainUid, replicaCount, "nosuffix");
146-
// Expose the admin service external node port as a route for OKD
147-
adminSvcExtHost = createRouteForOKD(getExternalServicePodName(adminServerPodName), domainNamespace);
148-
verifyEMconsoleAccess(domainNamespace, domainUid, adminSvcExtHost);
149+
150+
if (OKE_CLUSTER) {
151+
final String resourcePath = "/em";
152+
testUntil(
153+
isAppInServerPodReady(domainNamespace,
154+
adminServerPodName, 7001, resourcePath, ""),
155+
logger, "verify EM console access {0} in server {1}",
156+
resourcePath, adminServerPodName);
157+
} else {
158+
// Expose the admin service external node port as a route for OKD
159+
adminSvcExtHost = createRouteForOKD(getExternalServicePodName(adminServerPodName), domainNamespace);
160+
verifyEMconsoleAccess(domainNamespace, domainUid, adminSvcExtHost);
161+
}
149162
}
150163

164+
151165
private void createFmwDomainAndVerify() {
152166
// Create the repo secret to pull the image
153167
// this secret is used only for non-kind cluster

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

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_WDT_MODEL_FILE;
6262
import static oracle.weblogic.kubernetes.TestConstants.MII_TWO_APP_WDT_MODEL_FILE;
6363
import static oracle.weblogic.kubernetes.TestConstants.OKD;
64+
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER;
6465
import static oracle.weblogic.kubernetes.TestConstants.OPERATOR_RELEASE_NAME;
6566
import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO;
6667
import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_PASSWORD;
@@ -101,6 +102,7 @@
101102
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
102103
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort;
103104
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
105+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.isAppInServerPodReady;
104106
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.startPortForwardProcess;
105107
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.stopPortForwardProcess;
106108
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
@@ -132,9 +134,9 @@
132134
@DisplayName("Test to a create model in image domain and start the domain")
133135
@IntegrationTest
134136
@Tag("olcne-mrg")
135-
@Tag("oke-parallel")
136137
@Tag("kind-parallel")
137138
@Tag("okd-wls-srg")
139+
@Tag("oke-gate")
138140
class ItMiiDomain {
139141

140142
private static String opNamespace = null;
@@ -285,35 +287,55 @@ void testCreateMiiDomain() {
285287
"Could not get the default-secure external service node port");
286288
logger.info("Found the administration service nodePort {0}", sslNodePort);
287289
String hostAndPort = getHostAndPort(adminSvcSslPortExtHost, sslNodePort);
290+
291+
final String resourcePath = "/console/login/LoginForm.jsp";
288292
if (!WEBLOGIC_SLIM) {
289-
String curlCmd = "curl --globoff -sk --show-error --noproxy '*' "
290-
+ " https://" + hostAndPort
291-
+ "/console/login/LoginForm.jsp --write-out %{http_code} -o /dev/null";
292-
logger.info("Executing default-admin nodeport curl command {0}", curlCmd);
293-
assertTrue(callWebAppAndWaitTillReady(curlCmd, 10));
294-
logger.info("WebLogic console is accessible thru default-secure service");
293+
if (OKE_CLUSTER) {
294+
testUntil(
295+
isAppInServerPodReady(domainNamespace,
296+
adminServerPodName, 7001, resourcePath, ""),
297+
logger, "verify EM console access {0} in server {1}",
298+
resourcePath,
299+
adminServerPodName);
300+
} else {
301+
String curlCmd = "curl -sk --show-error --noproxy '*' "
302+
+ " https://" + hostAndPort
303+
+ "/console/login/LoginForm.jsp --write-out %{http_code} -o /dev/null";
304+
logger.info("Executing default-admin nodeport curl command {0}", curlCmd);
305+
assertTrue(callWebAppAndWaitTillReady(curlCmd, 10));
306+
logger.info("WebLogic console is accessible thru default-secure service");
307+
}
295308
} else {
296309
logger.info("Skipping WebLogic console in WebLogic slim image");
297310
}
298311

299312
int nodePort = getServiceNodePort(
300-
domainNamespace, getExternalServicePodName(adminServerPodName), "default");
313+
domainNamespace, getExternalServicePodName(adminServerPodName), "default");
301314
assertNotEquals(-1, nodePort,
302-
"Could not get the default external service node port");
315+
"Could not get the default external service node port");
303316
logger.info("Found the default service nodePort {0}", nodePort);
304317
hostAndPort = getHostAndPort(adminSvcExtHost, nodePort);
305318

306319
if (!WEBLOGIC_SLIM) {
307-
String curlCmd2 = "curl -g -s --show-error --noproxy '*' "
308-
+ " http://" + hostAndPort
309-
+ "/console/login/LoginForm.jsp --write-out %{http_code} -o /dev/null";
310-
logger.info("Executing default nodeport curl command {0}", curlCmd2);
311-
assertTrue(callWebAppAndWaitTillReady(curlCmd2, 5));
320+
if (OKE_CLUSTER) {
321+
testUntil(
322+
isAppInServerPodReady(domainNamespace,
323+
adminServerPodName, 7001, resourcePath, ""),
324+
logger, "verify EM console access {0} in server {1}",
325+
resourcePath,
326+
adminServerPodName);
327+
} else {
328+
String curlCmd2 = "curl -s --show-error --noproxy '*' "
329+
+ " http://" + hostAndPort
330+
+ "/console/login/LoginForm.jsp --write-out %{http_code} -o /dev/null";
331+
logger.info("Executing default nodeport curl command {0}", curlCmd2);
332+
assertTrue(callWebAppAndWaitTillReady(curlCmd2, 5));
333+
}
312334
logger.info("WebLogic console is accessible thru default service");
313335
} else {
314336
logger.info("Checking Rest API management console in WebLogic slim image");
315337
verifyCredentials(7001, adminServerPodName, domainNamespace,
316-
ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT, true);
338+
ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT, true);
317339
}
318340

319341
// Test that `kubectl port-foward` is able to forward a local port to default channel port (7001 in this test)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.junit.jupiter.api.DisplayName;
3636
import org.junit.jupiter.api.Tag;
3737
import org.junit.jupiter.api.Test;
38+
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
3839

3940
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_DEFAULT;
4041
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_SERVER_NAME_BASE;
@@ -94,9 +95,9 @@
9495
@DisplayName("Test to verify the validating webhook for domain or cluster resource replicas count")
9596
@IntegrationTest
9697
@Tag("olcne-mrg")
97-
@Tag("oke-parallel")
9898
@Tag("kind-parallel")
9999
@Tag("okd-wls-mrg")
100+
@Tag("oke-gate")
100101
class ItValidateWebhookReplicas {
101102
private static String opNamespace = null;
102103
private static String domainNamespace = null;
@@ -222,6 +223,7 @@ void testClusterReplicasTooHigh() {
222223
*/
223224
@Test
224225
@DisplayName("Verify increasing the replicas of a cluster beyond configured WebLogic cluster size will be rejected")
226+
@DisabledIfEnvironmentVariable(named = "OKE_CLUSTER", matches = "true")
225227
void testScaleClusterReplicasTooHighUsingRest() {
226228
// scale the cluster with replicas value more than max cluster size using REST
227229
ExecResult execResult = scaleClusterWithRestApiAndReturnResult(domainUid, clusterName, replicaCountToPatch,

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

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
package oracle.weblogic.kubernetes.utils;
55

6+
import java.io.IOException;
7+
68
import io.kubernetes.client.custom.V1Patch;
79
import io.kubernetes.client.openapi.models.V1LocalObjectReference;
810
import io.kubernetes.client.openapi.models.V1ObjectMeta;
@@ -16,6 +18,8 @@
1618
import oracle.weblogic.kubernetes.logging.LoggingFacade;
1719
import org.awaitility.core.ConditionFactory;
1820

21+
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_DEFAULT;
22+
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
1923
import static oracle.weblogic.kubernetes.TestConstants.CLUSTER_API_VERSION;
2024
import static oracle.weblogic.kubernetes.TestConstants.CLUSTER_VERSION;
2125
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_VERSION;
@@ -300,6 +304,83 @@ public static boolean scaleClusterWithRestApi(String domainUid,
300304
return false;
301305
}
302306

307+
/**
308+
* Scale the cluster of the domain in the specified namespace with REST API.
309+
*
310+
* @param domainUid domainUid of the domain to be scaled
311+
* @param clusterName name of the WebLogic cluster to be scaled in the domain
312+
* @param numOfServers number of servers to be scaled to
313+
* @param nameSpace namespace of the pod
314+
* @param podName pod name to which the command should be sent to
315+
* @param podPort pod port number
316+
* @param decodedToken decoded secret token from operator sa
317+
* @param expectedMsg expected message in the http response
318+
* @param hasAuthHeader true or false to include auth header
319+
* @param hasHeader true or false to include header
320+
* @return true if REST call generate expected response message, false otherwise
321+
*/
322+
public static boolean scaleClusterWithRestApiInPod(String domainUid,
323+
String clusterName,
324+
int numOfServers,
325+
String nameSpace,
326+
String podName,
327+
int podPort,
328+
String decodedToken,
329+
String expectedMsg,
330+
boolean hasHeader,
331+
boolean hasAuthHeader) {
332+
LoggingFacade logger = getLogger();
333+
334+
// build the curl command to scale the cluster
335+
StringBuffer command = new StringBuffer(KUBERNETES_CLI)
336+
.append(" exec -n ")
337+
.append(nameSpace)
338+
.append(" ")
339+
.append(podName)
340+
.append(" -- curl --user ")
341+
.append(ADMIN_USERNAME_DEFAULT)
342+
.append(":")
343+
.append(ADMIN_PASSWORD_DEFAULT)
344+
.append(" --noproxy '*' -v -k ");
345+
if (hasAuthHeader) {
346+
command.append("-H \"Authorization:Bearer ").append(decodedToken).append("\" ");
347+
}
348+
command.append("-H Accept:application/json ").append("-H Content-Type:application/json ");
349+
if (hasHeader) {
350+
command.append("-H X-Requested-By:MyClient ");
351+
}
352+
command.append("-d '{\"spec\": {\"replicas\": ")
353+
.append(numOfServers)
354+
.append("}}' ")
355+
.append("-X POST https://")
356+
.append(podName)
357+
.append(":")
358+
.append(podPort)
359+
.append("/operator/latest/domains/")
360+
.append(domainUid)
361+
.append("/clusters/")
362+
.append(clusterName)
363+
.append("/scale");
364+
365+
ExecResult result = null;
366+
try {
367+
logger.info("Calling curl to scale the cluster");
368+
result = ExecCommand.exec(command.toString(), true);
369+
logger.info("result is: {0}", result.toString());
370+
logger.info("Return values {0}, errors {1}", result.stdout(), result.stderr());
371+
if (result != null) {
372+
logger.info("Return values {0}, errors {1}", result.stdout(), result.stderr());
373+
if (result.stdout().contains(expectedMsg) || result.stderr().contains(expectedMsg)) {
374+
return true;
375+
}
376+
}
377+
} catch (IOException | InterruptedException ex) {
378+
logger.severe(ex.getMessage());
379+
}
380+
381+
return false;
382+
}
383+
303384
/**
304385
* Scale the cluster of the domain in the specified namespace with the KUBERNETES_CLI.
305386
*

0 commit comments

Comments
 (0)