Add packetdrill tests to presubmit and CI testing
PiperOrigin-RevId: 293409718
This commit is contained in:
parent
665b614e4a
commit
37abbbc547
|
@ -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"
|
||||
}
|
||||
}
|
|
@ -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/...))")
|
|
@ -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
|
||||
)
|
||||
|
||||
|
|
|
@ -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}" \
|
||||
|
|
Loading…
Reference in New Issue