Skip to content

Commit

Permalink
[bazel]: Build Grid TNG with bazel
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed May 15, 2019
1 parent 2870009 commit c5334a3
Show file tree
Hide file tree
Showing 24 changed files with 291 additions and 4 deletions.
10 changes: 10 additions & 0 deletions java/server/src/org/openqa/selenium/cli/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
java_library(
name = "cli",
srcs = glob(["*.java"]),
deps = [
"//third_party/java/guava",
],
visibility = [
"//java/server/src/org/openqa/selenium/grid:__subpackages__",
]
)
12 changes: 12 additions & 0 deletions java/server/src/org/openqa/selenium/docker/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
java_library(
name = "docker",
srcs = glob(["*.java"]),
deps = [
"//java/client/src/org/openqa/selenium/json",
"//java/client/src/org/openqa/selenium/remote",
"//third_party/java/guava",
],
visibility = [
"//java/server/src/org/openqa/selenium/grid/docker:__pkg__",
]
)
19 changes: 16 additions & 3 deletions java/server/src/org/openqa/selenium/docker/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
import static org.openqa.selenium.remote.http.HttpMethod.DELETE;
import static org.openqa.selenium.remote.http.HttpMethod.POST;

import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.remote.http.Contents;
import org.openqa.selenium.remote.http.HttpRequest;
import org.openqa.selenium.remote.http.HttpResponse;

