John Griffith | 4debfe2 | 2013-11-01 00:00:40 +0000 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # **cinder_cert.sh** |
| 4 | |
| 5 | CERT_DIR=$(cd $(dirname "$0") && pwd) |
| 6 | TOP_DIR=$(cd $CERT_DIR/..; pwd) |
| 7 | |
| 8 | source $TOP_DIR/functions |
| 9 | source $TOP_DIR/stackrc |
| 10 | source $TOP_DIR/openrc |
| 11 | source $TOP_DIR/lib/tempest |
| 12 | source $TOP_DIR/lib/cinder |
| 13 | |
| 14 | TEMPFILE=`mktemp` |
| 15 | RECLONE=True |
| 16 | |
| 17 | function log_message() { |
| 18 | MESSAGE=$1 |
| 19 | STEP_HEADER=$2 |
| 20 | if [[ "$STEP_HEADER" = "True" ]]; then |
| 21 | echo -e "\n========================================================" | tee -a $TEMPFILE |
| 22 | fi |
| 23 | echo -e `date +%m/%d/%y/%T:`"${MESSAGE}" | tee -a $TEMPFILE |
| 24 | if [[ "$STEP_HEADER" = "True" ]]; then |
| 25 | echo -e "========================================================" | tee -a $TEMPFILE |
| 26 | fi |
| 27 | } |
| 28 | |
| 29 | if [[ "$OFFLINE" = "True" ]]; then |
| 30 | echo "ERROR: Driver cert requires fresh clone/pull from ${CINDER_BRANCH}" |
| 31 | echo " Please set OFFLINE=False and retry." |
| 32 | exit 1 |
| 33 | fi |
| 34 | |
| 35 | log_message "RUNNING CINDER DRIVER CERTIFICATION CHECK", True |
| 36 | log_message "Output is being logged to: $TEMPFILE" |
| 37 | |
| 38 | cd $CINDER_DIR |
| 39 | log_message "Cloning to ${CINDER_REPO}...", True |
| 40 | install_cinder |
| 41 | |
| 42 | log_message "Pull a fresh Clone of cinder repo...", True |
| 43 | git status | tee -a $TEMPFILE |
| 44 | git log --pretty=oneline -n 1 | tee -a $TEMPFILE |
| 45 | |
| 46 | log_message "Gathering copy of cinder.conf file (passwords will be scrubbed)...", True |
| 47 | cat /etc/cinder/cinder.conf | egrep -v "(^#.*|^$)" | tee -a $TEMPFILE |
| 48 | sed -i "s/\(.*password.*=\).*$/\1 xxx/i" $TEMPFILE |
| 49 | log_message "End of cinder.conf.", True |
| 50 | |
| 51 | cd $TOP_DIR |
| 52 | # Verify tempest is installed/enabled |
| 53 | if ! is_service_enabled tempest; then |
| 54 | log_message "ERROR!!! Cert requires tempest in enabled_services!", True |
| 55 | log_message" Please add tempest to enabled_services and retry." |
| 56 | exit 1 |
| 57 | fi |
| 58 | |
| 59 | cd $TEMPEST_DIR |
| 60 | install_tempest |
| 61 | |
| 62 | log_message "Verify tempest is current....", True |
| 63 | git status | tee -a $TEMPFILE |
| 64 | log_message "Check status and get latest commit..." |
| 65 | git log --pretty=oneline -n 1 | tee -a $TEMPFILE |
| 66 | |
| 67 | |
| 68 | #stop and restart cinder services |
| 69 | log_message "Restart Cinder services...", True |
| 70 | stop_cinder |
| 71 | sleep 1 |
| 72 | start_cinder |
| 73 | sleep 5 |
| 74 | |
| 75 | # run tempest api/volume/test_* |
| 76 | log_message "Run the actual tempest volume tests (run_tests.sh -N tempest.api.volume.test_*)...", True |
| 77 | exec 2> >(tee -a $TEMPFILE) |
| 78 | `./run_tests.sh -N tempest.api.volume.test_*` |
| 79 | if [[ $? = 0 ]]; then |
| 80 | log_message "CONGRATULATIONS!!! Device driver PASSED!", True |
| 81 | log_message "Submit output: ($TEMPFILE)" |
| 82 | exit 0 |
| 83 | else |
| 84 | log_message "SORRY!!! Device driver FAILED!", True |
| 85 | log_message "Check output in $TEMPFILE" |
| 86 | exit 1 |
| 87 | fi |