@@ -468,7 +468,6 @@ public void callWebAppAndVerifyLoadBalancing(String webappName, boolean verifyLo
468
468
.append (domainUid )
469
469
.append (".org' " )
470
470
.append (testAppUrl .toString ());
471
-
472
471
// curl cmd to get response code
473
472
StringBuffer curlCmdResCode = new StringBuffer (curlCmd .toString ());
474
473
curlCmdResCode .append (" --write-out %{http_code} -o /dev/null" );
@@ -705,6 +704,15 @@ public String getAdminServerName() {
705
704
return adminServerName ;
706
705
}
707
706
707
+ /**
708
+ * Get the name of the cluster in the domain
709
+ *
710
+ * @return the name of the cluster
711
+ */
712
+ public String getClusterName () {
713
+ return clusterName ;
714
+ }
715
+
708
716
/**
709
717
* Get the namespace in which the domain is running
710
718
*
@@ -1198,43 +1206,47 @@ private void callWebAppAndWaitTillReady(String curlCmd) throws Exception {
1198
1206
String responseCode = result .stdout ().trim ();
1199
1207
if (!responseCode .equals ("200" )) {
1200
1208
logger .info (
1201
- "testwebapp did not return 200 status code, got "
1209
+ "callWebApp did not return 200 status code, got "
1202
1210
+ responseCode
1203
1211
+ ", iteration "
1204
1212
+ i
1205
1213
+ " of "
1206
1214
+ maxIterations );
1207
1215
if (i == (maxIterations - 1 )) {
1208
1216
throw new RuntimeException (
1209
- "FAILURE: testwebapp did not return 200 status code, got " + responseCode );
1217
+ "FAILURE: callWebApp did not return 200 status code, got " + responseCode );
1210
1218
}
1211
1219
try {
1212
1220
Thread .sleep (waitTime * 1000 );
1213
1221
} catch (InterruptedException ignore ) {
1214
1222
}
1215
1223
} else {
1216
- logger .info ("testwebapp returned 200 response code, iteration " + i );
1224
+ logger .info ("callWebApp returned 200 response code, iteration " + i );
1217
1225
break ;
1218
1226
}
1219
1227
}
1220
1228
}
1221
1229
1222
1230
private void callWebAppAndCheckForServerNameInResponse (
1223
1231
String curlCmd , boolean verifyLoadBalancing ) throws Exception {
1232
+ callWebAppAndCheckForServerNameInResponse (curlCmd , verifyLoadBalancing , 50 );
1233
+ }
1234
+
1235
+ private void callWebAppAndCheckForServerNameInResponse (
1236
+ String curlCmd , boolean verifyLoadBalancing , int maxIterations ) throws Exception {
1224
1237
// map with server names and boolean values
1225
1238
HashMap <String , Boolean > managedServers = new HashMap <String , Boolean >();
1226
1239
for (int i = 1 ; i <= TestUtils .getClusterReplicas (domainUid , clusterName , domainNS ); i ++) {
1227
1240
managedServers .put (domainUid + "-" + managedServerNameBase + i , new Boolean (false ));
1228
1241
}
1229
- logger .info ("Calling webapp 20 times " + curlCmd );
1242
+ logger .info ("Calling webapp " + maxIterations + " times " + curlCmd );
1230
1243
// number of times to call webapp
1231
- for (int i = 0 ; i < 20 ; i ++) {
1232
- ExecResult result = TestUtils .exec (curlCmd );
1233
1244
1245
+ for (int i = 0 ; i < maxIterations ; i ++) {
1246
+ ExecResult result = ExecCommand .exec (curlCmd .toString ());
1234
1247
logger .info ("webapp invoked successfully for curlCmd:" + curlCmd );
1235
1248
if (verifyLoadBalancing ) {
1236
1249
String response = result .stdout ().trim ();
1237
- // logger.info("response: " + response);
1238
1250
for (String key : managedServers .keySet ()) {
1239
1251
if (response .contains (key )) {
1240
1252
managedServers .put (key , new Boolean (true ));
@@ -1243,6 +1255,7 @@ private void callWebAppAndCheckForServerNameInResponse(
1243
1255
}
1244
1256
}
1245
1257
}
1258
+
1246
1259
logger .info ("ManagedServers " + managedServers );
1247
1260
1248
1261
// error if any managedserver value is false
@@ -1643,19 +1656,13 @@ public void restartManagedServerUsingServerStartPolicy(String msName) throws Exc
1643
1656
* @param webappName - Web App Name to be deployed
1644
1657
* @param scriptName - a shell script to build WAR, EAR or JAR file and deploy the App in the
1645
1658
* admin pod
1646
- * @param archiveExt - archive extention
1647
- * @param infoDirNames - archive information dir location
1648
1659
* @param username - weblogic user name
1649
1660
* @param password - weblogc password
1661
+ * @param args - optional args to add for script if needed
1650
1662
* @throws Exception
1651
1663
*/
1652
- private void callShellScriptToBuildDeployAppInPod (
1653
- String webappName ,
1654
- String scriptName ,
1655
- String archiveExt ,
1656
- String infoDirNames ,
1657
- String username ,
1658
- String password )
1664
+ public void callShellScriptToBuildDeployAppInPod (
1665
+ String webappName , String scriptName , String username , String password , String ... args )
1659
1666
throws Exception {
1660
1667
1661
1668
String nodeHost = getHostNameForCurl ();
@@ -1692,9 +1699,7 @@ private void callShellScriptToBuildDeployAppInPod(
1692
1699
.append (" " )
1693
1700
.append (clusterName )
1694
1701
.append (" " )
1695
- .append (infoDirNames )
1696
- .append (" " )
1697
- .append (archiveExt )
1702
+ .append (String .join (" " , args ).toString ())
1698
1703
.append ("'" );
1699
1704
1700
1705
logger .info ("Command to exec script file: " + cmdKubectlSh );
@@ -1795,7 +1800,7 @@ public void buildDeployJavaAppInPod(
1795
1800
String scriptPathOnHost = BaseTest .getAppLocationOnHost () + "/" + scriptName ;
1796
1801
String scriptPathInPod = BaseTest .getAppLocationInPod () + "/" + scriptName ;
1797
1802
1798
- // Default velues to build archive file
1803
+ // Default values to build archive file
1799
1804
final String initInfoDirName = "WEB-INF" ;
1800
1805
String archiveExt = "war" ;
1801
1806
String infoDirName = initInfoDirName ;
@@ -1817,6 +1822,7 @@ public boolean accept(File dir, String name) {
1817
1822
// Check archive file type
1818
1823
if (!subDirList .contains (infoDirName )) {
1819
1824
infoDirName = "META-INF" ;
1825
+
1820
1826
// Create .ear file or .jar file for EJB
1821
1827
archiveExt = (args .length == 0 ) ? "ear" : args [0 ];
1822
1828
}
@@ -1833,9 +1839,8 @@ public boolean accept(File dir, String name) {
1833
1839
1834
1840
// Copy all App files to the admin pod
1835
1841
TestUtils .copyAppFilesToPod (appLocationOnHost , appLocationInPod , adminServerPod , domainNS );
1836
-
1837
1842
// Run the script to build WAR, EAR or JAR file and deploy the App in the admin pod
1838
1843
callShellScriptToBuildDeployAppInPod (
1839
- appName , scriptName , archiveExt , infoDirName , username , password );
1844
+ appName , scriptName , username , password , infoDirName , archiveExt );
1840
1845
}
1841
1846
}
0 commit comments