summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrei Vagin <avagin@google.com>2019-02-11 12:42:20 -0800
committerShentubot <shentubot@google.com>2019-02-11 12:43:38 -0800
commitecce96bab56de3aedd7d5cf47a6981f0f56acba1 (patch)
tree67dc95abad53f0fbda9a4865a21457f034472cb5
parentefe5e737d7da48e6f99a1d9a53fe04b6d21b7511 (diff)
gvisor: Run syscall tests in kokoro on the rbe cluster
PiperOrigin-RevId: 233458853 Change-Id: I92c734b8075aa31e040fe7b4770bcf608e271e7a
-rw-r--r--.bazelrc_rbe8
-rw-r--r--kokoro/presubmit.cfg1
-rwxr-xr-xkokoro/run_tests.sh27
-rw-r--r--test/BUILD52
-rw-r--r--test/syscalls/BUILD34
-rw-r--r--test/syscalls/build_defs.bzl2
-rwxr-xr-xtest/syscalls/syscall_test_runner.sh11
7 files changed, 104 insertions, 31 deletions
diff --git a/.bazelrc_rbe b/.bazelrc_rbe
index 126f91dfe..102eac397 100644
--- a/.bazelrc_rbe
+++ b/.bazelrc_rbe
@@ -51,10 +51,10 @@ build:remote --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
# "extra_toolchains" to be selected (given constraints defined in
# "exec_compatible_with").
# More about platforms: https://docs.bazel.build/versions/master/platforms.html
-build:remote --extra_toolchains=@bazel_toolchains//configs/ubuntu16_04_clang/1.1/bazel_0.20.0/cpp:cc-toolchain-clang-x86_64-default
-build:remote --extra_execution_platforms=@bazel_toolchains//configs/ubuntu16_04_clang/1.1:rbe_ubuntu1604
-build:remote --host_platform=@bazel_toolchains//configs/ubuntu16_04_clang/1.1:rbe_ubuntu1604
-build:remote --platforms=@bazel_toolchains//configs/ubuntu16_04_clang/1.1:rbe_ubuntu1604
+build:remote --extra_toolchains=//test:cc-toolchain-clang-x86_64-default
+build:remote --extra_execution_platforms=//test:rbe_ubuntu1604
+build:remote --host_platform=//test:rbe_ubuntu1604
+build:remote --platforms=//test:rbe_ubuntu1604
# Set various strategies so that all actions execute remotely. Mixing remote
# and local execution will lead to errors unless the toolchain and remote
diff --git a/kokoro/presubmit.cfg b/kokoro/presubmit.cfg
index a834db198..2d8ab76d6 100644
--- a/kokoro/presubmit.cfg
+++ b/kokoro/presubmit.cfg
@@ -7,5 +7,6 @@ action {
define_artifacts {
regex: "**/sponge_log.xml"
regex: "**/sponge_log.log"
+ regex: "**/outputs.zip"
}
}
diff --git a/kokoro/run_tests.sh b/kokoro/run_tests.sh
index 3343b3093..81d428d59 100755
--- a/kokoro/run_tests.sh
+++ b/kokoro/run_tests.sh
@@ -33,8 +33,6 @@ readonly RUNTIME="runsc_test_$((RANDOM))"
# Packages that will be built and tested.
readonly BUILD_PACKAGES=("//...")
-# TODO: Include syscall tests in "test" directory once all tests
-# pass on RBE.
readonly TEST_PACKAGES=("//pkg/..." "//runsc/..." "//tools/...")
#######################
@@ -174,17 +172,30 @@ run_root_tests() {
sudo -n -E RUNSC_RUNTIME="${RUNTIME}" RUNSC_EXEC=/tmp/"${RUNTIME}"/runsc ${root_test}
}
+# Run syscall unit tests.
+run_syscall_tests() {
+ cd ${WORKSPACE_DIR}
+ # TODO: Exclude tests which fail.
+ bazel \
+ "${BAZEL_RBE_FLAGS[@]}" \
+ test "${BAZEL_BUILD_RBE_FLAGS[@]}" \
+ `bazel query //test/syscalls/... |
+ grep runsc_ptrace |
+ grep -v affinity_test_runsc_ptrace |
+ grep -v exec_test_runsc_ptrace |
+ grep -v open_create_test_runsc_ptrace |
+ grep -v clock_gettime_test_runsc_ptrace`
+}
+
# Find and rename all test xml and log files so that Sponge can pick them up.
# XML files must be named sponge_log.xml, and log files must be named
# sponge_log.log. We move all such files into KOKORO_ARTIFACTS_DIR, in a
# subdirectory named with the test name.
upload_test_artifacts() {
cd ${WORKSPACE_DIR}
- for file in $(find -L "bazel-testlogs" -name "test.xml" -o -name "test.log"); do
- newpath=${KOKORO_ARTIFACTS_DIR}/$(dirname ${file})
- extension="${file##*.}"
- mkdir -p "${newpath}" && cp "${file}" "${newpath}/sponge_log.${extension}"
- done
+ find -L "bazel-testlogs" -name "test.xml" -o -name "test.log" -o -name "outputs.zip" |
+ tar --create --files-from - --transform 's/test\./sponge_log./' |
+ tar --extract --directory ${KOKORO_ARTIFACTS_DIR}
}
# Finish runs at exit, even in the event of an error, and uploads all test
@@ -214,6 +225,8 @@ main() {
run_docker_tests
run_root_tests
+ run_syscall_tests
+
# No need to call "finish" here, it will happen at exit.
}
diff --git a/test/BUILD b/test/BUILD
new file mode 100644
index 000000000..2beb8f7fb
--- /dev/null
+++ b/test/BUILD
@@ -0,0 +1,52 @@
+# gVisor is a general-purpose sandbox.
+
+package(licenses = ["notice"])
+
+exports_files(["LICENSE"])
+
+# We need to define a bazel platform and toolchain to specify dockerPrivileged
+# and dockerRunAsRoot options, they are required to run tests on the RBE
+# cluster in Kokoro.
+alias(
+ name = "rbe_ubuntu1604",
+ actual = ":rbe_ubuntu1604_r346485",
+)
+
+platform(
+ name = "rbe_ubuntu1604_r346485",
+ constraint_values = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:linux",
+ "@bazel_tools//tools/cpp:clang",
+ "@bazel_toolchains//constraints:xenial",
+ "@bazel_toolchains//constraints/sanitizers:support_msan",
+ ],
+ remote_execution_properties = """
+ properties: {
+ name: "container-image"
+ value:"docker://gcr.io/cloud-marketplace/google/rbe-ubuntu16-04@sha256:f3120a030a19d67626ababdac79cc787e699a1aa924081431285118f87e7b375"
+ }
+ properties: {
+ name: "dockerAddCapabilities"
+ value: "SYS_ADMIN"
+ }
+ properties: {
+ name: "dockerPrivileged"
+ value: "true"
+ }
+ properties: {
+ name: "dockerRunAsRoot"
+ value: "true"
+ }
+ """,
+)
+
+toolchain(
+ name = "cc-toolchain-clang-x86_64-default",
+ exec_compatible_with = [
+ ],
+ target_compatible_with = [
+ ],
+ toolchain = "@bazel_toolchains//configs/ubuntu16_04_clang/1.1/bazel_0.20.0/default:cc-compiler-k8",
+ toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
+)
diff --git a/test/syscalls/BUILD b/test/syscalls/BUILD
index a5abf8013..ca69f3309 100644
--- a/test/syscalls/BUILD
+++ b/test/syscalls/BUILD
@@ -9,7 +9,7 @@ syscall_test(test = "//test/syscalls/linux:accept_bind_stream_test")
syscall_test(
size = "large",
- shard_count = 50,
+ shard_count = 10,
test = "//test/syscalls/linux:accept_bind_test",
)
@@ -107,7 +107,7 @@ syscall_test(test = "//test/syscalls/linux:fsync_test")
syscall_test(
size = "medium",
- shard_count = 20,
+ shard_count = 5,
test = "//test/syscalls/linux:futex_test",
)
@@ -162,7 +162,7 @@ syscall_test(
syscall_test(
size = "medium",
- shard_count = 10,
+ shard_count = 5,
test = "//test/syscalls/linux:mmap_test",
)
@@ -296,7 +296,7 @@ syscall_test(
syscall_test(
size = "large",
- shard_count = 50,
+ shard_count = 10,
test = "//test/syscalls/linux:socket_abstract_test",
)
@@ -307,7 +307,7 @@ syscall_test(
syscall_test(
size = "large",
- shard_count = 50,
+ shard_count = 10,
test = "//test/syscalls/linux:socket_domain_test",
)
@@ -318,7 +318,7 @@ syscall_test(
syscall_test(
size = "large",
- shard_count = 50,
+ shard_count = 10,
test = "//test/syscalls/linux:socket_filesystem_test",
)
@@ -329,7 +329,7 @@ syscall_test(
syscall_test(
size = "large",
- shard_count = 50,
+ shard_count = 10,
test = "//test/syscalls/linux:socket_ip_tcp_generic_loopback_test",
)
@@ -340,13 +340,13 @@ syscall_test(
syscall_test(
size = "large",
- shard_count = 50,
+ shard_count = 10,
test = "//test/syscalls/linux:socket_ip_tcp_loopback_test",
)
syscall_test(
size = "medium",
- shard_count = 50,
+ shard_count = 10,
test = "//test/syscalls/linux:socket_ip_tcp_udp_generic_loopback_test",
)
@@ -357,7 +357,7 @@ syscall_test(
syscall_test(
size = "large",
- shard_count = 50,
+ shard_count = 10,
test = "//test/syscalls/linux:socket_ip_udp_loopback_test",
)
@@ -397,7 +397,7 @@ syscall_test(
syscall_test(
size = "large",
- shard_count = 50,
+ shard_count = 10,
test = "//test/syscalls/linux:socket_unix_abstract_test",
)
@@ -414,13 +414,13 @@ syscall_test(
syscall_test(
size = "large",
- shard_count = 50,
+ shard_count = 10,
test = "//test/syscalls/linux:socket_unix_filesystem_test",
)
syscall_test(
size = "large",
- shard_count = 50,
+ shard_count = 10,
test = "//test/syscalls/linux:socket_unix_pair_test",
)
@@ -452,13 +452,13 @@ syscall_test(
syscall_test(
size = "medium",
- shard_count = 50,
+ shard_count = 10,
test = "//test/syscalls/linux:socket_unix_unbound_seqpacket_test",
)
syscall_test(
size = "large",
- shard_count = 50,
+ shard_count = 10,
test = "//test/syscalls/linux:socket_unix_unbound_stream_test",
)
@@ -484,7 +484,7 @@ syscall_test(test = "//test/syscalls/linux:sysret_test")
syscall_test(
size = "medium",
- shard_count = 50,
+ shard_count = 10,
test = "//test/syscalls/linux:tcp_socket_test",
)
@@ -504,7 +504,7 @@ syscall_test(test = "//test/syscalls/linux:udp_bind_test")
syscall_test(
size = "medium",
- shard_count = 50,
+ shard_count = 10,
test = "//test/syscalls/linux:udp_socket_test",
)
diff --git a/test/syscalls/build_defs.bzl b/test/syscalls/build_defs.bzl
index e8a66a31a..b9f8c6503 100644
--- a/test/syscalls/build_defs.bzl
+++ b/test/syscalls/build_defs.bzl
@@ -2,7 +2,7 @@
# syscall_test is a macro that will create targets to run the given test target
# on the host (native) and runsc.
-def syscall_test(test, shard_count = 5, size = "small", use_tmpfs = False):
+def syscall_test(test, shard_count = 1, size = "small", use_tmpfs = False):
_syscall_test(test, shard_count, size, "native", False)
_syscall_test(test, shard_count, size, "kvm", use_tmpfs)
_syscall_test(test, shard_count, size, "ptrace", use_tmpfs)
diff --git a/test/syscalls/syscall_test_runner.sh b/test/syscalls/syscall_test_runner.sh
index 4f3790137..87d62786b 100755
--- a/test/syscalls/syscall_test_runner.sh
+++ b/test/syscalls/syscall_test_runner.sh
@@ -18,10 +18,17 @@
# It exists so that we can build the syscall test runner once, and use it for
# all syscall tests, rather than build it for each test run.
-set -euf -o pipefail
+set -euf -x -o pipefail
+
+echo -- "$@"
+
+if [[ -n "${TEST_UNDECLARED_OUTPUTS_DIR}" ]]; then
+ mkdir -p "${TEST_UNDECLARED_OUTPUTS_DIR}"
+ chmod a+rwx "${TEST_UNDECLARED_OUTPUTS_DIR}"
+fi
# Get location of syscall_test_runner binary.
-readonly runner=$(find ${TEST_SRCDIR} -name syscall_test_runner)
+readonly runner=$(find "${TEST_SRCDIR}" -name syscall_test_runner)
# Pass the arguments of this script directly to the runner.
exec "${runner}" "$@"