Skip to content

Commit a2ec1f3

Browse files
authored
marvin,test: fix directdownload template checksum test (#8096)
* marvin,test: fix directdownload template checksum test During failure while deploying a VM with wrong checksum template, VM may be left in Error state. This PR adds code to delete such VM. Signed-off-by: Abhishek Kumar <[email protected]> * remove unnecessary logs --------- Signed-off-by: Abhishek Kumar <[email protected]>
1 parent f62b634 commit a2ec1f3

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

test/integration/smoke/test_templates.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,8 @@ def test_09_list_templates_download_details(self):
989989
)
990990

991991
for template in list_template_response:
992+
if template.directdownload == True:
993+
continue
992994
self.assertNotEqual(
993995
len(template.downloaddetails),
994996
0,
@@ -1248,11 +1250,7 @@ def setUpClass(cls):
12481250

12491251
@classmethod
12501252
def tearDownClass(cls):
1251-
try:
1252-
cleanup_resources(cls.apiclient, cls._cleanup)
1253-
except Exception as e:
1254-
raise Exception("Warning: Exception during cleanup : %s" % e)
1255-
return
1253+
super(TestCreateTemplateWithDirectDownload, cls).tearDownClass()
12561254

12571255
def setUp(self):
12581256
self.apiclient = self.testClient.getApiClient()
@@ -1264,13 +1262,7 @@ def setUp(self):
12641262
return
12651263

12661264
def tearDown(self):
1267-
try:
1268-
#Clean up, terminate the created templates
1269-
cleanup_resources(self.apiclient, self.cleanup)
1270-
1271-
except Exception as e:
1272-
raise Exception("Warning: Exception during cleanup : %s" % e)
1273-
return
1265+
super(TestCreateTemplateWithDirectDownload, self).tearDown()
12741266

12751267
@attr(tags=["advanced", "smoke"], required_hardware="true")
12761268
def test_01_register_template_direct_download_flag(self):
@@ -1323,10 +1315,11 @@ def test_03_deploy_vm_wrong_checksum(self):
13231315
"""
13241316
Deploy a VM from a Direct Download registered template with wrong checksum
13251317
"""
1326-
self.template["checksum"]="{MD5}XXXXXXX"
1318+
self.template["checksum"]="{MD5}" + ("X" * 32)
13271319
tmpl = Template.register(self.apiclient, self.template, zoneid=self.zone.id, hypervisor=self.hypervisor, randomize_name=False)
13281320
self.cleanup.append(tmpl)
13291321

1322+
failed = False
13301323
try:
13311324
virtual_machine = VirtualMachine.create(
13321325
self.apiclient,
@@ -1337,8 +1330,19 @@ def test_03_deploy_vm_wrong_checksum(self):
13371330
serviceofferingid=self.service_offering.id
13381331
)
13391332
self.cleanup.append(virtual_machine)
1340-
self.fail("Expected to fail deployment")
1333+
failed = True
13411334
except Exception as e:
13421335
self.debug("Expected exception")
1336+
list_virtual_machine_response = VirtualMachine.list(
1337+
self.apiclient,
1338+
templateid=tmpl.id,
1339+
listall=True
1340+
)
1341+
if type(list_virtual_machine_response) == list and len(list_virtual_machine_response) > 0:
1342+
for virtual_machine_response in list_virtual_machine_response:
1343+
VirtualMachine.delete(virtual_machine_response, self.apiclient, expunge=True)
1344+
1345+
if failed == True:
1346+
self.fail("Expected to fail VM deployment with wrong checksum template")
13431347

13441348
return

tools/marvin/marvin/lib/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,8 @@ def register(cls, apiclient, services, zoneid=None,
15181518

15191519
if "directdownload" in services:
15201520
cmd.directdownload = services["directdownload"]
1521+
if "checksum" in services:
1522+
cmd.checksum = services["checksum"]
15211523

15221524
# Register Template
15231525
template = apiclient.registerTemplate(cmd)

0 commit comments

Comments
 (0)