Skip to content

Commit 373b107

Browse files
Priti Sarapyadvr
authored andcommitted
CLOUDSTACK-8636: Verify failure of creation of Custom disk offering with disksize parameter
- Clear disk offering in tearDown() class if gets created Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> This closes apache#592
1 parent abf216a commit 373b107

1 file changed

Lines changed: 89 additions & 0 deletions

File tree

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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 Create Custom DiskOffering with size Test Path
18+
"""
19+
20+
from nose.plugins.attrib import attr
21+
from marvin.cloudstackTestCase import cloudstackTestCase
22+
from marvin.cloudstackAPI import (createDiskOffering, deleteDiskOffering)
23+
from marvin.lib.utils import (cleanup_resources)
24+
from marvin.lib.common import (get_domain,
25+
get_zone,
26+
)
27+
28+
29+
class TestCustomDiskOfferingWithSize(cloudstackTestCase):
30+
31+
@classmethod
32+
def setUpClass(cls):
33+
testClient = super(
34+
TestCustomDiskOfferingWithSize,
35+
cls).getClsTestClient()
36+
cls.apiclient = testClient.getApiClient()
37+
cls.testdata = testClient.getParsedTestDataConfig()
38+
cls.hypervisor = cls.testClient.getHypervisorInfo()
39+
40+
# Get Zone, Domain and templates
41+
cls.domain = get_domain(cls.apiclient)
42+
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
43+
cls._cleanup = []
44+
45+
cls.tearDownClass()
46+
47+
return
48+
49+
@classmethod
50+
def tearDownClass(cls):
51+
try:
52+
cleanup_resources(cls.apiclient, cls._cleanup)
53+
except Exception as e:
54+
raise Exception("Warning: Exception during cleanup : %s" % e)
55+
56+
def setUp(self):
57+
self.apiclient = self.testClient.getApiClient()
58+
self.dbclient = self.testClient.getDbConnection()
59+
self.cleanup = []
60+
61+
def tearDown(self):
62+
try:
63+
if hasattr(self, 'disk_offering'):
64+
cmd = deleteDiskOffering.deleteDiskOfferingCmd()
65+
cmd.id = self.disk_offering.id
66+
self.apiclient.deleteDiskOffering(cmd)
67+
68+
cleanup_resources(self.apiclient, self.cleanup)
69+
except Exception as e:
70+
raise Exception("Warning: Exception during cleanup : %s" % e)
71+
return
72+
73+
@attr(tags=["basic", "advanced"], required_hardware="false")
74+
def test_create_custom_disk_offering_with_size(self):
75+
""" Create custom disk offerign with size
76+
1. Create custom disk offering with size.
77+
2. Should not allow to create custom disk offering
78+
with size mentioned.(Exception should be raised)
79+
"""
80+
81+
with self.assertRaises(Exception):
82+
cmd = createDiskOffering.createDiskOfferingCmd()
83+
cmd.displaytext = "Custom Disk Offering"
84+
cmd.name = "Custom Disk Offering"
85+
cmd.customized = True
86+
cmd.disksize = 2
87+
self.disk_offering = self.apiclient.createDiskOffering(cmd)
88+
89+
return

0 commit comments

Comments
 (0)