Greetings,
I have completed developing a suite of tests using Selenium RC and Java and I'm trying to integrate them with the build system so I can run the tests overnight. The process runs like this:
- Cruisecontrol does a full build
- A cron job on the Cruisecontrol server installs the build on a specific test cluster.
- When the build installation is complete a web page is updated with the results of the install (pass/fail).
- An application (trigger.jar) running on a client machine (Windows XP) will be monitoring the web page. When it detects a successful install it will start the Selenium tests:
java -jar overnightTests.jar
. - It is not necessary for the trigger application to do any logging or to capture the exit code for the test suite. All that stuff is handled by the test suite.
I've already written all the pieces but the trigger is giving me trouble.
Here's my code:
try {
String cmd = "java";
String jArg = "-jar";
String program = "overnightTests.jar";
String aptUrl = "https://apt.qa6.spockmate.com/apt/" ;
String campaignManagerURL = "http://app01.dev02.sn.spockmate.com:8080/cm/" ;
String contractDatafile = "C:\\testdata\\MasterDataForSelenium.xls" ;
String adMapDataDir = "C:\\testdata\\AdMaps\\" ;
String creativeAssetsFile = "C:\\testdata\\CreativeAssets\\CreativeAssetsForSeleniumTests.csv";
String adminURL = "https://admin.qa6.spockmate.com/admin/";
String [] commands = new String[]{cmd, jArg, program, aptUrl, campaignManagerURL, contractDatafile, adMapDataDir, creativeAssetsFile, adminURL};
Process child = Runtime.getRuntime().exec(commands);
} catch (IOException e) {
System.out.println("Exception thrown while calling Runtime:");
System.out.println(e.getCause());
e.printStackTrace();
}
When the line "Runtime.getRuntime().exec(commands)" executes, the trigger.jar hangs. It doesn't matter if I'm running the app from the DOS command line or from Eclipse. Here's the weird part: once I kill the trigger.jar application (via ctrl-c or Eclipse's stop button) the overnightTests.jar application that I'm trying to trigger will start. This happens every time I run the application. It's as if instead of starting the overnight_tests.jar the tool is being placed in a queue to be started "next". I've tried assigning 'Runtime.getRuntime().exec(commands);' to a Process variable and doing a wait() on the Process and I've tried ignoring the return altogether. The result is always the same.
My questions are:
- What is my code missing that would allow it to launch overnightTests.jar in a separate process and forget about it, allowing Selenium to go off on its merry way and do its thing?
- For anyone who has faced this problem before, is there an easier, cleaner, less-elaborate solution? I have a great deal of control over the format of the trigger signal and how it is sent and received and my main requirement is that the solution be robust. Anything that works and isn't over-elaborate or complex is worth a try.
Any help or suggestions would make me very happy and make it far more likely that I'll be able finish this project and go on vacation at the end of the month.