Skip to content

Commit dc3c43e

Browse files
author
Gaurav Aradhye
committed
CLOUDSTACK-8394: Skipping snapshots test cases for HyperV and LXC
Signed-off-by: Gaurav Aradhye <gaurav.aradhye@clogeny.com> This closes #212
1 parent 1d99a38 commit dc3c43e

File tree

2 files changed

+53
-27
lines changed

2 files changed

+53
-27
lines changed

test/integration/component/test_snapshots.py

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"""
1919
# Import Local Modules
2020
from nose.plugins.attrib import attr
21-
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
21+
from marvin.cloudstackTestCase import cloudstackTestCase
2222

2323
from marvin.lib.base import (Snapshot,
2424
Template,
@@ -167,9 +167,12 @@ def setUpClass(cls):
167167
cls.domain = get_domain(cls.api_client)
168168
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
169169
cls.services['mode'] = cls.zone.networktype
170-
cls.hypervisor = cls.testClient.getHypervisorInfo()
171-
if cls.hypervisor.lower() in ['lxc']:
172-
raise unittest.SkipTest("snapshots are not supported on %s" % cls.hypervisor.lower())
170+
cls._cleanup = []
171+
cls.unsupportedHypervisor = False
172+
cls.hypervisor = get_hypervisor_type(cls.api_client)
173+
if cls.hypervisor.lower() in ['hyperv', 'lxc']:
174+
cls.unsupportedHypervisor = True
175+
return
173176
cls.disk_offering = DiskOffering.create(
174177
cls.api_client,
175178
cls.services["disk_offering"]
@@ -196,9 +199,6 @@ def setUpClass(cls):
196199
cls.services["service_offering"]
197200
)
198201

199-
# Get Hypervisor Type
200-
cls.hypervisor = (get_hypervisor_type(cls.api_client)).lower()
201-
202202
cls._cleanup = [
203203
cls.service_offering,
204204
cls.disk_offering
@@ -216,15 +216,21 @@ def tearDownClass(cls):
216216

217217
def setUp(self):
218218
self.apiclient = self.testClient.getApiClient()
219-
self.hypervisor = str(self.testClient.getHypervisorInfo()).lower()
220219
self.dbclient = self.testClient.getDbConnection()
220+
self.cleanup = []
221+
222+
if self.unsupportedHypervisor:
223+
self.skipTest("Skipping test because unsupported hypervisor: %s" %
224+
self.hypervisor)
225+
221226

222227
# Create VMs, NAT Rules etc
223228
self.account = Account.create(
224229
self.apiclient,
225230
self.services["account"],
226231
domainid=self.domain.id
227232
)
233+
self.cleanup.append(self.account)
228234

229235
self.virtual_machine = self.virtual_machine_with_disk = \
230236
VirtualMachine.create(
@@ -236,7 +242,6 @@ def setUp(self):
236242
serviceofferingid=self.service_offering.id,
237243
mode=self.services["mode"]
238244
)
239-
self.cleanup = [self.account, ]
240245
return
241246

242247
def tearDown(self):
@@ -966,15 +971,17 @@ def setUpClass(cls):
966971
TestCreateVMSnapshotTemplate,
967972
cls).getClsTestClient()
968973
cls.api_client = cls.testClient.getApiClient()
969-
cls.hypervisor = cls.testClient.getHypervisorInfo()
974+
cls._cleanup = []
970975
cls.services = Services().services
971976
# Get Zone, Domain and templates
972977
cls.domain = get_domain(cls.api_client)
973978
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
974979
cls.services['mode'] = cls.zone.networktype
975-
cls.hypervisor = cls.testClient.getHypervisorInfo()
976-
if cls.hypervisor.lower() in ['lxc']:
977-
raise unittest.SkipTest("snapshots are not supported on %s" % cls.hypervisor.lower())
980+
cls.unsupportedHypervisor = False
981+
cls.hypervisor = get_hypervisor_type(cls.api_client)
982+
if cls.hypervisor.lower() in ['hyperv', 'lxc']:
983+
cls.unsupportedHypervisor = True
984+
return
978985

979986
cls.template = get_template(
980987
cls.api_client,
@@ -1012,9 +1019,11 @@ def tearDownClass(cls):
10121019

10131020
def setUp(self):
10141021
self.apiclient = self.testClient.getApiClient()
1015-
self.hypervisor = str(self.testClient.getHypervisorInfo()).lower()
10161022
self.dbclient = self.testClient.getDbConnection()
10171023
self.cleanup = []
1024+
1025+
if self.unsupportedHypervisor:
1026+
self.skipTest("snapshots are not supported on %s" % self.hypervisor.lower())
10181027
return
10191028

10201029
def tearDown(self):
@@ -1183,15 +1192,17 @@ class TestSnapshotEvents(cloudstackTestCase):
11831192
def setUpClass(cls):
11841193
cls.testClient = super(TestSnapshotEvents, cls).getClsTestClient()
11851194
cls.api_client = cls.testClient.getApiClient()
1186-
cls.hypervisor = cls.testClient.getHypervisorInfo()
11871195
cls.services = Services().services
1196+
cls._cleanup = []
11881197
# Get Zone, Domain and templates
11891198
cls.domain = get_domain(cls.api_client)
11901199
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
11911200
cls.services['mode'] = cls.zone.networktype
1192-
cls.hypervisor = cls.testClient.getHypervisorInfo()
1193-
if cls.hypervisor.lower() in ['lxc']:
1194-
raise unittest.SkipTest("snapshots are not supported on %s" % cls.hypervisor.lower())
1201+
cls.unsupportedHypervisor = False
1202+
cls.hypervisor = get_hypervisor_type(cls.api_client)
1203+
if cls.hypervisor.lower() in ['hyperv', 'lxc']:
1204+
cls.unsupportedHypervisor = True
1205+
return
11951206

11961207
template = get_template(
11971208
cls.api_client,
@@ -1241,9 +1252,11 @@ def tearDownClass(cls):
12411252

12421253
def setUp(self):
12431254
self.apiclient = self.testClient.getApiClient()
1244-
self.hypervisor = str(self.testClient.getHypervisorInfo()).lower()
12451255
self.dbclient = self.testClient.getDbConnection()
12461256
self.cleanup = []
1257+
1258+
if self.unsupportedHypervisor:
1259+
self.skipTest("snapshots are not supported on %s" % self.hypervisor)
12471260
return
12481261

12491262
def tearDown(self):

test/integration/component/test_snapshots_improvement.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"""
2020
# Import Local Modules
2121
from nose.plugins.attrib import attr
22-
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
22+
from marvin.cloudstackTestCase import cloudstackTestCase
2323
from marvin.lib.utils import (random_gen,
2424
is_snapshot_on_nfs,
2525
cleanup_resources)
@@ -128,14 +128,17 @@ class TestSnapshotOnRootVolume(cloudstackTestCase):
128128
def setUpClass(cls):
129129
cls.testClient = super(TestSnapshotOnRootVolume, cls).getClsTestClient()
130130
cls.api_client = cls.testClient.getApiClient()
131+
cls._cleanup = []
131132

