diff options
author | Alpha Lam <alpha.lam.ts@gmail.com> | 2016-05-15 19:13:52 +0000 |
---|---|---|
committer | Kristina Chodorow <kchodorow@google.com> | 2016-05-16 15:17:02 +0000 |
commit | a1a79cb0a1880e825618c6440219680f27faa0b7 (patch) | |
tree | aecf14deeb67de64710884785b495379d6379817 /src/test/shell | |
parent | db89a643180895c0b9ca27911adf1ff692212d1c (diff) |
Prototype for remote execution using gRPC and Netty transport
This change implements a remote worker that executes work (build or test).
Bazel will be a client of the remote worker. The communication uses gRPC
and Netty as transport.
A single remote worker has little advantage over running locally. Additional
infrastructure is needed to run workers on multiple machines and distributing
the work among them.
This change provides the basic building blocks for a distributed build farm.
(Mainly reformatting changes compared to https://bazel-review.googlesource.com/3110, some BUILD file changes.)
--
Change-Id: If7d285444ef42a6823b59443af17b61b04b9ce6a
Reviewed-on: https://bazel-review.googlesource.com/#/c/3110/
MOS_MIGRATED_REVID=122376861
Diffstat (limited to 'src/test/shell')
-rw-r--r-- | src/test/shell/bazel/BUILD | 10 | ||||
-rwxr-xr-x | src/test/shell/bazel/remote_execution_test.sh | 82 |
2 files changed, 92 insertions, 0 deletions
diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD index 9c7b5562ec..7f3937e71e 100644 --- a/src/test/shell/bazel/BUILD +++ b/src/test/shell/bazel/BUILD @@ -326,6 +326,16 @@ sh_test( ], ) +sh_test( + name = "remote_execution_test", + size = "large", + srcs = ["remote_execution_test.sh"], + data = [ + ":test-deps", + "//src/tools/remote_worker", + ], +) + test_suite( name = "all_tests", visibility = ["//visibility:public"], diff --git a/src/test/shell/bazel/remote_execution_test.sh b/src/test/shell/bazel/remote_execution_test.sh new file mode 100755 index 0000000000..0083ba7357 --- /dev/null +++ b/src/test/shell/bazel/remote_execution_test.sh @@ -0,0 +1,82 @@ +#!/bin/bash +# +# Copyright 2016 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Tests remote execution and caching. +# + +# Load test environment +src_dir=$(cd "$(dirname ${BASH_SOURCE[0]})" && pwd) +source $src_dir/test-setup.sh \ + || { echo "test-setup.sh not found!" >&2; exit 1; } + +function set_up() { + mkdir -p a + cat > a/BUILD <<EOF +package(default_visibility = ["//visibility:public"]) +cc_binary( +name = 'test', +srcs = [ 'test.cc' ], +) +EOF + cat > a/test.cc <<EOF +#include <iostream> +int main() { std::cout << "Hello world!" << std::endl; return 0; } +EOF + work_path=$(mktemp -d ${TEST_TMPDIR}/remote.XXXXXXXX) + pid_file=$(mktemp -u ${TEST_TMPDIR}/remote.XXXXXXXX) + ${bazel_data}/src/tools/remote_worker/remote_worker \ + --work_path=${work_path} \ + --listen_port 8080 \ + --pid_file=${pid_file} >& $TEST_log & + local wait_seconds=0 + until [ -s "${pid_file}" ] || [ $wait_seconds -eq 30 ]; do + sleep 1 + ((wait_seconds++)) + done + if [ ! -s "${pid_file}" ]; then + fail "Timed out waiting for remote worker to start." + fi +} + +function tear_down() { + if [ -s ${pid_file} ]; then + local pid=$(cat ${pid_file}) + kill ${pid} || true + fi + rm -rf ${pid_file} + rm -rf ${work_path} +} + +function test_cc_binary() { + bazel build //a:test >& $TEST_log \ + || fail "Failed to build //a:test without remote execution" + cp bazel-bin/a/test ${TEST_TMPDIR}/test_expected + bazel clean --expunge + + bazel build \ + --spawn_strategy=remote \ + --hazelcast_node=localhost:5701 \ + --remote_worker=localhost:8080 \ + //a:test >& $TEST_log \ + || fail "Failed to build //a:test with remote execution" + diff bazel-bin/a/test ${TEST_TMPDIR}/test_expected \ + || fail "Remote execution generated different result" +} + +# TODO(alpha): Add a test that fails remote execution when remote worker +# supports sandbox. + +run_suite "Remote execution tests" |