Skip to content

Commit b558176

Browse files
committed
sync smoke-test changes from master
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent a78647e commit b558176

2 files changed

Lines changed: 36 additions & 44 deletions

File tree

test/integration/smoke/test_deploy_virtio_scsi_vm.py

Lines changed: 35 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,30 @@
2525
# base - contains all resources as entities and defines create, delete,
2626
# list operations on them
2727
from marvin.lib.base import (Account,
28-
VirtualMachine,
29-
ServiceOffering,
30-
NetworkOffering,
31-
Network,
32-
Template,
33-
DiskOffering,
34-
StoragePool,
35-
Volume,
36-
Host,
37-
GuestOs)
38-
39-
28+
VirtualMachine,
29+
ServiceOffering,
30+
Template,
31+
DiskOffering,
32+
Volume,
33+
Host,
34+
GuestOs)
4035

4136
# utils - utility classes for common cleanup, external library wrappers etc
4237
from marvin.lib.utils import cleanup_resources, get_hypervisor_type, validateList
4338

4439
# common - commonly used methods for all tests are listed here
45-
from marvin.lib.common import get_zone, get_domain, get_template, list_hosts, get_pod
40+
from marvin.lib.common import get_zone, get_domain, get_pod
4641

4742
from marvin.sshClient import SshClient
4843

49-
from marvin.codes import FAILED, PASS
44+
from marvin.codes import FAILED
5045

5146
from nose.plugins.attrib import attr
5247

5348
import xml.etree.ElementTree as ET
54-
import code
5549
import logging
5650

51+
5752
class Templates:
5853
"""Test data for templates
5954
"""
@@ -75,11 +70,12 @@ def __init__(self):
7570
}
7671
}
7772

78-
class TestDeployVirtioSCSIVM(cloudstackTestCase):
7973

74+
class TestDeployVirtioSCSIVM(cloudstackTestCase):
8075
"""
8176
Test deploy a kvm virtio scsi template
8277
"""
78+
8379
@classmethod
8480
def setUpClass(cls):
8581
cls.logger = logging.getLogger('TestDeployVirtioSCSIVM')
@@ -100,7 +96,6 @@ def setUpClass(cls):
10096
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
10197
cls.pod = get_pod(cls.apiclient, cls.zone.id)
10298
cls.services['mode'] = cls.zone.networktype
103-
cls._cleanup = []
10499
if cls.hypervisor.lower() not in ['kvm']:
105100
cls.hypervisorNotSupported = True
106101
return
@@ -153,41 +148,38 @@ def setUpClass(cls):
153148

154149
cls.vmhost = hosts[0]
155150

156-
151+
# Stop VM to reset password
152+
cls.virtual_machine.stop(cls.apiclient)
157153

158154
password = cls.virtual_machine.resetPassword(cls.apiclient)
159155
cls.virtual_machine.username = "ubuntu"
160156
cls.virtual_machine.password = password
161-
cls._cleanup = [
157+
158+
# Start VM after password reset
159+
cls.virtual_machine.start(cls.apiclient)
160+
161+
cls.cleanup = [
162162
cls.template,
163163
cls.service_offering,
164164
cls.sparse_disk_offering,
165165
cls.account
166166
]
167167

168-
169168
@classmethod
170169
def tearDownClass(cls):
171170
try:
171+
cls.apiclient = super(
172+
TestDeployVirtioSCSIVM,
173+
cls
174+
).getClsTestClient().getApiClient()
172175
# Cleanup resources used
173-
cleanup_resources(cls.apiclient, cls._cleanup)
176+
cleanup_resources(cls.apiclient, cls.cleanup)
174177
except Exception as e:
175178
raise Exception("Warning: Exception during cleanup : %s" % e)
176-
return
177179

178180
def setUp(self):
179181
self.apiclient = self.testClient.getApiClient()
180182
self.dbclient = self.testClient.getDbConnection()
181-
self.cleanup = []
182-
return
183-
184-
def tearDown(self):
185-
try:
186-
# Clean up, terminate the created instance, volumes and snapshots
187-
cleanup_resources(self.apiclient, self.cleanup)
188-
except Exception as e:
189-
raise Exception("Warning: Exception during cleanup : %s" % e)
190-
return
191183

192184
def verifyVirshState(self, diskcount):
193185
host = self.vmhost.ipaddress
@@ -212,14 +204,14 @@ def verifyVirshState(self, diskcount):
212204
for child in disk:
213205
if child.tag.lower() == "target":
214206
dev = child.get("dev")
215-
self.assert_(dev != None and dev.startswith("sd"), "disk dev is invalid")
207+
self.assert_(dev is not None and dev.startswith("sd"), "disk dev is invalid")
216208
elif child.tag.lower() == "address":
217209
con = child.get("controller")
218210
self.assertEqual(con, scsiindex, "disk controller not equal to SCSI " \
219-
"controller index")
211+
"controller index")
220212
elif child.tag.lower() == "driver":
221213
discard = child.get("discard")
222-
if discard: # may not be defined by older qemu/libvirt
214+
if discard: # may not be defined by older qemu/libvirt
223215
self.assertEqual(discard, "unmap", "discard settings not unmap")
224216

225217
def verifyGuestState(self, diskcount):
@@ -234,21 +226,21 @@ def verifyGuestState(self, diskcount):
234226
"Could not find appropriate number of scsi disks in guest")
235227

236228
def getVirshXML(self, host, instancename):
237-
if host == None:
229+
if host is None:
238230
self.logger.debug("getVirshXML: host is none")
239231
return ""
240232
else:
241233
self.logger.debug("host is: " + host)
242-
if instancename == None:
234+
if instancename is None:
243235
self.logger.debug("getVirshXML: instancename is none")
244236
return ""
245237
else:
246238
self.logger.debug("instancename is: " + instancename)
247239
sshc = SshClient(
248-
host=host,
249-
port=self.services['configurableData']['host']["publicport"],
250-
user=self.hostConfig['username'],
251-
passwd=self.hostConfig['password'])
240+
host=host,
241+
port=self.services['configurableData']['host']["publicport"],
242+
user=self.hostConfig['username'],
243+
passwd=self.hostConfig['password'])
252244

253245
ssh = sshc.ssh
254246

@@ -354,9 +346,8 @@ def test_05_change_vm_ostype_restart(self):
354346
self.assertIsNotNone(ostypeid,
355347
"Could not find ostypeid for Ubuntu 16.0.4 (64-bit) mapped to kvm")
356348

357-
358349
self.virtual_machine.update(self.apiclient, ostypeid=ostypeid,
359-
details=[{"rootDiskController":"scsi"}])
350+
details=[{"rootDiskController": "scsi"}])
360351

361352
self.virtual_machine.start(self.apiclient)
362353

@@ -371,6 +362,7 @@ def test_06_verify_guest_lspci_again(self):
371362

372363
self.verifyGuestState(3)
373364

365+
374366
class CommandNonzeroException(Exception):
375367
def __init__(self, code, stderr):
376368
self.code = code

test/integration/smoke/test_vm_life_cycle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ def secure_all_hosts(self):
918918
cmd = provisionCertificate.provisionCertificateCmd()
919919
cmd.hostid = host.id
920920
cmd.reconnect = True
921-
self.apiclient.updateConfiguration(cmd)
921+
self.apiclient.provisionCertificate(cmd)
922922

923923
for host in self.hosts:
924924
self.check_connection(secured='true', host=host)

0 commit comments

Comments
 (0)