"Fossies" - the Fresh Open Source Software Archive

Member "manila-8.1.4/contrib/ci/common.sh" (19 Nov 2020, 3249 Bytes) of package /linux/misc/openstack/manila-8.1.4.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 and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "common.sh": 8.1.3_vs_8.1.4.

    1 # Environment variables
    2 
    3 # ----------------------------------------------
    4 
    5 # Functions
    6 
    7 # Import devstack functions
    8 source $BASE/new/devstack/functions
    9 
   10 function manila_check_service_vm_availability {
   11     # First argument is expected to be IP address of a service VM
   12 
   13     wait_step=10
   14     wait_timeout=300
   15     available='false'
   16     while (( wait_timeout > 0 )) ; do
   17         if ping -w 1 $1; then
   18             available='true'
   19             break
   20         fi
   21         ((wait_timeout-=$wait_step))
   22         sleep $wait_step
   23     done
   24 
   25     if [[ $available == 'true' ]]; then
   26         echo "SUCCESS! Service VM $1 is available."
   27     else
   28         echo "FAILURE! Service VM $1 is not available."
   29         exit 1
   30     fi
   31 }
   32 
   33 function manila_wait_for_generic_driver_init {
   34     # First argument is expected to be file path to Manila config
   35 
   36     MANILA_CONF=$1
   37     DRIVER_GROUPS=$(iniget $MANILA_CONF DEFAULT enabled_share_backends)
   38     for driver_group in ${DRIVER_GROUPS//,/ }; do
   39         SHARE_DRIVER=$(iniget $MANILA_CONF $driver_group share_driver)
   40         GENERIC_DRIVER='manila.share.drivers.generic.GenericShareDriver'
   41         DHSS=$(iniget $MANILA_CONF $driver_group driver_handles_share_servers)
   42         if [[ $SHARE_DRIVER == $GENERIC_DRIVER && $(trueorfalse False DHSS) == False ]]; then
   43             # Wait for service VM availability
   44             source /opt/stack/new/devstack/openrc admin demo
   45             vm_ip=$(iniget $MANILA_CONF $driver_group service_net_name_or_ip)
   46 
   47             # Check availability
   48             manila_check_service_vm_availability $vm_ip
   49         fi
   50     done
   51 }
   52 
   53 function manila_wait_for_drivers_init {
   54     # First argument is expected to be file path to Manila config
   55 
   56     manila_wait_for_generic_driver_init $1
   57 
   58     # Sleep to make manila-share service notify manila-scheduler about
   59     # its capabilities on time.
   60     sleep 10
   61 }
   62 
   63 function save_tempest_results {
   64     # First argument is expected to be number or tempest run
   65 
   66     local src_dirname
   67     local dst_dirname
   68 
   69     src_dirname="$BASE/new/tempest"
   70     dst_dirname="$BASE/logs/tempest_$1"
   71 
   72     # 1. Create destination directory
   73     sudo mkdir $dst_dirname
   74     sudo chown $USER:stack $dst_dirname
   75     sudo chmod 755 $dst_dirname
   76 
   77     # 2. Save tempest configuration file
   78     sudo cp $src_dirname/etc/tempest.conf $dst_dirname/tempest_conf.txt
   79 
   80     # 3. Save tempest log file
   81     cp $src_dirname/tempest.log $src_dirname/tempest.txt
   82     echo '' > $src_dirname/tempest.log
   83     sudo mv $src_dirname/tempest.txt $dst_dirname/tempest.txt
   84 
   85     # 4. Save tempest stestr results
   86 
   87     if [ -f $src_dirname/.stestr/0 ]; then
   88         pushd $src_dirname
   89         sudo stestr last --subunit > $src_dirname/tempest.subunit
   90         popd
   91     else
   92         echo "Tests have not run!"
   93     fi
   94 
   95     if [ -f $src_dirname/tempest.subunit ]; then
   96         s2h=`type -p subunit2html`
   97         sudo $s2h $src_dirname/tempest.subunit $src_dirname/testr_results.html
   98         sudo mv $src_dirname/tempest.subunit $dst_dirname/tempest.subunit
   99         sudo mv $src_dirname/testr_results.html $dst_dirname/testr_results.html
  100 
  101         # 5. Cleanup
  102         sudo rm -rf $src_dirname/.stestr
  103     else
  104         echo "No 'stestr' results available for saving. File '$src_dirname/tempest.subunit' is absent."
  105     fi
  106 }