@@ -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