Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 17 additions & 104 deletions test/integration/component/maint/test_vpc_on_host_maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,65 +24,23 @@
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())
Expand Down Expand Up @@ -135,9 +93,7 @@ def setUpClass(cls):
host.name)
timeout = timeout - 1

cls._cleanup = [
cls.vpc_off
]
cls._cleanup.append(cls.vpc_off)
return

@classmethod
Expand Down Expand Up @@ -166,13 +122,18 @@ def tearDownClass(cls):
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):
Expand Down Expand Up @@ -255,53 +216,5 @@ def test_01_create_vpc_host_maintenance(self):
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