Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vdi-streaming: add lvm streaming support #168

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 67 additions & 27 deletions test_vgpu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ TEMPEST_DIR=$DEST/tempest
NOVA_CONF=/etc/nova/nova.conf
IMAGE_NAME=${IMAGE_NAME:-"cirros-0.3.5-x86_64-disk"}
VM_NAME=${VM_NAME:-"testVM"}
SNAPSHOT_NAME=${SNAPSHOT_NAME:-"testSnapshot"}
SNAPSHOT_VM_NAME=${SNAPSHOT_VM_NAME:-"testSnapshot_VM"}
JOURNAL_DIR=/var/log/journal
VGPU_TEST_LOG_DIR=${VGPU_TEST_LOG_DIR:-"/opt/stack/workspace/test_vgpu/logs"}
OPENSTACK_LOGS=${OPENSTACK_LOGS:-"/opt/stack/workspace/test_vgpu/logs"}
TMP_LOG_DIR=/tmp/openstack


SLEEP_TIME_GAP=3
SLEEP_MAX_TRIES=40

Expand All @@ -56,17 +57,42 @@ on_exit()
do
sudo journalctl --unit $service > $TMP_LOG_DIR/$service".log";
done
cp $TMP_LOG_DIR/* $VGPU_TEST_LOG_DIR/
cp $TMP_LOG_DIR/* $OPENSTACK_LOGS/
echo "###################Clean environment if requested#####################"
if [ $keep_env != "true" ]; then
pushd $DEVSTACK_PATH/
nova delete $VM_NAME
nova delete $VM_NAME $SNAPSHOT_VM_NAME
openstack image delete $SNAPSHOT_NAME
./clean.sh
popd
rm $DEVSTACK_PATH -rf

fi
set +x
}

waiting_vm_active ()
{
count=0
vm_name=$1
while :
do
echo "Waitting to VM active"
sleep $SLEEP_TIME_GAP
count=$((count + 1))
vm_state=$(nova show $vm_name | grep -w 'status' | awk '{print $4}')
if [ $vm_state = "ERROR" ]; then
error_log=$error_log"\n\tVM create failed"
exit 1
elif [ $vm_state = "ACTIVE" ]; then
break
elif [ $count -gt $SLEEP_MAX_TRIES ]; then
error_log=$error_log"\n\tVM can not reach active status"
exit 1
fi
done
}

trap on_exit EXIT

error_log="VGPU test failed with the following errors: "
Expand All @@ -77,6 +103,13 @@ _SSH_OPTIONS="\
-o UserKnownHostsFile=/dev/null \
-i /opt/stack/.ssh/id_rsa"

pushd $ROOT_DIR
rm $DEVSTACK_PATH -rf
git clone https://github.com/openstack-dev/devstack.git
popd

cp $ROOT_DIR/local.conf $DEVSTACK_PATH

DOM0_IP=$(grep XENAPI_CONNECTION_URL ${DEVSTACK_PATH}/local.conf | cut -d'=' -f2 | sed 's/[^0-9,.]*//g')

echo "Dom0 IP is: $DOM0_IP"
Expand Down Expand Up @@ -107,16 +140,21 @@ echo "###################Update openstack repositories#####################"
PROJECT_LIST=$(echo $ZUUL_CHANGES | tr '^' '\n' | cut -d: -f1 | cut -d/ -f2 | sort | uniq)

pushd ${DEST}

# remove requirements folder because it contains run time modifications
rm requirements -rf

for dir in ${DEST}/*
do
if [ -d "${dir}" ] ; then
echo "check ${dir}"
pushd ${dir}
if [ -d .git ]; then
echo "update repository ${dir}"
git checkout master
if ! git diff-index --quiet HEAD --; then
git checkout *
cur_branch=$(git branch | grep \* | cut -d ' ' -f2)
if [ $cur_branch != 'master' ]; then
git checkout master
git branch -D $cur_branch
fi
git pull --ff origin master

Expand Down Expand Up @@ -155,14 +193,20 @@ done
END_OF_REQ_VGPU_TYPE
)

echo "###################Devstack start stack#####################"
pushd $DEVSTACK_PATH/
if ! grep "enabled_vgpu_types=" ${DEVSTACK_PATH}/local.conf; then
echo "[devices]" >> ${DEVSTACK_PATH}/local.conf
echo "enabled_vgpu_types = $first_vgpu_type" >> ${DEVSTACK_PATH}/local.conf
fi
echo "###################Set image handler to remote stream#####################"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're doing this here, why do we also need the line at 109?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, forgot to remove it. It doesn't work when I modify local.conf.

if ! grep "image_handler = vdi_remote_stream" ${DEVSTACK_PATH}/local.conf; then
echo "[xenserver]" >> ${DEVSTACK_PATH}/local.conf
echo "image_handler = vdi_remote_stream" >> ${DEVSTACK_PATH}/local.conf
fi

sudo find $JOURNAL_DIR -name "*.journal" -exec rm {} \;
sudo systemctl restart systemd-journald
echo "###################Devstack start stack#####################"
./stack.sh
popd

Expand All @@ -182,23 +226,7 @@ prv_net=$(openstack network list | grep "private" | awk '{print $2}')
nova boot --image $IMAGE_NAME --flavor 1 --nic net-id=$prv_net $VM_NAME

nova_vm_id=$(nova show $VM_NAME | grep -w 'id' | awk '{print $4}')
count=0
while :
do
echo "Waitting to VM active"
sleep $SLEEP_TIME_GAP
count=$((count + 1))
vm_state=$(nova show $VM_NAME | grep -w 'status' | awk '{print $4}')
if [ $vm_state = "ERROR" ]; then
error_log=$error_log"\n\tVM create failed"
break
elif [ $vm_state = "ACTIVE" ]; then
break
elif [ $count -gt $SLEEP_MAX_TRIES ]; then
error_log=$error_log"\n\tVM can not reach active status"
break
fi
done
waiting_vm_active $VM_NAME

echo "###################Check VGPU create status#####################"
if [ $vm_state = "ACTIVE" ]; then
Expand All @@ -215,10 +243,22 @@ END_OF_VGPU_CONFIRM
fi

if [ -n "$result" ]; then
echo "VGPU create success"
echo $VGPU_CREATE_SUCCESS_FLAG
echo "###################Check LVM image upload status#####################"
nova image-create --poll $VM_NAME $SNAPSHOT_NAME
Copy link
Member

@BobBall BobBall Jun 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also retrieve the image please? Since the upload/download are creating VHDs on the fly, we need to check that the uploaded VHD is still valid. Best way is to create an new server from the image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add another VM create based on the new image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if ! openstack image show $SNAPSHOT_NAME; then
error_log=$error_log"\n\tImage create failed!"
echo $error_log
exit 1
fi
nova boot --image $SNAPSHOT_NAME --flavor 1 --nic net-id=$prv_net $SNAPSHOT_VM_NAME
waiting_vm_active $SNAPSHOT_VM_NAME
else
error_log=$error_log"\n\tVGPU create failed"
error_log=$error_log"\n\tVGPU create failed!"
echo $error_log
exit 1
fi



set +ex