Add detection of failed VM test case (semiauto)

https://storyboard.openstack.org/#!/story/2002719
Task:37366

Change-Id: I5d0661d0f601635763f7cf92cd705ed8ea5eb23c
Signed-off-by: VictorRodriguez <vm.rod25@gmail.com>
This commit is contained in:
VictorRodriguez 2019-11-05 08:11:00 -06:00
parent a8acbf01c5
commit da03e06d5d
5 changed files with 246 additions and 0 deletions

View File

@ -27,3 +27,4 @@ For more information about StarlingX, see https://docs.starlingx.io/.
distributed_cloud/index
system_inventory/index
AIO_simplex/index
performance/index

View File

@ -0,0 +1,72 @@
===================================
Detection of failed virtual machine
===================================
.. contents::
:local:
:depth: 1
-----------------------
detection_fail_VM_01
-----------------------
:Test ID: detection_fail_VM_01
:Test Title: Detection of failed virtual machine
:Tags: performance
~~~~~~~~~~~~~~~~~~
Testcase Objective
~~~~~~~~~~~~~~~~~~
The objective of this test is to verify how much time is cosumed StarlingX to
detect when a Virtual Machine has failed.
~~~~~~~~~~~~~~~~~~~
Test Pre-Conditions
~~~~~~~~~~~~~~~~~~~
The StarlingX configuration deployed for this is the Standard Controller
(2 controllers + 2 computes) in order to review the behavior in a multinode
environment.
~~~~~~~~~~
Test Steps
~~~~~~~~~~
1. Launch a VM with the features described below, this section includes an
script which could help to do that (Another alternative is to use the
OpenStack dashboard).
::
| Feature | Description |
|------------|------------------------|
| RAM | 2GB |
| Disk | 20GB |
| VCPUS | 1 |
| Properties | hw:mem_page_size=large |
| Image | [Debian] |
* Detect the compute where that VM was deployed and kill the QEMU process,
immediately after this, the initial time must be taken.
* Make a constant of pull request of the VM status and stop the test when it
changes.
* Finally take the end time and calculate the delta.
~~~~~~~~~~~~~~~~~
Expected Behavior
~~~~~~~~~~~~~~~~~
Result being around 500ms
~~~~~~~~~~
References
~~~~~~~~~~
N/A

View File

