blob: b076631688e1678bf85237a99ed1db2948c75786 [file] [log] [blame]
koder aka kdanilov8ad6e812015-03-22 14:42:18 +02001#!/bin/bash
2MASTER_IP=$1
3FUEL_PASSWD=$2
gstepanov08c0d7e2015-03-25 23:55:44 +02004NEW_IP=$3
gstepanovd2826632015-04-02 15:01:18 +03005FIXED_NET_NAME=$4
6FLOATING_NET=$5
7VM_NAME=disk-io-test
koder aka kdanilov8ad6e812015-03-22 14:42:18 +02008
koder aka kdanilovee4b2412015-03-22 23:32:35 +02009# VM_IP=$(nova floating-ip-create "$FLOATIN_NET" | grep "$FLOATIN_NET" | awk '{print $2}')
gstepanova2d37602015-04-02 19:23:49 +030010VM_IP=172.16.53.23
gstepanov08c0d7e2015-03-25 23:55:44 +020011OS_ORIGIN_IP=10.20.0.129
12OS_EXT_IP=172.16.53.66
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020013
gstepanov08c0d7e2015-03-25 23:55:44 +020014
15
gstepanovd2826632015-04-02 15:01:18 +030016FIXED_NET_NAME="novanetwork"
17FLOATING_NET="nova"
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020018
gstepanov08c0d7e2015-03-25 23:55:44 +020019my_dir="$(dirname -- "$0")"
20source "$my_dir/config.sh"
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020021SSH_OVER_MASTER="sshpass -p${FUEL_PASSWD} ssh root@${MASTER_IP}"
22VOLUME_NAME="test-volume"
23VOLUME_SIZE=20
24VOLUME_DEVICE="/dev/vdb"
25
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020026
27function get_openrc() {
gstepanova2d37602015-04-02 19:23:49 +030028 echo "get openrc"
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020029 OPENRC=`tempfile`
30 CONTROLLER_NODE=$($SSH_OVER_MASTER fuel node | grep controller | awk '-F|' '{gsub(" ", "", $5); print $5}')
gstepanov08c0d7e2015-03-25 23:55:44 +020031 $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 kdanilov8ad6e812015-03-22 14:42:18 +020033 echo $OPENRC
34}
35
koder aka kdanilovee4b2412015-03-22 23:32:35 +020036function wait_vm_active() {
37 vm_state="none"
gstepanov08c0d7e2015-03-25 23:55:44 +020038 vm_name=$VM_NAME
39 counter=0
koder aka kdanilovee4b2412015-03-22 23:32:35 +020040
gstepanov08c0d7e2015-03-25 23:55:44 +020041 while [ $vm_state != "ACTIVE" ] ; do
koder aka kdanilovee4b2412015-03-22 23:32:35 +020042 sleep 1
43 vm_state=$(nova list | grep $vm_name | awk '{print $6}')
gstepanov08c0d7e2015-03-25 23:55:44 +020044 counter=$((counter + 1))
45
46 if [ $counter -eq $TIMEOUT ]
47 then
48 echo "Time limit exceed"
49 break
50 fi
koder aka kdanilovee4b2412015-03-22 23:32:35 +020051 done
52}
53
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020054function boot_vm() {
55 FIXED_NET_ID=$(nova net-list | grep "\b${FIXED_NET_NAME}\b" | awk '{print $2}')
gstepanovd2826632015-04-02 15:01:18 +030056 echo "FIXED NET id : $FIXED_NET_ID"
57 sleep 10
58
gstepanov08c0d7e2015-03-25 23:55:44 +020059 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 kdanilovee4b2412015-03-22 23:32:35 +020065 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
gstepanov08c0d7e2015-03-25 23:55:44 +020069
koder aka kdanilovee4b2412015-03-22 23:32:35 +020070 nova volume-attach $VM_NAME $VOL_ID $VOLUME_DEVICE >/dev/null
koder aka kdanilovfb23a262015-03-27 16:50:58 +020071 echo "VOL_ID=$VOL_ID"
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020072}
73
74function prepare_vm() {
gstepanov08c0d7e2015-03-25 23:55:44 +020075 echo "Copy io scenario folded"
gstepanova2d37602015-04-02 19:23:49 +030076 scp -i "$KEY_FILE_NAME" -r ../tests ubuntu@${VM_IP}:/tmp >/dev/null
koder aka kdanilovfb23a262015-03-27 16:50:58 +020077
gstepanov08c0d7e2015-03-25 23:55:44 +020078 echo "Copy DEBS packages"
koder aka kdanilovfb23a262015-03-27 16:50:58 +020079 scp -i "$KEY_FILE_NAME" $DEBS ubuntu@${VM_IP}:/tmp >/dev/null
80
gstepanov08c0d7e2015-03-25 23:55:44 +020081 echo "Copy single_node_test_short"
koder aka kdanilovfb23a262015-03-27 16:50:58 +020082 scp -i "$KEY_FILE_NAME" single_node_test_short.sh ubuntu@${VM_IP}:/tmp >/dev/null
83
gstepanov08c0d7e2015-03-25 23:55:44 +020084 echo "dpkg on vm"
koder aka kdanilovfb23a262015-03-27 16:50:58 +020085 ssh $SSH_OPTS -i "$KEY_FILE_NAME" ubuntu@${VM_IP} sudo dpkg -i $DEBS >/dev/null
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020086}
87
88function prepare_node() {
koder aka kdanilovfb23a262015-03-27 16:50:58 +020089 # set -e
90 # set -o pipefail
gstepanovb65b9a82015-03-28 18:09:17 +020091 echo "Preparing node"
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020092 COMPUTE_NODE=$($SSH_OVER_MASTER fuel node | grep compute | awk '-F|' '{gsub(" ", "", $5); print $5}')
93
gstepanovb65b9a82015-03-28 18:09:17 +020094 echo "Copying io_scenario to compute node"
95 sshpass -p${FUEL_MASTER_PASSWD} scp -r ../io_scenario root@${FUEL_MASTER_IP}:/tmp
koder aka kdanilovee4b2412015-03-22 23:32:35 +020096 $SSH_OVER_MASTER scp -r /tmp/io_scenario $COMPUTE_NODE:/tmp >/dev/null
koder aka kdanilov8ad6e812015-03-22 14:42:18 +020097
gstepanovb65b9a82015-03-28 18:09:17 +020098 echo "Copying debs to compute node"
99 sshpass -p${FUEL_MASTER_PASSWD} scp $DEBS root@${FUEL_MASTER_IP}:/tmp
koder aka kdanilov8ad6e812015-03-22 14:42:18 +0200100
101 $SSH_OVER_MASTER scp $DEBS $COMPUTE_NODE:/tmp
102 $SSH_OVER_MASTER ssh $COMPUTE_NODE dpkg -i $DEBS
103
gstepanovb65b9a82015-03-28 18:09:17 +0200104 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 kdanilov8ad6e812015-03-22 14:42:18 +0200106 $SSH_OVER_MASTER scp /tmp/single_node_test_short.sh $COMPUTE_NODE:/tmp
107}
108
109function 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 kdanilovee4b2412015-03-22 23:32:35 +0200117# OPENRC=`get_openrc`
118# source $OPENRC
119# rm $OPENRC
koder aka kdanilov8ad6e812015-03-22 14:42:18 +0200120
koder aka kdanilovee4b2412015-03-22 23:32:35 +0200121# boot_vm
122# prepare_vm
koder aka kdanilov8ad6e812015-03-22 14:42:18 +0200123
124