Skip to content

Commit c5ebb68

Browse files
Priti Sarapsanjeev
authored andcommitted
CLOUDSTACK-8689: Verify effect of changing value of XenServer Max guest limitis on previously added hosts
CLOUDSTACK-8689-Verify-effect-of-changing-value-of-XenServer-Max-guest-limitis-on-previously-added-hosts -Addning check for empty list and increamenting maxguestlimit accordingly CLOUDSTACK-8689: Verify effect of changing value of XenServer Maxguestlimits on previously added hosts -As testcase is changing maxguestlimits global setting it will affect on other testcases also hence moving it to component/maint folder This closes #638
1 parent c1ac5f3 commit c5ebb68

1 file changed

Lines changed: 225 additions & 0 deletions

File tree

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
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 cases for Testing Max Hypervisor Limit
18+
"""
19+
from nose.plugins.attrib import attr
20+
from marvin.cloudstackTestCase import cloudstackTestCase
21+
from marvin.lib.utils import (cleanup_resources,
22+
validateList)
23+
from marvin.lib.base import (Account,
24+
ServiceOffering,
25+
VirtualMachine,
26+
Host
27+
)
28+
from marvin.lib.common import (get_domain,
29+
get_zone,
30+
get_template,
31+
list_virtual_machines,
32+
list_ssvms,
33+
list_routers
34+
)
35+
36+
37+
from marvin.cloudstackAPI import (updateHypervisorCapabilities,
38+
listHypervisorCapabilities)
39+
40+
from marvin.codes import PASS
41+
42+
43+
class TestMaxHyperviosrLimit(cloudstackTestCase):
44+
45+
@classmethod
46+
def setUpClass(cls):
47+
testClient = super(TestMaxHyperviosrLimit, cls).getClsTestClient()
48+
cls.apiclient = testClient.getApiClient()
49+
cls.testdata = testClient.getParsedTestDataConfig()
50+
51+
cls.hypervisor = cls.testClient.getHypervisorInfo()
52+
# Get Zone, Domain and templates
53+
54+
cls.domain = get_domain(cls.apiclient)
55+
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
56+
57+
cls.template = get_template(
58+
cls.apiclient,
59+
cls.zone.id,
60+
cls.testdata["ostype"])
61+
62+
cls._cleanup = []
63+
try:
64+
cls.skiptest = False
65+
if cls.hypervisor.lower() not in ['xenserver']:
66+
cls.skiptest = True
67+
return
68+
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 = ServiceOffering.create(
83+
cls.apiclient,
84+
cls.testdata["service_offering"],
85+
hosttags="host1"
86+
)
87+
88+
cls._cleanup = [
89+
cls.account,
90+
cls.service_offering,
91+
]
92+
except Exception as e:
93+
cls.tearDownClass()
94+
raise e
95+
return
96+
97+
@classmethod
98+
def tearDownClass(cls):
99+
try:
100+
cleanup_resources(cls.apiclient, cls._cleanup)
101+
except Exception as e:
102+
raise Exception("Warning: Exception during cleanup : %s" % e)
103+
104+
def setUp(self):
105+
self.cleanup = []
106+
if self.skiptest:
107+
self.skipTest("This test is to be checked on xenserver \
108+
only Hence, skip for %s" % self.hypervisor)
109+
110+
self.apiclient = self.testClient.getApiClient()
111+
self.dbclient = self.testClient.getDbConnection()
112+
113+
def tearDown(self):
114+
try:
115+
116+
cmd = updateHypervisorCapabilities.updateHypervisorCapabilitiesCmd()
117+
cmd.id = self.hostCapId
118+
cmd.maxguestslimit = self.originalLimit
119+
self.apiclient.updateHypervisorCapabilities(cmd)
120+
121+
cleanup_resources(self.apiclient, self.cleanup)
122+
except Exception as e:
123+
raise Exception("Warning: Exception during cleanup : %s" % e)
124+
return
125+
126+
@attr(tags=["advanced", "basic"], required_hardware="false")
127+
def test_check_hypervisor_max_limit_effect(self):
128+
""" Test hypervisor max limits effect
129+
130+
# 1. Read exsiting count of VM's on the host including SSVM and VR
131+
and modify maxguestcount accordingly
132+
# 2. Deploy a VM
133+
# 2. Try to deploy another vm
134+
# 3. Verify that second VM
135+
deployment fails (2 SSVMs 1 VR VM and 1 deployed VM)
136+
"""
137+
138+
hostList = Host.list(
139+
self.apiclient,
140+
zoneid=self.zone.id,
141+
type="Routing")
142+
event_validation_result = validateList(hostList)
143+
self.assertEqual(
144+
event_validation_result[0],
145+
PASS,
146+
"host list validation failed due to %s" %
147+
event_validation_result[2])
148+
149+
self.host = Host(hostList[0])
150+
Host.update(self.apiclient, id=self.host.id, hosttags="host1")
151+
152+
# Step 1
153+
# List VM's , SSVM's and VR on selected host
154+
listVm = list_virtual_machines(self.apiclient,
155+
hostid=self.host.id)
156+
157+
listssvm = list_ssvms(self.apiclient,
158+
hostid=self.host.id)
159+
160+
listvr = list_routers(self.apiclient,
161+
hostid=self.host.id)
162+
163+
newValue = 1
164+
if listVm is not None:
165+
newValue = len(listVm) + newValue
166+
167+
if listssvm is not None:
168+
newValue = len(listssvm) + newValue
169+
170+
if listvr is not None:
171+
newValue = len(listvr) + newValue
172+
173+
qresultset = self.dbclient.execute(
174+
"select hypervisor_version from host where uuid='%s'" %
175+
self.host.id)
176+
177+
event_validation_result = validateList(qresultset)
178+
self.assertEqual(
179+
event_validation_result[0],
180+
PASS,
181+
"event list validation failed due to %s" %
182+
event_validation_result[2])
183+
184+
cmdList = listHypervisorCapabilities.listHypervisorCapabilitiesCmd()
185+
cmdList.hypervisor = self.hypervisor
186+
config = self.apiclient.listHypervisorCapabilities(cmdList)
187+
188+
for host in config:
189+
if host.hypervisorversion == qresultset[0][0]:
190+
self.hostCapId = host.id
191+
self.originalLimit = host.maxguestslimit
192+
break
193+
else:
194+
self.skipTest("No hypervisor capabilities found for %s \
195+
with version %s" % (self.hypervisor, qresultset[0][0]))
196+
197+
cmdUpdate = updateHypervisorCapabilities.\
198+
updateHypervisorCapabilitiesCmd()
199+
cmdUpdate.id = self.hostCapId
200+
cmdUpdate.maxguestslimit = newValue
201+
self.apiclient.updateHypervisorCapabilities(cmdUpdate)
202+
203+
# Step 2
204+
vm = VirtualMachine.create(
205+
self.userapiclient,
206+
self.testdata["small"],
207+
templateid=self.template.id,
208+
accountid=self.account.name,
209+
domainid=self.account.domainid,
210+
serviceofferingid=self.service_offering.id,
211+
zoneid=self.zone.id,
212+
)
213+
214+
self.cleanup.append(vm)
215+
# Step 3
216+
with self.assertRaises(Exception):
217+
VirtualMachine.create(
218+
self.userapiclient,
219+
self.testdata["small"],
220+
templateid=self.template.id,
221+
accountid=self.account.name,
222+
domainid=self.account.domainid,
223+
serviceofferingid=self.service_offering.id,
224+
zoneid=self.zone.id,
225+
)

0 commit comments

Comments
 (0)