Mehdi Abaakouk | 8008151 | 2015-07-29 19:03:26 +0200 | [diff] [blame] | 1 | #!/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 Abaakouk | 31291f8 | 2016-11-25 10:56:26 +0100 | [diff] [blame] | 17 | function export_subunit_data { |
| 18 | target="$1" |
Mehdi Abaakouk | 8008151 | 2015-07-29 19:03:26 +0200 | [diff] [blame] | 19 | if [ -f .testrepository/0 ]; then |
Mehdi Abaakouk | 31291f8 | 2016-11-25 10:56:26 +0100 | [diff] [blame] | 20 | sudo testr last --subunit > $WORKSPACE/testrepository.subunit.$target |
Mehdi Abaakouk | 8008151 | 2015-07-29 19:03:26 +0200 | [diff] [blame] | 21 | fi |
| 22 | } |
| 23 | |
Mehdi Abaakouk | 31291f8 | 2016-11-25 10:56:26 +0100 | [diff] [blame] | 24 | function 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 Van | ef853d4 | 2017-10-18 09:11:43 +0700 | [diff] [blame] | 29 | sudo chown $USER:$USER $BASE/logs/testrepository.subunit.gz $BASE/logs/testr_results.html.gz |
Mehdi Abaakouk | 31291f8 | 2016-11-25 10:56:26 +0100 | [diff] [blame] | 30 | sudo chmod a+r $BASE/logs/testrepository.subunit.gz $BASE/logs/testr_results.html.gz |
| 31 | } |
| 32 | |
Mehdi Abaakouk | 8ecffaf | 2016-12-15 11:53:00 +0100 | [diff] [blame] | 33 | function generate_telemetry_report(){ |
Mehdi Abaakouk | 7f0e315 | 2019-02-08 12:30:17 +0100 | [diff] [blame] | 34 | set -x |
Mehdi Abaakouk | 510f3ce | 2017-05-02 19:23:41 +0200 | [diff] [blame] | 35 | set +e |
Mehdi Abaakouk | 8ecffaf | 2016-12-15 11:53:00 +0100 | [diff] [blame] | 36 | |
| 37 | echo "* Message queue status:" |
| 38 | sudo rabbitmqctl list_queues | grep -e \\.sample -e \\.info |
| 39 | |
Mehdi Abaakouk | a8ea368 | 2017-04-27 08:40:21 +0200 | [diff] [blame] | 40 | source $BASE/new/devstack/openrc admin admin |
| 41 | |
Mehdi Abaakouk | 8ecffaf | 2016-12-15 11:53:00 +0100 | [diff] [blame] | 42 | echo "* Heat stack:" |
| 43 | openstack stack show integration_test |
| 44 | echo "* Alarm list:" |
| 45 | aodh alarm list |
zhurong | 24f1bcd | 2019-04-09 16:51:54 +0800 | [diff] [blame^] | 46 | echo "* Alarm show:" |
| 47 | aodh alarm show $(aodh alarm list -f value -c alarm_id) |
Mehdi Abaakouk | 8ecffaf | 2016-12-15 11:53:00 +0100 | [diff] [blame] | 48 | echo "* Nova instance list:" |
Mehdi Abaakouk | 5284457 | 2018-06-14 16:46:45 +0200 | [diff] [blame] | 49 | openstack server list --all-projects |
Mehdi Abaakouk | 8ecffaf | 2016-12-15 11:53:00 +0100 | [diff] [blame] | 50 | |
| 51 | echo "* Gnocchi instance list:" |
| 52 | gnocchi resource list -t instance |
Mehdi Abaakouk | 5284457 | 2018-06-14 16:46:45 +0200 | [diff] [blame] | 53 | for instance_id in $(openstack server list -f value -c ID --all-projects); do |
Mehdi Abaakouk | 8ecffaf | 2016-12-15 11:53:00 +0100 | [diff] [blame] | 54 | 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}:" |
zhurong | 24f1bcd | 2019-04-09 16:51:54 +0800 | [diff] [blame^] | 59 | 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 Abaakouk | 8ecffaf | 2016-12-15 11:53:00 +0100 | [diff] [blame] | 66 | done |
| 67 | |
| 68 | gnocchi status |
| 69 | |
Mehdi Abaakouk | 8ecffaf | 2016-12-15 11:53:00 +0100 | [diff] [blame] | 70 | echo "* Unprocessed measures:" |
Julien Danjou | 1be043e | 2017-10-19 09:52:41 +0200 | [diff] [blame] | 71 | for key in $(redis-cli --scan --pattern 'incoming*'); do echo -n "$key length = " && redis-cli llen $key; done |
Mehdi Abaakouk | 8ecffaf | 2016-12-15 11:53:00 +0100 | [diff] [blame] | 72 | |
Mehdi Abaakouk | b64d2b0 | 2018-09-03 11:50:49 +0200 | [diff] [blame] | 73 | 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 Abaakouk | 510f3ce | 2017-05-02 19:23:41 +0200 | [diff] [blame] | 83 | set -e |
Mehdi Abaakouk | 8ecffaf | 2016-12-15 11:53:00 +0100 | [diff] [blame] | 84 | set -x |
| 85 | } |
| 86 | |
| 87 | function 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 | |
zhurong | 24f1bcd | 2019-04-09 16:51:54 +0800 | [diff] [blame^] | 97 | function 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 Abaakouk | 8ecffaf | 2016-12-15 11:53:00 +0100 | [diff] [blame] | 110 | |
Mehdi Abaakouk | c5ebe73 | 2017-04-19 09:17:58 +0200 | [diff] [blame] | 111 | # Run tests with tempest |
Mehdi Abaakouk | de7d41e | 2017-03-22 17:09:51 +0100 | [diff] [blame] | 112 | sudo chown -R tempest:stack $BASE/new/tempest |
| 113 | sudo chown -R tempest:stack $BASE/data/tempest |
Mehdi Abaakouk | de7d41e | 2017-03-22 17:09:51 +0100 | [diff] [blame] | 114 | cd $BASE/new/tempest |
zhurong | 24f1bcd | 2019-04-09 16:51:54 +0800 | [diff] [blame^] | 115 | change_config_for_old_branch |
Mehdi Abaakouk | b64d2b0 | 2018-09-03 11:50:49 +0200 | [diff] [blame] | 116 | sudo -H -u tempest tox -evenv-tempest -- pip install /opt/stack/new/telemetry-tempest-plugin |
Mehdi Abaakouk | 7f0e315 | 2019-02-08 12:30:17 +0100 | [diff] [blame] | 117 | sudo -H -u tempest tox -evenv-tempest -- pip install /opt/stack/new/heat-tempest-plugin |
Mehdi Abaakouk | 16251bb | 2018-06-13 14:44:13 +0200 | [diff] [blame] | 118 | echo "Checking installed Tempest plugins:" |
| 119 | sudo -H -u tempest tox -evenv-tempest -- tempest list-plugins |
Mehdi Abaakouk | a8ea368 | 2017-04-27 08:40:21 +0200 | [diff] [blame] | 120 | set +e |
Chandan Kumar | 358c65f | 2018-02-05 12:17:08 +0530 | [diff] [blame] | 121 | sudo -H -u tempest OS_TEST_TIMEOUT=$TEMPEST_OS_TEST_TIMEOUT tox -evenv-tempest -- tempest run -r telemetry_tempest_plugin --concurrency=$TEMPEST_CONCURRENCY |
Mehdi Abaakouk | 8008151 | 2015-07-29 19:03:26 +0200 | [diff] [blame] | 122 | EXIT_CODE=$? |
Mehdi Abaakouk | a8ea368 | 2017-04-27 08:40:21 +0200 | [diff] [blame] | 123 | set -e |
Mehdi Abaakouk | b64d2b0 | 2018-09-03 11:50:49 +0200 | [diff] [blame] | 124 | export_subunit_data "venv-tempest" |
Mehdi Abaakouk | de7d41e | 2017-03-22 17:09:51 +0100 | [diff] [blame] | 125 | generate_reports_and_maybe_exit $EXIT_CODE |
Mehdi Abaakouk | 8ecffaf | 2016-12-15 11:53:00 +0100 | [diff] [blame] | 126 | |
Mehdi Abaakouk | 8008151 | 2015-07-29 19:03:26 +0200 | [diff] [blame] | 127 | exit $EXIT_CODE |