132133
cls.services = Services().services
133134
# Get Zone, Domain and templates
134135
cls.domain = get_domain(cls.api_client)
135136
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
137+
cls.unsupportedHypervisor = False
136138
cls.hypervisor = cls.testClient.getHypervisorInfo()
137-
if cls.hypervisor.lower() in ['lxc']:
138-
raise unittest.SkipTest("snapshots are not supported on %s" % cls.hypervisor.lower())
139+
if cls.hypervisor.lower() in ['hyperv', 'lxc']:
140+
cls.unsupportedHypervisor = True
141+
return
139142
cls.template = get_template(
140143
cls.api_client,
141144
cls.zone.id,
@@ -177,6 +180,10 @@ def setUp(self):
177180
self.apiclient = self.testClient.getApiClient()
178181
self.dbclient = self.testClient.getDbConnection()
179182
self.cleanup = []
183+
184+
if self.unsupportedHypervisor:
185+
self.skipTest("snapshots are not supported on %s" %
186+
self.hypervisor)
180187
return
181188

182189
def tearDown(self):
@@ -305,9 +312,12 @@ class TestCreateSnapshot(cloudstackTestCase):
305312
def setUpClass(cls):
306313
cls.testClient = super(TestCreateSnapshot, cls).getClsTestClient()
307314
cls.api_client = cls.testClient.getApiClient()
315+
cls._cleanup = []
316+
cls.unsupportedHypervisor = False
308317
cls.hypervisor = cls.testClient.getHypervisorInfo()
309318
if cls.hypervisor.lower() in ['hyperv', 'lxc']:
310-
raise unittest.SkipTest("Snapshots feature is not supported on %s" % cls.hypervisor.lower())
319+
cls.unsupportedHypervisor = True
320+
return
311321
cls.services = Services().services
312322
# Get Zone, Domain and templates
313323
cls.domain = get_domain(cls.api_client)
@@ -326,9 +336,7 @@ def setUpClass(cls):
326336
cls.api_client,
327337
cls.services["service_offering"]
328338
)
329-
cls._cleanup = [
330-
cls.service_offering,
331-
]
339+
cls._cleanup.append(cls.service_offering)
332340
return
333341

334342
@classmethod
@@ -343,17 +351,22 @@ def tearDownClass(cls):
343351
def setUp(self):
344352
self.apiclient = self.testClient.getApiClient()
345353
self.dbclient = self.testClient.getDbConnection()
354+
self.cleanup = []
355+
356+
if self.unsupportedHypervisor:
357+
self.skipTest("Snapshots are not supported on %s"
358+
% self.hypervisor)
346359

347360
self.account = Account.create(
348361
self.apiclient,
349362
self.services["account"],
350363
domainid=self.domain.id
351364
)
365+
self.cleanup.append(self.account)
352366

353367
self.apiclient = self.testClient.getUserApiClient(
354368
UserName=self.account.name,
355369
DomainName=self.account.domain)
356-
self.cleanup = [self.account, ]
357370
return
358371

359372
def tearDown(self):

0 commit comments

Comments
 (0)