Automated test lanucher has been added.
Run a bunch of test that create vm, configure it,
run test and clean allocated resources.
diff --git a/scripts/run_all_tests.sh b/scripts/run_all_tests.sh
new file mode 100644
index 0000000..4bb9d26
--- /dev/null
+++ b/scripts/run_all_tests.sh
@@ -0,0 +1,4 @@
+bash run_test.sh 172.16.52.108 test37 172.16.55.2 disk_io_perf.pem
+bash run_test.sh 172.16.52.108 test37 172.16.55.2 disk_io_perf.pem
+bash run_test.sh 172.16.52.108 test37 172.16.55.2 disk_io_perf.pem
+bash run_test.sh 172.16.52.108 test37 172.16.55.2 disk_io_perf.pem
\ No newline at end of file
diff --git a/scripts/run_test.sh b/scripts/run_test.sh
new file mode 100644
index 0000000..483f583
--- /dev/null
+++ b/scripts/run_test.sh
@@ -0,0 +1,127 @@
+FUEL_MASTER_IP=$1
+FUEL_MASTER_PASSWD=$2
+EXTERNAL_IP=$3
+KEY_FILE_NAME=$4
+
+if [ ! -z $5 ]
+then
+ FILE_TO_TEST=$5
+else
+ FILE_TO_TEST="bbb.txt"
+fi
+
+if [ ! -z $6 ]
+then
+ FILE_TO_STORE_RESULTS=$6
+else
+ FILE_TO_STORE_RESULTS="aaa.txt"
+fi
+
+if [ ! -z $7 ]
+then
+ TIMEOUT=$7
+else
+ TIMEOUT=60
+fi
+
+
+echo "Fuel master IP: $FUEL_MASTER_IP"
+echo "Fuel master password: $FUEL_MASTER_PASSWD"
+echo "External IP: $EXTERNAL_IP"
+echo "Key file name: $KEY_FILE_NAME"
+
+# note : function will works properly only when image dame is single string without spaces that can brake awk
+function wait_image_active() {
+ image_state="none"
+ image_name=$IMAGE_NAME
+ counter=0
+
+ while [ $image_state != "active" ] ; do
+ sleep 1
+ image_state=$(glance image-list | grep $image_name | awk '{print $12}')
+ echo $image_state
+ counter=$((counter + 1))
+
+ if [ $counter -eq $TIMEOUT ]
+ then
+ echo "Time limit exceed"
+ break
+ fi
+ done
+}
+
+
+function wait_floating_ip() {
+ sleep 10
+ floating_ip="|"
+ vm_name=$VM_NAME
+ counter=0
+
+ while [ $floating_ip != "|" ] ; do
+ sleep 1
+ floating_ip=$(nova floating-ip-list | grep $vm_name | awk '{print $13}' | head -1)
+ counter=$((counter + 1))
+
+ if [ $counter -eq $TIMEOUT ]
+ then
+ echo "Time limit exceed"
+ break
+ fi
+ done
+}
+
+
+function wait_vm_deleted() {
+ vm_name=$(nova list| grep $VM_NAME| awk '{print $4}'| head -1)
+ counter=0
+
+ while [ ! -z $vm_name ] ; do
+ sleep 1
+ vm_name=$(nova list| grep $VM_NAME| awk '{print $4}'| head -1)
+ counter=$((counter + 1))
+
+ if [ $counter -eq $TIMEOUT ]
+ then
+ echo "Time limit exceed"
+ break
+ fi
+ done
+}
+
+source run_vm.sh $FUEL_MASTER_IP $FUEL_MASTER_PASSWD $EXTERNAL_IP
+source `get_openrc`
+list=$(nova list)
+if [ "$list" == "" ]; then
+ echo "openrc variables are unset or set to the empty string"
+fi
+
+IP=$(nova floating-ip-list | grep $FLOATING_NET | awk '{if ($5 == "-") print $2}' | head -n1)
+
+if [ -z $IP ]; then
+ IP=$(nova floating-ip-create net04_ext| awk '{print $2}')
+
+ if [ -z $list ]; then
+ echo "Cannot allocate new floating ip"
+ fi
+fi
+
+VM_IP=$IP
+echo "VM IP: $VM_IP"
+
+# sends images to glance
+bash prepare.sh
+wait_image_active
+echo "Image has been saved"
+VOL_ID=$(boot_vm)
+echo "VM has been booted"
+wait_floating_ip
+echo "Floating IP has been obtained"
+source `prepare_vm`
+echo "VM has been prepared"
+ssh -i $KEY_FILE_NAME ubuntu@$VM_IP \
+ "cd /tmp/io_scenario; sudo bash ../single_node_test_short.sh $FILE_TO_TEST $FILE_TO_STORE_RESULTS"
+nova delete $VM_NAME
+wait_vm_deleted
+echo "$VM_NAME has been deleted successfully"
+cinder delete $VOL_ID
+echo "Volume has been deleted $VOL_ID"
diff --git a/scripts/run_vm.sh b/scripts/run_vm.sh
index f93e475..94a39ea 100644
--- a/scripts/run_vm.sh
+++ b/scripts/run_vm.sh
@@ -1,21 +1,21 @@
#!/bin/bash
MASTER_IP=$1
FUEL_PASSWD=$2
+NEW_IP=$3
+VM_NAME=disk-io-test
# VM_IP=$(nova floating-ip-create "$FLOATIN_NET" | grep "$FLOATIN_NET" | awk '{print $2}')
-VM_IP=172.16.53.16
-OS_ORIGIN_IP=192.168.0.2
-OS_EXT_IP=172.16.53.2
-VM_NAME=koder-disk-test
+VM_IP=172.16.55.14
+OS_ORIGIN_IP=10.20.0.129
+OS_EXT_IP=172.16.53.66
-# FIXED_NET_NAME="net04"
-FIXED_NET_NAME="novanetwork"
+
+
+FIXED_NET_NAME="net04"
FLOATING_NET="net04_ext"
-# my_dir="$(dirname "$0")"
-# source "$my_dir/config.sh"
-source config.sh
-
+my_dir="$(dirname -- "$0")"
+source "$my_dir/config.sh"
SSH_OVER_MASTER="sshpass -p${FUEL_PASSWD} ssh root@${MASTER_IP}"
VOLUME_NAME="test-volume"
VOLUME_SIZE=20
@@ -25,35 +25,55 @@
function get_openrc() {
OPENRC=`tempfile`
CONTROLLER_NODE=$($SSH_OVER_MASTER fuel node | grep controller | awk '-F|' '{gsub(" ", "", $5); print $5}')
- $SSH_OVER_MASTER ssh $CONTROLLER_NODE cat openrc 2>/dev/null | sed "s/$OS_ORIGIN_IP/$OS_EXT_IP/g" > $OPENRC
+ $SSH_OVER_MASTER ssh $CONTROLLER_NODE cat openrc 2>/dev/null | \
+ sed -r 's/(\b[0-9]{1,3}\.){3}[0-9]{1,3}\b'/$NEW_IP/ > $OPENRC
echo $OPENRC
}
function wait_vm_active() {
vm_state="none"
- vm_name=$1
+ vm_name=$VM_NAME
+ counter=0
- while [ "$vm_state" != "ACTIVE" ] ; do
+ while [ $vm_state != "ACTIVE" ] ; do
sleep 1
vm_state=$(nova list | grep $vm_name | awk '{print $6}')
+ counter=$((counter + 1))
+
+ if [ $counter -eq $TIMEOUT ]
+ then
+ echo "Time limit exceed"
+ break
+ fi
done
}
function boot_vm() {
FIXED_NET_ID=$(nova net-list | grep "\b${FIXED_NET_NAME}\b" | awk '{print $2}')
- VOL_ID=$(cinder create --display-name $VOLUME_NAME $VOLUME_SIZE | grep '\bid\b' | awk '{print $4}')
+ VOL_ID=$(cinder create --display-name $VOLUME_NAME $VOLUME_SIZE | grep '\bid\b' | grep available | awk '{print $4}')
+
+ if [ -z $VOL_ID ]; then
+ VOL_ID=$(cinder list | grep test-volume | grep available| awk '{print $2}'| head -1)
+ fi
+
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
wait_vm_active $VM_NAME
nova floating-ip-associate $VM_NAME $VM_IP
+
nova volume-attach $VM_NAME $VOL_ID $VOLUME_DEVICE >/dev/null
+ echo $VOL_ID
}
function prepare_vm() {
scp -i "$KEY_FILE_NAME" -r ../io_scenario ubuntu@${VM_IP}:/tmp >/dev/null
+ echo "Copy io scenario folded"
scp -i "$KEY_FILE_NAME" $DEBS ubuntu@${VM_IP}:/tmp >/dev/null
+ echo "Copy DEBS packages"
scp -i "$KEY_FILE_NAME" single_node_test_short.sh ubuntu@${VM_IP}:/tmp >/dev/null
+ echo "Copy single_node_test_short"
ssh -i "$KEY_FILE_NAME" ubuntu@${VM_IP} sudo dpkg -i $DEBS >/dev/null
+ echo "dpkg on vm"
}
function prepare_node() {