Skip to content

Commit 935016b

Browse files
authored
Merge pull request #488 from oracle/fix_wldf_scale_test
Fix wldf scaling test
2 parents 0a1c9e9 + 1ca06a7 commit 935016b

File tree

2 files changed

+42
-36
lines changed

2 files changed

+42
-36
lines changed

integration-tests/src/test/java/oracle/kubernetes/operator/BaseTest.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -408,23 +408,28 @@ private void copyScalingScriptToPod(
408408

409409
private void callWebAppAndVerifyScaling(Domain domain, int replicas) throws Exception {
410410
Map<String, Object> domainMap = domain.getDomainMap();
411-
String domainNS = (String) domainMap.get("namespace");
411+
String domainNS = domainMap.get("namespace").toString();
412+
String domainUid = domain.getDomainUid();
413+
String clusterName = domainMap.get("clusterName").toString();
412414

413415
// call opensessionapp
414416
domain.callWebAppAndVerifyLoadBalancing("opensessionapp", false);
415417
logger.info("Sleeping for 30 seconds for scaleup");
416418
Thread.sleep(30 * 1000);
417419

420+
int replicaCntAfterScaleup = TestUtils.getClusterReplicas(domainUid, clusterName, domainNS);
418421
String managedServerNameBase = (String) domainMap.get("managedServerNameBase");
419-
String podName = domain.getDomainUid() + "-" + managedServerNameBase + replicas;
422+
for (int i = replicas; i <= replicaCntAfterScaleup; i++) {
423+
String podName = domain.getDomainUid() + "-" + managedServerNameBase + i;
420424

421-
logger.info("Checking if managed pod(" + podName + ") is Running");
422-
TestUtils.checkPodCreated(podName, domainNS);
425+
logger.info("Checking if managed pod(" + podName + ") is Running");
426+
TestUtils.checkPodCreated(podName, domainNS);
423427

424-
logger.info("Checking if managed server (" + podName + ") is Running");
425-
TestUtils.checkPodReady(podName, domainNS);
428+
logger.info("Checking if managed server (" + podName + ") is Running");
429+
TestUtils.checkPodReady(podName, domainNS);
426430

427-
logger.info("Checking if managed service(" + podName + ") is created");
428-
TestUtils.checkServiceCreated(podName, domainNS);
431+
logger.info("Checking if managed service(" + podName + ") is created");
432+
TestUtils.checkServiceCreated(podName, domainNS);
433+
}
429434
}
430435
}

integration-tests/src/test/java/oracle/kubernetes/operator/utils/Domain.java

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -312,29 +312,24 @@ public void callWebAppAndVerifyLoadBalancing(String webappName, boolean verifyLo
312312
.append(":")
313313
.append(loadBalancerWebPort)
314314
.append("/");
315-
316315
if (loadBalancer.equals("APACHE")) {
317316
testAppUrl.append("weblogic/");
318317
}
319-
testAppUrl.append(webappName).append("/");
320-
321-
// curl cmd to call webapp
318+
testAppUrl.append(webappName).append("/"); // curl cmd to call webapp
322319
StringBuffer curlCmd = new StringBuffer("curl --silent --show-error --noproxy ");
323-
curlCmd.append(TestUtils.getHostName()).append(" ").append(testAppUrl.toString());
324-
325-
// curl cmd to get response code
320+
curlCmd
321+
.append(TestUtils.getHostName())
322+
.append(" ")
323+
.append(testAppUrl.toString()); // curl cmd to get response code
326324
StringBuffer curlCmdResCode = new StringBuffer(curlCmd.toString());
327-
curlCmdResCode.append(" --write-out %{http_code} -o /dev/null");
328-
329-
// call webapp iteratively till its deployed/ready
330-
callWebAppAndWaitTillReady(curlCmdResCode.toString());
331-
332-
if (verifyLoadBalance) {
333-
// execute curl and look for the managed server name in response
334-
callWebAppAndCheckForServerNameInResponse(curlCmd.toString());
335-
}
325+
curlCmdResCode.append(
326+
" --write-out %{http_code} -o /dev/null"); // call webapp iteratively till its
327+
// deployed/ready
328+
callWebAppAndWaitTillReady(
329+
curlCmdResCode
330+
.toString()); // execute curl and look for the managed server name in response
331+
callWebAppAndCheckForServerNameInResponse(curlCmd.toString(), verifyLoadBalance);
336332
// logger.info("curlCmd "+curlCmd);
337-
338333
}
339334
}
340335

@@ -706,34 +701,40 @@ private void callWebAppAndWaitTillReady(String curlCmd) throws Exception {
706701
}
707702
}
708703

709-
private void callWebAppAndCheckForServerNameInResponse(String curlCmd) throws Exception {
704+
private void callWebAppAndCheckForServerNameInResponse(
705+
String curlCmd, boolean verifyLoadBalancing) throws Exception {
710706
// map with server names and boolean values
711707
HashMap<String, Boolean> managedServers = new HashMap<String, Boolean>();
712708
for (int i = 1; i <= TestUtils.getClusterReplicas(domainUid, clusterName, domainNS); i++) {
713709
managedServers.put(domainUid + "-" + managedServerNameBase + i, new Boolean(false));
714710
}
715-
711+
logger.info("Calling webapp 20 times " + curlCmd);
716712
// number of times to call webapp
717713
for (int i = 0; i < 20; i++) {
718714
ExecResult result = ExecCommand.exec(curlCmd.toString());
719715
if (result.exitValue() != 0) {
720716
throw new RuntimeException(
721717
"FAILURE: command " + curlCmd + " failed, returned " + result.stderr());
722718
}
723-
String response = result.stdout().trim();
724-
// logger.info("response "+ response);
725-
for (String key : managedServers.keySet()) {
726-
if (response.contains(key)) {
727-
managedServers.put(key, new Boolean(true));
728-
break;
719+
if (verifyLoadBalancing) {
720+
String response = result.stdout().trim();
721+
// logger.info("response "+ response);
722+
for (String key : managedServers.keySet()) {
723+
if (response.contains(key)) {
724+
managedServers.put(key, new Boolean(true));
725+
break;
726+
}
729727
}
730728
}
731729
}
732730
logger.info("ManagedServers " + managedServers);
733731
// error if any managedserver value is false
734-
for (Map.Entry<String, Boolean> entry : managedServers.entrySet()) {
735-
if (!entry.getValue().booleanValue()) {
736-
throw new RuntimeException("FAILURE: Load balancer can not reach server " + entry.getKey());
732+
if (verifyLoadBalancing) {
733+
for (Map.Entry<String, Boolean> entry : managedServers.entrySet()) {
734+
if (!entry.getValue().booleanValue()) {
735+
throw new RuntimeException(
736+
"FAILURE: Load balancer can not reach server " + entry.getKey());
737+
}
737738
}
738739
}
739740
}

0 commit comments

Comments
 (0)