2015-07-13 15:04:45 -04:00
|
|
|
#!/bin/bash -ex
|
2015-08-07 09:25:02 -04:00
|
|
|
# Copyright 2015 Red Hat, Inc.
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2015-10-01 12:46:02 -04:00
|
|
|
export SCENARIO=${SCENARIO:-scenario001}
|
2016-02-16 14:32:33 -08:00
|
|
|
export MANAGE_PUPPET_MODULES=${MANAGE_PUPPET_MODULES:-true}
|
2015-12-15 15:27:32 -05:00
|
|
|
export MANAGE_REPOS=${MANAGE_REPOS:-true}
|
2016-02-16 14:29:03 -08:00
|
|
|
export PUPPET_ARGS=${PUPPET_ARGS:-}
|
2015-11-05 12:02:15 -05:00
|
|
|
export SCRIPT_DIR=$(cd `dirname $0` && pwd -P)
|
|
|
|
source $SCRIPT_DIR/functions
|
2015-10-01 12:46:02 -04:00
|
|
|
|
|
|
|
if [ ! -f fixtures/${SCENARIO}.pp ]; then
|
|
|
|
echo "fixtures/${SCENARIO}.pp file does not exist. Please define a valid scenario."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-08-07 09:25:02 -04:00
|
|
|
if [ $(id -u) != 0 ]; then
|
|
|
|
# preserve environment so we can have ZUUL_* params
|
|
|
|
SUDO='sudo -E'
|
|
|
|
fi
|
|
|
|
|
2015-08-26 10:35:35 -04:00
|
|
|
# TODO(pabelanger): Move this into tools/install_tempest.sh and add logic so we
|
|
|
|
# can clone tempest outside of the gate. Also, tempest should be sandboxed into
|
|
|
|
# the local directory but works needs to be added into puppet to properly find
|
|
|
|
# the path.
|
|
|
|
if [ -e /usr/zuul-env/bin/zuul-cloner ] ; then
|
|
|
|
/usr/zuul-env/bin/zuul-cloner --workspace /tmp --cache-dir /opt/git \
|
|
|
|
git://git.openstack.org openstack/tempest
|
2015-11-25 12:23:48 -05:00
|
|
|
else
|
2016-03-02 11:25:06 +08:00
|
|
|
# remove existed checkout before clone
|
|
|
|
$SUDO rm -rf /tmp/openstack/tempest
|
|
|
|
|
2015-11-25 12:23:48 -05:00
|
|
|
# We're outside the gate, just do a regular git clone
|
|
|
|
git clone git://git.openstack.org/openstack/tempest /tmp/openstack/tempest
|
2015-08-26 10:35:35 -04:00
|
|
|
fi
|
2015-07-13 15:04:45 -04:00
|
|
|
|
2016-02-16 14:29:03 -08:00
|
|
|
PUPPET_ARGS="${PUPPET_ARGS} --detailed-exitcodes --verbose --color=false --debug"
|
2015-07-13 15:04:45 -04:00
|
|
|
|
|
|
|
function run_puppet() {
|
|
|
|
local manifest=$1
|
|
|
|
$SUDO puppet apply $PUPPET_ARGS fixtures/${manifest}.pp
|
|
|
|
local res=$?
|
|
|
|
|
|
|
|
return $res
|
|
|
|
}
|
|
|
|
|
2015-08-29 12:22:57 -04:00
|
|
|
if uses_debs; then
|
2016-03-02 11:25:06 +08:00
|
|
|
if dpkg -l puppetlabs-release >/dev/null 2>&1; then
|
|
|
|
$SUDO apt-get purge -y puppetlabs-release
|
|
|
|
fi
|
|
|
|
$SUDO rm -f /tmp/puppet.deb
|
|
|
|
|
2015-11-03 14:23:50 -05:00
|
|
|
wget https://apt.puppetlabs.com/puppetlabs-release-trusty.deb -O /tmp/puppet.deb
|
|
|
|
$SUDO dpkg -i /tmp/puppet.deb
|
2015-09-29 13:59:17 -04:00
|
|
|
$SUDO apt-get update
|
2015-11-03 14:23:50 -05:00
|
|
|
$SUDO apt-get install -y dstat puppet
|
2015-08-29 12:22:57 -04:00
|
|
|
elif is_fedora; then
|
2016-03-02 11:25:06 +08:00
|
|
|
if rpm --quiet -q puppetlabs-release; then
|
|
|
|
$SUDO rpm -e puppetlabs-release
|
|
|
|
fi
|
|
|
|
$SUDO rm -f /tmp/puppet.rpm
|
|
|
|
|
2015-11-03 14:23:50 -05:00
|
|
|
wget https://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm -O /tmp/puppet.rpm
|
|
|
|
$SUDO rpm -ivh /tmp/puppet.rpm
|
|
|
|
$SUDO yum install -y dstat puppet
|
2015-08-29 12:22:57 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# use dstat to monitor system activity during integration testing
|
|
|
|
if type "dstat" 2>/dev/null; then
|
2015-09-29 13:59:17 -04:00
|
|
|
$SUDO dstat -tcmndrylpg --top-cpu-adv --top-io-adv --nocolor | $SUDO tee --append /var/log/dstat.log > /dev/null &
|
2015-08-29 12:22:57 -04:00
|
|
|
fi
|
|
|
|
|
2016-02-23 23:08:08 -05:00
|
|
|
if [ "${MANAGE_PUPPET_MODULES}" = true ]; then
|
|
|
|
$SUDO ./install_modules.sh
|
|
|
|
fi
|
|
|
|
|
2015-07-13 15:04:45 -04:00
|
|
|
# Run puppet and assert something changes.
|
|
|
|
set +e
|
2015-12-15 15:27:32 -05:00
|
|
|
if [ "${MANAGE_REPOS}" = true ]; then
|
|
|
|
$SUDO puppet apply $PUPPET_ARGS -e "include ::openstack_integration::repos"
|
|
|
|
fi
|
2015-10-01 12:46:02 -04:00
|
|
|
run_puppet $SCENARIO
|
2015-07-13 15:04:45 -04:00
|
|
|
RESULT=$?
|
|
|
|
set -e
|
|
|
|
if [ $RESULT -ne 2 ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Run puppet a second time and assert nothing changes.
|
|
|
|
set +e
|
2015-10-01 12:46:02 -04:00
|
|
|
run_puppet $SCENARIO
|
2015-07-13 15:04:45 -04:00
|
|
|
RESULT=$?
|
|
|
|
set -e
|
|
|
|
if [ $RESULT -ne 0 ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2015-07-29 10:57:52 -04:00
|
|
|
|
2016-03-02 11:25:06 +08:00
|
|
|
mkdir -p /tmp/openstack/tempest
|
|
|
|
|
|
|
|
$SUDO rm -f /tmp/openstack/tempest/cirros-0.3.4-x86_64-disk.img
|
|
|
|
|
2015-08-26 14:59:04 -04:00
|
|
|
# TODO(emilien) later, we should use local image if present. That would be a next iteration.
|
|
|
|
wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img -P /tmp/openstack/tempest
|
|
|
|
|
2016-02-23 23:23:04 -05:00
|
|
|
set +e
|
2015-10-26 07:30:29 +09:00
|
|
|
# Select what to test:
|
|
|
|
# - smoke suite
|
|
|
|
# - dashboard (horizon)
|
|
|
|
# - TelemetryAlarming (Aodh)
|
2016-01-02 07:24:27 -05:00
|
|
|
# - api.baremetal (Ironic)
|
2016-02-11 11:52:42 -05:00
|
|
|
cd /tmp/openstack/tempest; tox -eall -- --concurrency=2 smoke dashboard TelemetryAlarming api.baremetal
|
2016-02-23 23:23:04 -05:00
|
|
|
RESULT=$?
|
|
|
|
set -e
|
2015-12-04 17:51:36 -05:00
|
|
|
/tmp/openstack/tempest/.tox/all/bin/testr last --subunit > /tmp/openstack/tempest/testrepository.subunit
|
2016-02-23 23:23:04 -05:00
|
|
|
exit $RESULT
|