- In one machine, run registry file MaxUserPort.reg
-
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters] "EnableICMPRedirect"=dword:00000000 "TcpTimedWaitDelay"=dword:0000001e "MaxUserPort"=dword:0000ea60 "DisableIPSourceRouting"=dword:00000002 "EnableDeadGWDetect"=dword:00000000 "KeepAliveTime"=dword:000493e0 "TcpMaxDataRetransmissions"=dword:00000004
- Run stress test:IEGridTest.java ChromeGridTest.java GridTest.java
/**
* @author junjshi, created on Sep 3, 2013
*
*/
import java.io.File;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.testng.annotations.Test;
import com.ebay.maui.controller.TestPlan;
@Test
public class GridTest extends TestPlan{
private static String browser="firefox";
private static final int threadPoolSize = 200;
private static int count = 0;
private static String profilePath = "C:\\grid\\profile\\customProfileDirCUSTFF";
private static String url = "http://gear2-hub-8915.phx-os1.stratus.dev.ebay.com:8080/wd/hub";
private static final int interval = 2;//minutes
public static void main(String[] args) {
ExecutorService exec = Executors.newFixedThreadPool(threadPoolSize);
CommonTest.setUrl(url);
CommonTest.setProfilePath(profilePath);
CommonTest.setInterval(interval);
Runnable task = new Runnable() {
@Override
public void run() {
while (true) {
try {
System.out.println("Clean "+System.getProperty("java.io.tmpdir"));
File tempDir = new File(System.getProperty("java.io.tmpdir"));
CommonTest.deleteDirectory(tempDir);
System.out.println("Executing thread #"+ count++);
new CommonTest().testGrid(browser);
} catch (Exception e) {
e.printStackTrace();
}
}
}
};
for (int i = 0; i < threadPoolSize; i++) {
exec.execute(task);
}
}
}
CommonTest.java
import java.io.File;
import java.net.MalformedURLException;
import java.util.Calendar;
import java.util.Date;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.openqa.selenium.WebDriver;
import com.ebay.maui.driver.web.WebUXDriver;
/**
* @author junjshi, created on Dec 9, 2013
*
*/
public class CommonTest {
private static String profilePath = "C:\\grid\\profile\\customProfileDirCUSTFF";
private static String url = "http://gear2-hub-8915.phx-os1.stratus.dev.ebay.com:8080/wd/hub";
private static int interval = 2;//minutes
public static void setInterval(int interval) {
CommonTest.interval = interval;
}
public static String getProfilePath() {
return profilePath;
}
public static void setProfilePath(String profilePath) {
CommonTest.profilePath = profilePath;
}
public static String getUrl() {
return url;
}
public static void setUrl(String url) {
CommonTest.url = url;
}
public static int getInterval() {
return interval;
}
public void runTest(String url) throws MalformedURLException{
WebUXDriver.getWebUXDriver().setMode("ExistingGrid");
WebUXDriver.getWebUXDriver().setHubUrl(url);
WebUXDriver.getWebUXDriver().setFfProfilePath(profilePath);
WebDriver driver = WebUXDriver.getWebDriver(true);
driver.get("http://www.qa.ebay.com");
driver.get("http://www.qa.ebay.com");
driver.get("http://www.qa.ebay.com");
System.out.println(driver.getTitle());
try{
driver.quit();
}catch(Exception ex){}
}
public void runChromeTest(String url) throws MalformedURLException{
WebUXDriver.getWebUXDriver().setBrowser("chrome");
WebUXDriver.getWebUXDriver().setMode("ExistingGrid");
WebUXDriver.getWebUXDriver().setHubUrl(url);
WebDriver driver = WebUXDriver.getWebDriver(true);
driver.get("http://www.qa.ebay.com");
driver.get("http://www.qa.ebay.com");
driver.get("http://www.qa.ebay.com");
System.out.println(driver.getTitle());
try{
driver.quit();
}catch(Exception ex){}
}
public void runIETest(String url) throws MalformedURLException{
WebUXDriver.getWebUXDriver().setBrowser("iexplore");
WebUXDriver.getWebUXDriver().setMode("ExistingGrid");
WebUXDriver.getWebUXDriver().setHubUrl(url);
WebDriver driver = WebUXDriver.getWebDriver(true);
driver.get("http://www.qa.ebay.com");
System.out.println(driver.getTitle());
try{
driver.quit();
}catch(Exception ex){}
}
public void testGrid(String browser) throws MalformedURLException, InterruptedException{
ExecutorService exec = Executors.newCachedThreadPool();
int timeout = 60 * 30;
final String browserName = browser;
Callable<Boolean> task = new Callable<Boolean>(){
@Override
public Boolean call() throws Exception {
if(browserName.equalsIgnoreCase("chrome")){
runChromeTest(url);
return Boolean.TRUE;
}else if(browserName.equalsIgnoreCase("firefox")){
runTest(url);
return Boolean.TRUE;
}else
{
runIETest(url);
return Boolean.TRUE;
}
}
};
Calendar start = Calendar.getInstance();
start.setTime(new Date());