| John Griffith | 4debfe2 | 2013-11-01 00:00:40 +0000 | [diff] [blame] | 1 | #!/usr/bin/env bash | 
 | 2 |  | 
 | 3 | # **cinder_cert.sh** | 
 | 4 |  | 
| john-griffith | fe4c4f7 | 2014-01-15 11:24:03 -0700 | [diff] [blame] | 5 | # This script is a simple wrapper around the tempest volume api tests | 
 | 6 | # It requires that you have a working and functional devstack install | 
 | 7 | # and that you've enabled your device driver by making the necessary | 
 | 8 | # modifications to /etc/cinder/cinder.conf | 
 | 9 |  | 
 | 10 | # This script will refresh your openstack repo's and restart the cinder | 
 | 11 | # services to pick up your driver changes. | 
 | 12 | # please NOTE; this script assumes your devstack install is functional | 
 | 13 | # and includes tempest. A good first step is to make sure you can | 
 | 14 | # create volumes on your device before you even try and run this script. | 
 | 15 |  | 
 | 16 | # It also assumes default install location (/opt/stack/xxx) | 
 | 17 | # to aid in debug, you should also verify that you've added | 
 | 18 | # an output directory for screen logs: | 
 | 19 | #     SCREEN_LOGDIR=/opt/stack/screen-logs | 
 | 20 |  | 
| John Griffith | 4debfe2 | 2013-11-01 00:00:40 +0000 | [diff] [blame] | 21 | CERT_DIR=$(cd $(dirname "$0") && pwd) | 
 | 22 | TOP_DIR=$(cd $CERT_DIR/..; pwd) | 
 | 23 |  | 
 | 24 | source $TOP_DIR/functions | 
 | 25 | source $TOP_DIR/stackrc | 
 | 26 | source $TOP_DIR/openrc | 
| Walter A. Boring IV | 75dbd9b | 2014-02-04 14:56:15 -0800 | [diff] [blame] | 27 | source $TOP_DIR/lib/infra | 
| John Griffith | 4debfe2 | 2013-11-01 00:00:40 +0000 | [diff] [blame] | 28 | source $TOP_DIR/lib/tempest | 
 | 29 | source $TOP_DIR/lib/cinder | 
 | 30 |  | 
 | 31 | TEMPFILE=`mktemp` | 
 | 32 | RECLONE=True | 
 | 33 |  | 
 | 34 | function log_message() { | 
 | 35 |     MESSAGE=$1 | 
 | 36 |     STEP_HEADER=$2 | 
 | 37 |     if [[ "$STEP_HEADER" = "True" ]]; then | 
 | 38 |         echo -e "\n========================================================" | tee -a $TEMPFILE | 
 | 39 |     fi | 
 | 40 |     echo -e `date +%m/%d/%y/%T:`"${MESSAGE}" | tee -a $TEMPFILE | 
 | 41 |     if [[ "$STEP_HEADER" = "True" ]]; then | 
 | 42 |         echo -e "========================================================" | tee -a $TEMPFILE | 
 | 43 |     fi | 
 | 44 | } | 
 | 45 |  | 
 | 46 | if [[ "$OFFLINE" = "True" ]]; then | 
 | 47 |     echo "ERROR: Driver cert requires fresh clone/pull from ${CINDER_BRANCH}" | 
 | 48 |     echo "       Please set OFFLINE=False and retry." | 
 | 49 |     exit 1 | 
 | 50 | fi | 
 | 51 |  | 
 | 52 | log_message "RUNNING CINDER DRIVER CERTIFICATION CHECK", True | 
 | 53 | log_message "Output is being logged to: $TEMPFILE" | 
 | 54 |  | 
 | 55 | cd $CINDER_DIR | 
 | 56 | log_message "Cloning to ${CINDER_REPO}...", True | 
 | 57 | install_cinder | 
 | 58 |  | 
 | 59 | log_message "Pull a fresh Clone of cinder repo...", True | 
 | 60 | git status | tee -a $TEMPFILE | 
 | 61 | git log --pretty=oneline -n 1 | tee -a $TEMPFILE | 
 | 62 |  | 
 | 63 | log_message "Gathering copy of cinder.conf file (passwords will be scrubbed)...", True | 
 | 64 | cat /etc/cinder/cinder.conf | egrep -v "(^#.*|^$)" | tee -a $TEMPFILE | 
 | 65 | sed -i "s/\(.*password.*=\).*$/\1 xxx/i" $TEMPFILE | 
 | 66 | log_message "End of cinder.conf.", True | 
 | 67 |  | 
 | 68 | cd $TOP_DIR | 
 | 69 | # Verify tempest is installed/enabled | 
 | 70 | if ! is_service_enabled tempest; then | 
 | 71 |     log_message "ERROR!!! Cert requires tempest in enabled_services!", True | 
 | 72 |     log_message"       Please add tempest to enabled_services and retry." | 
 | 73 |     exit 1 | 
 | 74 | fi | 
 | 75 |  | 
 | 76 | cd $TEMPEST_DIR | 
 | 77 | install_tempest | 
 | 78 |  | 
 | 79 | log_message "Verify tempest is current....", True | 
 | 80 | git status | tee -a $TEMPFILE | 
 | 81 | log_message "Check status and get latest commit..." | 
 | 82 | git log --pretty=oneline -n 1 | tee -a $TEMPFILE | 
 | 83 |  | 
 | 84 |  | 
 | 85 | #stop and restart cinder services | 
 | 86 | log_message "Restart Cinder services...", True | 
 | 87 | stop_cinder | 
 | 88 | sleep 1 | 
 | 89 | start_cinder | 
 | 90 | sleep 5 | 
 | 91 |  | 
 | 92 | # run tempest api/volume/test_* | 
| John Griffith | d6997d3 | 2014-02-13 22:56:29 +0000 | [diff] [blame] | 93 | log_message "Run the actual tempest volume tests (./tools/pretty_tox.sh api.volume)...", True | 
 | 94 | ./tools/pretty_tox.sh api.volume 2>&1 | tee -a $TEMPFILE | 
| John Griffith | 4debfe2 | 2013-11-01 00:00:40 +0000 | [diff] [blame] | 95 | if [[ $? = 0 ]]; then | 
 | 96 |     log_message "CONGRATULATIONS!!!  Device driver PASSED!", True | 
 | 97 |     log_message "Submit output: ($TEMPFILE)" | 
 | 98 |     exit 0 | 
 | 99 | else | 
 | 100 |     log_message "SORRY!!!  Device driver FAILED!", True | 
 | 101 |     log_message "Check output in $TEMPFILE" | 
 | 102 |     exit 1 | 
 | 103 | fi |