telemetry-tempest-plugin/playbooks/legacy/telemetry-dsvm-integration-tempest-plugin/post_test_hook.sh
zhurong 24f1bcd138 Fix old branch telemetry-dsvm-integration job
Change-Id: If0711d1e74729295c4355c0d2eb5a6f545657590
2019-04-11 14:46:03 +08:00

128 lines
4.6 KiB
Bash
Executable File

#!/bin/bash -xe
# 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.
# This script is executed inside post_test_hook function in devstack gate.
function export_subunit_data {
target="$1"
if [ -f .testrepository/0 ]; then
sudo testr last --subunit > $WORKSPACE/testrepository.subunit.$target
fi
}
function generate_testr_results {
cat $WORKSPACE/testrepository.subunit.* | sudo tee $BASE/logs/testrepository.subunit
sudo /usr/os-testr-env/bin/subunit2html $BASE/logs/testrepository.subunit $BASE/logs/testr_results.html
sudo gzip -9 $BASE/logs/testrepository.subunit
sudo gzip -9 $BASE/logs/testr_results.html
sudo chown $USER:$USER $BASE/logs/testrepository.subunit.gz $BASE/logs/testr_results.html.gz
sudo chmod a+r $BASE/logs/testrepository.subunit.gz $BASE/logs/testr_results.html.gz
}
function generate_telemetry_report(){
set -x
set +e
echo "* Message queue status:"
sudo rabbitmqctl list_queues | grep -e \\.sample -e \\.info
source $BASE/new/devstack/openrc admin admin
echo "* Heat stack:"
openstack stack show integration_test
echo "* Alarm list:"
aodh alarm list
echo "* Alarm show:"
aodh alarm show $(aodh alarm list -f value -c alarm_id)
echo "* Nova instance list:"
openstack server list --all-projects
echo "* Gnocchi instance list:"
gnocchi resource list -t instance
for instance_id in $(openstack server list -f value -c ID --all-projects); do
echo "* Nova instance detail:"
openstack server show $instance_id
echo "* Gnocchi instance detail:"
gnocchi resource show -t instance $instance_id
echo "* Gnocchi measures for instance ${instance_id}:"
if [[ $ZUUL_BRANCH =~ (stable/ocata|stable/pike|stable/queens|stable/rocky) ]]; then
gnocchi metric show -r $instance_id cpu_util
gnocchi --debug measures show -r $instance_id --aggregation mean cpu_util
else
gnocchi metric show -r $instance_id cpu
gnocchi --debug measures show -r $instance_id --aggregation rate:mean cpu
fi
done
gnocchi status
echo "* Unprocessed measures:"
for key in $(redis-cli --scan --pattern 'incoming*'); do echo -n "$key length = " && redis-cli llen $key; done
echo "* locale:"
locale
echo
echo "* tempest locale:"
sudo -H -u tempest locale
echo
echo "* tempest tox locale:"
sudo -H -u tempest tox -evenv-tempest -- locale
echo
set -e
set -x
}
function generate_reports_and_maybe_exit() {
local ret="$1"
if [[ $ret != 0 ]]; then
# Collect and parse result
generate_telemetry_report
generate_testr_results
exit $ret
fi
}
function change_config_for_old_branch() {
local TEMPEST_CONFIG="$BASE/new/tempest/etc/tempest.conf"
if [[ $ZUUL_BRANCH =~ (stable/ocata|stable/pike|stable/queens|stable/rocky) ]]; then
if ! sudo grep -q "alarm_aggregation_method" "$TEMPEST_CONFIG" 2>/dev/null; then
sudo echo -e "alarm_aggregation_method = mean" | sudo tee --append "$TEMPEST_CONFIG" > /dev/null
sudo echo -e "alarm_metric_name = cpu_util" | sudo tee --append "$TEMPEST_CONFIG" > /dev/null
else
sudo sed -e "s/\(^\s*alarm_aggregation_method \s*=\).*$/\1 mean/" -i "$TEMPEST_CONFIG"
sudo sed -e "s/\(^\s*alarm_metric_name \s*=\).*$/\1 cpu_util/" -i "$TEMPEST_CONFIG"
fi
fi
}
# Run tests with tempest
sudo chown -R tempest:stack $BASE/new/tempest
sudo chown -R tempest:stack $BASE/data/tempest
cd $BASE/new/tempest
change_config_for_old_branch
sudo -H -u tempest tox -evenv-tempest -- pip install /opt/stack/new/telemetry-tempest-plugin
sudo -H -u tempest tox -evenv-tempest -- pip install /opt/stack/new/heat-tempest-plugin
echo "Checking installed Tempest plugins:"
sudo -H -u tempest tox -evenv-tempest -- tempest list-plugins
set +e
sudo -H -u tempest OS_TEST_TIMEOUT=$TEMPEST_OS_TEST_TIMEOUT tox -evenv-tempest -- tempest run -r telemetry_tempest_plugin --concurrency=$TEMPEST_CONCURRENCY
EXIT_CODE=$?
set -e
export_subunit_data "venv-tempest"
generate_reports_and_maybe_exit $EXIT_CODE
exit $EXIT_CODE