Files
d1c02c5390e75642cfaaa9af7fda1c5f147b693d
puppet-openstack-integration /run_tests.sh

409 lines
15 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 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:
if [ $(lsb_release --id -s) = "Ubuntu" ]; then
export TEMPEST_FROM_SOURCE=${TEMPEST_FROM_SOURCE:-true}
else
export TEMPEST_FROM_SOURCE=${TEMPEST_FROM_SOURCE:-false}
fi
export IMG_DIR=${IMG_DIR:-'/tmp/openstack/image'}
# so we can disable it.
export WRITE_FACTS=false
source ${SCRIPT_DIR}/configure_facts.sh
if [ "${OS_NAME_VERS}" == "centos9" ]; then
export PUPPET_BASE_PATH=/etc/puppet
export PUPPET_PKG="puppet"
else
export PUPPET_BASE_PATH=/etc/puppetlabs/code
export PUPPET_PKG=${PUPPET_PKG:-puppet-agent}
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
# is run remotely via ansible using a user which doesn't have .bashrc file
if [ -f /etc/fedora-release -a -f /etc/bashrc ]; then
source /etc/bashrc
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.
if [ -d /home/zuul/src/opendev.org/openstack/tempest ]; then
[ ! -d /tmp/openstack ] && mkdir -p /tmp/openstack
cp -R /home/zuul/src/opendev.org/openstack/tempest /tmp/openstack/tempest
else
git clone https://opendev.org/openstack/tempest /tmp/openstack/tempest
git reset --hard $TEMPEST_VERSION
popd
if [ "${TEMPEST_FROM_SOURCE}" = true ]; then
$SUDO rm -rf /tmp/openstack/tempest
git clone https://opendev.org/openstack/tempest /tmp/openstack/tempest
fi
# exists.
if [[ ! -e $IMG_DIR ]]; then
mkdir -p $IMG_DIR
fi
ln -s ~/cache/files/cirros-0.5.1-x86_64-disk.img $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
set -e
if dstat --help 2>&1 | grep -q "top-io-adv"; then
DSTAT_OPTS="${DSTAT_OPTS} --top-io-adv"
fi
if dstat --help 2>&1 | grep -q "top-cpu-adv"; then
DSTAT_OPTS="${DSTAT_OPTS} --top-cpu-adv"
fi
set +e
$SUDO dstat -tcmndrylpg $DSTAT_OPTS --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
RESULT=$?
exit 1
fi
if is_fedora; then
$SUDO $YUM update -y
update_ret=$?
elif uses_debs; then
$SUDO apt-get -y -o Dpkg::Options::="--force-confnew" upgrade
fi
if [ $update_ret -ne 0 ]; then
print_header 'Error updating packages'
exit 1
fi
# the following change is shipped
# https://github.com/redhat-plumbers/systemd-rhel8/pull/246
if is_fedora; then
sudo sysctl -w net.ipv4.ping_group_range='0 2147483647'
fi
set -e
#catch_selinux_alerts
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
#catch_selinux_alerts
# 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 apt-get install -y $pkglist
# Horizon
# Aodh
# Note: running all Ironic tests under SSL is not working
# https://bugs.launchpad.net/ironic/+bug/1554237
# NOTE(tobias-urdin): Disabled because magnum network access from inside instance to
# Magnum
# Below is here just for testing in ci, would be removed soon, at least below version of werkzeug is required for magnum tls to work
#if is_fedora; then
# $SUDO yum -y install http://cbs.centos.org/kojifiles/packages/python-werkzeug/0.11.6/1.el7/noarch/python-werkzeug-0.11.6-1.el7.noarch.rpm
# $SUDO systemctl restart openstack-magnum-*
#fi
# As soon as enabling neutron_vpnaas_available works there, the VPN tests can
# be included.
# We have to ignore a smoke test because of:
# https://bugs.launchpad.net/mistral/+bug/1654555
# We have to enable additional tests because no smoke tests will be run with
# noop drivers.
echo "octavia_tempest_plugin.tests.scenario.*standalone_CRUD" >> /tmp/openstack/tempest/test-include-list.txt
echo "mistral_tempest_tests.tests.api.v2.test_executions.ExecutionTestsV2.test_get_list_executions" > /tmp/openstack/tempest/test-exclude-list.txt
echo "tempest.*.scenario.test_dashboard_basic_ops.TestDashboardBasicOps.test_basic_scenario" >> /tmp/openstack/tempest/test-exclude-list.txt
echo "telemetry_tempest_plugin.scenario.test_telemetry_integration.TestTelemetryIntegration" >> /tmp/openstack/tempest/test-exclude-list.txt
EXCLUDES="--exclude-list=/tmp/openstack/tempest/test-exclude-list.txt"
# TODO(tobias-urdin): We must have the neutron-tempest-plugin to even test Neutron, is also required by
# vpnaas and dynamic routing projects.
$SUDO apt install -y python3-pip
if [ -d /home/zuul/src/opendev.org/openstack/neutron-tempest-plugin ]; then
cp -R /home/zuul/src/opendev.org/openstack/neutron-tempest-plugin /tmp/openstack/neutron-tempest-plugin
else
git clone https://opendev.org/openstack/neutron-tempest-plugin /tmp/openstack/neutron-tempest-plugin
fi
$SUDO pip3 install .
popd
# Note these tests were disabled in https://review.opendev.org/#/c/461969/ and hopefully it's more stable now and allows
EXCLUDES="--exclude-regex=^tempest.*.scenario.test_dashboard_basic_ops|telemetry_tempest_plugin.scenario.test_telemetry_integration.TestTelemetryIntegration"
python3 -m virtualenv --system-site-packages run_tempest
run_tempest/bin/pip3 install -c https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt -U -r requirements.txt
run_tempest/bin/python3 setup.py install
fi
$tempest_binary --version
$tempest_binary list-plugins
# list tempest workspace
$tempest_binary workspace list
# list tempest tests before running tempest
set -e
testr last --subunit > /tmp/openstack/tempest/testrepository.subunit
elif [ -d .stestr ]; then
stestr-3 last --subunit > /tmp/openstack/tempest/testrepository.subunit
else
stestr last --subunit > /tmp/openstack/tempest/testrepository.subunit
fi