Deflake maven_test
Change the test to only starts up the fileserver when needed, not before each test
case, to prevent timeouts.
--
MOS_MIGRATED_REVID=103216306
diff --git a/src/test/shell/bazel/maven_test.sh b/src/test/shell/bazel/maven_test.sh
index b7b7def..57f20d2 100755
--- a/src/test/shell/bazel/maven_test.sh
+++ b/src/test/shell/bazel/maven_test.sh
@@ -24,8 +24,7 @@
source $src/remote_helpers.sh \
|| { echo "remote_helpers.sh not found!" >&2; exit 1; }
-function set_up() {
- startup_server $PWD
+function setup_zoo() {
mkdir -p zoo
cat > zoo/BUILD <<EOF
java_binary(
@@ -52,6 +51,7 @@
}
function test_maven_jar() {
+ setup_zoo
serve_jar
cat > WORKSPACE <<EOF
@@ -89,6 +89,7 @@
}
function test_maven_jar_404() {
+ setup_zoo
http_response=$TEST_TMPDIR/http_response
cat > $http_response <<EOF
HTTP/1.0 404 Not Found
@@ -113,6 +114,7 @@
}
function test_maven_jar_mismatched_sha1() {
+ setup_zoo
serve_jar
cat > WORKSPACE <<EOF
@@ -217,5 +219,4 @@
expect_log "no such package '@x//'"
}
-
run_suite "maven tests"
diff --git a/src/test/shell/bazel/remote_helpers.sh b/src/test/shell/bazel/remote_helpers.sh
index e1a7a55..28d4b14 100755
--- a/src/test/shell/bazel/remote_helpers.sh
+++ b/src/test/shell/bazel/remote_helpers.sh
@@ -109,6 +109,7 @@
function serve_artifact() {
+ startup_server $PWD
local group_id=$1
local artifact_id=$2
local version=$3
@@ -130,14 +131,14 @@
}
function shutdown_server() {
- kill $fileserver_pid
-}
-
-function kill_nc() {
# Try to kill nc, otherwise the test will time out if Bazel has a bug and
# didn't make a request to it.
- kill $nc_pid || true # kill can fails if the process already finished
+ [ -z "${fileserver_pid:-}" ] || kill $fileserver_pid || true
[ -z "${redirect_pid:-}" ] || kill $redirect_pid || true
[ -z "${nc_log:-}" ] || cat $nc_log
[ -z "${redirect_log:-}" ] || cat $redirect_log
}
+
+function kill_nc() {
+ shutdown_server
+}