summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorEyal Soha <eyalsoha@google.com>2020-02-05 11:17:14 -0800
committergVisor bot <gvisor-bot@google.com>2020-02-05 11:18:02 -0800
commit37abbbc547d9d78e0bf42f192403c8eca30593d8 (patch)
tree3d0e58e37ca49ee01f2c5e7bbaa595db17591ea8
parent665b614e4a6e715bac25bea15c5c29184016e549 (diff)
Add packetdrill tests to presubmit and CI testing
PiperOrigin-RevId: 293409718
-rw-r--r--kokoro/packetdrill_tests.cfg9
-rwxr-xr-xscripts/packetdrill_tests.sh20
-rw-r--r--test/packetdrill/defs.bzl6
-rwxr-xr-xtest/packetdrill/packetdrill_test.sh20
4 files changed, 49 insertions, 6 deletions
diff --git a/kokoro/packetdrill_tests.cfg b/kokoro/packetdrill_tests.cfg
new file mode 100644
index 000000000..258d7deb4
--- /dev/null
+++ b/kokoro/packetdrill_tests.cfg
@@ -0,0 +1,9 @@
+build_file: "repo/scripts/packetdrill_tests.sh"
+
+action {
+ define_artifacts {
+ regex: "**/sponge_log.xml"
+ regex: "**/sponge_log.log"
+ regex: "**/outputs.zip"
+ }
+}
diff --git a/scripts/packetdrill_tests.sh b/scripts/packetdrill_tests.sh
new file mode 100755
index 000000000..fc6bef79c
--- /dev/null
+++ b/scripts/packetdrill_tests.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# Copyright 2019 The gVisor Authors.
+#
+# 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.
+
+source $(dirname $0)/common.sh
+
+install_runsc_for_test runsc-d
+test_runsc $(bazel query "attr(tags, manual, tests(//test/packetdrill/...))")
diff --git a/test/packetdrill/defs.bzl b/test/packetdrill/defs.bzl
index 582f97e0c..8623ce7b1 100644
--- a/test/packetdrill/defs.bzl
+++ b/test/packetdrill/defs.bzl
@@ -15,7 +15,7 @@ def _packetdrill_test_impl(ctx):
# Make sure that everything is readable here.
"find . -type f -exec chmod a+rx {} \\;",
"find . -type d -exec chmod a+rx {} \\;",
- "%s %s --init_script %s -- %s\n" % (
+ "%s %s --init_script %s $@ -- %s\n" % (
test_runner.short_path,
" ".join(ctx.attr.flags),
ctx.files._init_script[0].short_path,
@@ -76,7 +76,9 @@ def packetdrill_netstack_test(name, **kwargs):
kwargs["tags"] = _PACKETDRILL_TAGS
_packetdrill_test(
name = name + "_netstack_test",
- flags = ["--dut_platform", "netstack"],
+ # This is the default runtime unless
+ # "--test_arg=--runtime=OTHER_RUNTIME" is used to override the value.
+ flags = ["--dut_platform", "netstack", "--runtime", "runsc-d"],
**kwargs
)
diff --git a/test/packetdrill/packetdrill_test.sh b/test/packetdrill/packetdrill_test.sh
index 614d94d74..0b22dfd5c 100755
--- a/test/packetdrill/packetdrill_test.sh
+++ b/test/packetdrill/packetdrill_test.sh
@@ -29,7 +29,7 @@ function failure() {
}
trap 'failure ${LINENO} "$BASH_COMMAND"' ERR
-declare -r LONGOPTS="dut_platform:,init_script:"
+declare -r LONGOPTS="dut_platform:,init_script:,runtime:"
# Don't use declare below so that the error from getopt will end the script.
PARSED=$(getopt --options "" --longoptions=$LONGOPTS --name "$0" -- "$@")
@@ -39,6 +39,7 @@ eval set -- "$PARSED"
while true; do
case "$1" in
--dut_platform)
+ # Either "linux" or "netstack".
declare -r DUT_PLATFORM="$2"
shift 2
;;
@@ -46,6 +47,13 @@ while true; do
declare -r INIT_SCRIPT="$2"
shift 2
;;
+ --runtime)
+ # Not readonly because there might be multiple --runtime arguments and we
+ # want to use just the last one. Only used if --dut_platform is
+ # "netstack".
+ declare RUNTIME="$2"
+ shift 2
+ ;;
--)
shift
break
@@ -61,9 +69,13 @@ declare -r scripts="$@"
# Check that the required flags are defined in a way that is safe for "set -u".
if [[ "${DUT_PLATFORM-}" == "netstack" ]]; then
- declare -r RUNTIME="--runtime runsc-d"
+ if [[ -z "${RUNTIME-}" ]]; then
+ echo "FAIL: Missing --runtime argument: ${RUNTIME-}"
+ exit 2
+ fi
+ declare -r RUNTIME_ARG="--runtime ${RUNTIME}"
elif [[ "${DUT_PLATFORM-}" == "linux" ]]; then
- declare -r RUNTIME=""
+ declare -r RUNTIME_ARG=""
else
echo "FAIL: Bad or missing --dut_platform argument: ${DUT_PLATFORM-}"
exit 2
@@ -143,7 +155,7 @@ done
docker pull "${IMAGE_TAG}"
# Create the DUT container and connect to network.
-DUT=$(docker create ${RUNTIME} --privileged --rm \
+DUT=$(docker create ${RUNTIME_ARG} --privileged --rm \
--stop-timeout ${TIMEOUT} -it ${IMAGE_TAG})
docker network connect "${CTRL_NET}" \
--ip "${CTRL_NET_PREFIX}${DUT_NET_SUFFIX}" "${DUT}" \