import java.net.HttpURLConnection;
import java.time.Duration;
import java.util.Objects;
import java.util.function.Function;
Expand All @@ -46,7 +49,11 @@ public ContainerId getId() {

public void start() {
LOG.info("Starting " + getId());
client.apply(new HttpRequest(POST, String.format("/containers/%s/start", id)));
HttpResponse res = client.apply(
new HttpRequest(POST, String.format("/containers/%s/start", id)));
if (res.getStatus() != HttpURLConnection.HTTP_OK) {
throw new WebDriverException("Unable to start container: " + Contents.string(res));
}
}

public void stop(Duration timeout) {
Expand All @@ -59,13 +66,19 @@ public void stop(Duration timeout) {
HttpRequest request = new HttpRequest(POST, String.format("/containers/%s/stop", id));
request.addQueryParameter("t", seconds);

client.apply(request);
HttpResponse res = client.apply(request);
if (res.getStatus() != HttpURLConnection.HTTP_OK) {
throw new WebDriverException("Unable to stop container: " + Contents.string(res));
}
}

public void delete() {
LOG.info("Removing " + getId());

HttpRequest request = new HttpRequest(DELETE, "/containers/" + id);
client.apply(request);
HttpResponse res = client.apply(request);
if (res.getStatus() != HttpURLConnection.HTTP_OK) {
LOG.warning("Unable to delete container");
}
}
}
8 changes: 7 additions & 1 deletion java/server/src/org/openqa/selenium/docker/Docker.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@

import com.google.common.reflect.TypeToken;

import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.json.Json;
import org.openqa.selenium.json.JsonException;
import org.openqa.selenium.json.JsonOutput;
import org.openqa.selenium.remote.http.Contents;
import org.openqa.selenium.remote.http.HttpClient;
import org.openqa.selenium.remote.http.HttpRequest;
import org.openqa.selenium.remote.http.HttpResponse;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.HttpURLConnection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -94,7 +97,10 @@ public Image pull(String name, String tag) {
request.addQueryParameter("fromImage", name);
request.addQueryParameter("tag", tag);

client.apply(request);
HttpResponse res = client.apply(request);
if (res.getStatus() != HttpURLConnection.HTTP_OK) {
throw new WebDriverException("Unable to pull container: " + name);
}

LOG.info(String.format("Pull of %s:%s complete", name, tag));

Expand Down
2 changes: 2 additions & 0 deletions java/server/src/org/openqa/selenium/events/local/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ java_library(
name = "local",
srcs = glob(["*.java"]),
visibility = [
"//java/server/src/org/openqa/selenium/grid:__pkg__",
"//java/server/src/org/openqa/selenium/grid/commands:__pkg__",
"//java/server/test/org/openqa/selenium/grid:__subpackages__",
],
deps = [
Expand Down
3 changes: 3 additions & 0 deletions java/server/src/org/openqa/selenium/events/zeromq/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ java_library(
name = "zeromq",
srcs = glob(["*.java"]),
visibility = [
"//java/server/src/org/openqa/selenium/grid:__pkg__",
"//java/server/src/org/openqa/selenium/grid/commands:__pkg__",
"//java/server/src/org/openqa/selenium/grid/server:__pkg__",
"//java/server/test/org/openqa/selenium/grid/router:__pkg__",
],
deps = [
Expand Down
22 changes: 22 additions & 0 deletions java/server/src/org/openqa/selenium/grid/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
java_binary(
name = "grid",
main_class = "org.openqa.selenium.grid.Main",
srcs = glob(["*.java"]),
deps = [
"//java/server/src/org/openqa/selenium/cli",
],
runtime_deps = [
"//java/client/src/org/openqa/selenium/chrome",
"//java/client/src/org/openqa/selenium/edge",
"//java/client/src/org/openqa/selenium/firefox",
"//java/client/src/org/openqa/selenium/ie",
"//java/client/src/org/openqa/selenium/safari",
"//java/server/src/org/openqa/selenium/events/local",
"//java/server/src/org/openqa/selenium/events/zeromq",
"//java/server/src/org/openqa/selenium/grid/commands",
"//java/server/src/org/openqa/selenium/grid/distributor/httpd",
"//java/server/src/org/openqa/selenium/grid/node/httpd",
"//java/server/src/org/openqa/selenium/grid/router/httpd",
"//java/server/src/org/openqa/selenium/grid/sessionmap/httpd",
]
)
34 changes: 34 additions & 0 deletions java/server/src/org/openqa/selenium/grid/commands/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
java_library(
name = "commands",
srcs = glob(["*.java"]),
deps = [
"//java/client/src/org/openqa/selenium:core",
"//java/client/src/org/openqa/selenium/net",
"//java/client/src/org/openqa/selenium/remote/http",
"//java/client/src/org/openqa/selenium/remote/tracing",
"//java/server/src/org/openqa/selenium/cli",
"//java/server/src/org/openqa/selenium/events",
"//java/server/src/org/openqa/selenium/grid/config",
"//java/server/src/org/openqa/selenium/grid/distributor",
"//java/server/src/org/openqa/selenium/grid/distributor/local",
"//java/server/src/org/openqa/selenium/grid/docker",
"//java/server/src/org/openqa/selenium/grid/log",
"//java/server/src/org/openqa/selenium/grid/node",
"//java/server/src/org/openqa/selenium/grid/node/config",
"//java/server/src/org/openqa/selenium/grid/node/local",
"//java/server/src/org/openqa/selenium/grid/router",
"//java/server/src/org/openqa/selenium/grid/server",
"//java/server/src/org/openqa/selenium/grid/sessionmap",
"//java/server/src/org/openqa/selenium/grid/sessionmap/local",
"//java/server/src/org/openqa/selenium/grid/web",
"//third_party/java/beust:jcommander",
"//third_party/java/guava",
"//third_party/java/service",
],
runtime_deps = [
"//java/server/src/org/openqa/selenium/events/local",
],
visibility = [
"//java/server/src/org/openqa/selenium/grid:__pkg__",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
java_library(
name = "config",
srcs = glob(["*.java"]),
deps = [
"//java/client/src/org/openqa/selenium/net",
"//java/client/src/org/openqa/selenium/remote/http",
"//java/client/src/org/openqa/selenium/remote/tracing",
"//java/server/src/org/openqa/selenium/grid/config",
"//java/server/src/org/openqa/selenium/grid/distributor",
"//java/server/src/org/openqa/selenium/grid/distributor/remote",
"//third_party/java/beust:jcommander",
],
visibility = [
"//java/server/src/org/openqa/selenium/grid:__subpackages__",
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
java_library(
name = "httpd",
srcs = glob(["*.java"]),
deps = [
"//java/client/src/org/openqa/selenium/remote/tracing",
"//java/server/src/org/openqa/selenium/cli",
"//java/server/src/org/openqa/selenium/events",
"//java/server/src/org/openqa/selenium/grid/config",
"//java/server/src/org/openqa/selenium/grid/distributor",
"//java/server/src/org/openqa/selenium/grid/distributor/local",
"//java/server/src/org/openqa/selenium/grid/log",
"//java/server/src/org/openqa/selenium/grid/server",
"//java/server/src/org/openqa/selenium/grid/sessionmap",
"//java/server/src/org/openqa/selenium/grid/sessionmap/config",
"//java/server/src/org/openqa/selenium/grid/web",
"//third_party/java/beust:jcommander",
"//third_party/java/guava",
"//third_party/java/service",
],
visibility = [
"//java/server/src/org/openqa/selenium/grid:__pkg__",
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ java_library(
name = "local",
srcs = glob(["*.java"]),
visibility = [
"//java/server/src/org/openqa/selenium/grid/commands:__pkg__",
"//java/server/src/org/openqa/selenium/grid/distributor/httpd:__pkg__",
"//java/server/test/org/openqa/selenium/grid/distributor:__pkg__",
"//java/server/test/org/openqa/selenium/grid/router:__pkg__",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ java_library(
name = "remote",
srcs = glob(["*.java"]),
visibility = [
"//java/server/src/org/openqa/selenium/grid:__subpackages__",
"//java/server/test/org/openqa/selenium/grid/distributor:__pkg__",
"//java/server/test/org/openqa/selenium/grid/router:__pkg__",
],
Expand Down
21 changes: 21 additions & 0 deletions java/server/src/org/openqa/selenium/grid/docker/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
java_library(
name = "docker",
srcs = glob(["*.java"]),
deps = [
"//java/client/src/org/openqa/selenium/json",
"//java/client/src/org/openqa/selenium/net",
"//java/client/src/org/openqa/selenium/remote",
"//java/client/src/org/openqa/selenium/support",
"//java/server/src/org/openqa/selenium/docker",
"//java/server/src/org/openqa/selenium/grid/config",
"//java/server/src/org/openqa/selenium/grid/data",
"//java/server/src/org/openqa/selenium/grid/node",
"//java/server/src/org/openqa/selenium/grid/node/local",
"//third_party/java/beust:jcommander",
"//third_party/java/guava",
],
visibility = [
"//java/server/src/org/openqa/selenium/grid/commands:__pkg__",
"//java/server/src/org/openqa/selenium/grid/node/httpd:__pkg__",
]
)
12 changes: 12 additions & 0 deletions java/server/src/org/openqa/selenium/grid/log/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
java_library(
name = "log",
srcs = glob(["*.java"]),
deps = [
"//java/client/src/org/openqa/selenium/json",
"//java/client/src/org/openqa/selenium/remote/tracing",
"//java/server/src/org/openqa/selenium/grid/config",
],
visibility = [
"//java/server/src/org/openqa/selenium/grid:__subpackages__",
]
)
14 changes: 14 additions & 0 deletions java/server/src/org/openqa/selenium/grid/node/config/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
java_library(
name = "config",
srcs = glob(["*.java"]),
deps = [
"//java/client/src/org/openqa/selenium/remote",
"//java/server/src/org/openqa/selenium/grid/config",
"//java/server/src/org/openqa/selenium/grid/data",
"//java/server/src/org/openqa/selenium/grid/node",
"//java/server/src/org/openqa/selenium/grid/node/local",
],
visibility = [
"//java/server/src/org/openqa/selenium/grid:__subpackages__",
]
)
25 changes: 25 additions & 0 deletions java/server/src/org/openqa/selenium/grid/node/httpd/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
java_library(
name = "httpd",
srcs = glob(["*.java"]),
deps = [
"//java/client/src/org/openqa/selenium/remote/tracing",
"//java/server/src/org/openqa/selenium/cli",
"//java/server/src/org/openqa/selenium/concurrent",
"//java/server/src/org/openqa/selenium/events",
"//java/server/src/org/openqa/selenium/grid/component",
"//java/server/src/org/openqa/selenium/grid/config",
"//java/server/src/org/openqa/selenium/grid/data",
"//java/server/src/org/openqa/selenium/grid/docker",
"//java/server/src/org/openqa/selenium/grid/log",
"//java/server/src/org/openqa/selenium/grid/node/config",
"//java/server/src/org/openqa/selenium/grid/node/local",
"//java/server/src/org/openqa/selenium/grid/server",
"//java/server/src/org/openqa/selenium/grid/web",
"//third_party/java/beust:jcommander",
"//third_party/java/guava",
"//third_party/java/service",
],
visibility = [
"//java/server/src/org/openqa/selenium/grid:__pkg__",
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ java_library(
name = "local",
srcs = glob(["*.java"]),
visibility = [
"//java/server/src/org/openqa/selenium/grid/commands:__pkg__",
"//java/server/src/org/openqa/selenium/grid/docker:__pkg__",
"//java/server/src/org/openqa/selenium/grid/node/config:__pkg__",
"//java/server/src/org/openqa/selenium/grid/node/httpd:__pkg__",
"//java/server/test/org/openqa/selenium/grid:__subpackages__",
],
deps = [
Expand Down
2 changes: 2 additions & 0 deletions java/server/src/org/openqa/selenium/grid/router/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ java_library(
name = "router",
srcs = glob(["*.java"]),
visibility = [
"//java/server/src/org/openqa/selenium/grid/commands:__subpackages__",
"//java/server/src/org/openqa/selenium/grid/router:__subpackages__",
"//java/server/test/org/openqa/selenium/grid:__subpackages__",
],
deps = [
Expand Down
24 changes: 24 additions & 0 deletions java/server/src/org/openqa/selenium/grid/router/httpd/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
java_library(
name = "httpd",
srcs = glob(["*.java"]),
deps = [
"//java/client/src/org/openqa/selenium/remote/http",
"//java/client/src/org/openqa/selenium/remote/tracing",
"//java/server/src/org/openqa/selenium/cli",
"//java/server/src/org/openqa/selenium/grid/config",
"//java/server/src/org/openqa/selenium/grid/distributor",
"//java/server/src/org/openqa/selenium/grid/distributor/config",
"//java/server/src/org/openqa/selenium/grid/log",
"//java/server/src/org/openqa/selenium/grid/node",
"//java/server/src/org/openqa/selenium/grid/router",
"//java/server/src/org/openqa/selenium/grid/server",
"//java/server/src/org/openqa/selenium/grid/sessionmap",
"//java/server/src/org/openqa/selenium/grid/sessionmap/config",
"//java/server/src/org/openqa/selenium/grid/web",
"//third_party/java/beust:jcommander",
"//third_party/java/service",
],
visibility = [
"//java/server/src/org/openqa/selenium/grid:__pkg__",
]
)
3 changes: 3 additions & 0 deletions java/server/src/org/openqa/selenium/grid/server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ java_library(
"//java/server/src/org/openqa/selenium/netty/server:__pkg__",
"//java/server/test/org/openqa/selenium/grid:__subpackages__",
],
runtime_deps = [
"//java/server/src/org/openqa/selenium/events/zeromq",
],
deps = [
"//java/client/src/org/openqa/selenium:core",
"//java/client/src/org/openqa/selenium/json",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
java_library(
name = "config",
srcs = glob(["*.java"]),
deps = [
"//java/client/src/org/openqa/selenium/remote/http",
"//java/server/src/org/openqa/selenium/grid/config",
"//java/server/src/org/openqa/selenium/grid/sessionmap",
"//java/server/src/org/openqa/selenium/grid/sessionmap/remote",
"//third_party/java/beust:jcommander",
],
visibility = [
"//java/server/src/org/openqa/selenium/grid:__subpackages__",
]
)

0 comments on commit c5334a3

Please sign in to comment.