@ -0,0 +1,24 @@
=================
PERFORMANCE TESTS
=================
The proposed test cases create a set of scripts and documentation under the
starlingx testing repository (https://opendev.org/starlingx/test) that anyone
can use to measure the metric they need under their hardware and software
environment.
-----------------
Test Requirements
-----------------
NA
----------
Subdomains
----------
.. toctree::
:maxdepth: 2
detection_fail_VM

View File

@ -0,0 +1,114 @@
#!/bin/bash
# This script has to be executed in the controller.
CLOUD_IMAGE="debian-9.9.5-20190721-openstack-amd64.qcow2"
TEST_IMAGE="debian"
TEST_KEY_NAME="stx-key-test"
DEBIAN_CLOUD_URL="http://cdimage.debian.org/cdimage/openstack/9.9.5-20190721"
TEST_FLAVOR="f2.small"
TEST_NETWORK="network-1"
INSTANCE_NAME="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 10 ; echo '')"
TIMEOUT=300
if [ -z "$OS_CLOUD" ]; then
export OS_CLOUD=openstack_helm
fi
# Verify if the controller already has a SSH key.
if [ ! -f "$HOME/.ssh/id_rsa" ]; then
ssh-keygen -t rsa -N "" -f $HOME/.ssh/id_rsa
fi
if [ -z "$(openstack keypair list | grep -wo $TEST_KEY_NAME)" ]; then
openstack keypair create \
--public-key $HOME/.ssh/id_rsa.pub \
$TEST_KEY_NAME
else
echo "key: $TEST_KEY_NAME OK"
fi
# Verify OpenStack image.
# This section looks for a debian image, this is
# because the cirrOS image did not work.
if [ -z "$(openstack image list -c Name | grep -w $TEST_IMAGE)" ]; then
echo "image: $TEST_IMAGE no found"
echo "$TEST_IMAGE will be installed"
if [ ! -f "$CLOUD_IMAGE" ]; then
curl -OL "${DEBIAN_CLOUD_URL}/${CLOUD_IMAGE}"
fi
openstack image create \
--file $CLOUD_IMAGE \
--disk-format qcow2 \
--property hw:mem_page_size=large \
--public $TEST_IMAGE
else
echo "image: $TEST_IMAGE OK"
fi
# Verify customized flavor
if [ -z "$(openstack flavor list -c Name | grep -w $TEST_FLAVOR)" ]; then
openstack flavor create \
--ram 2048 \
--disk 20 \
--vcpus 1 \
--public \
--id auto \
--property hw:mem_page_size=large $TEST_FLAVOR
else
echo "flavor: $TEST_FLAVOR OK"
fi
# Verify network
if [ -z "$(openstack network list -c Name | grep -w $TEST_NETWORK)" ]; then
echo "Create $TEST_NETWORK"
openstack network create $TEST_NETWORK
# Configure subnets
openstack subnet create \
--network $TEST_NETWORK \
--subnet-range 192.168.0.0/24 \
--ip-version 4 \
--dhcp subnet-1
else
echo "network: $TEST_NETWORK OK"
fi
# Create instance using the image, flavor and network verified before
TEST_NETWORK_ID="$(openstack network list --name=$TEST_NETWORK -c ID -f value)"
echo "Launch instance ..."
openstack server create \
--image $TEST_IMAGE \
--flavor $TEST_FLAVOR \
--nic net-id=$TEST_NETWORK_ID \
--config-drive true \
--key-name $TEST_KEY_NAME \
$INSTANCE_NAME
if [ $? -ne 0 ]; then
echo "error: $INSTANCE_NAME no created"
exit 1;
fi
for (( count=0; i<${TIMEOUT}; count++ )); do
INSTANCE_STATUS="$(openstack server list \
--name=$INSTANCE_NAME -c Status -f value)"
if [ "$INSTANCE_STATUS" == "ACTIVE" ]; then
echo "new instance status: $INSTANCE_STATUS"
break;
fi
echo "wait for active instance, current status: $INSTANCE_STATUS"
done
if [ "$(( $TIMEOUT - 1 ))" -eq "$count" ]; then
echo "error: someting was wrong timeout expired!"
exit 1
fi
COMPUTE="$(openstack server show \
-c OS-EXT-SRV-ATTR:host -f value $INSTANCE_NAME)"
echo "The instance $INSTANCE_NAME was created successfully in $COMPUTE"
exit 0

View File

@ -0,0 +1,35 @@
#!/bin/bash
INSTANCE_NAME="$1"
if [ -z "$INSTANCE_NAME" ]; then
echo "error: instance no specified."
exit 1;
fi
if [ -z "$(openstack server list --name $INSTANCE_NAME -c ID -f value)" ]; then
echo "error: $INSTANCE_NAME no found"
exit 1
else
echo "$INSTANCE_NAME: OK"
fi
COMPUTE="$(openstack server show \
-c OS-EXT-SRV-ATTR:host -f value $INSTANCE_NAME)"
echo "kill QEMU process..."
INIT_TIME=$(echo $(($(date +%s%N)/1000000)))
ssh $COMPUTE sudo pkill qemu
while [ 1 ]; do
INSTANCE_STATUS="$(openstack server list \
--name=$INSTANCE_NAME -c Status -f value)"
if [ "$INSTANCE_STATUS" != "ACTIVE" ]; then
END_TIME=$(echo $(($(date +%s%N)/1000000)))
break;
fi
done
echo "instance status: $INSTANCE_STATUS"
echo "init time (ms): $INIT_TIME"
echo "end time (ms): $END_TIME"
echo "delta: INIT_TIME=$(echo $(($END_TIME - $INIT_TIME)))"