Skip to content

Commit aa4aab8

Browse files
author
Priti Sarap
committed
CLOUDSTACK-8716: Verify creation of snapshot from volume when the task is performed repeatedly in zone wide primary Storage
CLOUDSTACK-8716: Verify creation of snapshot from volume when the task is performed repeatedly in zone wide primary Storage -Removing redundent code -Added validate list function for list snapshot operation CLOUDSTACK-8716: Verify creation of snapshot from volume when the task is performed repeatedly in zone wide primary Storage
1 parent 7b47c49 commit aa4aab8

2 files changed

Lines changed: 291 additions & 1 deletion

File tree

Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
""" Test case for Multiple Volume Snapshot in ZWPS
19+
"""
20+
from nose.plugins.attrib import attr
21+
from marvin.cloudstackTestCase import cloudstackTestCase
22+
from marvin.lib.utils import (cleanup_resources,
23+
validateList)
24+
from marvin.lib.base import (Account,
25+
ServiceOffering,
26+
DiskOffering,
27+
Snapshot,
28+
VirtualMachine,
29+
StoragePool
30+
)
31+
from marvin.lib.common import (get_domain,
32+
get_zone,
33+
list_volumes,
34+
list_clusters,
35+
get_template
36+
)
37+
38+
from marvin.codes import PASS, ZONETAG1, ROOT, DATA
39+
40+
41+
class TestMultipleVolumeSnapshots(cloudstackTestCase):
42+
43+
@classmethod
44+
def setUpClass(cls):
45+
testClient = super(TestMultipleVolumeSnapshots, cls).getClsTestClient()
46+
cls.apiclient = testClient.getApiClient()
47+
cls.testdata = testClient.getParsedTestDataConfig()
48+
49+
# Get Zone, Domain and templates
50+
cls.domain = get_domain(cls.apiclient)
51+
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
52+
cls.hypervisor = cls.testClient.getHypervisorInfo()
53+
cls.template = get_template(
54+
cls.apiclient,
55+
cls.zone.id,
56+
cls.testdata["ostype"])
57+
58+
cls._cleanup = []
59+
60+
cls.skiptest = False
61+
62+
clus_list = list_clusters(cls.apiclient)
63+
64+
if cls.hypervisor.lower() not in ['vmware'] or len(clus_list) < 2:
65+
cls.skiptest = True
66+
return
67+
68+
try:
69+
# Create an account
70+
cls.account = Account.create(
71+
cls.apiclient,
72+
cls.testdata["account"],
73+
domainid=cls.domain.id
74+
)
75+
76+
# Create user api client of the account
77+
cls.userapiclient = testClient.getUserApiClient(
78+
UserName=cls.account.name,
79+
DomainName=cls.account.domain
80+
)
81+
# Create Service offering
82+
cls.service_offering_zwps = ServiceOffering.create(
83+
cls.apiclient,
84+
cls.testdata["service_offering"],
85+
tags=ZONETAG1
86+
)
87+
88+
cls.disk_offering_zwps = DiskOffering.create(
89+
cls.apiclient,
90+
cls.testdata["disk_offering"],
91+
tags=ZONETAG1
92+
)
93+
94+
cls._cleanup = [
95+
cls.account,
96+
cls.service_offering_zwps,
97+
cls.disk_offering_zwps,
98+
]
99+
except Exception as e:
100+
cls.tearDownClass()
101+
raise e
102+
return
103+
104+
@classmethod
105+
def tearDownClass(cls):
106+
try:
107+
cleanup_resources(cls.apiclient, cls._cleanup)
108+
except Exception as e:
109+
raise Exception("Warning: Exception during cleanup : %s" % e)
110+
111+
def setUp(self):
112+
113+
self.cleanup = []
114+
if self.skiptest:
115+
self.skipTest("Skip test as setup is either not VMWare or \
116+
having less than 2 clusters %s" % self.hypervisor)
117+
118+
self.apiclient = self.testClient.getApiClient()
119+
self.dbclient = self.testClient.getDbConnection()
120+
self.pools = []
121+
122+
def tearDown(self):
123+
try:
124+
for storagePool in self.pools:
125+
StoragePool.update(self.apiclient, id=storagePool.id, tags="")
126+
127+
cleanup_resources(self.apiclient, self.cleanup)
128+
except Exception as e:
129+
raise Exception("Warning: Exception during cleanup : %s" % e)
130+
return
131+
132+
@attr(tags=["advanced", "basic"], required_hardware="true")
133+
def test_01_multiple_snapshot_in_zwps(self):
134+
""" Test multiple volume snapshot in zwps
135+
136+
# 1. Verify if setup has a ZWPS and 2 CWPS
137+
# 2. Deploy a VM with data disk in ZWPS
138+
# 1. Verify ROOT and DATA Disk of the VM is in ZWPS.
139+
# 2. Take a snapshot of VM.
140+
# 3. Create Multiple Snapshots till operation fails.
141+
"""
142+
try:
143+
self.pools = StoragePool.list(self.apiclient, zoneid=self.zone.id)
144+
status = validateList(self.pools)
145+
146+
self.assertEqual(
147+
status[0],
148+
PASS,
149+
"Check: Failed to list storage pools due to %s" %
150+
status[2])
151+
152+
zonepoolList = list(storagePool for storagePool in self.pools
153+
if storagePool.scope == "ZONE")
154+
155+
if len(zonepoolList) < 1:
156+
self.skipTest("There must be at least one zone wide\
157+
storage pools available in the setup")
158+
if len(list(storagePool for storagePool in self.pools
159+
if storagePool.scope == "CLUSTER")) < 2:
160+
self.skipTest("There must be at atleast two cluster wide\
161+
storage pools available in the setup")
162+
except Exception as e:
163+
self.skipTest(e)
164+
165+
# Adding tags to Storage Pools
166+
zone_no = 1
167+
StoragePool.update(
168+
self.apiclient,
169+
id=zonepoolList[0].id,
170+
tags=[ZONETAG1[:-1] + repr(zone_no)])
171+
172+
self.vm_zwps = VirtualMachine.create(
173+
self.apiclient,
174+
self.testdata["small"],
175+
templateid=self.template.id,
176+
accountid=self.account.name,
177+
domainid=self.account.domainid,
178+
serviceofferingid=self.service_offering_zwps.id,
179+
diskofferingid=self.disk_offering_zwps.id,
180+
zoneid=self.zone.id,
181+
)
182+
183+
self.cleanup.append(self.vm_zwps)
184+
185+
# Step 1
186+
volumes_root_list = list_volumes(
187+
self.apiclient,
188+
virtualmachineid=self.vm_zwps.id,
189+
type=ROOT,
190+
listall=True
191+
)
192+
status = validateList(volumes_root_list)
193+
194+
self.assertEqual(
195+
status[0],
196+
PASS,
197+
"Check: Failed to list root vloume due to %s" %
198+
status[2])
199+
200+
root_volume = volumes_root_list[0]
201+
202+
if root_volume.storage != zonepoolList[0].name:
203+
self.fail("Root Volume not in Zone-Wide Storage Pool !")
204+
205+
volumes_data_list = list_volumes(
206+
self.apiclient,
207+
virtualmachineid=self.vm_zwps.id,
208+
type=DATA,
209+
listall=True
210+
)
211+
status = validateList(volumes_data_list)
212+
213+
self.assertEqual(
214+
status[0],
215+
PASS,
216+
"Check: Failed to list data vloume due to %s" %
217+
status[2])
218+
219+
data_volume = volumes_data_list[0]
220+
221+
if data_volume.storage != zonepoolList[0].name:
222+
self.fail("Data Volume not in Zone-Wide Storage Pool !")
223+
224+
# Step 2
225+
self.vm_zwps.stop(self.apiclient)
226+
227+
self.debug(
228+
"Creation of Snapshot of Data Volume after VM is stopped.....")
229+
230+
Snapshot.create(
231+
self.apiclient,
232+
data_volume.id)
233+
234+
snapshots_list = Snapshot.list(
235+
self.apiclient,
236+
volumeid=data_volume.id,
237+
listall=True)
238+
239+
snap_list_validation_result = validateList(snapshots_list)
240+
241+
self.assertEqual(
242+
snap_list_validation_result[0],
243+
PASS,
244+
"snapshot list validation failed due to %s" %
245+
snap_list_validation_result[2])
246+
247+
snap_count = len(snapshots_list)
248+
249+
# Step 3
250+
self.debug(
251+
"Creating Multiple Snapshots(Should create more than 10).....")
252+
try:
253+
while snap_count <= 12:
254+
Snapshot.create(
255+
self.apiclient,
256+
data_volume.id)
257+
258+
snapshots_list = Snapshot.list(
259+
self.apiclient,
260+
volumeid=data_volume.id,
261+
listall=True)
262+
263+
snap_list_validation_result = validateList(snapshots_list)
264+
265+
self.assertEqual(
266+
snap_list_validation_result[0],
267+
PASS,
268+
"snapshot list validation failed due to %s" %
269+
snap_list_validation_result[2])
270+
271+
snap_count = len(snapshots_list)
272+
except Exception as e:
273+
snapshots_list = Snapshot.list(
274+
self.apiclient,
275+
volumeid=data_volume.id,
276+
listall=True)
277+
278+
snap_list_validation_result = validateList(snapshots_list)
279+
280+
self.assertEqual(
281+
snap_list_validation_result[0],
282+
PASS,
283+
"snapshot list validation failed due to %s" %
284+
snap_list_validation_result[2])
285+
286+
assert len(snapshots_list) >= 10,\
287+
"Less than 10 snapshots created...."
288+
raise Exception("Snapshot creation failed !: %s" % e)
289+
290+
return

‎tools/marvin/marvin/codes.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,4 @@
147147
'''
148148

149149
CLUSTER = "cluster"
150-
150+
DATA = "DATA"

0 commit comments

Comments
 (0)