mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-4757. Marvin test to verify support for OVA containing multiple disk
This commit is contained in:
parent
a6fd25ac3f
commit
3532ffe5af
|
|
@ -0,0 +1,306 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
""" P1 tests for OVA templates with multiple disks
|
||||
"""
|
||||
import marvin
|
||||
from nose.plugins.attrib import attr
|
||||
from marvin.cloudstackTestCase import *
|
||||
from marvin.cloudstackAPI import *
|
||||
from marvin.integration.lib.utils import *
|
||||
from marvin.integration.lib.base import *
|
||||
from marvin.integration.lib.common import *
|
||||
import urllib
|
||||
from random import random
|
||||
import time
|
||||
|
||||
|
||||
class Services:
|
||||
"""Test OVA template with mutiple disks
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.services = {
|
||||
"account": {
|
||||
"email": "test@test.com",
|
||||
"firstname": "Test",
|
||||
"lastname": "User",
|
||||
"username": "test",
|
||||
"password": "password",
|
||||
},
|
||||
"service_offering": {
|
||||
"name": "Tiny Instance",
|
||||
"displaytext": "Tiny Instance",
|
||||
"cpunumber": 1,
|
||||
"cpuspeed": 100, # in MHz
|
||||
"memory": 128, # In MBs
|
||||
},
|
||||
"disk_offering": {
|
||||
"displaytext": "Small",
|
||||
"name": "Small",
|
||||
"disksize": 1
|
||||
},
|
||||
"virtual_machine": {
|
||||
"displayname": "testVM",
|
||||
"hypervisor": 'VMware',
|
||||
"protocol": 'TCP',
|
||||
"ssh_port": 22,
|
||||
"username": "root",
|
||||
"password": "password",
|
||||
"privateport": 22,
|
||||
"publicport": 22,
|
||||
},
|
||||
"templates": {
|
||||
0: {
|
||||
"displaytext": "Template with multiple disks",
|
||||
"name": "Template with multiple disks",
|
||||
"ostype": 'CentOS 5.3 (64-bit)',
|
||||
"url": "http://10.147.28.7/templates/multipledisk.ova",
|
||||
"hypervisor": 'VMware',
|
||||
"format": 'OVA',
|
||||
"isfeatured": True,
|
||||
"ispublic": True,
|
||||
"isextractable": False,
|
||||
},
|
||||
},
|
||||
"sleep": 60,
|
||||
"timeout": 10,
|
||||
}
|
||||
|
||||
|
||||
class TestOVATemplateWithMupltipleDisks(cloudstackTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
self.cleanup = []
|
||||
return
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
# Clean up, terminate the created templates
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.services = Services().services
|
||||
cls.api_client = super(TestOVATemplateWithMupltipleDisks, cls).getClsTestClient().getApiClient()
|
||||
cls.api_client.hypervisor = 'VMware'
|
||||
|
||||
# Get Zone, Domain and templates
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
cls.domain = get_domain(cls.api_client, cls.services)
|
||||
cls.services['mode'] = cls.zone.networktype
|
||||
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
|
||||
|
||||
cls.service_offering = ServiceOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["service_offering"]
|
||||
)
|
||||
cls.disk_offering = DiskOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["disk_offering"]
|
||||
)
|
||||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"],
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
cls.services["account"] = cls.account.name
|
||||
|
||||
cls._cleanup = [
|
||||
cls.account,
|
||||
cls.service_offering,
|
||||
cls.disk_offering,
|
||||
]
|
||||
return
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
try:
|
||||
cls.api_client = super(TestOVATemplateWithMupltipleDisks, cls).getClsTestClient().getApiClient()
|
||||
# Cleanup resources used
|
||||
cleanup_resources(cls.api_client, cls._cleanup)
|
||||
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
|
||||
return
|
||||
|
||||
@attr(tags = ["vmware"])
|
||||
def test_01_template_with_multiple_disks(self):
|
||||
"""Test template with 1 data disks
|
||||
"""
|
||||
# Validate the following:
|
||||
# 1. Register a template in OVA format that contains 1 data disks
|
||||
# 2. Verify template is in READY state
|
||||
# 3. Veriy 1 additonal Datadisk Template got created
|
||||
# 3. Deploy a VM from the registered template and 1 datadisk template
|
||||
# 4. Verify VM is in Running state
|
||||
# 5. Verify an additional data disk attached to the VM
|
||||
|
||||
# Register new template
|
||||
template = Template.register(
|
||||
self.apiclient,
|
||||
self.services["templates"][0],
|
||||
zoneid=self.zone.id,
|
||||
account=self.account.name,
|
||||
domainid=self.account.domainid
|
||||
)
|
||||
self.debug(
|
||||
"Registered a template of format: %s with ID: %s" % (
|
||||
self.services["templates"][0]["format"],
|
||||
template.id
|
||||
))
|
||||
# Wait for template to download
|
||||
template.download(self.apiclient)
|
||||
self.cleanup.append(template)
|
||||
|
||||
# Wait for template status to be changed across
|
||||
time.sleep(self.services["sleep"])
|
||||
timeout = self.services["timeout"]
|
||||
while True:
|
||||
list_template_response = list_templates(
|
||||
self.apiclient,
|
||||
templatefilter='all',
|
||||
id=template.id,
|
||||
zoneid=self.zone.id,
|
||||
account=self.account.name,
|
||||
domainid=self.account.domainid
|
||||
)
|
||||
if isinstance(list_template_response, list):
|
||||
break
|
||||
elif timeout == 0:
|
||||
raise Exception("List template failed!")
|
||||
|
||||
time.sleep(5)
|
||||
timeout = timeout - 1
|
||||
# Verify template response to check if template was successfully added
|
||||
self.assertEqual(
|
||||
isinstance(list_template_response, list),
|
||||
True,
|
||||
"Check for list template response return valid data"
|
||||
)
|
||||
|
||||
self.assertNotEqual(
|
||||
len(list_template_response),
|
||||
0,
|
||||
"Check template available in List Templates"
|
||||
)
|
||||
|
||||
template_response = list_template_response[0]
|
||||
self.assertEqual(
|
||||
template_response.isready,
|
||||
True,
|
||||
"Template state is not ready, it is %s" % template_response.isready
|
||||
)
|
||||
|
||||
time.sleep(120)
|
||||
# Veriy 1 additonal Datadisk Templates got created
|
||||
list_datadisk_template_response = list_templates(
|
||||
self.apiclient,
|
||||
templatefilter='all',
|
||||
parenttemplateid=template.id,
|
||||
zoneid=self.zone.id,
|
||||
account=self.account.name,
|
||||
domainid=self.account.domainid
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
isinstance(list_datadisk_template_response, list),
|
||||
True,
|
||||
"Check for datadisk list template response return valid data"
|
||||
)
|
||||
|
||||
self.assertNotEqual(
|
||||
len(list_datadisk_template_response),
|
||||
0,
|
||||
"Check datadisk template available in List Templates"
|
||||
)
|
||||
|
||||
datadisk_template_response = list_datadisk_template_response[0]
|
||||
self.assertEqual(
|
||||
datadisk_template_response.isready,
|
||||
True,
|
||||
"Datadisk template state is not ready, it is %s" % datadisk_template_response.isready
|
||||
)
|
||||
|
||||
# Deploy new virtual machine using template
|
||||
virtual_machine = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
templateid=template.id,
|
||||
accountid=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
mode=self.services["mode"],
|
||||
datadisktemplateid=datadisk_template_response.id,
|
||||
datadiskofferingid=self.disk_offering.id
|
||||
)
|
||||
self.debug("Creating an instance with template ID: %s" % template.id)
|
||||
vm_response = list_virtual_machines(
|
||||
self.apiclient,
|
||||
id=virtual_machine.id,
|
||||
account=self.account.name,
|
||||
domainid=self.account.domainid
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vm_response, list),
|
||||
True,
|
||||
"Check for list VMs response after VM deployment"
|
||||
)
|
||||
# Verify VM response to check if VM deployment was successful
|
||||
self.assertNotEqual(
|
||||
len(vm_response),
|
||||
0,
|
||||
"Check VMs available in List VMs response"
|
||||
)
|
||||
vm = vm_response[0]
|
||||
self.assertEqual(
|
||||
vm.state,
|
||||
'Running',
|
||||
"Check the state of VM created from Template"
|
||||
)
|
||||
|
||||
# Check 1 DATA volume is attached to the VM
|
||||
list_volume_response = list_volumes(
|
||||
self.apiclient,
|
||||
virtualmachineid=vm.id,
|
||||
type='DATADISK',
|
||||
listall=True
|
||||
)
|
||||
self.assertNotEqual(
|
||||
list_volume_response,
|
||||
None,
|
||||
"Check if additinal data volume is attached to VM %s "
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(list_volume_response, list),
|
||||
True,
|
||||
"Check list volumes response for valid list"
|
||||
)
|
||||
self.assertEqual(
|
||||
len(list_volume_response),
|
||||
1,
|
||||
"Additional DATA volume attached to the VM %s. Expected %s" % (len(list_volume_response), 1)
|
||||
)
|
||||
|
||||
return
|
||||
|
|
@ -329,6 +329,7 @@ class VirtualMachine:
|
|||
diskofferingid=None, affinitygroupnames=None, affinitygroupids=None, group=None,
|
||||
hostid=None, keypair=None, ipaddress=None, mode='default', method='GET',hypervisor=None,
|
||||
customcpunumber=None, customcpuspeed=None, custommemory=None, rootdisksize=None):
|
||||
datadisktemplateid=None, datadiskofferingid=None):
|
||||
"""Create the instance"""
|
||||
|
||||
cmd = deployVirtualMachine.deployVirtualMachineCmd()
|
||||
|
|
@ -433,6 +434,13 @@ class VirtualMachine:
|
|||
if group:
|
||||
cmd.group = group
|
||||
|
||||
if datadisktemplateid is not None and datadiskofferingid is not None:
|
||||
cmd.datadisktemplatetodiskofferinglist = []
|
||||
cmd.datadisktemplatetodiskofferinglist.append({
|
||||
'datadisktemplateid': datadisktemplateid,
|
||||
'diskofferingid': datadiskofferingid
|
||||
})
|
||||
|
||||
#program default access to ssh
|
||||
if mode.lower() == 'basic':
|
||||
cls.ssh_access_group(apiclient, cmd)
|
||||
|
|
|
|||
Loading…
Reference in New Issue