summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrei Vagin <avagin@google.com>2019-06-18 01:40:12 -0700
committergVisor bot <gvisor-bot@google.com>2019-06-18 01:41:29 -0700
commit3d1e44a677ecacbf81888211a93cef0a71c1c6c0 (patch)
tree39ba6e6996c2adff48c464e3de395f706b3a435d
parent66cc0e9f928218ca642a41fa67bb163197aa1f37 (diff)
gvisor/kokoro: don't modify tests names in the BUILD file
PiperOrigin-RevId: 253746380
-rw-r--r--runsc/test/BUILD0
-rw-r--r--runsc/test/build_defs.bzl19
-rw-r--r--runsc/test/image/BUILD5
-rw-r--r--runsc/test/integration/BUILD5
-rw-r--r--runsc/test/testutil/docker.go8
-rwxr-xr-xtools/run_tests.sh32
6 files changed, 50 insertions, 19 deletions
diff --git a/runsc/test/BUILD b/runsc/test/BUILD
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/runsc/test/BUILD
diff --git a/runsc/test/build_defs.bzl b/runsc/test/build_defs.bzl
new file mode 100644
index 000000000..ac28cc037
--- /dev/null
+++ b/runsc/test/build_defs.bzl
@@ -0,0 +1,19 @@
+"""Defines a rule for runsc test targets."""
+
+load("@io_bazel_rules_go//go:def.bzl", _go_test = "go_test")
+
+# runtime_test is a macro that will create targets to run the given test target
+# with different runtime options.
+def runtime_test(**kwargs):
+ """Runs the given test target with different runtime options."""
+ name = kwargs["name"]
+ _go_test(**kwargs)
+ kwargs["name"] = name + "_hostnet"
+ kwargs["args"] = ["--runtime-type=hostnet"]
+ _go_test(**kwargs)
+ kwargs["name"] = name + "_kvm"
+ kwargs["args"] = ["--runtime-type=kvm"]
+ _go_test(**kwargs)
+ kwargs["name"] = name + "_overlay"
+ kwargs["args"] = ["--runtime-type=overlay"]
+ _go_test(**kwargs)
diff --git a/runsc/test/image/BUILD b/runsc/test/image/BUILD
index f3ceccb69..58758fde5 100644
--- a/runsc/test/image/BUILD
+++ b/runsc/test/image/BUILD
@@ -1,8 +1,9 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//runsc/test:build_defs.bzl", "runtime_test")
package(licenses = ["notice"])
-go_test(
+runtime_test(
name = "image_test",
size = "large",
srcs = [
diff --git a/runsc/test/integration/BUILD b/runsc/test/integration/BUILD
index 45cfd98ba..12065617c 100644
--- a/runsc/test/integration/BUILD
+++ b/runsc/test/integration/BUILD
@@ -1,8 +1,9 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//runsc/test:build_defs.bzl", "runtime_test")
package(licenses = ["notice"])
-go_test(
+runtime_test(
name = "integration_test",
size = "large",
srcs = [
diff --git a/runsc/test/testutil/docker.go b/runsc/test/testutil/docker.go
index 81f5a9ef0..b20f8e783 100644
--- a/runsc/test/testutil/docker.go
+++ b/runsc/test/testutil/docker.go
@@ -15,6 +15,7 @@
package testutil
import (
+ "flag"
"fmt"
"io/ioutil"
"log"
@@ -30,10 +31,15 @@ import (
"github.com/kr/pty"
)
+var runtimeType = flag.String("runtime-type", "", "specify which runtime to use: kvm, hostnet, overlay")
+
func getRuntime() string {
r, ok := os.LookupEnv("RUNSC_RUNTIME")
if !ok {
- return "runsc-test"
+ r = "runsc-test"
+ }
+ if *runtimeType != "" {
+ r += "-" + *runtimeType
}
return r
}
diff --git a/tools/run_tests.sh b/tools/run_tests.sh
index 00b6b92b5..d1669b343 100755
--- a/tools/run_tests.sh
+++ b/tools/run_tests.sh
@@ -181,20 +181,24 @@ run_docker_tests() {
# These names are used to exclude tests not supported in certain
# configuration, e.g. save/restore not supported with hostnet.
- declare -a variations=("" "-kvm" "-hostnet" "-overlay")
- for v in "${variations[@]}"; do
- # Change test names otherwise each run of tests will overwrite logs and
- # results of the previous run.
- sed -i "s/name = \"integration_test.*\"/name = \"integration_test${v}\"/" runsc/test/integration/BUILD
- sed -i "s/name = \"image_test.*\"/name = \"image_test${v}\"/" runsc/test/image/BUILD
- # Run runsc tests with docker that are tagged manual.
- bazel test \
- "${BAZEL_BUILD_FLAGS[@]}" \
- --test_env=RUNSC_RUNTIME="${RUNTIME}${v}" \
- --test_output=all \
- //runsc/test/image:image_test${v} \
- //runsc/test/integration:integration_test${v}
- done
+ # Run runsc tests with docker that are tagged manual.
+ #
+ # The --nocache_test_results option is used here to eliminate cached results
+ # from the previous run for the runc runtime.
+ bazel test \
+ "${BAZEL_BUILD_FLAGS[@]}" \
+ --test_env=RUNSC_RUNTIME="${RUNTIME}" \
+ --test_output=all \
+ --nocache_test_results \
+ --test_output=streamed \
+ //runsc/test/integration:integration_test \
+ //runsc/test/integration:integration_test_hostnet \
+ //runsc/test/integration:integration_test_overlay \
+ //runsc/test/integration:integration_test_kvm \
+ //runsc/test/image:image_test \
+ //runsc/test/image:image_test_overlay \
+ //runsc/test/image:image_test_hostnet \
+ //runsc/test/image:image_test_kvm
}
# Run the tests that require root.