"veyron/services/mgmt": Prevent credentials sharing in shell tests
This CL modifies the shell tests in veyron/services/mgmt/...,
veyron/tools/debug, and veyron/tools/principal to prevent them from
simultaeneously running multiple processes that share the same
credential directories.
Change-Id: I2a42bd1efdd29a375c5460e4e1830d75ac5a9a00
diff --git a/tools/debug/test.sh b/tools/debug/test.sh
index dc5bdd0..5cfafe4 100755
--- a/tools/debug/test.sh
+++ b/tools/debug/test.sh
@@ -30,9 +30,14 @@
export TMPDIR="${WORKDIR}/tmp"
export VEYRON_CREDENTIALS=$(shell::tmp_dir)
+ # Create specific VeyronCredentials for the debug command forked from the environment's
+ # VeyronCredentials.
+ export DEBUG_CREDENTIALS=$(shell_test::forkcredentials "${VEYRON_CREDENTIALS}" debug)
+
shell_test::setup_server_test || shell_test::fail "setup_server_test failed"
local -r EP="${NAMESPACE_ROOT}"
unset NAMESPACE_ROOT
+ export VEYRON_CREDENTIALS="${DEBUG_CREDENTIALS}"
# Test top level glob.
local -r DBGLOG="${WORKDIR}/debug.log"
diff --git a/tools/principal/test.sh b/tools/principal/test.sh
index 970099e..965e4c9 100755
--- a/tools/principal/test.sh
+++ b/tools/principal/test.sh
@@ -71,8 +71,9 @@
SEND_BLESSINGS_CMD="${PRINCIPAL_BIN_DIR}/${SEND_BLESSINGS_CMD}"
$(${SEND_BLESSINGS_CMD}) || shell_test::fail "line ${LINENO}: ${SEND_BLESSINGS_CMD} failed"
grep "Received blessings: alice/friend/carol/foralice" carol.recvblessings >/dev/null || shell_test::fail "line ${LINENO}: recvblessings did not log any blessings received $(cat carol.recvblessings)"
- # Mucking around with the private key should fail
+ # Mucking around with the public key should fail
"${PRINCIPAL_BIN}" --veyron.credentials=./carol --veyron.tcp.address=127.0.0.1:0 recvblessings >carol.recvblessings&
+ local -r RECV_BLESSINGS_PID="$!"
shell::timed_wait_for "${shell_test_DEFAULT_MESSAGE_TIMEOUT}" carol.recvblessings "bless --remote_key" || shell_test::fail "line ${LINENO}: recvblessings did not print command for sender"
SEND_BLESSINGS_CMD=$(grep "bless --remote_key" carol.recvblessings | sed -e 's|remote_key=|remote_key=BAD|')
SEND_BLESSINGS_CMD="${PRINCIPAL_BIN_DIR}/${SEND_BLESSINGS_CMD}"
@@ -85,6 +86,7 @@
grep "blessings received from unexpected sender" error >/dev/null || shell_test::fail "line ${LINENO}: unexpected sender error not printed"
# Dump carol out, the only blessing that survives should be from the first
# "bless" command. (alice/friend/carol).
+ kill -9 "${RECV_BLESSINGS_PID}"
"${PRINCIPAL_BIN}" --veyron.credentials=./carol dump >carol.dump || shell_test::fail "line ${LINENO}: dump failed"
# Any other commands to be run without VEYRON_CREDENTIALS set.