|
24 | 24 | VpcOffering) |
25 | 25 | from marvin.lib.common import (get_domain, |
26 | 26 | get_zone, |
27 | | - get_template, |
28 | | - list_configurations) |
| 27 | + get_template) |
29 | 28 | import time |
30 | 29 |
|
31 | | - |
32 | | -class Services: |
33 | | - |
34 | | - """Test VPC services |
35 | | - """ |
36 | | - |
37 | | - def __init__(self): |
38 | | - self.services = { |
39 | | - "account": { |
40 | | - |
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 | | - |
78 | 30 | class TestVPCHostMaintenance(cloudstackTestCase): |
79 | 31 |
|
80 | 32 | @classmethod |
81 | 33 | def setUpClass(cls): |
82 | 34 | cls.testClient = super(TestVPCHostMaintenance, cls).getClsTestClient() |
83 | 35 | 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() |
86 | 44 | # Get Zone, Domain and templates |
87 | 45 | cls.domain = get_domain(cls.api_client) |
88 | 46 | cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) |
@@ -135,9 +93,7 @@ def setUpClass(cls): |
135 | 93 | host.name) |
136 | 94 | timeout = timeout - 1 |
137 | 95 |
|
138 | | - cls._cleanup = [ |
139 | | - cls.vpc_off |
140 | | - ] |
| 96 | + cls._cleanup.append(cls.vpc_off) |
141 | 97 | return |
142 | 98 |
|
143 | 99 | @classmethod |
@@ -166,13 +122,18 @@ def tearDownClass(cls): |
166 | 122 | def setUp(self): |
167 | 123 | self.apiclient = self.testClient.getApiClient() |
168 | 124 | 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 | + |
169 | 130 | self.account = Account.create( |
170 | 131 | self.apiclient, |
171 | 132 | self.services["account"], |
172 | 133 | admin=True, |
173 | 134 | domainid=self.domain.id |
174 | 135 | ) |
175 | | - self.cleanup = [self.account] |
| 136 | + self.cleanup.append(self.account) |
176 | 137 | return |
177 | 138 |
|
178 | 139 | def tearDown(self): |
@@ -255,53 +216,5 @@ def test_01_create_vpc_host_maintenance(self): |
255 | 216 | domainid=self.account.domainid, |
256 | 217 | start=False |
257 | 218 | ) |
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') |
307 | 220 | return |
0 commit comments