Skip to content

Commit 608fff5

Browse files
author
Priti Sarap
committed
CLOUDSTACK-8686: Data disk attach failed for clusters with only zone wide primary
-Attaching the uploaded/allocated volume to a VM on zwps
1 parent c27c694 commit 608fff5

File tree

1 file changed

+185
-0
lines changed

1 file changed

+185
-0
lines changed
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
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+
""" Test case for Data Disk Attach to VM on ZWPS Test Path
18+
"""
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+
Volume,
28+
VirtualMachine,
29+
StoragePool
30+
)
31+
from marvin.lib.common import (get_domain,
32+
get_zone,
33+
get_template
34+
)
35+
36+
from marvin.codes import (PASS,
37+
ZONETAG1)
38+
39+
40+
class TestAttachDataDisk(cloudstackTestCase):
41+
42+
@classmethod
43+
def setUpClass(cls):
44+
testClient = super(TestAttachDataDisk, cls).getClsTestClient()
45+
cls.apiclient = testClient.getApiClient()
46+
cls.testdata = testClient.getParsedTestDataConfig()
47+
cls.hypervisor = cls.testClient.getHypervisorInfo()
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._cleanup = []
53+
cls.template = get_template(
54+
cls.apiclient,
55+
cls.zone.id,
56+
cls.testdata["ostype"])
57+
cls.skiptest = False
58+
59+
try:
60+
cls.pools = StoragePool.list(cls.apiclient, zoneid=cls.zone.id)
61+
except Exception as e:
62+
cls.skiptest = True
63+
return
64+
try:
65+
66+
# Create an account
67+
cls.account = Account.create(
68+
cls.apiclient,
69+
cls.testdata["account"],
70+
domainid=cls.domain.id
71+
)
72+
cls._cleanup.append(cls.account)
73+
74+
# Create user api client of the account
75+
cls.userapiclient = testClient.getUserApiClient(
76+
UserName=cls.account.name,
77+
DomainName=cls.account.domain
78+
)
79+
# Create Service offering
80+
cls.service_offering_zone1 = ServiceOffering.create(
81+
cls.apiclient,
82+
cls.testdata["service_offering"],
83+
tags=ZONETAG1
84+
)
85+
cls._cleanup.append(cls.service_offering_zone1)
86+
87+
# Create Disk offering
88+
cls.disk_offering = DiskOffering.create(
89+
cls.apiclient,
90+
cls.testdata["disk_offering"]
91+
)
92+
93+
cls._cleanup.append(cls.disk_offering)
94+
95+
except Exception as e:
96+
cls.tearDownClass()
97+
raise e
98+
return
99+
100+
@classmethod
101+
def tearDownClass(cls):
102+
try:
103+
cleanup_resources(cls.apiclient, cls._cleanup)
104+
except Exception as e:
105+
raise Exception("Warning: Exception during cleanup : %s" % e)
106+
107+
def setUp(self):
108+
self.apiclient = self.testClient.getApiClient()
109+
self.dbclient = self.testClient.getDbConnection()
110+
self.cleanup = []
111+
112+
def tearDown(self):
113+
try:
114+
if hasattr(self, "data_volume_created"):
115+
data_volumes_list = Volume.list(
116+
self.userapiclient,
117+
id=self.data_volume_created.id,
118+
virtualmachineid=self.vm.id
119+
)
120+
if data_volumes_list:
121+
self.vm.detach_volume(
122+
self.userapiclient,
123+
data_volumes_list[0]
124+
)
125+
126+
status = validateList(data_volumes_list)
127+
self.assertEqual(
128+
status[0],
129+
PASS,
130+
"DATA Volume List Validation Failed")
131+
132+
cleanup_resources(self.apiclient, self.cleanup)
133+
except Exception as e:
134+
raise Exception("Warning: Exception during cleanup : %s" % e)
135+
return
136+
137+
@attr(tags=["basic", "advanced"], required_hardware="true")
138+
def test_01_attach_datadisk_to_vm_on_zwps(self):
139+
""" Attach Data Disk To VM on ZWPS
140+
1. Get zwps storage pool.
141+
2. Attach data disk to vm which is on zwps.
142+
3. Verify disk is attached.
143+
"""
144+
145+
self.vm = VirtualMachine.create(
146+
self.apiclient,
147+
self.testdata["small"],
148+
templateid=self.template.id,
149+
accountid=self.account.name,
150+
domainid=self.account.domainid,
151+
serviceofferingid=self.service_offering_zone1.id,
152+
zoneid=self.zone.id
153+
)
154+
155+
self.data_volume_created = Volume.create(
156+
self.userapiclient,
157+
self.testdata["volume"],
158+
zoneid=self.zone.id,
159+
account=self.account.name,
160+
domainid=self.account.domainid,
161+
diskofferingid=self.disk_offering.id
162+
)
163+
164+
self.cleanup.append(self.data_volume_created)
165+
166+
self.vm.attach_volume(
167+
self.userapiclient,
168+
self.data_volume_created
169+
)
170+
171+
data_volumes_list = Volume.list(
172+
self.userapiclient,
173+
id=self.data_volume_created.id,
174+
virtualmachineid=self.vm.id
175+
)
176+
177+
data_volume = data_volumes_list[0]
178+
179+
status = validateList(data_volume)
180+
self.assertEqual(
181+
status[0],
182+
PASS,
183+
"Check: Data if Disk is attached to VM")
184+
185+
return

0 commit comments

Comments
 (0)