mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-8542: Correcting test case in test_vpc_on_host_maintenance.py
Signed-off-by: Gaurav Aradhye <gaurav.aradhye@clogeny.com> This closes #360
This commit is contained in:
parent
b272d7717e
commit
6140db50b3
|
|
@ -24,65 +24,23 @@ from marvin.lib.base import (Account,
|
|||
VpcOffering)
|
||||
from marvin.lib.common import (get_domain,
|
||||
get_zone,
|
||||
get_template,
|
||||
list_configurations)
|
||||
get_template)
|
||||
import time
|
||||
|
||||
|
||||
class Services:
|
||||
|
||||
"""Test VPC services
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.services = {
|
||||
"account": {
|
||||
"email": "test@test.com",
|
||||
"firstname": "Test",
|
||||
"lastname": "User",
|
||||
"username": "test",
|
||||
# Random characters are appended for unique
|
||||
# username
|
||||
"password": "password",
|
||||
},
|
||||
"vpc_offering": {
|
||||
"name": 'VPC off',
|
||||
"displaytext": 'VPC off',
|
||||
"supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Lb,\
|
||||
UserData,StaticNat,NetworkACL',
|
||||
},
|
||||
"vpc": {
|
||||
"name": "TestVPC",
|
||||
"displaytext": "TestVPC",
|
||||
"cidr": '10.0.0.1/24'
|
||||
},
|
||||
"virtual_machine": {
|
||||
"displayname": "Test VM",
|
||||
"username": "root",
|
||||
"password": "password",
|
||||
"ssh_port": 22,
|
||||
"hypervisor": 'XenServer',
|
||||
# Hypervisor type should be same as
|
||||
# hypervisor type of cluster
|
||||
"privateport": 22,
|
||||
"publicport": 22,
|
||||
"protocol": 'TCP',
|
||||
},
|
||||
"ostype": 'CentOS 5.3 (64-bit)',
|
||||
# Cent OS 5.3 (64 bit)
|
||||
"sleep": 60,
|
||||
"timeout": 10
|
||||
}
|
||||
|
||||
|
||||
class TestVPCHostMaintenance(cloudstackTestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.testClient = super(TestVPCHostMaintenance, cls).getClsTestClient()
|
||||
cls.api_client = cls.testClient.getApiClient()
|
||||
|
||||
cls.services = Services().services
|
||||
cls._cleanup = []
|
||||
cls.hosts = []
|
||||
cls.vpcSupported = True
|
||||
cls.hypervisor = cls.testClient.getHypervisorInfo()
|
||||
if cls.hypervisor.lower() in ['hyperv']:
|
||||
cls.vpcSupported = False
|
||||
return
|
||||
cls.services = cls.testClient.getParsedTestDataConfig()
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client)
|
||||
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
|
||||
|
|
@ -135,9 +93,7 @@ class TestVPCHostMaintenance(cloudstackTestCase):
|
|||
host.name)
|
||||
timeout = timeout - 1
|
||||
|
||||
cls._cleanup = [
|
||||
cls.vpc_off
|
||||
]
|
||||
cls._cleanup.append(cls.vpc_off)
|
||||
return
|
||||
|
||||
@classmethod
|
||||
|
|
@ -166,13 +122,18 @@ class TestVPCHostMaintenance(cloudstackTestCase):
|
|||
def setUp(self):
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
self.cleanup = []
|
||||
|
||||
if not self.vpcSupported:
|
||||
self.skipTest("VPC is not supported on %s" % self.hypervisor)
|
||||
|
||||
self.account = Account.create(
|
||||
self.apiclient,
|
||||
self.services["account"],
|
||||
admin=True,
|
||||
domainid=self.domain.id
|
||||
)
|
||||
self.cleanup = [self.account]
|
||||
self.cleanup.append(self.account)
|
||||
return
|
||||
|
||||
def tearDown(self):
|
||||
|
|
@ -255,53 +216,5 @@ class TestVPCHostMaintenance(cloudstackTestCase):
|
|||
domainid=self.account.domainid,
|
||||
start=False
|
||||
)
|
||||
self.validate_vpc_network(vpc, state='inactive')
|
||||
return
|
||||
|
||||
@attr(tags=["advanced", "intervlan"])
|
||||
def test_02_create_vpc_wait_gc(self):
|
||||
""" Test VPC when host is in maintenance mode and wait till nw gc
|
||||
"""
|
||||
|
||||
# Validate the following
|
||||
# 1. Put the host in maintenance mode.
|
||||
# 2. Attempt to Create a VPC with cidr - 10.1.1.1/16
|
||||
# 3. Wait for the VPC GC thread to run.
|
||||
# 3. VPC will be created but will be in "Disabled" state and should
|
||||
# get deleted
|
||||
|
||||
self.debug("creating a VPC network in the account: %s" %
|
||||
self.account.name)
|
||||
self.services["vpc"]["cidr"] = '10.1.1.1/16'
|
||||
vpc = VPC.create(
|
||||
self.apiclient,
|
||||
self.services["vpc"],
|
||||
vpcofferingid=self.vpc_off.id,
|
||||
zoneid=self.zone.id,
|
||||
account=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
start=False
|
||||
)
|
||||
self.validate_vpc_network(vpc, state='inactive')
|
||||
interval = list_configurations(
|
||||
self.apiclient,
|
||||
name='network.gc.interval'
|
||||
)
|
||||
wait = list_configurations(
|
||||
self.apiclient,
|
||||
name='network.gc.wait'
|
||||
)
|
||||
self.debug("Sleep till network gc thread runs..")
|
||||
# Sleep to ensure that all resources are deleted
|
||||
time.sleep(int(interval[0].value) + int(wait[0].value))
|
||||
vpcs = VPC.list(
|
||||
self.apiclient,
|
||||
id=vpc.id,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
vpcs,
|
||||
None,
|
||||
"List VPC should not return anything after network gc"
|
||||
)
|
||||
self.validate_vpc_network(vpc, state='enabled')
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in New Issue