aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar Alpha Lam <alpha.lam.ts@gmail.com>2017-03-28 12:42:36 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2017-03-28 19:51:11 +0000
commitf7ceb426c71aa14eb09dc7b24d696897b5c5fb44 (patch)
tree02b4bc53c37e4f61c9a283e611eb4293e0b2e60c /src/test
parent3718a36c83657238f458076ddf5da957f6b54118 (diff)
Refactor simple distributed caching support
The simple distributed caching in Bazel used ConcurrentMap as a blob store. It is incorrect to use an overloaded interface for this purpose. This change defines a SimpleBlobStore interface that only has put(), get() and containsKey() methods and allows a simple implementation of a blob store as remote cache for Bazel. Also updated documentation to summarize the options available in the remote spwan strategy. There is no functional change. TESTED=shell integration tests -- Change-Id: Iedff0bc4f06c4a93c398c53801014d998c3df13b Reviewed-on: https://cr.bazel.build/9330 PiperOrigin-RevId: 151439467 MOS_MIGRATED_REVID=151439467
Diffstat (limited to 'src/test')
-rw-r--r--src/test/shell/bazel/BUILD10
-rwxr-xr-xsrc/test/shell/bazel/remote_execution_test.sh60
2 files changed, 67 insertions, 3 deletions
diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD
index 8a479e61a3..409ad004d6 100644
--- a/src/test/shell/bazel/BUILD
+++ b/src/test/shell/bazel/BUILD
@@ -370,6 +370,16 @@ sh_test(
)
sh_test(
+ name = "remote_cache_test",
+ size = "large",
+ srcs = ["remote_cache_test.sh"],
+ data = [
+ ":test-deps",
+ "//src/tools/remote_worker",
+ ],
+)
+
+sh_test(
name = "client_test",
size = "medium",
srcs = ["client_test.sh"],
diff --git a/src/test/shell/bazel/remote_execution_test.sh b/src/test/shell/bazel/remote_execution_test.sh
index 9726ad07ed..7dd6949b64 100755
--- a/src/test/shell/bazel/remote_execution_test.sh
+++ b/src/test/shell/bazel/remote_execution_test.sh
@@ -66,9 +66,9 @@ int main() { std::cout << "Hello world!" << std::endl; return 0; }
EOF
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
+ cp -f bazel-bin/a/test ${TEST_TMPDIR}/test_expected
+ bazel clean --expunge
bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 build \
--spawn_strategy=remote \
--remote_worker=localhost:${worker_port} \
@@ -101,7 +101,61 @@ EOF
|| fail "Failed to run //a:test with remote execution"
}
+function test_cc_binary_grpc_cache() {
+ 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
+ bazel build //a:test >& $TEST_log \
+ || fail "Failed to build //a:test without remote cache"
+ cp -f bazel-bin/a/test ${TEST_TMPDIR}/test_expected
+
+ bazel clean --expunge
+ bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 build \
+ --spawn_strategy=remote \
+ --remote_cache=localhost:${worker_port} \
+ //a:test >& $TEST_log \
+ || fail "Failed to build //a:test with remote gRPC cache service"
+ diff bazel-bin/a/test ${TEST_TMPDIR}/test_expected \
+ || fail "Remote cache generated different result"
+}
+
+function test_cc_binary_rest_cache() {
+ 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
+ bazel build //a:test >& $TEST_log \
+ || fail "Failed to build //a:test without remote cache"
+ cp -f bazel-bin/a/test ${TEST_TMPDIR}/test_expected
+
+ bazel clean --expunge
+ bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 build \
+ --spawn_strategy=remote \
+ --rest_cache_url=http://localhost:${hazelcast_port}/hazelcast/rest/maps/cache \
+ //a:test >& $TEST_log \
+ || fail "Failed to build //a:test with remote gRPC cache service"
+ diff bazel-bin/a/test ${TEST_TMPDIR}/test_expected \
+ || fail "Remote cache generated different result"
+}
+
# TODO(alpha): Add a test that fails remote execution when remote worker
# supports sandbox.
-run_suite "Remote execution tests"
+run_suite "Remote execution and remote cache tests"