Files
746fde810878d21edd4fef90a5d4a5ee81f7f97c
puppet-openstack-integration /run_tests.sh

362 lines
13 KiB
Bash
Raw Normal View History

#
# 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.
source ${SCRIPT_DIR}/functions
export MANAGE_HIERA=${MANAGE_HIERA:-true}
export PUPPET_ARGS="${PUPPET_ARGS} --detailed-exitcodes --color=false --test --summarize --trace --hiera_config ${HIERA_CONFIG} --logdest ${WORKSPACE}/puppet.log"
# If openstack/tempest is broken on master, we can pin the repository to a specific commit
# by using the following line:
# export TEMPEST_VERSION=${TEMPEST_VERSION:-'382a2065f3364a36c110bfcc6275a0f8f6894773'}
export IMG_DIR=${IMG_DIR:-'/tmp/openstack/image'}
# so we can disable it.
export WRITE_FACTS=false
source ${SCRIPT_DIR}/configure_facts.sh
export PUPPET_BASE_PATH=/etc/puppetlabs/code
export PATH=${PATH}:/opt/puppetlabs/bin:/opt/puppetlabs/puppet/bin
export PUPPET_RELEASE_FILE=puppet5-nightly-release
export PUPPET_BASE_PATH=/etc/puppetlabs/code
export PUPPET_PKG=${PUPPET_PKG:-puppet-agent}
if is_fedora; then
PUPPET_URL_SUFFIX='puppet5-nightly/'
fi
if [ ! -f fixtures/${SCENARIO}.pp ]; then
echo "fixtures/${SCENARIO}.pp file does not exist. Please define a valid scenario."
exit 1
fi
# preserve environment so we can have ZUUL_* params
print_header "Create $SWAP_SIZE_GB GB swapfile"
$SUDO swapon -s |grep -q '/swapfile'
RESULT=$?
set -e
if [ $RESULT -eq 0 ]; then
$SUDO chmod 0600 /swapfile
$SUDO mkswap /swapfile
$SUDO swapon /swapfile
fi
# OpenStack Infra mirrors.
if [ -f ~/.gemrc ]; then
cat ~/.gemrc | $SUDO tee /root/.gemrc
fi
# 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.
# patch.
if [[ "${ZUUL_PROJECT}" = "openstack/tempest" ]]; then
TEMPEST_FROM_SOURCE=true
fi
if [ -e /usr/zuul-env/bin/zuul-cloner ] ; then
# For ubuntu we always need to deploy tempest-horizon from source
/usr/zuul-env/bin/zuul-cloner --workspace /tmp --cache-dir /opt/git \
git://git.openstack.org openstack/tempest-horizon
fi
/usr/zuul-env/bin/zuul-cloner --workspace /tmp --cache-dir /opt/git \
git://git.openstack.org openstack/tempest
# Pin Tempest to TEMPEST_VERSION unless we're running inside the
# openstack/tempest gate.
if [[ "${ZUUL_PROJECT}" != "openstack/tempest" ]]; then
pushd /tmp/openstack/tempest
git reset --hard $TEMPEST_VERSION
popd
fi
# For ubuntu we always need to deploy tempest-horizon from source
fi
$SUDO rm -rf /tmp/openstack/tempest
git clone git://git.openstack.org/openstack/tempest /tmp/openstack/tempest
pushd /tmp/openstack/tempest
git reset --hard origin/$TEMPEST_VERSION
popd
fi
# exists.
if [[ ! -e $IMG_DIR ]]; then
mkdir -p $IMG_DIR
fi
if [ -f ~/cache/files/cirros-0.4.0-x86_64-disk.img ]; then
ln -s ~/cache/files/cirros-0.4.0-x86_64-disk.img $IMG_DIR
fi
wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img -P $IMG_DIR
configure_hiera
fi
$SUDO $YUM install -y dstat setools setroubleshoot audit iotop sysstat
# use dstat to monitor system activity during integration testing
if type "dstat" 2>/dev/null; then
$SUDO dstat -tcmndrylpg --top-cpu-adv --top-io-adv --nocolor | $SUDO tee --append /var/log/dstat.log > /dev/null &
print_header 'Start iostat'
$SUDO iostat -x -k -d -t 4 | $SUDO tee --append /var/log/iostat.log > /dev/null &
fi
if [ -f "/usr/sbin/iotop" ]; then
print_header 'Start iotop'
$SUDO /usr/sbin/iotop --kilobytes --only --batch --time --delay=2 --processes --quiet | $SUDO tee --append /var/log/iotop.log > /dev/null &
fi
$SUDO ./install_modules.sh
fi
if [ "${TEMPEST_FROM_SOURCE}" = false ]; then
echo "tempest::install_from_source: false" >> ${SCRIPT_DIR}/hiera/common.yaml
fi
set +e
$SUDO $PUPPET_FULL_PATH apply $PUPPET_ARGS -e "include ::openstack_integration::repos"
if [ $RESULT -ne 0 ] && [ $RESULT -ne 2 ]; then
exit 1
fi
print_header 'Updating packages'
print_header 'Error updating packages'
exit 1
fi
fi
set -e
fi
set +e
print_header "Running Puppet Scenario: ${SCENARIO} (2nd time)"
run_puppet $SCENARIO
RESULT=$?
set -e
if [ $RESULT -ne 0 ]; then
print_header 'Second Puppet run is not idempotent.'
catch_puppet_failures
print_header 'SELinux Alerts (2nd time)'
catch_selinux_alerts
exit 1
# FIXME: Since tempest create tempest workspace which is owned by root user.
# We need to fix it in puppet-tempest, as a workaround we are changing the mode
# of tempest workspace and run tempest command using root.
$SUDO touch /tmp/openstack/tempest/test-whitelist.txt
if uses_debs; then
if [ $(lsb_release --id -s) = "Debian" ] ; then
$SUDO python setup.py install
$SUDO pip install -U stestr os-testr
fi
# Horizon
# Aodh
uses_debs || echo "test_telemetry_integration" >> /tmp/openstack/tempest/test-whitelist.txt
# Note: running all Ironic tests under SSL is not working
# https://bugs.launchpad.net/ironic/+bug/1554237
# As soon as enabling neutron_vpnaas_available works there, the VPN tests can
# be included.
echo "VolumesBackupsAdminV2Test" >> /tmp/openstack/tempest/test-whitelist.txt
# We have to ignore a smoke test because of:
# https://bugs.launchpad.net/mistral/+bug/1654555
echo "test_create_and_delete_workflow" >> /tmp/openstack/tempest/test-whitelist.txt
echo "test_create_bgpvpn" >> /tmp/openstack/tempest/test-whitelist.txt
echo "test_create_show_list_update_delete_l2gateway" >> /tmp/openstack/tempest/test-whitelist.txt
EXCLUDES="--regex=^(?!mistral_tempest_tests.tests.api.v2.test_executions.ExecutionTestsV2.test_get_list_executions.*$)(?!ceilometer.tests.tempest.api.test_telemetry_notification_api.TelemetryNotificationAPITest.test_check_glance_v2_notifications.*$)(?!tempest.api.object_storage.*$).*"
# and now operator between them is OR when filtering tests (which is how it was documented, btw). In order to promote
# we need to remove this regex option and implement https://review.openstack.org/#/c/547278 when ready.
# Note these tests were disabled in https://review.openstack.org/#/c/461969/ and hopefully it's more stable now and allows
# us to run it until we can implement --blacklist-file in a stable way.
#EXCLUDES="--regex=^(?!tempest.scenario.gnocchi.test.live_assert_vcpus_metric_is_really_expurged.test_request.*$)(?!tempest.scenario.gnocchi.test.live_assert_no_delete_metrics_have_the_gabbilive_policy.test_request.*$).*"
EXCLUDES=""
virtualenv --system-site-packages run_tempest
fi
$tempest_binary list-plugins
# list tempest workspace
$tempest_binary workspace list
# list tempest tests before running tempest
$tempest_binary run -l --whitelist_file=/tmp/openstack/tempest/test-whitelist.txt
$tempest_binary run --whitelist_file=/tmp/openstack/tempest/test-whitelist.txt --concurrency=2 $EXCLUDES
RESULT=$?
set -e
testr last --subunit > /tmp/openstack/tempest/testrepository.subunit
elif [ -d .stestr ]; then
stestr last --subunit > /tmp/openstack/tempest/testrepository.subunit
fi