nodepool/tools/test-setup-docker.sh
James E. Blair d921fc2622 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
2021-02-24 17:21:01 -08:00

46 lines
871 B
Bash
Executable File

#!/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"