| 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 | 
|  | 27 | source $TOP_DIR/lib/tempest | 
|  | 28 | source $TOP_DIR/lib/cinder | 
|  | 29 |  | 
|  | 30 | TEMPFILE=`mktemp` | 
|  | 31 | RECLONE=True | 
|  | 32 |  | 
|  | 33 | function log_message() { | 
|  | 34 | MESSAGE=$1 | 
|  | 35 | STEP_HEADER=$2 | 
|  | 36 | if [[ "$STEP_HEADER" = "True" ]]; then | 
|  | 37 | echo -e "\n========================================================" | tee -a $TEMPFILE | 
|  | 38 | fi | 
|  | 39 | echo -e `date +%m/%d/%y/%T:`"${MESSAGE}" | tee -a $TEMPFILE | 
|  | 40 | if [[ "$STEP_HEADER" = "True" ]]; then | 
|  | 41 | echo -e "========================================================" | tee -a $TEMPFILE | 
|  | 42 | fi | 
|  | 43 | } | 
|  | 44 |  | 
|  | 45 | if [[ "$OFFLINE" = "True" ]]; then | 
|  | 46 | echo "ERROR: Driver cert requires fresh clone/pull from ${CINDER_BRANCH}" | 
|  | 47 | echo "       Please set OFFLINE=False and retry." | 
|  | 48 | exit 1 | 
|  | 49 | fi | 
|  | 50 |  | 
|  | 51 | log_message "RUNNING CINDER DRIVER CERTIFICATION CHECK", True | 
|  | 52 | log_message "Output is being logged to: $TEMPFILE" | 
|  | 53 |  | 
|  | 54 | cd $CINDER_DIR | 
|  | 55 | log_message "Cloning to ${CINDER_REPO}...", True | 
|  | 56 | install_cinder | 
|  | 57 |  | 
|  | 58 | log_message "Pull a fresh Clone of cinder repo...", True | 
|  | 59 | git status | tee -a $TEMPFILE | 
|  | 60 | git log --pretty=oneline -n 1 | tee -a $TEMPFILE | 
|  | 61 |  | 
|  | 62 | log_message "Gathering copy of cinder.conf file (passwords will be scrubbed)...", True | 
|  | 63 | cat /etc/cinder/cinder.conf | egrep -v "(^#.*|^$)" | tee -a $TEMPFILE | 
|  | 64 | sed -i "s/\(.*password.*=\).*$/\1 xxx/i" $TEMPFILE | 
|  | 65 | log_message "End of cinder.conf.", True | 
|  | 66 |  | 
|  | 67 | cd $TOP_DIR | 
|  | 68 | # Verify tempest is installed/enabled | 
|  | 69 | if ! is_service_enabled tempest; then | 
|  | 70 | log_message "ERROR!!! Cert requires tempest in enabled_services!", True | 
|  | 71 | log_message"       Please add tempest to enabled_services and retry." | 
|  | 72 | exit 1 | 
|  | 73 | fi | 
|  | 74 |  | 
|  | 75 | cd $TEMPEST_DIR | 
|  | 76 | install_tempest | 
|  | 77 |  | 
|  | 78 | log_message "Verify tempest is current....", True | 
|  | 79 | git status | tee -a $TEMPFILE | 
|  | 80 | log_message "Check status and get latest commit..." | 
|  | 81 | git log --pretty=oneline -n 1 | tee -a $TEMPFILE | 
|  | 82 |  | 
|  | 83 |  | 
|  | 84 | #stop and restart cinder services | 
|  | 85 | log_message "Restart Cinder services...", True | 
|  | 86 | stop_cinder | 
|  | 87 | sleep 1 | 
|  | 88 | start_cinder | 
|  | 89 | sleep 5 | 
|  | 90 |  | 
|  | 91 | # run tempest api/volume/test_* | 
| john-griffith | fe4c4f7 | 2014-01-15 11:24:03 -0700 | [diff] [blame] | 92 | log_message "Run the actual tempest volume tests (./tools/pretty_tox.sh api.volume_*)...", True | 
| John Griffith | 4debfe2 | 2013-11-01 00:00:40 +0000 | [diff] [blame] | 93 | exec 2> >(tee -a $TEMPFILE) | 
| john-griffith | fe4c4f7 | 2014-01-15 11:24:03 -0700 | [diff] [blame] | 94 | `./tools/pretty_tox.sh api.volume` | 
| 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 |