Skip to content

Commit eb37f61

Browse files
committed
Get the remote tests running again on the command line.
It wasn't great that they weren't working, but at least they are now.
1 parent 70d1962 commit eb37f61

File tree

5 files changed

+26
-29
lines changed

5 files changed

+26
-29
lines changed

java/client/test/org/openqa/selenium/testing/drivers/BUCK

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ java_library(name = 'drivers',
3131
'//java/client/test/org/openqa/selenium:helpers',
3232
'//java/client/test/org/openqa/selenium/testing:annotations',
3333
'//java/client/test/org/openqa/selenium/testing:helpers',
34+
'//java/server/src/org/openqa/grid/selenium:selenium',
3435
'//third_party/java/guava:guava',
3536
'//third_party/java/junit:junit',
3637
'//third_party/java/phantomjs-driver:phantomjs-driver',

java/client/test/org/openqa/selenium/testing/drivers/OutOfProcessSeleniumServer.java

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919

2020
import static java.util.concurrent.TimeUnit.SECONDS;
2121

22-
import com.google.common.io.Files;
23-
24-
import org.openqa.selenium.Build;
22+
import org.openqa.selenium.BuckBuild;
2523
import org.openqa.selenium.Capabilities;
2624
import org.openqa.selenium.net.NetworkUtils;
2725
import org.openqa.selenium.net.PortProber;
@@ -30,11 +28,10 @@
3028
import org.openqa.selenium.remote.DesiredCapabilities;
3129
import org.openqa.selenium.testing.InProject;
3230

33-
import java.io.File;
3431
import java.io.IOException;
3532
import java.net.MalformedURLException;
3633
import java.net.URL;
37-
import java.nio.charset.Charset;
34+
import java.nio.file.Path;
3835
import java.util.LinkedList;
3936
import java.util.List;
4037
import java.util.logging.Logger;
@@ -56,30 +53,25 @@ public void enableLogCapture() {
5653
*
5754
* @return The new server.
5855
*/
59-
public OutOfProcessSeleniumServer start() {
56+
public OutOfProcessSeleniumServer start() throws IOException {
6057
log.info("Got a request to start a new selenium server");
6158
if (command != null) {
6259
log.info("Server already started");
6360
throw new RuntimeException("Server already started");
6461
}
6562

66-
String classPath = buildServerAndClasspath();
63+
String serverJar = buildServerAndClasspath();
6764

6865
int port = PortProber.findFreePort();
6966
String localAddress = new NetworkUtils().getPrivateLocalAddress();
7067
baseUrl = String.format("http://%s:%d", localAddress, port);
7168

7269
List<String> cmdLine = new LinkedList<>();
7370
cmdLine.add("java");
74-
cmdLine.add("-cp");
75-
cmdLine.add(classPath);
76-
cmdLine.add("org.openqa.grid.selenium.GridLauncher");
71+
cmdLine.add("-jar");
72+
cmdLine.add(serverJar);
7773
cmdLine.add("-port");
7874
cmdLine.add(String.valueOf(port));
79-
cmdLine.add("-browserSideLog");
80-
if (captureLogs) {
81-
cmdLine.add("-captureLogsOnQuit");
82-
}
8375
command = new CommandLine(cmdLine.toArray(new String[cmdLine.size()]));
8476

8577
if (Boolean.getBoolean("webdriver.development")) {
@@ -92,10 +84,13 @@ public OutOfProcessSeleniumServer start() {
9284
try {
9385
URL url = new URL(baseUrl + "/wd/hub/status");
9486
log.info("Waiting for server status on URL " + url);
95-
new UrlChecker().waitUntilAvailable(60, SECONDS, url);
87+
new UrlChecker().waitUntilAvailable(30, SECONDS, url);
9688
log.info("Server is ready");
9789
} catch (UrlChecker.TimeoutException e) {
9890
log.severe("Server failed to start: " + e.getMessage());
91+
command.destroy();
92+
log.severe(command.getStdOut());
93+
command = null;
9994
throw new RuntimeException(e);
10095
} catch (MalformedURLException e) {
10196
throw new RuntimeException(e);
@@ -122,18 +117,9 @@ public void stop() {
122117
command = null;
123118
}
124119

125-
private String buildServerAndClasspath() {
126-
new Build().of("//java/server/src/org/openqa/grid/selenium:selenium")
127-
.of("//java/server/src/org/openqa/grid/selenium:selenium:classpath")
128-
.go();
129-
130-
String classpathFile = InProject.locate(
131-
"build/java/server/src/org/openqa/grid/selenium/selenium.classpath").getAbsolutePath();
132-
try {
133-
return Files.readFirstLine(new File(classpathFile), Charset.defaultCharset());
134-
} catch (IOException e) {
135-
throw new RuntimeException(e);
136-
}
120+
private String buildServerAndClasspath() throws IOException {
121+
Path serverJar = new BuckBuild().of("//java/server/src/org/openqa/grid/selenium:selenium").go();
122+
return serverJar.toAbsolutePath().toString();
137123
}
138124

139125
public URL getWebDriverUrl() {

java/client/test/org/openqa/selenium/testing/drivers/RemoteSupplier.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import org.openqa.selenium.remote.LocalFileDetector;
2525
import org.openqa.selenium.remote.RemoteWebDriver;
2626

27+
import java.io.IOException;
28+
2729
public class RemoteSupplier implements Supplier<WebDriver> {
2830

2931
private static OutOfProcessSeleniumServer server = new OutOfProcessSeleniumServer();
@@ -57,7 +59,11 @@ private synchronized void startServer() {
5759
return;
5860
}
5961

60-
server.start();
62+
try {
63+
server.start();
64+
} catch (IOException e) {
65+
throw new RuntimeException(e);
66+
}
6167
started = true;
6268
}
6369
}

java/server/src/org/openqa/grid/selenium/BUCK

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ java_binary(name = 'selenium',
99
deps = [
1010
':classes',
1111
],
12+
visibility = [
13+
'//java/client/test/org/openqa/selenium/testing/drivers:drivers',
14+
]
1215
)
1316

1417
genrule(name = 'manifest',

java/server/test/org/openqa/selenium/remote/server/SessionLogsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import org.openqa.selenium.testing.drivers.BrowserToCapabilities;
5050
import org.openqa.selenium.testing.drivers.OutOfProcessSeleniumServer;
5151

52+
import java.io.IOException;
5253
import java.io.InputStreamReader;
5354
import java.net.URL;
5455
import java.util.Map;
@@ -61,7 +62,7 @@ public class SessionLogsTest extends JUnit4TestBase {
6162
private RemoteWebDriver localDriver;
6263

6364
@BeforeClass
64-
public static void startUpServer() {
65+
public static void startUpServer() throws IOException {
6566
server = new OutOfProcessSeleniumServer();
6667
server.enableLogCapture();
6768
server.start();

0 commit comments

Comments
 (0)