From 95763c3d44f34106492cdd3c0334a72ff259b0b4 Mon Sep 17 00:00:00 2001 From: Pete Birley Date: Thu, 26 Apr 2018 16:43:06 -0500 Subject: [PATCH] Gate: add basic cinder tests to gate This PS adds basic tests for cinder to the OSH gates. Change-Id: Idfd2a738fe4ac69eda0ebc85a10d2e408127c0de --- .../deployment/developer/common/900-use-it.sh | 27 +++++++++++++++++++ .../gate/files/heat-basic-vm-deployment.yaml | 6 +++++ tools/gate/files/heat-vm-volume-attach.yaml | 20 ++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 tools/gate/files/heat-vm-volume-attach.yaml diff --git a/tools/deployment/developer/common/900-use-it.sh b/tools/deployment/developer/common/900-use-it.sh index 409aec0a44..1ca518a0a0 100755 --- a/tools/deployment/developer/common/900-use-it.sh +++ b/tools/deployment/developer/common/900-use-it.sh @@ -96,3 +96,30 @@ ssh -i ${HOME}/.ssh/osh_key cirros@${FLOATING_IP} ping -q -c 1 -W 2 ${OSH_BR_EX_ # Check the VM can reach the metadata server ssh -i ${HOME}/.ssh/osh_key cirros@${FLOATING_IP} curl --verbose --connect-timeout 5 169.254.169.254 + +# Check to see if cinder has been deployed, if it has then perform a volume attach. +if helm ls --short | grep -q "^cinder$"; then + INSTANCE_ID=$(openstack stack output show \ + heat-basic-vm-deployment \ + instance_uuid \ + -f value -c output_value) + + # Get the the devices that are present on the instance + DEVS_PRE_ATTACH=$(mktemp) + ssh -i ${HOME}/.ssh/osh_key cirros@${FLOATING_IP} lsblk > ${DEVS_PRE_ATTACH} + + # Create and attach a block device to the instance + openstack stack create --wait \ + --parameter instance_uuid=${INSTANCE_ID} \ + -t ./tools/gate/files/heat-vm-volume-attach.yaml \ + heat-vm-volume-attach + + # Get the the devices that are present on the instance + DEVS_POST_ATTACH=$(mktemp) + ssh -i ${HOME}/.ssh/osh_key cirros@${FLOATING_IP} lsblk > ${DEVS_POST_ATTACH} + + # Check that we have the expected number of extra devices on the instance post attach + if ! [ "$(comm -13 ${DEVS_PRE_ATTACH} ${DEVS_POST_ATTACH} | wc -l)" -eq "1" ]; then + exit 1 + fi +fi diff --git a/tools/gate/files/heat-basic-vm-deployment.yaml b/tools/gate/files/heat-basic-vm-deployment.yaml index 21b70a8079..1c5d05ab5b 100644 --- a/tools/gate/files/heat-basic-vm-deployment.yaml +++ b/tools/gate/files/heat-basic-vm-deployment.yaml @@ -106,3 +106,9 @@ outputs: get_attr: - server_floating_ip - floating_ip_address + instance_uuid: + value: + get_attr: + - server + - show + - id diff --git a/tools/gate/files/heat-vm-volume-attach.yaml b/tools/gate/files/heat-vm-volume-attach.yaml new file mode 100644 index 0000000000..1cad39ce0a --- /dev/null +++ b/tools/gate/files/heat-vm-volume-attach.yaml @@ -0,0 +1,20 @@ +heat_template_version: 2016-10-14 + +parameters: + instance_uuid: + type: string + +resources: + cinder_volume: + type: OS::Cinder::Volume + properties: + name: vol1 + size: 1 + + cinder_volume_attach: + type: OS::Cinder::VolumeAttachment + properties: + instance_uuid: + get_param: instance_uuid + volume_id: + get_resource: cinder_volume