mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
Moving maintenance mode into component/maint
All tests that could possible disrupt the runs of other tests because of putting resources into maintenace will be put under maint/. This should allow us to run the tests sequentially when other tests are not running on a deployment. Signed-off-by: Prasanna Santhanam <tsp@apache.org>
This commit is contained in:
parent
a3d585ea4e
commit
0587d3a496
21
test/integration/component/maint/__init__.py
Normal file
21
test/integration/component/maint/__init__.py
Normal file
@ -0,0 +1,21 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""
|
||||
Tests that put hosts, zones, resources in to maintenance mode are here.
|
||||
These will have to be run sequentiall when resources are available so as not disrupt other tests
|
||||
"""
|
||||
@ -15,7 +15,7 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
""" P1 tests for dedicated Host high availability
|
||||
""" P1 tests for dedicated Host high availability
|
||||
"""
|
||||
#Import Local Modules
|
||||
from nose.plugins.attrib import attr
|
||||
@ -157,7 +157,7 @@ class TestHostHighAvailability(cloudstackTestCase):
|
||||
# Validations,
|
||||
#1. Ensure that the offering is created and that in the UI the 'Offer HA' field is enabled (Yes)
|
||||
#The listServiceOffering API should list 'offerha' as true.
|
||||
#2. Select the newly created VM and ensure that the Compute offering field value lists the compute service offering that was selected.
|
||||
#2. Select the newly created VM and ensure that the Compute offering field value lists the compute service offering that was selected.
|
||||
# Also, check that the HA Enabled field is enabled 'Yes'.
|
||||
|
||||
#list and validate above created service offering with Ha enabled
|
||||
@ -257,7 +257,7 @@ class TestHostHighAvailability(cloudstackTestCase):
|
||||
|
||||
self.debug("Deployed VM on host: %s" % vm.hostid)
|
||||
|
||||
#validate the virtual machine created is host Ha enabled
|
||||
#validate the virtual machine created is host Ha enabled
|
||||
list_hosts_response = list_hosts(
|
||||
self.apiclient,
|
||||
id=vm.hostid
|
||||
@ -593,7 +593,7 @@ class TestHostHighAvailability(cloudstackTestCase):
|
||||
|
||||
vm_with_ha_enabled = vms[0]
|
||||
|
||||
#Verify the virtual machine got created on non HA host
|
||||
#Verify the virtual machine got created on non HA host
|
||||
list_hosts_response = list_hosts(
|
||||
self.apiclient,
|
||||
id=vm_with_ha_enabled.hostid
|
||||
@ -725,7 +725,7 @@ class TestHostHighAvailability(cloudstackTestCase):
|
||||
|
||||
vm_with_ha_disabled = vms[0]
|
||||
|
||||
#Verify the virtual machine got created on non HA host
|
||||
#Verify the virtual machine got created on non HA host
|
||||
list_hosts_response = list_hosts(
|
||||
self.apiclient,
|
||||
id=vm_with_ha_disabled.hostid
|
||||
@ -558,332 +558,4 @@ class TestVMLifeCycleHostmaintenance(cloudstackTestCase):
|
||||
"Router state should be running"
|
||||
)
|
||||
# TODO: Check for the network connectivity
|
||||
return
|
||||
|
||||
|
||||
class TestVPCNetworkRules(cloudstackTestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.api_client = super(
|
||||
TestVPCNetworkRules,
|
||||
cls
|
||||
).getClsTestClient().getApiClient()
|
||||
cls.services = Services().services
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client, cls.services)
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
cls.template = get_template(
|
||||
cls.api_client,
|
||||
cls.zone.id,
|
||||
cls.services["ostype"]
|
||||
)
|
||||
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
|
||||
cls.services["virtual_machine"]["template"] = cls.template.id
|
||||
|
||||
cls.service_offering_1 = ServiceOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["service_offering_1"]
|
||||
)
|
||||
cls.service_offering_2 = ServiceOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["service_offering_2"]
|
||||
)
|
||||
cls.vpc_off = VpcOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["vpc_offering"]
|
||||
)
|
||||
cls.vpc_off.update(cls.api_client, state='Enabled')
|
||||
|
||||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"],
|
||||
admin=True,
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
|
||||
cls.vpc_off = VpcOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["vpc_offering"]
|
||||
)
|
||||
|
||||
cls.vpc_off.update(cls.api_client, state='Enabled')
|
||||
|
||||
cls.services["vpc"]["cidr"] = '10.1.1.1/16'
|
||||
cls.vpc = VPC.create(
|
||||
cls.api_client,
|
||||
cls.services["vpc"],
|
||||
vpcofferingid=cls.vpc_off.id,
|
||||
zoneid=cls.zone.id,
|
||||
account=cls.account.name,
|
||||
domainid=cls.account.domainid
|
||||
)
|
||||
|
||||
cls.nw_off = NetworkOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["network_offering"],
|
||||
conservemode=False
|
||||
)
|
||||
# Enable Network offering
|
||||
cls.nw_off.update(cls.api_client, state='Enabled')
|
||||
|
||||
# Creating network using the network offering created
|
||||
cls.network_1 = Network.create(
|
||||
cls.api_client,
|
||||
cls.services["network"],
|
||||
accountid=cls.account.name,
|
||||
domainid=cls.account.domainid,
|
||||
networkofferingid=cls.nw_off.id,
|
||||
zoneid=cls.zone.id,
|
||||
gateway='10.1.1.1',
|
||||
vpcid=cls.vpc.id
|
||||
)
|
||||
cls.nw_off_no_lb = NetworkOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["network_offering_no_lb"],
|
||||
conservemode=False
|
||||
)
|
||||
# Enable Network offering
|
||||
cls.nw_off_no_lb.update(cls.api_client, state='Enabled')
|
||||
|
||||
# Creating network using the network offering created
|
||||
cls.network_2 = Network.create(
|
||||
cls.api_client,
|
||||
cls.services["network"],
|
||||
accountid=cls.account.name,
|
||||
domainid=cls.account.domainid,
|
||||
networkofferingid=cls.nw_off_no_lb.id,
|
||||
zoneid=cls.zone.id,
|
||||
gateway='10.1.2.1',
|
||||
vpcid=cls.vpc.id
|
||||
)
|
||||
# Spawn an instance in that network
|
||||
cls.vm_1 = VirtualMachine.create(
|
||||
cls.api_client,
|
||||
cls.services["virtual_machine"],
|
||||
accountid=cls.account.name,
|
||||
domainid=cls.account.domainid,
|
||||
serviceofferingid=cls.service_offering_1.id,
|
||||
networkids=[str(cls.network_1.id)]
|
||||
)
|
||||
# Spawn an instance in that network
|
||||
cls.vm_2 = VirtualMachine.create(
|
||||
cls.api_client,
|
||||
cls.services["virtual_machine"],
|
||||
accountid=cls.account.name,
|
||||
domainid=cls.account.domainid,
|
||||
serviceofferingid=cls.service_offering_2.id,
|
||||
networkids=[str(cls.network_1.id)]
|
||||
)
|
||||
cls.vm_3 = VirtualMachine.create(
|
||||
cls.api_client,
|
||||
cls.services["virtual_machine"],
|
||||
accountid=cls.account.name,
|
||||
domainid=cls.account.domainid,
|
||||
serviceofferingid=cls.service_offering_1.id,
|
||||
networkids=[str(cls.network_2.id)]
|
||||
)
|
||||
cls.vm_4 = VirtualMachine.create(
|
||||
cls.api_client,
|
||||
cls.services["virtual_machine"],
|
||||
accountid=cls.account.name,
|
||||
domainid=cls.account.domainid,
|
||||
serviceofferingid=cls.service_offering_2.id,
|
||||
networkids=[str(cls.network_2.id)]
|
||||
)
|
||||
|
||||
cls._cleanup = [
|
||||
cls.service_offering_1,
|
||||
cls.service_offering_2,
|
||||
cls.nw_off,
|
||||
cls.nw_off_no_lb,
|
||||
]
|
||||
return
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
try:
|
||||
cls.account.delete(cls.api_client)
|
||||
wait_for_cleanup(cls.api_client, ["account.cleanup.interval"])
|
||||
#Cleanup resources used
|
||||
cleanup_resources(cls.api_client, cls._cleanup)
|
||||
|
||||
# Waiting for network cleanup to delete vpc offering
|
||||
wait_for_cleanup(cls.api_client, ["network.gc.wait",
|
||||
"network.gc.interval"])
|
||||
cls.vpc_off.delete(cls.api_client)
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
def setUp(self):
|
||||
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
self.cleanup = []
|
||||
return
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
#Clean up, terminate the created network offerings
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
def validate_vm_deployment(self):
|
||||
"""Validates VM deployment on different hosts"""
|
||||
|
||||
vms = VirtualMachine.list(
|
||||
self.apiclient,
|
||||
account=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
networkid=self.network_1.id,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vms, list),
|
||||
True,
|
||||
"List VMs shall return a valid response"
|
||||
)
|
||||
host_1 = vms[0].hostid
|
||||
self.debug("Host for network 1: %s" % vms[0].hostid)
|
||||
|
||||
vms = VirtualMachine.list(
|
||||
self.apiclient,
|
||||
account=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
networkid=self.network_2.id,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vms, list),
|
||||
True,
|
||||
"List VMs shall return a valid response"
|
||||
)
|
||||
host_2 = vms[0].hostid
|
||||
self.debug("Host for network 2: %s" % vms[0].hostid)
|
||||
|
||||
self.assertNotEqual(
|
||||
host_1,
|
||||
host_2,
|
||||
"Both the virtual machines should be deployed on diff hosts "
|
||||
)
|
||||
return
|
||||
|
||||
@attr(tags=["advanced", "intervlan"])
|
||||
def test_list_pf_rules_for_vpc(self):
|
||||
""" Test List Port Forwarding Rules & vms belonging to a VPC
|
||||
"""
|
||||
|
||||
# Validate the following
|
||||
# 1. Create a VPC with cidr - 10.1.1.1/16
|
||||
# 2. Add network1(10.1.1.1/24) and network2(10.1.2.1/24) to this VPC.
|
||||
# 3. Deploy vm1 and vm2 in network1 and vm3 and vm4 in network2.
|
||||
# Make sure vm1 and vm3 are deployed on one host in the cluster
|
||||
# while vm2 and vm4 are deployed on the other host in the cluster.
|
||||
# This can be done using host's tags and service offerings with
|
||||
# host tags.
|
||||
# 4. Create a PF rule for vms in network1.
|
||||
# 5. Create a PF rule for vms in network2.
|
||||
# Steps:
|
||||
# 1. List all the Port Forwarding Rules belonging to a VPC
|
||||
# 2. Successfully List the Port Forwarding Rules belonging to the VPC
|
||||
# 3. List the VMs on network1 for selection for the PF Rule
|
||||
# 4. Successfully list the VMs for Port Forwarding Rule creation
|
||||
|
||||
self.debug("Associating public IP for network: %s" %
|
||||
self.network_1.name)
|
||||
public_ip_1 = PublicIPAddress.create(
|
||||
self.apiclient,
|
||||
accountid=self.account.name,
|
||||
zoneid=self.zone.id,
|
||||
domainid=self.account.domainid,
|
||||
networkid=self.network_1.id,
|
||||
vpcid=self.vpc.id
|
||||
)
|
||||
self.debug("Associated %s with network %s" % (
|
||||
public_ip_1.ipaddress.ipaddress,
|
||||
self.network_1.id
|
||||
))
|
||||
|
||||
nat_rule_1 = NATRule.create(
|
||||
self.apiclient,
|
||||
self.vm_1,
|
||||
self.services["natrule"],
|
||||
ipaddressid=public_ip_1.ipaddress.id,
|
||||
openfirewall=False,
|
||||
networkid=self.network_1.id,
|
||||
vpcid=self.vpc.id
|
||||
)
|
||||
|
||||
self.debug("Associating public IP for network: %s" %
|
||||
self.network_2.name)
|
||||
public_ip_2 = PublicIPAddress.create(
|
||||
self.apiclient,
|
||||
accountid=self.account.name,
|
||||
zoneid=self.zone.id,
|
||||
domainid=self.account.domainid,
|
||||
networkid=self.network_2.id,
|
||||
vpcid=self.vpc.id
|
||||
)
|
||||
self.debug("Associated %s with network %s" % (
|
||||
public_ip_2.ipaddress.ipaddress,
|
||||
self.network_2.id
|
||||
))
|
||||
|
||||
nat_rule_2 = NATRule.create(
|
||||
self.apiclient,
|
||||
self.vm_3,
|
||||
self.services["natrule"],
|
||||
ipaddressid=public_ip_2.ipaddress.id,
|
||||
openfirewall=False,
|
||||
networkid=self.network_2.id,
|
||||
vpcid=self.vpc.id
|
||||
)
|
||||
|
||||
self.debug("Listing all the PF rules belonging to VPC")
|
||||
nat_rules = NATRule.list(
|
||||
self.apiclient,
|
||||
vpcid=self.vpc.id,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(nat_rules, list),
|
||||
True,
|
||||
"List NAT rules should return the valid list"
|
||||
)
|
||||
self.assertEqual(
|
||||
len(nat_rules),
|
||||
2,
|
||||
"List NAT for VPC shall return all NAT rules belonging to VPC"
|
||||
)
|
||||
for nat_rule in nat_rules:
|
||||
self.assertEqual(
|
||||
nat_rule.vpcid,
|
||||
self.vpc.id,
|
||||
"NAT rules should belong to VPC"
|
||||
)
|
||||
|
||||
self.debug(
|
||||
"Listing all the VMs belonging to VPC for network: %s" %
|
||||
self.network_1.name)
|
||||
vms = VirtualMachine.list(
|
||||
self.apiclient,
|
||||
networkid=self.network_1.id,
|
||||
vpcid=self.vpc.id,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vms, list),
|
||||
True,
|
||||
"List virtual machines should return the valid list"
|
||||
)
|
||||
for vm in vms:
|
||||
self.assertEqual(
|
||||
vm.networkid,
|
||||
self.network_1.id,
|
||||
"List VMs should return vms belonging to network_1"
|
||||
)
|
||||
return
|
||||
|
||||
return
|
||||
323
test/integration/component/maint/test_vpc_on_host_maintenance.py
Normal file
323
test/integration/component/maint/test_vpc_on_host_maintenance.py
Normal file
@ -0,0 +1,323 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from nose.plugins.attrib import attr
|
||||
from marvin.cloudstackTestCase import *
|
||||
from marvin.cloudstackAPI import *
|
||||
from marvin.integration.lib.utils import *
|
||||
from marvin.integration.lib.base import *
|
||||
from marvin.integration.lib.common import *
|
||||
|
||||
|
||||
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",
|
||||
},
|
||||
"service_offering": {
|
||||
"name": "Tiny Instance",
|
||||
"displaytext": "Tiny Instance",
|
||||
"cpunumber": 1,
|
||||
"cpuspeed": 100,
|
||||
"memory": 128,
|
||||
},
|
||||
"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.api_client = super(
|
||||
TestVPCHostMaintenance,
|
||||
cls
|
||||
).getClsTestClient().getApiClient()
|
||||
cls.services = Services().services
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client, cls.services)
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
cls.template = get_template(
|
||||
cls.api_client,
|
||||
cls.zone.id,
|
||||
cls.services["ostype"]
|
||||
)
|
||||
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
|
||||
cls.services["virtual_machine"]["template"] = cls.template.id
|
||||
cls.services["mode"] = cls.zone.networktype
|
||||
|
||||
cls.service_offering = ServiceOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["service_offering"]
|
||||
)
|
||||
cls.vpc_off = VpcOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["vpc_offering"]
|
||||
)
|
||||
cls.vpc_off.update(cls.api_client, state='Enabled')
|
||||
hosts = Host.list(
|
||||
cls.api_client,
|
||||
zoneid=cls.zone.id,
|
||||
listall=True,
|
||||
type='Routing'
|
||||
)
|
||||
|
||||
if isinstance(hosts, list):
|
||||
for host in hosts:
|
||||
Host.enableMaintenance(
|
||||
cls.api_client,
|
||||
id=host.id
|
||||
)
|
||||
|
||||
timeout = cls.services["timeout"]
|
||||
while True:
|
||||
time.sleep(cls.services["sleep"])
|
||||
hosts_states = Host.list(
|
||||
cls.api_client,
|
||||
id=host.id,
|
||||
listall=True
|
||||
)
|
||||
if hosts_states[0].resourcestate == 'PrepareForMaintenance':
|
||||
# Wait for sometimetill host goes in maintenance state
|
||||
time.sleep(cls.services["sleep"])
|
||||
elif hosts_states[0].resourcestate == 'Maintenance':
|
||||
time.sleep(cls.services["sleep"])
|
||||
break
|
||||
elif timeout == 0:
|
||||
raise unittest.SkipTest(
|
||||
"Failed to enable maintenance mode on %s" % host.name)
|
||||
timeout = timeout - 1
|
||||
|
||||
cls._cleanup = [
|
||||
cls.service_offering,
|
||||
cls.vpc_off
|
||||
]
|
||||
return
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
try:
|
||||
#Cleanup resources used
|
||||
cleanup_resources(cls.api_client, cls._cleanup)
|
||||
hosts = Host.list(
|
||||
cls.api_client,
|
||||
zoneid=cls.zone.id,
|
||||
listall=True,
|
||||
type='Routing'
|
||||
)
|
||||
if isinstance(hosts, list):
|
||||
for host in hosts:
|
||||
Host.cancelMaintenance(
|
||||
cls.api_client,
|
||||
id=host.id
|
||||
)
|
||||
hosts_states = Host.list(
|
||||
cls.api_client,
|
||||
id=host.id,
|
||||
listall=True
|
||||
)
|
||||
if hosts_states[0].resourcestate != 'Enabled':
|
||||
raise Exception(
|
||||
"Failed to cancel maintenance mode on %s" % (host.name))
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
def setUp(self):
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
self.account = Account.create(
|
||||
self.apiclient,
|
||||
self.services["account"],
|
||||
admin=True,
|
||||
domainid=self.domain.id
|
||||
)
|
||||
self.cleanup = [self.account]
|
||||
return
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
#Clean up, terminate the created network offerings
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
interval = list_configurations(
|
||||
self.apiclient,
|
||||
name='network.gc.interval'
|
||||
)
|
||||
wait = list_configurations(
|
||||
self.apiclient,
|
||||
name='network.gc.wait'
|
||||
)
|
||||
# Sleep to ensure that all resources are deleted
|
||||
time.sleep(int(interval[0].value) + int(wait[0].value))
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
def validate_vpc_offering(self, vpc_offering):
|
||||
"""Validates the VPC offering"""
|
||||
|
||||
self.debug("Check if the VPC offering is created successfully?")
|
||||
vpc_offs = VpcOffering.list(
|
||||
self.apiclient,
|
||||
id=vpc_offering.id
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vpc_offs, list),
|
||||
True,
|
||||
"List VPC offerings should return a valid list"
|
||||
)
|
||||
self.assertEqual(
|
||||
vpc_offering.name,
|
||||
vpc_offs[0].name,
|
||||
"Name of the VPC offering should match with listVPCOff data"
|
||||
)
|
||||
self.debug(
|
||||
"VPC offering is created successfully - %s" %
|
||||
vpc_offering.name)
|
||||
return
|
||||
|
||||
def validate_vpc_network(self, network, state=None):
|
||||
"""Validates the VPC network"""
|
||||
|
||||
self.debug("Check if the VPC network is created successfully?")
|
||||
vpc_networks = VPC.list(
|
||||
self.apiclient,
|
||||
id=network.id
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vpc_networks, list),
|
||||
True,
|
||||
"List VPC network should return a valid list"
|
||||
)
|
||||
self.assertEqual(
|
||||
network.name,
|
||||
vpc_networks[0].name,
|
||||
"Name of the VPC network should match with listVPC data"
|
||||
)
|
||||
if state:
|
||||
self.assertEqual(
|
||||
vpc_networks[0].state,
|
||||
state,
|
||||
"VPC state should be '%s'" % state
|
||||
)
|
||||
self.debug("VPC network validated - %s" % network.name)
|
||||
return
|
||||
|
||||
@attr(tags=["advanced", "intervlan"])
|
||||
def test_01_create_vpc_host_maintenance(self):
|
||||
""" Test VPC when host is in maintenance mode
|
||||
"""
|
||||
|
||||
# Validate the following
|
||||
# 1. Put the host in maintenance mode.
|
||||
# 2. Attempt to Create a VPC with cidr - 10.1.1.1/16
|
||||
# 3. VPC will be created but will be in "Disabled" state
|
||||
|
||||
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
|
||||
)
|
||||
self.validate_vpc_network(vpc, state='Disabled')
|
||||
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
|
||||
)
|
||||
self.validate_vpc_network(vpc, state='Disabled')
|
||||
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"
|
||||
)
|
||||
return
|
||||
@ -18,16 +18,12 @@
|
||||
""" Component tests for VPC functionality
|
||||
"""
|
||||
#Import Local Modules
|
||||
import marvin
|
||||
import unittest
|
||||
from nose.plugins.attrib import attr
|
||||
from marvin.cloudstackTestCase import *
|
||||
from marvin.cloudstackAPI import *
|
||||
from marvin.integration.lib.utils import *
|
||||
from marvin.integration.lib.base import *
|
||||
from marvin.integration.lib.common import *
|
||||
from marvin.remoteSSHClient import remoteSSHClient
|
||||
import datetime
|
||||
|
||||
|
||||
class Services:
|
||||
@ -331,7 +327,7 @@ class TestVPC(cloudstackTestCase):
|
||||
|
||||
@attr(tags=["advanced", "intervlan"])
|
||||
def test_02_restart_vpc_with_networks(self):
|
||||
""" Test restart VPC having with networks
|
||||
""" Test restart VPC having networks
|
||||
"""
|
||||
|
||||
# Validate the following
|
||||
@ -2474,250 +2470,4 @@ class TestVPC(cloudstackTestCase):
|
||||
"Updation of VPC display text failed.")
|
||||
|
||||
|
||||
class TestVPCHostMaintenance(cloudstackTestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.api_client = super(
|
||||
TestVPCHostMaintenance,
|
||||
cls
|
||||
).getClsTestClient().getApiClient()
|
||||
cls.services = Services().services
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client, cls.services)
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
cls.template = get_template(
|
||||
cls.api_client,
|
||||
cls.zone.id,
|
||||
cls.services["ostype"]
|
||||
)
|
||||
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
|
||||
cls.services["virtual_machine"]["template"] = cls.template.id
|
||||
|
||||
cls.service_offering = ServiceOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["service_offering"]
|
||||
)
|
||||
cls.vpc_off = VpcOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["vpc_offering"]
|
||||
)
|
||||
cls.vpc_off.update(cls.api_client, state='Enabled')
|
||||
hosts = Host.list(
|
||||
cls.api_client,
|
||||
zoneid=cls.zone.id,
|
||||
listall=True,
|
||||
type='Routing'
|
||||
)
|
||||
|
||||
if isinstance(hosts, list):
|
||||
for host in hosts:
|
||||
Host.enableMaintenance(
|
||||
cls.api_client,
|
||||
id=host.id
|
||||
)
|
||||
|
||||
timeout = cls.services["timeout"]
|
||||
while True:
|
||||
time.sleep(cls.services["sleep"])
|
||||
hosts_states = Host.list(
|
||||
cls.api_client,
|
||||
id=host.id,
|
||||
listall=True
|
||||
)
|
||||
if hosts_states[0].resourcestate == 'PrepareForMaintenance':
|
||||
# Wait for sometimetill host goes in maintenance state
|
||||
time.sleep(cls.services["sleep"])
|
||||
elif hosts_states[0].resourcestate == 'Maintenance':
|
||||
time.sleep(cls.services["sleep"])
|
||||
break
|
||||
elif timeout == 0:
|
||||
raise unittest.SkipTest(
|
||||
"Failed to enable maintenance mode on %s" % host.name)
|
||||
timeout = timeout - 1
|
||||
|
||||
cls._cleanup = [
|
||||
cls.service_offering,
|
||||
cls.vpc_off
|
||||
]
|
||||
return
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
try:
|
||||
#Cleanup resources used
|
||||
cleanup_resources(cls.api_client, cls._cleanup)
|
||||
hosts = Host.list(
|
||||
cls.api_client,
|
||||
zoneid=cls.zone.id,
|
||||
listall=True,
|
||||
type='Routing'
|
||||
)
|
||||
if isinstance(hosts, list):
|
||||
for host in hosts:
|
||||
Host.cancelMaintenance(
|
||||
cls.api_client,
|
||||
id=host.id
|
||||
)
|
||||
hosts_states = Host.list(
|
||||
cls.api_client,
|
||||
id=host.id,
|
||||
listall=True
|
||||
)
|
||||
if hosts_states[0].resourcestate != 'Enabled':
|
||||
raise Exception(
|
||||
"Failed to cancel maintenance mode on %s" % (host.name))
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
def setUp(self):
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
self.account = Account.create(
|
||||
self.apiclient,
|
||||
self.services["account"],
|
||||
admin=True,
|
||||
domainid=self.domain.id
|
||||
)
|
||||
self.cleanup = [self.account]
|
||||
return
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
#Clean up, terminate the created network offerings
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
interval = list_configurations(
|
||||
self.apiclient,
|
||||
name='network.gc.interval'
|
||||
)
|
||||
wait = list_configurations(
|
||||
self.apiclient,
|
||||
name='network.gc.wait'
|
||||
)
|
||||
# Sleep to ensure that all resources are deleted
|
||||
time.sleep(int(interval[0].value) + int(wait[0].value))
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
def validate_vpc_offering(self, vpc_offering):
|
||||
"""Validates the VPC offering"""
|
||||
|
||||
self.debug("Check if the VPC offering is created successfully?")
|
||||
vpc_offs = VpcOffering.list(
|
||||
self.apiclient,
|
||||
id=vpc_offering.id
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vpc_offs, list),
|
||||
True,
|
||||
"List VPC offerings should return a valid list"
|
||||
)
|
||||
self.assertEqual(
|
||||
vpc_offering.name,
|
||||
vpc_offs[0].name,
|
||||
"Name of the VPC offering should match with listVPCOff data"
|
||||
)
|
||||
self.debug(
|
||||
"VPC offering is created successfully - %s" %
|
||||
vpc_offering.name)
|
||||
return
|
||||
|
||||
def validate_vpc_network(self, network, state=None):
|
||||
"""Validates the VPC network"""
|
||||
|
||||
self.debug("Check if the VPC network is created successfully?")
|
||||
vpc_networks = VPC.list(
|
||||
self.apiclient,
|
||||
id=network.id
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vpc_networks, list),
|
||||
True,
|
||||
"List VPC network should return a valid list"
|
||||
)
|
||||
self.assertEqual(
|
||||
network.name,
|
||||
vpc_networks[0].name,
|
||||
"Name of the VPC network should match with listVPC data"
|
||||
)
|
||||
if state:
|
||||
self.assertEqual(
|
||||
vpc_networks[0].state,
|
||||
state,
|
||||
"VPC state should be '%s'" % state
|
||||
)
|
||||
self.debug("VPC network validated - %s" % network.name)
|
||||
return
|
||||
|
||||
@attr(tags=["advanced", "intervlan"])
|
||||
def test_01_create_vpc_host_maintenance(self):
|
||||
""" Test VPC when host is in maintenance mode
|
||||
"""
|
||||
|
||||
# Validate the following
|
||||
# 1. Put the host in maintenance mode.
|
||||
# 2. Attempt to Create a VPC with cidr - 10.1.1.1/16
|
||||
# 3. VPC will be created but will be in "Disabled" state
|
||||
|
||||
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
|
||||
)
|
||||
self.validate_vpc_network(vpc, state='Disabled')
|
||||
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
|
||||
)
|
||||
self.validate_vpc_network(vpc, state='Disabled')
|
||||
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"
|
||||
)
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user