| 1 | #!/bin/sh |
| 2 | |
| 3 | set -e |
| 4 | |
| 5 | if [ -z "$AWS_INSTANCE_ID" ] || [ -z "$AWS_REGION" ] || \ |
| 6 | [ -z "$AWS_ACCESS_KEY" ] || [ -z "$AWS_SECRET_KEY" ]; |
| 7 | then |
| 8 | echo "AWS environment not found, skipping test." |
| 9 | exit 77 |
| 10 | fi |
| 11 | |
| 12 | test_aws() { |
| 13 | printf "\n=== $1 ===\n" |
| 14 | /usr/sbin/fence_aws -r $AWS_REGION -a $AWS_ACCESS_KEY -s $AWS_SECRET_KEY -n $AWS_INSTANCE_ID -o $1 |
| 15 | } |
| 16 | |
| 17 | printf "=== version ===\n" |
| 18 | /usr/sbin/fence_aws -V |
| 19 | |
| 20 | test_aws list |
| 21 | |
| 22 | if test_aws status |
| 23 | then # instance is running |
| 24 | test_aws reboot |
| 25 | sleep 30 |
| 26 | test_aws status |
| 27 | |
| 28 | test_aws off |
| 29 | sleep 30 |
| 30 | test_aws status || true |
| 31 | |
| 32 | test_aws on |
| 33 | sleep 30 |
| 34 | test_aws status |
| 35 | else # instance is stopped |
| 36 | test_aws on |
| 37 | sleep 30 |
| 38 | test_aws status |
| 39 | |
| 40 | test_aws reboot |
| 41 | sleep 30 |
| 42 | test_aws status |
| 43 | |
| 44 | test_aws off |
| 45 | sleep 30 |
| 46 | test_aws status || true |
| 47 | fi |