Add test-setup-docker.sh

This is intended as an aid for developers (since we have moved the
ZK setup which was in test-setup.sh to a playbook for tox jobs).

Change-Id: I9ca03831a74928ec6875c5f6668cfcfcdedb37fd
This commit is contained in:
James E. Blair 2021-02-24 17:20:06 -08:00
parent 7e450a9328
commit d921fc2622
1 changed files with 45 additions and 0 deletions

45
tools/test-setup-docker.sh Executable file
View File

@ -0,0 +1,45 @@
#!/bin/bash
# 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.
set -xeu
cd $(dirname $0)
SCRIPT_DIR="$(pwd)"
# Select docker or podman
if command -v docker > /dev/null; then
DOCKER=docker
if ! docker ps; then
systemctl start docker
fi
elif command -v podman > /dev/null; then
DOCKER=podman
else
echo "Please install docker or podman."
exit 1
fi
# Select docker-compose or podman-compose
if command -v docker-compose > /dev/null; then
COMPOSE=docker-compose
elif command -v podman-compose > /dev/null; then
COMPOSE=podman-compose
else
echo "Please install docker-compose or podman-compose."
exit 1
fi
CA_DIR=$SCRIPT_DIR/ca
mkdir -p $CA_DIR
$SCRIPT_DIR/zk-ca.sh $CA_DIR nodepool-test-zookeeper
${COMPOSE} down
${COMPOSE} up -d
echo "Finished"