Alpha Lam has uploaded a new change for review.
https://bazel-review.googlesource.com/3650
Change subject: Remote worker to listen to a specific port for Hazelcast
......................................................................
Remote worker to listen to a specific port for Hazelcast
This change allows starting remote worker with an embedded hazelcast server
that listens to
a specific port. This allows test to run reliably.
Change-Id: I0bb36af5837f83cad3d76b8acb50f89cd599ee87
---
M
src/main/java/com/google/devtools/build/lib/remote/HazelcastCacheFactory.java
M src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java
M src/test/shell/bazel/remote_execution_test.sh
3 files changed, 26 insertions(+), 3 deletions(-)
diff --git
a/src/main/java/com/google/devtools/build/lib/remote/HazelcastCacheFactory.java
b/src/main/java/com/google/devtools/build/lib/remote/HazelcastCacheFactory.java
index f4e3486..081889a 100644
---
a/src/main/java/com/google/devtools/build/lib/remote/HazelcastCacheFactory.java
+++
b/src/main/java/com/google/devtools/build/lib/remote/HazelcastCacheFactory.java
@@ -17,6 +17,8 @@
import com.hazelcast.client.HazelcastClient;
import com.hazelcast.client.config.ClientConfig;
import com.hazelcast.client.config.ClientNetworkConfig;
+import com.hazelcast.config.Config;
+import com.hazelcast.config.NetworkConfig;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
@@ -38,6 +40,14 @@
ClientNetworkConfig net = config.getNetworkConfig();
net.addAddress(options.hazelcastNode.split(","));
instance = HazelcastClient.newHazelcastClient(config);
+ } else if (options.hazelcastStandaloneListenPort != 0) {
+ Config config = new Config();
+ config.getNetworkConfig()
+ .setPort(options.hazelcastStandaloneListenPort)
+ .getJoin()
+ .getMulticastConfig()
+ .setEnabled(false);
+ instance = Hazelcast.newHazelcastInstance(config);
} else {
// Otherwise create a default instance. This is going to look at
// -Dhazelcast.config=some-hazelcast.xml for configuration.
diff --git
a/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java
b/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java
index 5ca8abf..4116a93 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java
@@ -30,6 +30,16 @@
public String hazelcastNode;
@Option(
+ name = "hazelcast_standalone_listen_port",
+ defaultValue = "0",
+ category = "build_worker",
+ help =
+ "Runs an embedded hazelcast server that listens to this port. The
server does not join"
+ + " any cluster. This is useful for testing."
+ )
+ public int hazelcastStandaloneListenPort;
+
+ @Option(
name = "remote_worker",
defaultValue = "null",
category = "remote",
diff --git a/src/test/shell/bazel/remote_execution_test.sh
b/src/test/shell/bazel/remote_execution_test.sh
index 7f7cd68..65b421d 100755
--- a/src/test/shell/bazel/remote_execution_test.sh
+++ b/src/test/shell/bazel/remote_execution_test.sh
@@ -37,9 +37,12 @@
EOF
work_path=$(mktemp -d ${TEST_TMPDIR}/remote.XXXXXXXX)
pid_file=$(mktemp -u ${TEST_TMPDIR}/remote.XXXXXXXX)
+ worker_port=$(pick_random_unused_tcp_port) || exit 1
+ hazelcast_port=$(pick_random_unused_tcp_port) || exit 1
${bazel_data}/src/tools/remote_worker/remote_worker \
--work_path=${work_path} \
- --listen_port 8080 \
+ --listen_port=${worker_port} \
+ --hazelcast_standalone_listen_port=${hazelcast_port} \
--pid_file=${pid_file} >& $TEST_log &
local wait_seconds=0
until [ -s "${pid_file}" ] || [ $wait_seconds -eq 30 ]; do
@@ -68,8 +71,8 @@
bazel build \
--spawn_strategy=remote \
- --hazelcast_node=localhost:5701 \
- --remote_worker=localhost:8080 \
+ --hazelcast_node=localhost:${hazelcast_port} \
+ --remote_worker=localhost:${worker_port} \
//a:test >& $TEST_log \
|| fail "Failed to build //a:test with remote execution"
diff bazel-bin/a/test ${TEST_TMPDIR}/test_expected \
--
To view, visit
https://bazel-review.googlesource.com/3650
To unsubscribe, visit
https://bazel-review.googlesource.com/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0bb36af5837f83cad3d76b8acb50f89cd599ee87
Gerrit-PatchSet: 1
Gerrit-Project: bazel
Gerrit-Branch: master
Gerrit-Owner: Alpha Lam <
alpha....@gmail.com>