blob: 81f4b297764e825ff99cbdab795abd51793625a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#!/bin/bash
# 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)"
# Select docker or podman
if command -v docker > /dev/null; then
DOCKER=docker
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
MYSQL="${DOCKER} exec zuul-test-mysql mysql -u root -pinsecure_worker"
if [ "${COMPOSE}" == "docker-compose" ]; then
${ROOTCMD} docker-compose rm -sf
else
${ROOTCMD} podman-compose down
fi
CA_DIR=$SCRIPT_DIR/ca
mkdir -p $CA_DIR
$SCRIPT_DIR/zk-ca.sh $CA_DIR zuul-test-zookeeper
${ROOTCMD} USER_ID=$(id -u) ${COMPOSE} up -d
echo "Waiting for mysql"
timeout 30 bash -c "until ${ROOTCMD} ${MYSQL} -e 'show databases'; do sleep 0.5; done"
echo
echo "Setting up permissions for zuul tests"
${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"
|