+++ /dev/null
-#! /bin/bash
-
-set -o xtrace
-
-EC=0
-MYSQL_PASSWORD="cinder"
-
-update_ec(){
- local ec=$1
- [ "$ec" -gt "$EC" ] && EC=$ec
-}
-
-
-function prepare_vm(){
- if [[ $(cat /etc/*-release | head -n 1 | awk '{print $1}') =~ Ubuntu ]]
- then
- echo "mysql-server mysql-server/root_password select $MYSQL_PASSWORD" |
- debconf-set-selections
- echo "mysql-server mysql-server/root_password_again select $MYSQL_PASSWORD" |
- debconf-set-selections
- apt-get install -y mysql-server python-mysqldb rabbitmq-server curl screen nmap
- CONF_FILE='/usr/share/cinder-common/cinder.conf'
- else
- yum install -y mysql-server mysql-wsrep-client-5.6 MySQL-python nmap-ncat
- CONF_FILE='/usr/share/cinder/cinder-dist.conf'
- # workaround for `sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError)
- # (2002, "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)")`
- rm -f /etc/my.cnf
- local current_password=$(cat /root/.mysql_secret | head -1 | awk -F': ' '{print $2}')
- service mysql start
- mysqladmin -u root -p"$current_password" password "$MYSQL_PASSWORD"
- fi
- mysql -uroot -p"$MYSQL_PASSWORD" << MYSQL_SCRIPT
-CREATE DATABASE cinder;
-CREATE USER 'cinder'@'localhost' IDENTIFIED BY '$MYSQL_PASSWORD';
-GRANT ALL PRIVILEGES ON *.* TO 'cinder'@'localhost';
-MYSQL_SCRIPT
- cinder-manage --config-file $CONF_FILE db sync
-}
-
-
-function test_cinder_service(){
- local service=$1
- local port=$2
-
- echo "Starting $1..."
- service "$service" start
-
- sleep 5
- echo | ncat -w 5 127.0.0.1 "$port"
- local ec=$?
- update_ec "$ec"
-
- if [ "$ec" -eq 0 ]
- then
- echo "Cinder $1 successfully started"
- else
- echo "$service failed to start!"
- tail -n 40 /var/log/messages
- fi
-}
-
-
-function test_cinder_configs(){
- local files=("/etc/cinder/cinder.conf"
- "/etc/cinder/api-paste.ini"
- "/etc/cinder/policy.json")
- for f in "${files[@]}"
- do
- [ -f "$f" ] ; update_ec "$?"
- done
-}
-
-
-case $1 in
- python-cinder)
- local imports=("cinder"
- "cinder.volume.drivers.lvm"
- "cinder.volume.drivers.rbd")
- for x in "${imports[@]}"
- do
- python -c "import $x" ; update_ec "$?"
- done
- ;;
- openstack-cinder)
- prepare_vm
- test_cinder_configs
- ls /usr/bin/cinder* ; update_ec "$?"
- test_cinder_service openstack-cinder-api 8776 ; update_ec "$?"
- [ -f "/usr/bin/cinder-volume" ] ; update_ec "$?"
- [ -f "/usr/bin/cinder-scheduler" ] ; update_ec "$?"
- ;;
- cinder-common)
- test_cinder_configs
- [ -f "/usr/bin/cinder-manage" ] ; update_ec "$?"
- ;;
- cinder-scheduler)
- [ -f "/usr/bin/cinder-scheduler" ] ; update_ec "$?"
- ;;
- cinder-api)
- prepare_vm
- [ -f "/usr/bin/cinder-api" ] ; update_ec "$?"
- test_cinder_service cinder-api 8776 ; update_ec "$?"
- ;;
- cinder-volume)
- [ -f "/usr/bin/cinder-volume" ] ; update_ec "$?"
- ;;
- cinder-backup)
- [ -f "/usr/bin/cinder-backup" ] ; update_ec "$?"
- ;;
- cinder-doc|openstack-cinder-doc)
- echo "Skipping test for $1"
- EC=0
- ;;
- *)
- echo "Test not defined for $1"
- EC=1
- ;;
-esac
-
-exit "$EC"