tripleo-ci/roles/run-test/templates/toci_gate_test.sh.j2
Chandan Kumar 6fe02b09db Run tempest using os_tempest role in standalone job
In order to replace validate-tempest role, It is
the standalone job with os_tempest role to run
tempest in Tripleo CI.

Marking current os_tempest job as non-voting

https://tree.taiga.io/project/tripleo-ci-board/us/554

Change-Id: Iac7b09dc39a60ded493bdb36942311b861352b16
2019-01-31 08:38:53 +00:00

228 lines
9.2 KiB
Django/Jinja
Executable File

#!/usr/bin/env bash
source $(dirname $0)/scripts/common_vars.bash
set -eux
export START_JOB_TIME=$(date +%s)
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
source $TRIPLEO_ROOT/tripleo-ci/scripts/oooq_common_functions.sh
if [ -f /etc/nodepool/provider ] ; then
# this sets
# NODEPOOL_PROVIDER (e.g tripleo-test-cloud-rh1)
# NODEPOOL_CLOUD (e.g.tripleo-test-cloud-rh1)
# NODEPOOL_REGION (e.g. regionOne)
# NODEPOOL_AZ
source /etc/nodepool/provider
# source variables common across all the scripts.
source /etc/ci/mirror_info.sh
{% if rhcloud -%}
source $(dirname $0)/scripts/{{ rhcloud }}.env
# In order to save space remove the cached git repositories, at this point in
# CI the ones we are interested in have been cloned to /opt/stack/new. We
# can also remove some distro images cached on the images.
sudo rm -rf /opt/git
{% endif %}
fi
# default $NODEPOOL_PROVIDER if not already set as it's used later
export NODEPOOL_PROVIDER=${NODEPOOL_PROVIDER:-""}
# create logs dir (check if collect-logs doesn't already do this)
mkdir -p $WORKSPACE/logs
# Set job as failed until it's overwritten by pingtest/tempest real test subunit
cat $TRIPLEO_ROOT/tripleo-ci/scripts/fake_fail_subunit | gzip - > $WORKSPACE/logs/testrepository.subunit.gz
# Since python3 became default on some distros without even having a python/pip
# command installed due to PEP-0394, we can no longer rely on having
# unversioned commands available like python(2|3) or pip(2|3). We should only
# call pip using module approach which ensures we use the right version.
$(python_cmd) -m pip --version || \
(curl -s "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"; sudo $(python_cmd) get-pip.py)
if [ "$(python_cmd)" == "python3" ]; then
sudo $(package_manager) reinstall python3-setuptools
sudo $(package_manager) install python3-setuptools python3-requests python3-urllib3 python3-PyYAML shyaml
else
sudo $(package_manager) reinstall python2-setuptools
sudo $(package_manager) install python2-setuptools python2-requests python-requests python-urllib3 PyYAML
fi
# shyaml may not have a rpm on older distros
which shyaml 2>/dev/null || \
sudo $(python_cmd) -m pip install shyaml
# Sets whether or not this job will upload images.
export PERIODIC=0
# Sets which repositories to use in the job
export QUICKSTART_RELEASE="${STABLE_RELEASE:-master}"
# Stores OVB undercloud instance id
export UCINSTANCEID="null"
# Set the number of overcloud nodes
export NODECOUNT=0
# Set the overcloud hosts for multinode
export OVERCLOUD_HOSTS=
export CONTROLLER_HOSTS=
export SUBNODES_SSH_KEY=
export EXTRA_VARS=${EXTRA_VARS:-""}
export VXLAN_VARS=${VXLAN_VARS:-""}
export EXTRANODE=""
export EMIT_RELEASES_EXTRA_ARGS=""
LOCAL_WORKING_DIR="$WORKSPACE/.quickstart"
LWD=$LOCAL_WORKING_DIR
export RELEASES_FILE_OUTPUT=$WORKSPACE/logs/releases.sh
export RELEASES_SCRIPT=$TRIPLEO_ROOT/tripleo-ci/scripts/emit_releases_file/emit_releases_file.py
export RELEASES_SCRIPT_LOGFILE=$WORKSPACE/logs/emit_releases_file.log
case {{ environment_type | default('standalone') }} in
ovb)
OVB=1
METADATA_FILENAME='/mnt/config/openstack/latest/meta_data.json'
if sudo test -f $METADATA_FILENAME; then
METADATA=$(sudo cat /mnt/config/openstack/latest/meta_data.json)
set +x
UCINSTANCEID=$(echo $METADATA | python -c 'import json, sys; print json.load(sys.stdin)["uuid"]')
set -x
else
UCINSTANCEID=$(http_proxy= curl http://169.254.169.254/openstack/2015-10-15/meta_data.json | python -c 'import json, sys; print json.load(sys.stdin)["uuid"]')
fi
;;
multinode)
SUBNODES_SSH_KEY=/etc/nodepool/id_rsa
CONTROLLER_HOSTS=$(sed -n 1,1p /etc/nodepool/sub_nodes_private)
OVERCLOUD_HOSTS=$(cat /etc/nodepool/sub_nodes_private)
;;
esac
MIXED_UPGRADE_TYPE=''
# Order matters. ffu featureset has both mixed version and ffu_overcloud_upgrade.
if is_featureset ffu_overcloud_upgrade "{{ job_featureset_file }}"; then
MIXED_UPGRADE_TYPE='ffu_upgrade'
elif is_featureset mixed_upgrade "{{ job_featureset_file }}"; then
MIXED_UPGRADE_TYPE='mixed_upgrade'
elif is_featureset undercloud_upgrade "{{ job_featureset_file }}"; then
export UPGRADE_RELEASE=$QUICKSTART_RELEASE
export QUICKSTART_RELEASE=$(previous_release_mixed_upgrade_case "${UPGRADE_RELEASE}")
fi
# Set UPGRADE_RELEASE if applicable
if [ -n "${MIXED_UPGRADE_TYPE}" ]; then
export UPGRADE_RELEASE=$(previous_release_from "${STABLE_RELEASE}" "${MIXED_UPGRADE_TYPE}")
QUICKSTART_RELEASE="$QUICKSTART_RELEASE-undercloud-$UPGRADE_RELEASE-overcloud"
fi
{% if periodic|bool %}
PERIODIC=1
QUICKSTART_RELEASE="promotion-testing-hash-${QUICKSTART_RELEASE}"
EMIT_RELEASES_EXTRA_ARGS="$EMIT_RELEASES_EXTRA_ARGS --is-periodic"
{% endif %}
if [[ -f "$RELEASES_SCRIPT" ]] && [[ {{ featureset }} =~ 010|011|037|047|050|056 ]]; then
if [[ -f "$RELEASES_FILE_OUTPUT" ]]; then
echo "Importing ready releases.sh file - skipping releases.sh file generation."
else
python $RELEASES_SCRIPT \
--stable-release ${STABLE_RELEASE:-"master"} \
--featureset-file $TRIPLEO_ROOT/tripleo-quickstart/config/general_config/$(basename {{ job_featureset_file }}) \
--output-file $RELEASES_FILE_OUTPUT \
--log-file $RELEASES_SCRIPT_LOGFILE \
$EMIT_RELEASES_EXTRA_ARGS
fi
fi
{% if nodes is defined %}
if [[ ! -z {{ nodes_file }} ]]; then
pushd $TRIPLEO_ROOT/tripleo-quickstart
NODECOUNT=$(shyaml get-value node_count < {{ nodes_file }})
popd
for PART in $(sed 's/_/ /g' <<< "{{ nodes }}") ; do
if [[ "$PART" == *"supp"* ]]; then
EXTRANODE=" --extra-nodes ${PART//[!0-9]/} "
fi;
done
fi
{% endif %}
# Import gated tripleo-upgrade in oooq for upgrades/updates jobs
if [[ -d $TRIPLEO_ROOT/tripleo-upgrade ]]; then
echo "file://${TRIPLEO_ROOT}/tripleo-upgrade/#egg=tripleo-upgrade" >> ${TRIPLEO_ROOT}/tripleo-quickstart/quickstart-extras-requirements.txt
else
# Otherwise, if not importing it, oooq will fail when loading
# tripleo-upgrade role in the playbook.
echo "git+https://git.openstack.org/openstack/tripleo-upgrade.git@${ZUUL_BRANCH}#egg=tripleo-upgrade" >> ${TRIPLEO_ROOT}/tripleo-quickstart/quickstart-extras-requirements.txt
fi
# Import gated external repo in oooq - starting with browbeat, tripleo-ha-utils, openstack-ansible-os_tempest,
# ansible-config_template, ansible-role-python_venv_build
for EXTERNAL_REPO in 'browbeat' 'tripleo-ha-utils' 'tripleo-quickstart-extras' 'openstack-ansible-os_tempest' 'ansible-config_template' 'ansible-role-python_venv_build'; do
if [[ -d $TRIPLEO_ROOT/$EXTERNAL_REPO ]]; then
sed -i "s#git+https://git.openstack.org/openstack/$EXTERNAL_REPO#file://${TRIPLEO_ROOT}/$EXTERNAL_REPO#1" ${TRIPLEO_ROOT}/tripleo-quickstart/quickstart-extras-requirements.txt
fi
done
# Start time tracking
export STATS_TESTENV=$(date +%s)
pushd $TRIPLEO_ROOT/tripleo-ci
if [ ! -e $WORKSPACE/instackenv.json -a "{{ environment_infra }}" = "ovb" ] ; then
echo "Running with te-broker"
export GEARDSERVER=${TEBROKERIP-192.168.1.1}
# NOTE(pabelanger): We need gear for testenv, but this really should be
# handled by tox.
sudo yum install -y python-docutils
sudo $(python_cmd) -m pip install gear
# Kill the whole job if it doesn't get a testenv in 20 minutes as it likely will timout in zuul
( sleep 1800 ; [ ! -e /tmp/toci.started ] && sudo kill -9 $$ ) &
# We only support multi-nic at the moment
NETISO_ENV="multi-nic"
# provision env in rh cloud, then start quickstart
./testenv-client -b $GEARDSERVER:4730 -t {{ zuul.timeout }} \
--envsize $NODECOUNT --ucinstance $UCINSTANCEID \
--net-iso $NETISO_ENV $EXTRANODE -- ./toci_quickstart.sh
elif [ -e $WORKSPACE/instackenv.json -a "{{ environment_infra }}" = "ovb" ] ; then
echo "Running without te-broker"
export TE_DATAFILE=$WORKSPACE/instackenv.json
./toci_quickstart.sh
elif [ "{{ environment_infra }}" = "ovb" ] ; then
# We only support multi-nic at the moment
NETISO_ENV="multi-nic"
./toci_quickstart.sh
else
# Copy nodepool keys to current user
sudo cp /etc/nodepool/id_rsa* $HOME/.ssh/
sudo chown $USER:$USER $HOME/.ssh/id_rsa*
chmod 0600 $HOME/.ssh/id_rsa*
cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
# pre-ansible requirement
sudo mkdir -p /root/.ssh/
# everything below here *MUST* be translated to a role ASAP
# empty image to fool overcloud deployment
# set no_proxy variable
export IP_DEVICE=${IP_DEVICE:-"eth0"}
MY_IP=$(ip addr show dev $IP_DEVICE | awk '/inet / {gsub("/.*", "") ; print $2}')
MY_IP_eth1=$(ip addr show dev eth1 | awk '/inet / {gsub("/.*", "") ; print $2}') || MY_IP_eth1=""
export http_proxy=""
undercloud_net_range="192.168.24."
undercloud_services_ip=$undercloud_net_range"1"
undercloud_haproxy_public_ip=$undercloud_net_range"2"
undercloud_haproxy_admin_ip=$undercloud_net_range"3"
export no_proxy=$undercloud_services_ip,$undercloud_haproxy_public_ip,$undercloud_haproxy_admin_ip,$MY_IP,$MY_IP_eth1
# finally, run quickstart
./toci_quickstart.sh
fi
echo "Run completed"