blob: b787994df73ed183ddafc48becc6d5f28c76bb7c [file] [log] [blame]
Mehdi Abaakouk80081512015-07-29 19:03:26 +02001#!/bin/bash -xe
2
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15# This script is executed inside post_test_hook function in devstack gate.
16
Mehdi Abaakouk31291f82016-11-25 10:56:26 +010017function export_subunit_data {
18 target="$1"
Mehdi Abaakouk80081512015-07-29 19:03:26 +020019 if [ -f .testrepository/0 ]; then
Mehdi Abaakouk31291f82016-11-25 10:56:26 +010020 sudo testr last --subunit > $WORKSPACE/testrepository.subunit.$target
Mehdi Abaakouk80081512015-07-29 19:03:26 +020021 fi
22}
23
Mehdi Abaakouk31291f82016-11-25 10:56:26 +010024function generate_testr_results {
25 cat $WORKSPACE/testrepository.subunit.* | sudo tee $BASE/logs/testrepository.subunit
26 sudo /usr/os-testr-env/bin/subunit2html $BASE/logs/testrepository.subunit $BASE/logs/testr_results.html
27 sudo gzip -9 $BASE/logs/testrepository.subunit
28 sudo gzip -9 $BASE/logs/testr_results.html
Dai Dang Vanef853d42017-10-18 09:11:43 +070029 sudo chown $USER:$USER $BASE/logs/testrepository.subunit.gz $BASE/logs/testr_results.html.gz
Mehdi Abaakouk31291f82016-11-25 10:56:26 +010030 sudo chmod a+r $BASE/logs/testrepository.subunit.gz $BASE/logs/testr_results.html.gz
31}
32
Mehdi Abaakouk8ecffaf2016-12-15 11:53:00 +010033function generate_telemetry_report(){
Mehdi Abaakouk7f0e3152019-02-08 12:30:17 +010034 set -x
Mehdi Abaakouk510f3ce2017-05-02 19:23:41 +020035 set +e
Mehdi Abaakouk8ecffaf2016-12-15 11:53:00 +010036
37 echo "* Message queue status:"
38 sudo rabbitmqctl list_queues | grep -e \\.sample -e \\.info
39
Mehdi Abaakouka8ea3682017-04-27 08:40:21 +020040 source $BASE/new/devstack/openrc admin admin
41
Mehdi Abaakouk8ecffaf2016-12-15 11:53:00 +010042 echo "* Heat stack:"
43 openstack stack show integration_test
44 echo "* Alarm list:"
45 aodh alarm list
zhurong24f1bcd2019-04-09 16:51:54 +080046 echo "* Alarm show:"
47 aodh alarm show $(aodh alarm list -f value -c alarm_id)
Mehdi Abaakouk8ecffaf2016-12-15 11:53:00 +010048 echo "* Nova instance list:"
Mehdi Abaakouk52844572018-06-14 16:46:45 +020049 openstack server list --all-projects
Mehdi Abaakouk8ecffaf2016-12-15 11:53:00 +010050
51 echo "* Gnocchi instance list:"
52 gnocchi resource list -t instance
Mehdi Abaakouk52844572018-06-14 16:46:45 +020053 for instance_id in $(openstack server list -f value -c ID --all-projects); do
Mehdi Abaakouk8ecffaf2016-12-15 11:53:00 +010054 echo "* Nova instance detail:"
55 openstack server show $instance_id
56 echo "* Gnocchi instance detail:"
57 gnocchi resource show -t instance $instance_id
58 echo "* Gnocchi measures for instance ${instance_id}:"
zhurong24f1bcd2019-04-09 16:51:54 +080059 if [[ $ZUUL_BRANCH =~ (stable/ocata|stable/pike|stable/queens|stable/rocky) ]]; then
60 gnocchi metric show -r $instance_id cpu_util
61 gnocchi --debug measures show -r $instance_id --aggregation mean cpu_util
62 else
63 gnocchi metric show -r $instance_id cpu
64 gnocchi --debug measures show -r $instance_id --aggregation rate:mean cpu
65 fi
Mehdi Abaakouk8ecffaf2016-12-15 11:53:00 +010066 done
67
68 gnocchi status
69
Mehdi Abaakouk8ecffaf2016-12-15 11:53:00 +010070 echo "* Unprocessed measures:"
Julien Danjou1be043e2017-10-19 09:52:41 +020071 for key in $(redis-cli --scan --pattern 'incoming*'); do echo -n "$key length = " && redis-cli llen $key; done
Mehdi Abaakouk8ecffaf2016-12-15 11:53:00 +010072
Mehdi Abaakoukb64d2b02018-09-03 11:50:49 +020073 echo "* locale:"
74 locale
75 echo
76 echo "* tempest locale:"
77 sudo -H -u tempest locale
78 echo
79 echo "* tempest tox locale:"
80 sudo -H -u tempest tox -evenv-tempest -- locale
81 echo
82
Mehdi Abaakouk510f3ce2017-05-02 19:23:41 +020083 set -e
Mehdi Abaakouk8ecffaf2016-12-15 11:53:00 +010084 set -x
85}
86
87function generate_reports_and_maybe_exit() {
88 local ret="$1"
89 if [[ $ret != 0 ]]; then
90 # Collect and parse result
91 generate_telemetry_report
92 generate_testr_results
93 exit $ret
94 fi
95}
96
zhurong24f1bcd2019-04-09 16:51:54 +080097function change_config_for_old_branch() {
98 local TEMPEST_CONFIG="$BASE/new/tempest/etc/tempest.conf"
99 if [[ $ZUUL_BRANCH =~ (stable/ocata|stable/pike|stable/queens|stable/rocky) ]]; then
100 if ! sudo grep -q "alarm_aggregation_method" "$TEMPEST_CONFIG" 2>/dev/null; then
101 sudo echo -e "alarm_aggregation_method = mean" | sudo tee --append "$TEMPEST_CONFIG" > /dev/null
102 sudo echo -e "alarm_metric_name = cpu_util" | sudo tee --append "$TEMPEST_CONFIG" > /dev/null
103 else
104 sudo sed -e "s/\(^\s*alarm_aggregation_method \s*=\).*$/\1 mean/" -i "$TEMPEST_CONFIG"
105 sudo sed -e "s/\(^\s*alarm_metric_name \s*=\).*$/\1 cpu_util/" -i "$TEMPEST_CONFIG"
106 fi
107 fi
108}
109
Mehdi Abaakouk8ecffaf2016-12-15 11:53:00 +0100110
Mehdi Abaakoukc5ebe732017-04-19 09:17:58 +0200111# Run tests with tempest
Mehdi Abaakoukde7d41e2017-03-22 17:09:51 +0100112sudo chown -R tempest:stack $BASE/new/tempest
113sudo chown -R tempest:stack $BASE/data/tempest
Mehdi Abaakoukde7d41e2017-03-22 17:09:51 +0100114cd $BASE/new/tempest
zhurong24f1bcd2019-04-09 16:51:54 +0800115change_config_for_old_branch
Mehdi Abaakoukb64d2b02018-09-03 11:50:49 +0200116sudo -H -u tempest tox -evenv-tempest -- pip install /opt/stack/new/telemetry-tempest-plugin
Mehdi Abaakouk7f0e3152019-02-08 12:30:17 +0100117sudo -H -u tempest tox -evenv-tempest -- pip install /opt/stack/new/heat-tempest-plugin
Mehdi Abaakouk16251bb2018-06-13 14:44:13 +0200118echo "Checking installed Tempest plugins:"
119sudo -H -u tempest tox -evenv-tempest -- tempest list-plugins
Mehdi Abaakouka8ea3682017-04-27 08:40:21 +0200120set +e
Chandan Kumar358c65f2018-02-05 12:17:08 +0530121sudo -H -u tempest OS_TEST_TIMEOUT=$TEMPEST_OS_TEST_TIMEOUT tox -evenv-tempest -- tempest run -r telemetry_tempest_plugin --concurrency=$TEMPEST_CONCURRENCY
Mehdi Abaakouk80081512015-07-29 19:03:26 +0200122EXIT_CODE=$?
Mehdi Abaakouka8ea3682017-04-27 08:40:21 +0200123set -e
Mehdi Abaakoukb64d2b02018-09-03 11:50:49 +0200124export_subunit_data "venv-tempest"
Mehdi Abaakoukde7d41e2017-03-22 17:09:51 +0100125generate_reports_and_maybe_exit $EXIT_CODE
Mehdi Abaakouk8ecffaf2016-12-15 11:53:00 +0100126
Mehdi Abaakouk80081512015-07-29 19:03:26 +0200127exit $EXIT_CODE