Skip to content

Commit 6140db5

Browse files
author
Gaurav Aradhye
committed
CLOUDSTACK-8542: Correcting test case in test_vpc_on_host_maintenance.py
Signed-off-by: Gaurav Aradhye <[email protected]> This closes apache#360
1 parent b272d77 commit 6140db5

1 file changed

Lines changed: 17 additions & 104 deletions

File tree

test/integration/component/maint/test_vpc_on_host_maintenance.py

Lines changed: 17 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -24,65 +24,23 @@
2424
VpcOffering)
2525
from marvin.lib.common import (get_domain,
2626
get_zone,
27-
get_template,
28-
list_configurations)
27+
get_template)
2928
import time
3029

31-
32-
class Services:
33-
34-
"""Test VPC services
35-
"""
36-
37-
def __init__(self):
38-
self.services = {
39-
"account": {
40-
"email": "[email protected]",
41-
"firstname": "Test",
42-
"lastname": "User",
43-
"username": "test",
44-
# Random characters are appended for unique
45-
# username
46-
"password": "password",
47-
},
48-
"vpc_offering": {
49-
"name": 'VPC off',
50-
"displaytext": 'VPC off',
51-
"supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Lb,\
52-
UserData,StaticNat,NetworkACL',
53-
},
54-
"vpc": {
55-
"name": "TestVPC",
56-
"displaytext": "TestVPC",
57-
"cidr": '10.0.0.1/24'
58-
},
59-
"virtual_machine": {
60-
"displayname": "Test VM",
61-
"username": "root",
62-
"password": "password",
63-
"ssh_port": 22,
64-
"hypervisor": 'XenServer',
65-
# Hypervisor type should be same as
66-
# hypervisor type of cluster
67-
"privateport": 22,
68-
"publicport": 22,
69-
"protocol": 'TCP',
70-
},
71-
"ostype": 'CentOS 5.3 (64-bit)',
72-
# Cent OS 5.3 (64 bit)
73-
"sleep": 60,
74-
"timeout": 10
75-
}
76-
77-
7830
class TestVPCHostMaintenance(cloudstackTestCase):
7931

8032
@classmethod
8133
def setUpClass(cls):
8234
cls.testClient = super(TestVPCHostMaintenance, cls).getClsTestClient()
8335
cls.api_client = cls.testClient.getApiClient()
84-
85-
cls.services = Services().services
36+
cls._cleanup = []
37+
cls.hosts = []
38+
cls.vpcSupported = True
39+
cls.hypervisor = cls.testClient.getHypervisorInfo()
40+
if cls.hypervisor.lower() in ['hyperv']:
41+
cls.vpcSupported = False
42+
return
43+
cls.services = cls.testClient.getParsedTestDataConfig()
8644
# Get Zone, Domain and templates
8745
cls.domain = get_domain(cls.api_client)
8846
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
@@ -135,9 +93,7 @@ def setUpClass(cls):
13593
host.name)
13694
timeout = timeout - 1
13795

138-
cls._cleanup = [
139-
cls.vpc_off
140-
]
96+
cls._cleanup.append(cls.vpc_off)
14197
return
14298

14399
@classmethod
@@ -166,13 +122,18 @@ def tearDownClass(cls):
166122
def setUp(self):
167123
self.apiclient = self.testClient.getApiClient()
168124
self.dbclient = self.testClient.getDbConnection()
125+
self.cleanup = []
126+
127+
if not self.vpcSupported:
128+
self.skipTest("VPC is not supported on %s" % self.hypervisor)
129+
169130
self.account = Account.create(
170131
self.apiclient,
171132
self.services["account"],
172133
admin=True,
173134
domainid=self.domain.id
174135
)
175-
self.cleanup = [self.account]
136+
self.cleanup.append(self.account)
176137
return
177138

178139
def tearDown(self):
@@ -255,53 +216,5 @@ def test_01_create_vpc_host_maintenance(self):
255216
domainid=self.account.domainid,
256217
start=False
257218
)
258-
self.validate_vpc_network(vpc, state='inactive')
259-
return
260-
261-
@attr(tags=["advanced", "intervlan"])
262-
def test_02_create_vpc_wait_gc(self):
263-
""" Test VPC when host is in maintenance mode and wait till nw gc
264-
"""
265-
266-
# Validate the following
267-
# 1. Put the host in maintenance mode.
268-
# 2. Attempt to Create a VPC with cidr - 10.1.1.1/16
269-
# 3. Wait for the VPC GC thread to run.
270-
# 3. VPC will be created but will be in "Disabled" state and should
271-
# get deleted
272-
273-
self.debug("creating a VPC network in the account: %s" %
274-
self.account.name)
275-
self.services["vpc"]["cidr"] = '10.1.1.1/16'
276-
vpc = VPC.create(
277-
self.apiclient,
278-
self.services["vpc"],
279-
vpcofferingid=self.vpc_off.id,
280-
zoneid=self.zone.id,
281-
account=self.account.name,
282-
domainid=self.account.domainid,
283-
start=False
284-
)
285-
self.validate_vpc_network(vpc, state='inactive')
286-
interval = list_configurations(
287-
self.apiclient,
288-
name='network.gc.interval'
289-
)
290-
wait = list_configurations(
291-
self.apiclient,
292-
name='network.gc.wait'
293-
)
294-
self.debug("Sleep till network gc thread runs..")
295-
# Sleep to ensure that all resources are deleted
296-
time.sleep(int(interval[0].value) + int(wait[0].value))
297-
vpcs = VPC.list(
298-
self.apiclient,
299-
id=vpc.id,
300-
listall=True
301-
)
302-
self.assertEqual(
303-
vpcs,
304-
None,
305-
"List VPC should not return anything after network gc"
306-
)
219+
self.validate_vpc_network(vpc, state='enabled')
307220
return

0 commit comments

Comments
 (0)