"Fossies" - the Fresh Open Source Software Archive

Member "tacker-2.0.0/tacker/tests/contrib/post_test_hook.sh" (16 Oct 2019, 2364 Bytes) of package /linux/misc/openstack/tacker-2.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "post_test_hook.sh": 0.8.1_vs_0.9.0.

    1 #!/bin/bash -x
    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 
   17 set -xe
   18 
   19 TACKER_DIR="$BASE/new/tacker"
   20 DEVSTACK_DIR="$BASE/new/devstack"
   21 SCRIPTS_DIR="/usr/os-testr-env/bin/"
   22 
   23 venv=${1:-"dsvm-functional"}
   24 
   25 function generate_test_logs {
   26     local path="$1"
   27     # Compress all $path/*.txt files and move the directories holding those
   28     # files to /opt/stack/logs. Files with .log suffix have their
   29     # suffix changed to .txt (so browsers will know to open the compressed
   30     # files and not download them).
   31     if [ -d "$path" ]
   32     then
   33         sudo find $path -iname "*.log" -type f -exec mv {} {}.txt \; -exec gzip -9 {}.txt \;
   34         sudo mv $path/* /opt/stack/logs/
   35     fi
   36 }
   37 
   38 function generate_testr_results {
   39     # Give job user rights to access tox logs
   40     sudo -H -u $owner chmod o+rw .
   41     sudo -H -u $owner chmod o+rw -R .stestr
   42     if [ -f ".stestr/0" ] ; then
   43         .tox/$venv/bin/subunit-1to2 < .stestr/0 > ./stestr.subunit
   44         $SCRIPTS_DIR/subunit2html ./stestr.subunit testr_results.html
   45         gzip -9 ./stestr.subunit
   46         gzip -9 ./testr_results.html
   47         sudo mv ./*.gz /opt/stack/logs/
   48     fi
   49 
   50     if [[ "$venv" == dsvm-functional* ]]
   51     then
   52         generate_test_logs $log_dir
   53     fi
   54 }
   55 
   56 . ${TACKER_DIR}/tacker/tests/contrib/post_test_hook_lib.sh
   57 
   58 if [[ "$venv" == dsvm-functional* ]]
   59 then
   60     owner=stack
   61     sudo_env=
   62     log_dir="/tmp/${venv}-logs"
   63     . $DEVSTACK_DIR/openrc admin admin
   64     fixup_quota
   65     add_key
   66     add_secgrp
   67 fi
   68 
   69 # Set owner permissions according to job's requirements.
   70 cd $TACKER_DIR
   71 sudo chown -R $owner:stack $TACKER_DIR
   72 
   73 # Run tests
   74 echo "Running tacker $venv test suite"
   75 set +e
   76 
   77 sudo -H -u $owner $sudo_env tox -e $venv
   78 testr_exit_code=$?
   79 set -e
   80 
   81 # Collect and parse results
   82 generate_testr_results
   83 exit $testr_exit_code
   84