diff options
author | Jeremy Stanley <fungi@yuggoth.org> | 2022-08-05 21:00:02 +0000 |
---|---|---|
committer | Jeremy Stanley <fungi@yuggoth.org> | 2022-08-05 21:00:02 +0000 |
commit | 90d7dcb1ed66f9685b74cd68383c21c2203d4037 (patch) | |
tree | 77895c73931edb5099a5fef592f6cc5cf11a287c /tools | |
parent | 68684d519e9f906afd899a37f9e3da92b61f914d (diff) | |
download | zuul-90d7dcb1ed66f9685b74cd68383c21c2203d4037.tar.gz |
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, as well as running database servers.
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.
Related, the tox-docker plugin previously suggested in the document
is no longer a viable option for the same reasons, so clean up the
plumbing for it in tox.ini as well.
Change-Id: Iac32799425a5bd4b1bdbf56f34a2310241ac4499
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/test-setup-docker.sh | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/tools/test-setup-docker.sh b/tools/test-setup-docker.sh index b90a422c2..81f4b2977 100755 --- a/tools/test-setup-docker.sh +++ b/tools/test-setup-docker.sh @@ -1,6 +1,14 @@ #!/bin/bash -set -eu +# This runs ZooKeeper and databases in docker containers, which are +# required for tests. + +# 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)" @@ -29,9 +37,9 @@ fi MYSQL="${DOCKER} exec zuul-test-mysql mysql -u root -pinsecure_worker" if [ "${COMPOSE}" == "docker-compose" ]; then - docker-compose rm -sf + ${ROOTCMD} docker-compose rm -sf else - podman-compose down + ${ROOTCMD} podman-compose down fi CA_DIR=$SCRIPT_DIR/ca @@ -39,15 +47,14 @@ CA_DIR=$SCRIPT_DIR/ca mkdir -p $CA_DIR $SCRIPT_DIR/zk-ca.sh $CA_DIR zuul-test-zookeeper -export USER_ID=$(id -u) -${COMPOSE} up -d +${ROOTCMD} USER_ID=$(id -u) ${COMPOSE} up -d echo "Waiting for mysql" -timeout 30 bash -c "until ${MYSQL} -e 'show databases'; do sleep 0.5; done" +timeout 30 bash -c "until ${ROOTCMD} ${MYSQL} -e 'show databases'; do sleep 0.5; done" echo echo "Setting up permissions for zuul tests" -${MYSQL} -e "GRANT ALL PRIVILEGES ON *.* TO 'openstack_citest'@'%' identified by 'openstack_citest' WITH GRANT OPTION;" -${MYSQL} -u openstack_citest -popenstack_citest -e "SET default_storage_engine=MYISAM; DROP DATABASE IF EXISTS openstack_citest; CREATE DATABASE openstack_citest CHARACTER SET utf8;" +${ROOTCMD} ${MYSQL} -e "GRANT ALL PRIVILEGES ON *.* TO 'openstack_citest'@'%' identified by 'openstack_citest' WITH GRANT OPTION;" +${ROOTCMD} ${MYSQL} -u openstack_citest -popenstack_citest -e "SET default_storage_engine=MYISAM; DROP DATABASE IF EXISTS openstack_citest; CREATE DATABASE openstack_citest CHARACTER SET utf8;" echo "Finished" |