openstack-helm/tools/gate/funcs/openstack.sh
Pete Birley 960613e5c6 Boot VM's and basic functional test in Zuul Checks
This PS adds basic vm booting and functional testing to the single node
Zuul gates. Multinode testing will be once we have ceph running in zuul.

Change-Id: Ifcbdcaa4a30dee4088e369d4410dd737ef6f12cd
2017-06-22 14:23:26 -05:00

57 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
function wait_for_ping {
# Default wait timeout is 180 seconds
set +x
PING_CMD="ping -q -c 1 -W 1"
end=$(date +%s)
if [ x$2 != "x" ]; then
end=$((end + $2))
else
end=$((end + 180))
fi
while true; do
$PING_CMD $1 > /dev/null && \
break || true
sleep 1
now=$(date +%s)
[ $now -gt $end ] && echo "Could not ping $1 in time" && exit -1
done
set -x
$PING_CMD $1
}
function openstack_wait_for_vm {
# Default wait timeout is 180 seconds
set +x
end=$(date +%s)
if [ x$2 != "x" ]; then
end=$((end + $2))
else
end=$((end + 180))
fi
while true; do
STATUS=$($OPENSTACK server show $1 -f value -c status)
[ $STATUS == "ACTIVE" ] && \
break || true
sleep 1
now=$(date +%s)
[ $now -gt $end ] && echo VM failed to start. && \
$OPENSTACK server show $1 && exit -1
done
set -x
}