Update unit test container setup and instructions

Update the TESTING.rst file to reflect that just installing and
starting zookeeperd is no longer sufficient now that we require TLS
and auth for the connection. Suggest the container-based setup
script instead. Also improve that script to allow it to be invoked
as a normal user, with root command escalation tool choice (e.g.
"sudo") supplied through a ROOTCMD environment variable, so that
things created inside the git worktree like the CA don't end up
root-owned.

Change-Id: Ia00f5514ba0bd97b2ef17fb798b7c2dc68d9a55e
This commit is contained in:
Jeremy Stanley 2022-08-05 17:48:25 +00:00
parent f5a37d9ccc
commit d23662e50f
2 changed files with 14 additions and 13 deletions

View File

@ -18,15 +18,13 @@ More information on pip here: http://www.pip-installer.org/en/latest/
sudo pip3 install tox
A running zookeeper is required to execute tests.
A running zookeeper is required to execute tests, but it also needs to be
configured for TLS and a certificate authority set up to handle socket
authentication. Because of these complexities, it's recommended to use a
helper script to set up these dependencies::
*Install zookeeper*::
sudo apt-get install zookeeperd
*Start zookeeper*::
sudo service zookeeper start
sudo apt-get install docker-compose # or podman-compose if preferred
ROOTCMD=sudo tools/test-setup-docker.sh
Run The Tests
-------------

View File

@ -3,9 +3,12 @@
# This runs ZooKeeper in a docker container, which is required for
# tests.
# This setup needs to be run as a user that can run docker or podman.
# This setup needs to be run as a user that can run docker or podman, or by
# setting $ROOTCMD to a user substitution tool like "sudo" in the calling
# environment.
set -xeu
ROOTCMD=${ROOTCMD:-}
cd $(dirname $0)
SCRIPT_DIR="$(pwd)"
@ -13,8 +16,8 @@ SCRIPT_DIR="$(pwd)"
# Select docker or podman
if command -v docker > /dev/null; then
DOCKER=docker
if ! docker ps; then
systemctl start docker
if ! ${ROOTCMD} docker ps; then
${ROOTCMD} systemctl start docker
fi
elif command -v podman > /dev/null; then
DOCKER=podman
@ -38,8 +41,8 @@ CA_DIR=$SCRIPT_DIR/ca
mkdir -p $CA_DIR
$SCRIPT_DIR/zk-ca.sh $CA_DIR nodepool-test-zookeeper
${COMPOSE} down
${ROOTCMD} ${COMPOSE} down
${COMPOSE} up -d
${ROOTCMD} ${COMPOSE} up -d
echo "Finished"