Skip to content

Commit 896a5b6

Browse files
committed
Merge branch 'move-to-oke-seq2' into 'main'
OWLS-116810 [OKE] Update ItMultiDomainModelsScale to run on Internal Jenkin See merge request weblogic-cloud/weblogic-kubernetes-operator!4655
2 parents f7539c4 + 578fa65 commit 896a5b6

File tree

5 files changed

+856
-55
lines changed

5 files changed

+856
-55
lines changed

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

Lines changed: 135 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import oracle.weblogic.kubernetes.annotations.Namespaces;
3131
import oracle.weblogic.kubernetes.logging.LoggingFacade;
3232
import oracle.weblogic.kubernetes.utils.DomainUtils;
33+
import oracle.weblogic.kubernetes.utils.ExecResult;
3334
import org.junit.jupiter.api.BeforeAll;
3435
import org.junit.jupiter.api.DisplayName;
3536
import org.junit.jupiter.api.Tag;
@@ -48,7 +49,9 @@
4849
import static oracle.weblogic.kubernetes.TestConstants.MANAGED_SERVER_NAME_BASE;
4950
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_APP_NAME;
5051
import static oracle.weblogic.kubernetes.TestConstants.OKD;
52+
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER;
5153
import static oracle.weblogic.kubernetes.TestConstants.OPERATOR_EXTERNAL_REST_HTTPSPORT;
54+
import static oracle.weblogic.kubernetes.TestConstants.OPERATOR_RELEASE_NAME;
5255
import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_SECRET_NAME;
5356
import static oracle.weblogic.kubernetes.TestConstants.TRAEFIK_INGRESS_HTTP_HOSTPORT;
5457
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_NAME;
@@ -61,6 +64,7 @@
6164
import static oracle.weblogic.kubernetes.actions.TestActions.buildAppArchive;
6265
import static oracle.weblogic.kubernetes.actions.TestActions.defaultAppParams;
6366
import static oracle.weblogic.kubernetes.actions.TestActions.getDomainCustomResource;
67+
import static oracle.weblogic.kubernetes.actions.TestActions.getOperatorPodName;
6468
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
6569
import static oracle.weblogic.kubernetes.actions.TestActions.getServicePort;
6670
import static oracle.weblogic.kubernetes.actions.TestActions.listIngresses;
@@ -73,8 +77,10 @@
7377
import static oracle.weblogic.kubernetes.utils.ClusterUtils.createClusterResourceAndAddReferenceToDomain;
7478
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
7579
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createIngressHostRouting;
80+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.exeAppInServerPod;
7681
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort;
7782
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
83+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getServiceExtIPAddrtOke;
7884
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.scaleAndVerifyCluster;
7985
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.startPortForwardProcess;
8086
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.stopPortForwardProcess;
@@ -97,6 +103,7 @@
97103
import static oracle.weblogic.kubernetes.utils.SecretUtils.createSecretWithUsernamePassword;
98104
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
99105
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
106+
import static org.junit.jupiter.api.Assertions.assertEquals;
100107
import static org.junit.jupiter.api.Assertions.assertNotEquals;
101108
import static org.junit.jupiter.api.Assertions.assertNotNull;
102109
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -114,7 +121,7 @@
114121
+ "rolling restart behavior in a multi-cluster MII domain and "
115122
+ "the sample application can be accessed via NGINX ingress controller")
116123
@Tag("kind-sequential")
117-
@Tag("oke-sequential")
124+
@Tag("oke-gate")
118125
@IntegrationTest
119126
class ItMultiDomainModelsScale {
120127

@@ -140,6 +147,7 @@ class ItMultiDomainModelsScale {
140147
private static String opNamespace = null;
141148
private static String opServiceAccount = null;
142149
private static NginxParams nginxHelmParams = null;
150+
private static String nginxNamespace = null;
143151
private static int nodeportshttp = 0;
144152
private static LoggingFacade logger = null;
145153
private static String miiDomainNamespace = null;
@@ -170,7 +178,7 @@ public static void initAll(@Namespaces(5) List<String> namespaces) {
170178
// get a unique NGINX namespace
171179
logger.info("Get a unique namespace for NGINX");
172180
assertNotNull(namespaces.get(1), "Namespace list is null");
173-
String nginxNamespace = namespaces.get(1);
181+
nginxNamespace = namespaces.get(1);
174182

175183
// get unique namespaces for three different type of domains
176184
logger.info("Getting unique namespaces for three different type of domains");
@@ -245,23 +253,45 @@ void testScaleClustersByPatchingClusterResource(String domainType) {
245253
numberOfServers = 3;
246254
}
247255

248-
logger.info("Scaling cluster {0} of domain {1} in namespace {2} to {3} servers.",
249-
clusterName, domainUid, domainNamespace, numberOfServers);
250-
curlCmd = generateCurlCmd(domainUid, domainNamespace, clusterName, SAMPLE_APP_CONTEXT_ROOT);
251-
List<String> managedServersBeforeScale = listManagedServersBeforeScale(numClusters, clusterName, replicaCount);
252-
scaleAndVerifyCluster(clusterName, domainUid, domainNamespace, managedServerPodNamePrefix,
253-
replicaCount, numberOfServers, curlCmd, managedServersBeforeScale);
254-
255-
// then scale cluster back to 1 servers
256-
logger.info("Scaling cluster {0} of domain {1} in namespace {2} from {3} servers to {4} servers.",
257-
clusterName, domainUid, domainNamespace, numberOfServers, replicaCount);
258-
managedServersBeforeScale = listManagedServersBeforeScale(numClusters, clusterName, numberOfServers);
259-
scaleAndVerifyCluster(clusterName, domainUid, domainNamespace, managedServerPodNamePrefix,
260-
numberOfServers, replicaCount, curlCmd, managedServersBeforeScale);
256+
if (OKE_CLUSTER) {
257+
logger.info("Scaling cluster {0} of domain {1} in namespace {2} to {3} servers.",
258+
clusterName, domainUid, domainNamespace, numberOfServers);
259+
scaleAndVerifyCluster(clusterName, domainUid, domainNamespace, managedServerPodNamePrefix,
260+
replicaCount, numberOfServers, null, null);
261+
262+
// then scale cluster back to 1 servers
263+
logger.info("Scaling cluster {0} of domain {1} in namespace {2} from {3} servers to {4} servers.",
264+
clusterName, domainUid, domainNamespace, numberOfServers, replicaCount);
265+
scaleAndVerifyCluster(clusterName, domainUid, domainNamespace, managedServerPodNamePrefix,
266+
numberOfServers, replicaCount, null, null);
267+
} else {
268+
logger.info("Scaling cluster {0} of domain {1} in namespace {2} to {3} servers.",
269+
clusterName, domainUid, domainNamespace, numberOfServers);
270+
curlCmd = generateCurlCmd(domainUid, domainNamespace, clusterName, SAMPLE_APP_CONTEXT_ROOT);
271+
List<String> managedServersBeforeScale = listManagedServersBeforeScale(numClusters, clusterName, replicaCount);
272+
scaleAndVerifyCluster(clusterName, domainUid, domainNamespace, managedServerPodNamePrefix,
273+
replicaCount, numberOfServers, curlCmd, managedServersBeforeScale);
274+
275+
// then scale cluster back to 1 servers
276+
logger.info("Scaling cluster {0} of domain {1} in namespace {2} from {3} servers to {4} servers.",
277+
clusterName, domainUid, domainNamespace, numberOfServers, replicaCount);
278+
managedServersBeforeScale = listManagedServersBeforeScale(numClusters, clusterName, numberOfServers);
279+
scaleAndVerifyCluster(clusterName, domainUid, domainNamespace, managedServerPodNamePrefix,
280+
numberOfServers, replicaCount, curlCmd, managedServersBeforeScale);
281+
}
261282
}
262283

263284
// verify admin console login
264-
if (!WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
285+
if (OKE_CLUSTER) {
286+
String resourcePath = "/console/login/LoginForm.jsp";
287+
final String adminServerPodName = domainUid + "-admin-server";
288+
ExecResult result = exeAppInServerPod(domainNamespace, adminServerPodName, ADMIN_SERVER_PORT, resourcePath);
289+
logger.info("result in OKE_CLUSTER is {0}", result.toString());
290+
assertEquals(0, result.exitValue(), "Failed to access WebLogic console");
291+
292+
// verify admin console login using ingress controller
293+
verifyReadyAppUsingIngressController(domainUid, domainNamespace);
294+
} else if (!WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
265295
hostHeader = createIngressHostRoutingIfNotExists(domainNamespace, domainUid);
266296
assertDoesNotThrow(()
267297
-> verifyAdminServerRESTAccess("localhost", TRAEFIK_INGRESS_HTTP_HOSTPORT, false, hostHeader));
@@ -305,25 +335,47 @@ void testScaleClustersWithRestApi(String domainType) {
305335
String clusterName = domain.getSpec().getClusters().get(0).getName();
306336
String managedServerPodNamePrefix = generateMsPodNamePrefix(numClusters, domainUid, clusterName);
307337
int numberOfServers = 3;
338+
String operatorPodName = null;
339+
curlCmd = generateCurlCmd(domainUid, domainNamespace, clusterName, SAMPLE_APP_CONTEXT_ROOT);
340+
341+
if (OKE_CLUSTER) {
342+
// get operator pod name
343+
operatorPodName = assertDoesNotThrow(() -> getOperatorPodName(OPERATOR_RELEASE_NAME, opNamespace));
344+
assertNotNull(operatorPodName, "Operator pod name returned is null");
345+
logger.info("Operator pod name {0}", operatorPodName);
346+
curlCmd = domainType.contains("modelInImage")
347+
? generateCurlCmd(domainUid, domainNamespace, clusterName, SAMPLE_APP_CONTEXT_ROOT) : null;
348+
}
308349

309350
logger.info("Scaling cluster {0} of domain {1} in namespace {2} from {3} servers to {4} servers.",
310351
clusterName, domainUid, domainNamespace, replicaCount, numberOfServers);
311-
curlCmd = generateCurlCmd(domainUid, domainNamespace, clusterName, SAMPLE_APP_CONTEXT_ROOT);
352+
//curlCmd = generateCurlCmd(domainUid, domainNamespace, clusterName, SAMPLE_APP_CONTEXT_ROOT);
312353
List<String> managedServersBeforeScale = listManagedServersBeforeScale(numClusters, clusterName, replicaCount);
313354
scaleAndVerifyCluster(clusterName, domainUid, domainNamespace, managedServerPodNamePrefix,
314355
replicaCount, numberOfServers, true, OPERATOR_EXTERNAL_REST_HTTPSPORT, opNamespace, opServiceAccount,
315-
false, "", "", 0, "", "", curlCmd, managedServersBeforeScale);
356+
false, "", "", 0, "", "",
357+
curlCmd, managedServersBeforeScale, operatorPodName);
316358

317359
// then scale cluster back to 2 servers
318360
logger.info("Scaling cluster {0} of domain {1} in namespace {2} from {3} servers to {4} servers.",
319361
clusterName, domainUid, domainNamespace, numberOfServers, replicaCount);
320362
managedServersBeforeScale = listManagedServersBeforeScale(numClusters, clusterName, numberOfServers);
321363
scaleAndVerifyCluster(clusterName, domainUid, domainNamespace, managedServerPodNamePrefix,
322364
numberOfServers, replicaCount, true, OPERATOR_EXTERNAL_REST_HTTPSPORT, opNamespace, opServiceAccount,
323-
false, "", "", 0, "", "", curlCmd, managedServersBeforeScale);
365+
false, "", "", 0, "", "",
366+
curlCmd, managedServersBeforeScale, operatorPodName);
324367

325368
// verify admin console login
326-
if (!WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
369+
if (OKE_CLUSTER) {
370+
String resourcePath = "/console/login/LoginForm.jsp";
371+
final String adminServerPodName = domainUid + "-admin-server";
372+
ExecResult result = exeAppInServerPod(domainNamespace, adminServerPodName,ADMIN_SERVER_PORT, resourcePath);
373+
logger.info("result in OKE_CLUSTER is {0}", result.toString());
374+
assertEquals(0, result.exitValue(), "Failed to access WebLogic console");
375+
376+
// verify admin console login using ingress controller
377+
verifyReadyAppUsingIngressController(domainUid, domainNamespace);
378+
} else if (!WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
327379
hostHeader = createIngressHostRoutingIfNotExists(domainNamespace, domainUid);
328380
assertDoesNotThrow(()
329381
-> verifyAdminServerRESTAccess("localhost", TRAEFIK_INGRESS_HTTP_HOSTPORT, false, hostHeader));
@@ -341,6 +393,10 @@ void testScaleClustersWithRestApi(String domainType) {
341393
* Scale cluster using WLDF policy for three different type of domains.
342394
* i.e. domain-on-pv, domain-in-image and model-in-image
343395
*
396+
* In internal OKE env, we only test scaling cluster using WLDF policy for domain type, model-in-image.
397+
* domain type, domain-in-image is excluded and domain type, domain-on-pv is tested in
398+
* ItMultiDomainModelsScaleWithWLDFDomainOnPV.java
399+
*
344400
* @param domainType domain type, possible value: modelInImage, domainInImage, domainOnPV
345401
*/
346402
@ParameterizedTest
@@ -361,15 +417,21 @@ void testScaleClustersWithWLDF(String domainType) {
361417
String managedServerPodNamePrefix = generateMsPodNamePrefix(numClusters, domainUid, clusterName);
362418

363419
curlCmd = generateCurlCmd(domainUid, domainNamespace, clusterName, SAMPLE_APP_CONTEXT_ROOT);
364-
logger.info("BR: curlCmd = {0}", curlCmd);
420+
logger.info("Generated curlCmd = {0}", curlCmd);
421+
422+
// domain type, domain-in-image is excluded and domain type, domain-on-pv is tested in
423+
// ItMultiDomainModelsScaleWithWLDFDomainOnPV.java
424+
if (OKE_CLUSTER && (domainType.contains("domainInImage") || domainType.contains("domainOnPV"))) {
425+
return;
426+
}
365427

366428
// scale up the cluster by 1 server
367429
logger.info("Scaling cluster {0} of domain {1} in namespace {2} from {3} servers to {4} servers.",
368430
clusterName, domainUid, domainNamespace, replicaCount, replicaCount + 1);
369431
List<String> managedServersBeforeScale = listManagedServersBeforeScale(numClusters, clusterName, replicaCount);
370432
String curlCmdForWLDFScript =
371433
generateCurlCmd(domainUid, domainNamespace, clusterName, WLDF_OPENSESSION_APP_CONTEXT_ROOT);
372-
logger.info("BR: curlCmdForWLDFScript = {0}", curlCmdForWLDFScript);
434+
logger.info("Generated curlCmdForWLDFScript = {0}", curlCmdForWLDFScript);
373435

374436
scaleAndVerifyCluster(clusterName, domainUid, domainNamespace, managedServerPodNamePrefix,
375437
replicaCount, replicaCount + 1, false, OPERATOR_EXTERNAL_REST_HTTPSPORT, opNamespace, opServiceAccount,
@@ -387,7 +449,16 @@ void testScaleClustersWithWLDF(String domainType) {
387449
WLDF_OPENSESSION_APP, curlCmdForWLDFScript, curlCmd, managedServersBeforeScale);
388450

389451
// verify admin console login
390-
if (!WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
452+
if (OKE_CLUSTER) {
453+
String resourcePath = "/console/login/LoginForm.jsp";
454+
final String adminServerPodName = domainUid + "-admin-server";
455+
ExecResult result = exeAppInServerPod(domainNamespace, adminServerPodName,ADMIN_SERVER_PORT, resourcePath);
456+
logger.info("result in OKE_CLUSTER is {0}", result.toString());
457+
assertEquals(0, result.exitValue(), "Failed to access WebLogic console");
458+
459+
// verify admin console login using ingress controller
460+
verifyReadyAppUsingIngressController(domainUid, domainNamespace);
461+
} else if (!WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
391462
hostHeader = createIngressHostRoutingIfNotExists(domainNamespace, domainUid);
392463
assertDoesNotThrow(()
393464
-> verifyAdminServerRESTAccess("localhost", TRAEFIK_INGRESS_HTTP_HOSTPORT, false, hostHeader));
@@ -575,22 +646,30 @@ private static DomainResource createDomainOnPvUsingWdt(String domainUid, String
575646
* @param appContextRoot the context root of the application
576647
* @return curl command string
577648
*/
578-
private static String generateCurlCmd(String domainUid, String domainNamespace, String clusterName,
649+
private static String generateCurlCmd(String domainUid,
650+
String domainNamespace,
651+
String clusterName,
579652
String appContextRoot) {
580653
if (OKD) {
581654
String routeHost = getRouteHost(domainNamespace, domainUid + "-cluster-" + clusterName);
582655
logger.info("routeHost = {0}", routeHost);
583-
return String.format("curl -g -v --show-error --noproxy '*' http://%s/%s/index.jsp",
584-
routeHost, appContextRoot);
585-
656+
return String.format("curl -g -v --show-error --noproxy '*' http://%s/%s/index.jsp", routeHost, appContextRoot);
586657
} else {
587658
String host = K8S_NODEPORT_HOST;
588659
if (host.contains(":")) {
589660
host = "[" + host + "]";
590661
}
591-
return String.format("curl -g -v --show-error --noproxy '*' -H 'host: %s' http://%s/%s/index.jsp",
592-
domainUid + "." + domainNamespace + "." + clusterName + ".test",
593-
getHostAndPort(host, nodeportshttp), appContextRoot);
662+
if (OKE_CLUSTER) {
663+
String nginxServiceName = nginxHelmParams.getHelmParams().getReleaseName() + "-ingress-nginx-controller";
664+
665+
return String.format("curl -g -v --show-error --noproxy '*' -H 'host: %s' http://%s/%s/index.jsp",
666+
domainUid + "." + domainNamespace + "." + clusterName + ".test",
667+
getServiceExtIPAddrtOke(nginxServiceName, nginxNamespace), appContextRoot);
668+
} else {
669+
return String.format("curl -g -v --show-error --noproxy '*' -H 'host: %s' http://%s/%s/index.jsp",
670+
domainUid + "." + domainNamespace + "." + clusterName + ".test",
671+
getHostAndPort(host, nodeportshttp), appContextRoot);
672+
}
594673
}
595674
}
596675

@@ -740,7 +819,10 @@ private static void createRouteForOKDOrIngressForDomain(DomainResource domain) {
740819

741820
if (!OKD) {
742821
logger.info("Creating ingress for domain {0} in namespace {1}", domainUid, domainNamespace);
743-
if (WLSIMG_BUILDER.equals(WLSIMG_BUILDER_DEFAULT)) {
822+
if (OKE_CLUSTER) {
823+
createIngressForDomainAndVerify(domainUid, domainNamespace, 0, clusterNameMsPortMap,
824+
false, nginxHelmParams.getIngressClassName(), false, 0);
825+
} else if (WLSIMG_BUILDER.equals(WLSIMG_BUILDER_DEFAULT)) {
744826
createIngressForDomainAndVerify(domainUid, domainNamespace, nodeportshttp, clusterNameMsPortMap,
745827
true, nginxHelmParams.getIngressClassName(), true, ADMIN_SERVER_PORT);
746828
} else {
@@ -820,22 +902,30 @@ private void verifyReadyAppUsingAdminNodePort(String domainUid, String domainNam
820902
private void verifyReadyAppUsingIngressController(String domainUid, String domainNamespace) {
821903

822904
if (!OKD) {
905+
if (OKE_CLUSTER) {
906+
final String adminServerPodName = domainUid + "-admin-server";
907+
String resourcePath = "/weblogic/ready";
908+
ExecResult result = exeAppInServerPod(domainNamespace, adminServerPodName, 7002, resourcePath);
909+
logger.info("result in OKE_CLUSTER is {0}", result.toString());
910+
assertEquals(0, result.exitValue(), "Failed to access WebLogic ready app");
911+
} else {
912+
String host = K8S_NODEPORT_HOST;
913+
if (host.contains(":")) {
914+
host = "[" + host + "]";
915+
}
823916

824-
String host = K8S_NODEPORT_HOST;
825-
if (host.contains(":")) {
826-
host = "[" + host + "]";
917+
String curlCmd = "curl -g --silent --show-error --noproxy '*' -H 'host: "
918+
+ domainUid + "." + domainNamespace + ".adminserver.test"
919+
+ "' http://" + host + ":" + nodeportshttp
920+
+ "/weblogic/ready --write-out %{http_code} -o /dev/null";
921+
922+
logger.info("Executing curl command {0}", curlCmd);
923+
testUntil(() -> callWebAppAndWaitTillReady(curlCmd, 5),
924+
logger,
925+
"Ready app on domain {0} in namespace {1} is accessible",
926+
domainUid,
927+
domainNamespace);
827928
}
828-
String curlCmd = "curl -g --silent --show-error --noproxy '*' -H 'host: "
829-
+ domainUid + "." + domainNamespace + ".adminserver.test"
830-
+ "' http://" + host + ":" + nodeportshttp
831-
+ "/weblogic/ready --write-out %{http_code} -o /dev/null";
832-
833-
logger.info("Executing curl command {0}", curlCmd);
834-
testUntil(() -> callWebAppAndWaitTillReady(curlCmd, 5),
835-
logger,
836-
"Ready app on domain {0} in namespace {1} is accessible",
837-
domainUid,
838-
domainNamespace);
839929

840930
logger.info("Ready app on domain1 is accessible");
841931
} else {

0 commit comments

Comments
 (0)