koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | MASTER_IP=$1 |
| 3 | FUEL_PASSWD=$2 |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 4 | NEW_IP=$3 |
gstepanov | d282663 | 2015-04-02 15:01:18 +0300 | [diff] [blame] | 5 | FIXED_NET_NAME=$4 |
| 6 | FLOATING_NET=$5 |
| 7 | VM_NAME=disk-io-test |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 8 | |
koder aka kdanilov | ee4b241 | 2015-03-22 23:32:35 +0200 | [diff] [blame] | 9 | # VM_IP=$(nova floating-ip-create "$FLOATIN_NET" | grep "$FLOATIN_NET" | awk '{print $2}') |
gstepanov | a2d3760 | 2015-04-02 19:23:49 +0300 | [diff] [blame] | 10 | VM_IP=172.16.53.23 |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 11 | OS_ORIGIN_IP=10.20.0.129 |
| 12 | OS_EXT_IP=172.16.53.66 |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 13 | |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 14 | |
| 15 | |
gstepanov | d282663 | 2015-04-02 15:01:18 +0300 | [diff] [blame] | 16 | FIXED_NET_NAME="novanetwork" |
| 17 | FLOATING_NET="nova" |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 18 | |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 19 | my_dir="$(dirname -- "$0")" |
| 20 | source "$my_dir/config.sh" |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 21 | SSH_OVER_MASTER="sshpass -p${FUEL_PASSWD} ssh root@${MASTER_IP}" |
| 22 | VOLUME_NAME="test-volume" |
| 23 | VOLUME_SIZE=20 |
| 24 | VOLUME_DEVICE="/dev/vdb" |
| 25 | |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 26 | |
| 27 | function get_openrc() { |
gstepanov | a2d3760 | 2015-04-02 19:23:49 +0300 | [diff] [blame] | 28 | echo "get openrc" |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 29 | OPENRC=`tempfile` |
| 30 | CONTROLLER_NODE=$($SSH_OVER_MASTER fuel node | grep controller | awk '-F|' '{gsub(" ", "", $5); print $5}') |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 31 | $SSH_OVER_MASTER ssh $CONTROLLER_NODE cat openrc 2>/dev/null | \ |
| 32 | sed -r 's/(\b[0-9]{1,3}\.){3}[0-9]{1,3}\b'/$NEW_IP/ > $OPENRC |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 33 | echo $OPENRC |
| 34 | } |
| 35 | |
koder aka kdanilov | ee4b241 | 2015-03-22 23:32:35 +0200 | [diff] [blame] | 36 | function wait_vm_active() { |
| 37 | vm_state="none" |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 38 | vm_name=$VM_NAME |
| 39 | counter=0 |
koder aka kdanilov | ee4b241 | 2015-03-22 23:32:35 +0200 | [diff] [blame] | 40 | |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 41 | while [ $vm_state != "ACTIVE" ] ; do |
koder aka kdanilov | ee4b241 | 2015-03-22 23:32:35 +0200 | [diff] [blame] | 42 | sleep 1 |
| 43 | vm_state=$(nova list | grep $vm_name | awk '{print $6}') |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 44 | counter=$((counter + 1)) |
| 45 | |
| 46 | if [ $counter -eq $TIMEOUT ] |
| 47 | then |
| 48 | echo "Time limit exceed" |
| 49 | break |
| 50 | fi |
koder aka kdanilov | ee4b241 | 2015-03-22 23:32:35 +0200 | [diff] [blame] | 51 | done |
| 52 | } |
| 53 | |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 54 | function boot_vm() { |
| 55 | FIXED_NET_ID=$(nova net-list | grep "\b${FIXED_NET_NAME}\b" | awk '{print $2}') |
gstepanov | d282663 | 2015-04-02 15:01:18 +0300 | [diff] [blame] | 56 | echo "FIXED NET id : $FIXED_NET_ID" |
| 57 | sleep 10 |
| 58 | |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 59 | VOL_ID=$(cinder create --display-name $VOLUME_NAME $VOLUME_SIZE | grep '\bid\b' | grep available | awk '{print $4}') |
| 60 | |
| 61 | if [ -z $VOL_ID ]; then |
| 62 | VOL_ID=$(cinder list | grep test-volume | grep available| awk '{print $2}'| head -1) |
| 63 | fi |
| 64 | |
koder aka kdanilov | ee4b241 | 2015-03-22 23:32:35 +0200 | [diff] [blame] | 65 | nova boot --flavor "$FLAVOR_NAME" --image "$IMAGE_NAME" --key-name "$KEYPAIR_NAME" --security-groups default --nic net-id=$FIXED_NET_ID $VM_NAME >/dev/null |
| 66 | wait_vm_active $VM_NAME |
| 67 | |
| 68 | nova floating-ip-associate $VM_NAME $VM_IP |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 69 | |
koder aka kdanilov | ee4b241 | 2015-03-22 23:32:35 +0200 | [diff] [blame] | 70 | nova volume-attach $VM_NAME $VOL_ID $VOLUME_DEVICE >/dev/null |
koder aka kdanilov | fb23a26 | 2015-03-27 16:50:58 +0200 | [diff] [blame] | 71 | echo "VOL_ID=$VOL_ID" |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | function prepare_vm() { |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 75 | echo "Copy io scenario folded" |
gstepanov | a2d3760 | 2015-04-02 19:23:49 +0300 | [diff] [blame] | 76 | scp -i "$KEY_FILE_NAME" -r ../tests ubuntu@${VM_IP}:/tmp >/dev/null |
koder aka kdanilov | fb23a26 | 2015-03-27 16:50:58 +0200 | [diff] [blame] | 77 | |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 78 | echo "Copy DEBS packages" |
koder aka kdanilov | fb23a26 | 2015-03-27 16:50:58 +0200 | [diff] [blame] | 79 | scp -i "$KEY_FILE_NAME" $DEBS ubuntu@${VM_IP}:/tmp >/dev/null |
| 80 | |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 81 | echo "Copy single_node_test_short" |
koder aka kdanilov | fb23a26 | 2015-03-27 16:50:58 +0200 | [diff] [blame] | 82 | scp -i "$KEY_FILE_NAME" single_node_test_short.sh ubuntu@${VM_IP}:/tmp >/dev/null |
| 83 | |
gstepanov | 08c0d7e | 2015-03-25 23:55:44 +0200 | [diff] [blame] | 84 | echo "dpkg on vm" |
koder aka kdanilov | fb23a26 | 2015-03-27 16:50:58 +0200 | [diff] [blame] | 85 | ssh $SSH_OPTS -i "$KEY_FILE_NAME" ubuntu@${VM_IP} sudo dpkg -i $DEBS >/dev/null |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | function prepare_node() { |
koder aka kdanilov | fb23a26 | 2015-03-27 16:50:58 +0200 | [diff] [blame] | 89 | # set -e |
| 90 | # set -o pipefail |
gstepanov | b65b9a8 | 2015-03-28 18:09:17 +0200 | [diff] [blame] | 91 | echo "Preparing node" |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 92 | COMPUTE_NODE=$($SSH_OVER_MASTER fuel node | grep compute | awk '-F|' '{gsub(" ", "", $5); print $5}') |
| 93 | |
gstepanov | b65b9a8 | 2015-03-28 18:09:17 +0200 | [diff] [blame] | 94 | echo "Copying io_scenario to compute node" |
| 95 | sshpass -p${FUEL_MASTER_PASSWD} scp -r ../io_scenario root@${FUEL_MASTER_IP}:/tmp |
koder aka kdanilov | ee4b241 | 2015-03-22 23:32:35 +0200 | [diff] [blame] | 96 | $SSH_OVER_MASTER scp -r /tmp/io_scenario $COMPUTE_NODE:/tmp >/dev/null |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 97 | |
gstepanov | b65b9a8 | 2015-03-28 18:09:17 +0200 | [diff] [blame] | 98 | echo "Copying debs to compute node" |
| 99 | sshpass -p${FUEL_MASTER_PASSWD} scp $DEBS root@${FUEL_MASTER_IP}:/tmp |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 100 | |
| 101 | $SSH_OVER_MASTER scp $DEBS $COMPUTE_NODE:/tmp |
| 102 | $SSH_OVER_MASTER ssh $COMPUTE_NODE dpkg -i $DEBS |
| 103 | |
gstepanov | b65b9a8 | 2015-03-28 18:09:17 +0200 | [diff] [blame] | 104 | echo "Copying single_node_test.sh to compute node" |
| 105 | sshpass -p${FUEL_MASTER_PASSWD} scp single_node_test_short.sh root@${FUEL_MASTER_IP}:/tmp |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 106 | $SSH_OVER_MASTER scp /tmp/single_node_test_short.sh $COMPUTE_NODE:/tmp |
| 107 | } |
| 108 | |
| 109 | function download_debs() { |
| 110 | pushd /tmp >/dev/null |
| 111 | rm -f *.deb >/dev/null |
| 112 | aptitude download libibverbs1 librdmacm1 libaio1 fio >/dev/null |
| 113 | popd >/dev/null |
| 114 | echo /tmp/*.deb |
| 115 | } |
| 116 | |
koder aka kdanilov | ee4b241 | 2015-03-22 23:32:35 +0200 | [diff] [blame] | 117 | # OPENRC=`get_openrc` |
| 118 | # source $OPENRC |
| 119 | # rm $OPENRC |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 120 | |
koder aka kdanilov | ee4b241 | 2015-03-22 23:32:35 +0200 | [diff] [blame] | 121 | # boot_vm |
| 122 | # prepare_vm |
koder aka kdanilov | 8ad6e81 | 2015-03-22 14:42:18 +0200 | [diff] [blame] | 123 | |
| 124 | |