mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-8062: test_multiple_ip_ranges.py - Fix the test case to avoid using same vlan IP range in each test case
Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>
This commit is contained in:
parent
d773eee39c
commit
b45fe24e5c
@ -16,103 +16,35 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
""" Tests for Multiple IP Ranges feature
|
""" Tests for Multiple IP Ranges feature
|
||||||
"""
|
"""
|
||||||
from marvin.cloudstackTestCase import *
|
from marvin.cloudstackTestCase import cloudstackTestCase
|
||||||
from marvin.cloudstackAPI import *
|
|
||||||
from marvin.cloudstackException import CloudstackAPIException
|
from marvin.cloudstackException import CloudstackAPIException
|
||||||
from marvin.lib.utils import *
|
from marvin.lib.utils import cleanup_resources
|
||||||
from marvin.lib.base import *
|
from marvin.lib.base import (PublicIpRange)
|
||||||
from marvin.lib.common import *
|
from marvin.lib.common import (get_domain,
|
||||||
from netaddr import *
|
get_zone,
|
||||||
|
get_pod)
|
||||||
|
from netaddr import IPAddress, IPNetwork
|
||||||
|
import random
|
||||||
from nose.plugins.attrib import attr
|
from nose.plugins.attrib import attr
|
||||||
|
|
||||||
class Services:
|
|
||||||
"""Test Multiple IP Ranges
|
|
||||||
"""
|
|
||||||
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": 200, # in MHz
|
|
||||||
"memory": 256, # In MBs
|
|
||||||
},
|
|
||||||
"disk_offering": {
|
|
||||||
"displaytext": "Small Disk",
|
|
||||||
"name": "Small Disk",
|
|
||||||
"disksize": 1
|
|
||||||
},
|
|
||||||
"templates": {
|
|
||||||
"displaytext": 'Template',
|
|
||||||
"name": 'Template',
|
|
||||||
"ostype": "CentOS 5.3 (64-bit)",
|
|
||||||
"templatefilter": 'self',
|
|
||||||
},
|
|
||||||
"vlan_ip_range": {
|
|
||||||
"startip": "",
|
|
||||||
"endip": "",
|
|
||||||
"netmask": "",
|
|
||||||
"gateway": "",
|
|
||||||
"forvirtualnetwork": "false",
|
|
||||||
"vlan": "untagged",
|
|
||||||
},
|
|
||||||
"ostype": "CentOS 5.3 (64-bit)",
|
|
||||||
"sleep": 60,
|
|
||||||
"timeout": 10,
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestMultipleIpRanges(cloudstackTestCase):
|
class TestMultipleIpRanges(cloudstackTestCase):
|
||||||
|
|
||||||
"""Test Multiple IP Ranges for guest network
|
"""Test Multiple IP Ranges for guest network
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
cls.testClient = super(TestMultipleIpRanges, cls).getClsTestClient()
|
cls.testClient = super(TestMultipleIpRanges, cls).getClsTestClient()
|
||||||
cls.api_client = cls.testClient.getApiClient()
|
cls.api_client = cls.testClient.getApiClient()
|
||||||
|
|
||||||
cls.services = Services().services
|
cls.services = cls.testClient.getParsedTestDataConfig()
|
||||||
# Get Zone, Domain and templates
|
# Get Zone, Domain and templates
|
||||||
cls.domain = get_domain(cls.api_client)
|
cls.domain = get_domain(cls.api_client)
|
||||||
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
|
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
|
||||||
cls.pod = get_pod(cls.api_client, cls.zone.id)
|
cls.pod = get_pod(cls.api_client, cls.zone.id)
|
||||||
cls.services['mode'] = cls.zone.networktype
|
|
||||||
cls.services["domainid"] = cls.domain.id
|
|
||||||
cls.services["zoneid"] = cls.zone.id
|
cls.services["zoneid"] = cls.zone.id
|
||||||
cls.account = Account.create(
|
cls._cleanup = []
|
||||||
cls.api_client,
|
|
||||||
cls.services["account"],
|
|
||||||
domainid=cls.domain.id
|
|
||||||
)
|
|
||||||
cls.services["account"] = cls.account.name
|
|
||||||
cls.disk_offering = DiskOffering.create(
|
|
||||||
cls.api_client,
|
|
||||||
cls.services["disk_offering"]
|
|
||||||
)
|
|
||||||
cls.service_offering = ServiceOffering.create(
|
|
||||||
cls.api_client,
|
|
||||||
cls.services["service_offering"]
|
|
||||||
)
|
|
||||||
cls.template = get_template(
|
|
||||||
cls.api_client,
|
|
||||||
cls.zone.id,
|
|
||||||
cls.services["ostype"]
|
|
||||||
)
|
|
||||||
cls.services["templates"]["ostypeid"] = cls.template.ostypeid
|
|
||||||
cls.services["diskoffering"] = cls.disk_offering.id
|
|
||||||
cls._cleanup = [
|
|
||||||
cls.account,
|
|
||||||
]
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -148,7 +80,10 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
self.netmask = publicIpRange[0].netmask
|
self.netmask = publicIpRange[0].netmask
|
||||||
# Pass ip address and mask length to IPNetwork to findout the CIDR
|
# Pass ip address and mask length to IPNetwork to findout the CIDR
|
||||||
ip = IPNetwork(self.startIp + "/" + self.netmask)
|
ip = IPNetwork(self.startIp + "/" + self.netmask)
|
||||||
new_cidr = ip.__iadd__(1)
|
# Take random increment factor to avoid adding the same vlan ip range
|
||||||
|
# in each test case
|
||||||
|
networkIncrementFactor = random.randint(1,255)
|
||||||
|
new_cidr = ip.__iadd__(networkIncrementFactor)
|
||||||
ip2 = IPNetwork(new_cidr)
|
ip2 = IPNetwork(new_cidr)
|
||||||
return ip2
|
return ip2
|
||||||
|
|
||||||
@ -167,22 +102,26 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
str(vlan[0].startip),
|
str(vlan[0].startip),
|
||||||
str(services["startip"]),
|
str(services["startip"]),
|
||||||
"Start IP in vlan ip range is not matched with the configured start ip"
|
"Start IP in vlan ip range is not matched with\
|
||||||
|
the configured start ip"
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
str(vlan[0].endip),
|
str(vlan[0].endip),
|
||||||
str(services["endip"]),
|
str(services["endip"]),
|
||||||
"End IP in vlan ip range is not matched with the configured end ip"
|
"End IP in vlan ip range is not matched with\
|
||||||
|
the configured end ip"
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
str(vlan[0].gateway),
|
str(vlan[0].gateway),
|
||||||
str(services["gateway"]),
|
str(services["gateway"]),
|
||||||
"gateway in vlan ip range is not matched with the configured gateway"
|
"gateway in vlan ip range is not matched with\
|
||||||
|
the configured gateway"
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
str(vlan[0].netmask),
|
str(vlan[0].netmask),
|
||||||
str(services["netmask"]),
|
str(services["netmask"]),
|
||||||
"netmask in vlan ip range is not matched with the configured netmask"
|
"netmask in vlan ip range is not matched with\
|
||||||
|
the configured netmask"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -190,7 +129,8 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
def test_01_add_ip_same_cidr(self):
|
def test_01_add_ip_same_cidr(self):
|
||||||
"""Test add guest ip range in the existing cidr
|
"""Test add guest ip range in the existing cidr
|
||||||
"""
|
"""
|
||||||
#call increment_cidr function to get exiting cidr from the setup and increment it
|
# call increment_cidr function to get exiting cidr from the setup and
|
||||||
|
# increment it
|
||||||
ip2 = self.increment_cidr()
|
ip2 = self.increment_cidr()
|
||||||
test_nw = ip2.network
|
test_nw = ip2.network
|
||||||
ip = IPAddress(test_nw)
|
ip = IPAddress(test_nw)
|
||||||
@ -209,8 +149,12 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
self.services["vlan_ip_range"]["podid"] = self.pod.id
|
self.services["vlan_ip_range"]["podid"] = self.pod.id
|
||||||
# create new vlan ip range
|
# create new vlan ip range
|
||||||
self.debug("Creating new ip range with new cidr in the same vlan")
|
self.debug("Creating new ip range with new cidr in the same vlan")
|
||||||
new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
|
new_vlan = PublicIpRange.create(
|
||||||
self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp))
|
self.apiclient,
|
||||||
|
self.services["vlan_ip_range"])
|
||||||
|
self.debug(
|
||||||
|
"Created new vlan range with startip:%s and endip:%s" %
|
||||||
|
(test_startIp, test_endIp))
|
||||||
self.cleanup.append(new_vlan)
|
self.cleanup.append(new_vlan)
|
||||||
new_vlan_res = new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
new_vlan_res = new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
||||||
# Compare list output with configured values
|
# Compare list output with configured values
|
||||||
@ -219,8 +163,12 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
self.services["vlan_ip_range"]["startip"] = test_startIp2
|
self.services["vlan_ip_range"]["startip"] = test_startIp2
|
||||||
self.services["vlan_ip_range"]["endip"] = test_endIp2
|
self.services["vlan_ip_range"]["endip"] = test_endIp2
|
||||||
self.debug("Creating new ip range in the existing CIDR")
|
self.debug("Creating new ip range in the existing CIDR")
|
||||||
new_vlan2 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
|
new_vlan2 = PublicIpRange.create(
|
||||||
self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp2,test_endIp2))
|
self.apiclient,
|
||||||
|
self.services["vlan_ip_range"])
|
||||||
|
self.debug(
|
||||||
|
"Created new vlan range with startip:%s and endip:%s" %
|
||||||
|
(test_startIp2, test_endIp2))
|
||||||
self.cleanup.append(new_vlan2)
|
self.cleanup.append(new_vlan2)
|
||||||
# list new vlan ip range
|
# list new vlan ip range
|
||||||
new_vlan2_res = new_vlan2.list(self.apiclient, id=new_vlan2.vlan.id)
|
new_vlan2_res = new_vlan2.list(self.apiclient, id=new_vlan2.vlan.id)
|
||||||
@ -236,7 +184,8 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
1.Get public vlan range (guest cidr) from the setup
|
1.Get public vlan range (guest cidr) from the setup
|
||||||
2.Add IP range to a new cidr
|
2.Add IP range to a new cidr
|
||||||
"""
|
"""
|
||||||
#call increment_cidr function to get exiting cidr from the setup and increment it
|
# call increment_cidr function to get exiting cidr from the setup and
|
||||||
|
# increment it
|
||||||
ip2 = self.increment_cidr()
|
ip2 = self.increment_cidr()
|
||||||
test_nw = ip2.network
|
test_nw = ip2.network
|
||||||
ip = IPAddress(test_nw)
|
ip = IPAddress(test_nw)
|
||||||
@ -253,8 +202,12 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
self.services["vlan_ip_range"]["podid"] = self.pod.id
|
self.services["vlan_ip_range"]["podid"] = self.pod.id
|
||||||
# create new vlan ip range
|
# create new vlan ip range
|
||||||
self.debug("Adding new ip range in different CIDR in same vlan")
|
self.debug("Adding new ip range in different CIDR in same vlan")
|
||||||
new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
|
new_vlan = PublicIpRange.create(
|
||||||
self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp))
|
self.apiclient,
|
||||||
|
self.services["vlan_ip_range"])
|
||||||
|
self.debug(
|
||||||
|
"Created new vlan range with startip:%s and endip:%s" %
|
||||||
|
(test_startIp, test_endIp))
|
||||||
self.cleanup.append(new_vlan)
|
self.cleanup.append(new_vlan)
|
||||||
new_vlan_res = new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
new_vlan_res = new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
||||||
# Compare list output with configured values
|
# Compare list output with configured values
|
||||||
@ -270,7 +223,8 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
2.delete the ip range added at step1
|
2.delete the ip range added at step1
|
||||||
3.Verify the ip range deletion using list APIs
|
3.Verify the ip range deletion using list APIs
|
||||||
"""
|
"""
|
||||||
#call increment_cidr function to get exiting cidr from the setup and increment it
|
# call increment_cidr function to get exiting cidr from the setup and
|
||||||
|
# increment it
|
||||||
ip2 = self.increment_cidr()
|
ip2 = self.increment_cidr()
|
||||||
test_nw = ip2.network
|
test_nw = ip2.network
|
||||||
ip = IPAddress(test_nw)
|
ip = IPAddress(test_nw)
|
||||||
@ -287,20 +241,27 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
self.services["vlan_ip_range"]["podid"] = self.pod.id
|
self.services["vlan_ip_range"]["podid"] = self.pod.id
|
||||||
# create new vlan ip range
|
# create new vlan ip range
|
||||||
self.debug("Creating new ip range in the new cidr")
|
self.debug("Creating new ip range in the new cidr")
|
||||||
new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
|
new_vlan = PublicIpRange.create(
|
||||||
self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp))
|
self.apiclient,
|
||||||
|
self.services["vlan_ip_range"])
|
||||||
|
self.debug(
|
||||||
|
"Created new vlan range with startip:%s and endip:%s" %
|
||||||
|
(test_startIp, test_endIp))
|
||||||
new_vlan_res = new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
new_vlan_res = new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
||||||
# Compare list output with configured values
|
# Compare list output with configured values
|
||||||
self.verify_vlan_range(new_vlan_res, self.services["vlan_ip_range"])
|
self.verify_vlan_range(new_vlan_res, self.services["vlan_ip_range"])
|
||||||
# Delete the above IP range
|
# Delete the above IP range
|
||||||
self.debug("Deleting new ip range added in new cidr")
|
self.debug("Deleting new ip range added in new cidr")
|
||||||
new_vlan.delete(self.apiclient)
|
new_vlan.delete(self.apiclient)
|
||||||
#listing vlan ip ranges with the id should through exception , if not mark the test case as failed
|
# listing vlan ip ranges with the id should through exception , if not
|
||||||
|
# mark the test case as failed
|
||||||
try:
|
try:
|
||||||
new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
||||||
except CloudstackAPIException as cs:
|
except CloudstackAPIException as cs:
|
||||||
self.debug(cs.errorMsg)
|
self.debug(cs.errorMsg)
|
||||||
self.assertTrue(cs.errorMsg.find("entity does not exist")>0, msg="Failed to delete IP range")
|
self.assertTrue(
|
||||||
|
cs.errorMsg.find("entity does not exist") > 0,
|
||||||
|
msg="Failed to delete IP range")
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags=["sg"])
|
@attr(tags=["sg"])
|
||||||
@ -311,7 +272,8 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
1.Add non-contigous ip range in cidr added at step1
|
1.Add non-contigous ip range in cidr added at step1
|
||||||
2.Verify the ip range using list APIs
|
2.Verify the ip range using list APIs
|
||||||
"""
|
"""
|
||||||
#call increment_cidr function to get exiting cidr from the setup and increment it
|
# call increment_cidr function to get exiting cidr from the setup and
|
||||||
|
# increment it
|
||||||
ip2 = self.increment_cidr()
|
ip2 = self.increment_cidr()
|
||||||
test_nw = ip2.network
|
test_nw = ip2.network
|
||||||
ip = IPAddress(test_nw)
|
ip = IPAddress(test_nw)
|
||||||
@ -327,8 +289,12 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
self.services["vlan_ip_range"]["zoneid"] = self.zone.id
|
self.services["vlan_ip_range"]["zoneid"] = self.zone.id
|
||||||
self.services["vlan_ip_range"]["podid"] = self.pod.id
|
self.services["vlan_ip_range"]["podid"] = self.pod.id
|
||||||
# create new vlan ip range
|
# create new vlan ip range
|
||||||
new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
|
new_vlan = PublicIpRange.create(
|
||||||
self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp))
|
self.apiclient,
|
||||||
|
self.services["vlan_ip_range"])
|
||||||
|
self.debug(
|
||||||
|
"Created new vlan range with startip:%s and endip:%s" %
|
||||||
|
(test_startIp, test_endIp))
|
||||||
self.cleanup.append(new_vlan)
|
self.cleanup.append(new_vlan)
|
||||||
new_vlan_res = new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
new_vlan_res = new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
||||||
# Compare list output with configured values
|
# Compare list output with configured values
|
||||||
@ -341,8 +307,12 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
self.services["vlan_ip_range"]["endip"] = test_endIp2
|
self.services["vlan_ip_range"]["endip"] = test_endIp2
|
||||||
# create new vlan ip range
|
# create new vlan ip range
|
||||||
self.debug("Adding non contiguous ip range")
|
self.debug("Adding non contiguous ip range")
|
||||||
new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
|
new_vlan = PublicIpRange.create(
|
||||||
self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp))
|
self.apiclient,
|
||||||
|
self.services["vlan_ip_range"])
|
||||||
|
self.debug(
|
||||||
|
"Created new vlan range with startip:%s and endip:%s" %
|
||||||
|
(test_startIp, test_endIp))
|
||||||
self.cleanup.append(new_vlan)
|
self.cleanup.append(new_vlan)
|
||||||
new_vlan_res = new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
new_vlan_res = new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
||||||
# Compare list output with configured values
|
# Compare list output with configured values
|
||||||
@ -354,9 +324,11 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
"""Test adding overlapped ip range in existing cidr
|
"""Test adding overlapped ip range in existing cidr
|
||||||
|
|
||||||
1.Add ip range in new cidr e.g:10.147.40.10-10.147.40.100
|
1.Add ip range in new cidr e.g:10.147.40.10-10.147.40.100
|
||||||
2.Add ip range overlapped with the ip range in step1 e.g.10.147.40.90-150
|
2.Add ip range overlapped with the ip range in
|
||||||
|
step1 e.g.10.147.40.90-150
|
||||||
"""
|
"""
|
||||||
#call increment_cidr function to get exiting cidr from the setup and increment it
|
# call increment_cidr function to get exiting cidr from the setup and
|
||||||
|
# increment it
|
||||||
ip2 = self.increment_cidr()
|
ip2 = self.increment_cidr()
|
||||||
test_nw = ip2.network
|
test_nw = ip2.network
|
||||||
ip = IPAddress(test_nw)
|
ip = IPAddress(test_nw)
|
||||||
@ -374,9 +346,16 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
self.services["vlan_ip_range"]["zoneid"] = self.zone.id
|
self.services["vlan_ip_range"]["zoneid"] = self.zone.id
|
||||||
self.services["vlan_ip_range"]["podid"] = self.pod.id
|
self.services["vlan_ip_range"]["podid"] = self.pod.id
|
||||||
# create new vlan ip range
|
# create new vlan ip range
|
||||||
self.debug("Creating new ip range with startip:%s and endip: %s".format(test_startIp,test_endIp))
|
self.debug(
|
||||||
new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
|
"Creating new ip range with startip:%s and endip: %s".format(
|
||||||
self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp))
|
test_startIp,
|
||||||
|
test_endIp))
|
||||||
|
new_vlan = PublicIpRange.create(
|
||||||
|
self.apiclient,
|
||||||
|
self.services["vlan_ip_range"])
|
||||||
|
self.debug(
|
||||||
|
"Created new vlan range with startip:%s and endip:%s" %
|
||||||
|
(test_startIp, test_endIp))
|
||||||
self.cleanup.append(new_vlan)
|
self.cleanup.append(new_vlan)
|
||||||
new_vlan_res = new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
new_vlan_res = new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
||||||
# Compare list output with configured values
|
# Compare list output with configured values
|
||||||
@ -388,14 +367,21 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
# Try to create ip range overlapped with exiting ip range
|
# Try to create ip range overlapped with exiting ip range
|
||||||
self.debug("Adding overlapped ip range")
|
self.debug("Adding overlapped ip range")
|
||||||
try:
|
try:
|
||||||
new_vlan2 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
|
new_vlan2 = PublicIpRange.create(
|
||||||
|
self.apiclient,
|
||||||
|
self.services["vlan_ip_range"])
|
||||||
except CloudstackAPIException as cs:
|
except CloudstackAPIException as cs:
|
||||||
self.debug(cs.errorMsg)
|
self.debug(cs.errorMsg)
|
||||||
self.assertTrue(cs.errorMsg.find("already has IPs that overlap with the new range")>0, msg="Fail:CS allowed adding overlapped ip ranges in guest cidr")
|
self.assertTrue(
|
||||||
|
cs.errorMsg.find("already has IPs that overlap with the new range") > 0,
|
||||||
|
msg="Fail:CS allowed adding overlapped ip\
|
||||||
|
ranges in guest cidr")
|
||||||
return
|
return
|
||||||
# Test will reach here if there is a bug in overlap ip range checking
|
# Test will reach here if there is a bug in overlap ip range checking
|
||||||
self.cleanup.append(new_vlan2)
|
self.cleanup.append(new_vlan2)
|
||||||
self.fail("CS should not accept overlapped ip ranges in guest traffic, but it allowed")
|
self.fail(
|
||||||
|
"CS should not accept overlapped ip ranges in\
|
||||||
|
guest traffic, but it allowed")
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags=["sg"])
|
@attr(tags=["sg"])
|
||||||
@ -403,10 +389,13 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
"""Test adding overlapped ip range with two existing cidr
|
"""Test adding overlapped ip range with two existing cidr
|
||||||
|
|
||||||
1.Add ip range in new cidr e.g:10.147.40.2-10.147.40.10
|
1.Add ip range in new cidr e.g:10.147.40.2-10.147.40.10
|
||||||
2.Add another ip range in the same cidr e.g:10.147.40.20-10.147.40.30
|
2.Add another ip range in the same cidr
|
||||||
2.Add ip range overlapped with both the ip ranges e.g.10.147.40.10-20
|
e.g:10.147.40.20-10.147.40.30
|
||||||
|
3.Add ip range overlapped with both the ip ranges
|
||||||
|
e.g.10.147.40.10-20
|
||||||
"""
|
"""
|
||||||
#call increment_cidr function to get exiting cidr from the setup and increment it
|
# call increment_cidr function to get exiting cidr from the setup and
|
||||||
|
# increment it
|
||||||
ip2 = self.increment_cidr()
|
ip2 = self.increment_cidr()
|
||||||
test_nw = ip2.network
|
test_nw = ip2.network
|
||||||
ip = IPAddress(test_nw)
|
ip = IPAddress(test_nw)
|
||||||
@ -426,8 +415,12 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
self.services["vlan_ip_range"]["zoneid"] = self.zone.id
|
self.services["vlan_ip_range"]["zoneid"] = self.zone.id
|
||||||
self.services["vlan_ip_range"]["podid"] = self.pod.id
|
self.services["vlan_ip_range"]["podid"] = self.pod.id
|
||||||
# create new vlan ip range
|
# create new vlan ip range
|
||||||
new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
|
new_vlan = PublicIpRange.create(
|
||||||
self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp))
|
self.apiclient,
|
||||||
|
self.services["vlan_ip_range"])
|
||||||
|
self.debug(
|
||||||
|
"Created new vlan range with startip:%s and endip:%s" %
|
||||||
|
(test_startIp, test_endIp))
|
||||||
self.cleanup.append(new_vlan)
|
self.cleanup.append(new_vlan)
|
||||||
new_vlan_res = new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
new_vlan_res = new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
||||||
# Compare list output with configured values
|
# Compare list output with configured values
|
||||||
@ -435,8 +428,12 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
# Add 2nd IP range in the same CIDR
|
# Add 2nd IP range in the same CIDR
|
||||||
self.services["vlan_ip_range"]["startip"] = test_startIp2
|
self.services["vlan_ip_range"]["startip"] = test_startIp2
|
||||||
self.services["vlan_ip_range"]["endip"] = test_endIp2
|
self.services["vlan_ip_range"]["endip"] = test_endIp2
|
||||||
new_vlan2 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
|
new_vlan2 = PublicIpRange.create(
|
||||||
self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp2,test_endIp2))
|
self.apiclient,
|
||||||
|
self.services["vlan_ip_range"])
|
||||||
|
self.debug(
|
||||||
|
"Created new vlan range with startip:%s and endip:%s" %
|
||||||
|
(test_startIp2, test_endIp2))
|
||||||
self.cleanup.append(new_vlan2)
|
self.cleanup.append(new_vlan2)
|
||||||
# Populating services with new IP range
|
# Populating services with new IP range
|
||||||
self.services["vlan_ip_range"]["startip"] = test_startIp3
|
self.services["vlan_ip_range"]["startip"] = test_startIp3
|
||||||
@ -444,14 +441,21 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
# Try to create ip range overlapped with exiting ip range
|
# Try to create ip range overlapped with exiting ip range
|
||||||
self.debug("Adding ip range overlapped with two cidrs")
|
self.debug("Adding ip range overlapped with two cidrs")
|
||||||
try:
|
try:
|
||||||
new_vlan3 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
|
new_vlan3 = PublicIpRange.create(
|
||||||
|
self.apiclient,
|
||||||
|
self.services["vlan_ip_range"])
|
||||||
except CloudstackAPIException as cs:
|
except CloudstackAPIException as cs:
|
||||||
self.debug(cs.errorMsg)
|
self.debug(cs.errorMsg)
|
||||||
self.assertTrue(cs.errorMsg.find("already has IPs that overlap with the new range")>0, msg="Fail:CS allowed adding overlapped ip ranges in guest cidr")
|
self.assertTrue(
|
||||||
|
cs.errorMsg.find("already has IPs that overlap with the new range") > 0,
|
||||||
|
msg="Fail:CS allowed adding overlapped ip\
|
||||||
|
ranges in guest cidr")
|
||||||
return
|
return
|
||||||
# Test will reach here if there is a bug in overlap ip range checking
|
# Test will reach here if there is a bug in overlap ip range checking
|
||||||
self.cleanup.append(new_vlan3)
|
self.cleanup.append(new_vlan3)
|
||||||
self.fail("CS should not accept overlapped ip ranges in guest traffic, but it allowed")
|
self.fail(
|
||||||
|
"CS should not accept overlapped ip ranges in guest\
|
||||||
|
traffic, but it allowed")
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags=["sg"])
|
@attr(tags=["sg"])
|
||||||
@ -461,7 +465,8 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
1.Add IP range in new CIDR
|
1.Add IP range in new CIDR
|
||||||
2.Try to add ip range superset to CIDR added in step1
|
2.Try to add ip range superset to CIDR added in step1
|
||||||
"""
|
"""
|
||||||
#call increment_cidr function to get exiting cidr from the setup and increment it
|
# call increment_cidr function to get exiting cidr from the setup and
|
||||||
|
# increment it
|
||||||
ip2 = self.increment_cidr()
|
ip2 = self.increment_cidr()
|
||||||
test_nw = ip2.network
|
test_nw = ip2.network
|
||||||
ip = IPAddress(test_nw)
|
ip = IPAddress(test_nw)
|
||||||
@ -479,8 +484,12 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
self.services["vlan_ip_range"]["zoneid"] = self.zone.id
|
self.services["vlan_ip_range"]["zoneid"] = self.zone.id
|
||||||
self.services["vlan_ip_range"]["podid"] = self.pod.id
|
self.services["vlan_ip_range"]["podid"] = self.pod.id
|
||||||
# create new vlan ip range
|
# create new vlan ip range
|
||||||
new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
|
new_vlan = PublicIpRange.create(
|
||||||
self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp))
|
self.apiclient,
|
||||||
|
self.services["vlan_ip_range"])
|
||||||
|
self.debug(
|
||||||
|
"Created new vlan range with startip:%s and endip:%s" %
|
||||||
|
(test_startIp, test_endIp))
|
||||||
self.cleanup.append(new_vlan)
|
self.cleanup.append(new_vlan)
|
||||||
new_vlan_res = new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
new_vlan_res = new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
||||||
# Compare list output with configured values
|
# Compare list output with configured values
|
||||||
@ -497,14 +506,20 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
self.services["vlan_ip_range"]["endip"] = test_endIp2
|
self.services["vlan_ip_range"]["endip"] = test_endIp2
|
||||||
self.debug("Adding IP range super set to existing CIDR")
|
self.debug("Adding IP range super set to existing CIDR")
|
||||||
try:
|
try:
|
||||||
new_vlan2 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
|
new_vlan2 = PublicIpRange.create(
|
||||||
|
self.apiclient,
|
||||||
|
self.services["vlan_ip_range"])
|
||||||
except CloudstackAPIException as cs:
|
except CloudstackAPIException as cs:
|
||||||
self.debug(cs.errorMsg)
|
self.debug(cs.errorMsg)
|
||||||
self.assertTrue(cs.errorMsg.find("superset")>0, msg="Fail: CS allowed adding ip range superset to existing CIDR")
|
self.assertTrue(
|
||||||
|
cs.errorMsg.find("superset") > 0,
|
||||||
|
msg="Fail: CS allowed adding ip range\
|
||||||
|
superset to existing CIDR")
|
||||||
return
|
return
|
||||||
# Test will reach here if there is a bug in allowing superset ip range
|
# Test will reach here if there is a bug in allowing superset ip range
|
||||||
self.cleanup.append(new_vlan2)
|
self.cleanup.append(new_vlan2)
|
||||||
self.fail("CS should not allow adding ip range superset to existing CIDR")
|
self.fail(
|
||||||
|
"CS should not allow adding ip range superset to existing CIDR")
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags=["sg"])
|
@attr(tags=["sg"])
|
||||||
@ -514,7 +529,8 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
1.Add IP range in new CIDR
|
1.Add IP range in new CIDR
|
||||||
2.Try to add ip range subset to CIDR added in step1
|
2.Try to add ip range subset to CIDR added in step1
|
||||||
"""
|
"""
|
||||||
#call increment_cidr function to get exiting cidr from the setup and increment it
|
# call increment_cidr function to get exiting cidr from the setup and
|
||||||
|
# increment it
|
||||||
ip2 = self.increment_cidr()
|
ip2 = self.increment_cidr()
|
||||||
test_nw = ip2.network
|
test_nw = ip2.network
|
||||||
ip = IPAddress(test_nw)
|
ip = IPAddress(test_nw)
|
||||||
@ -532,8 +548,12 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
self.services["vlan_ip_range"]["zoneid"] = self.zone.id
|
self.services["vlan_ip_range"]["zoneid"] = self.zone.id
|
||||||
self.services["vlan_ip_range"]["podid"] = self.pod.id
|
self.services["vlan_ip_range"]["podid"] = self.pod.id
|
||||||
# create new vlan ip range
|
# create new vlan ip range
|
||||||
new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
|
new_vlan = PublicIpRange.create(
|
||||||
self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp))
|
self.apiclient,
|
||||||
|
self.services["vlan_ip_range"])
|
||||||
|
self.debug(
|
||||||
|
"Created new vlan range with startip:%s and endip:%s" %
|
||||||
|
(test_startIp, test_endIp))
|
||||||
self.cleanup.append(new_vlan)
|
self.cleanup.append(new_vlan)
|
||||||
new_vlan_res = new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
new_vlan_res = new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
|
||||||
# Compare list output with configured values
|
# Compare list output with configured values
|
||||||
@ -550,12 +570,17 @@ class TestMultipleIpRanges(cloudstackTestCase):
|
|||||||
self.services["vlan_ip_range"]["endip"] = test_endIp2
|
self.services["vlan_ip_range"]["endip"] = test_endIp2
|
||||||
self.debug("Adding ip range subset to existing cidr")
|
self.debug("Adding ip range subset to existing cidr")
|
||||||
try:
|
try:
|
||||||
new_vlan2 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
|
new_vlan2 = PublicIpRange.create(
|
||||||
|
self.apiclient,
|
||||||
|
self.services["vlan_ip_range"])
|
||||||
except CloudstackAPIException as cs:
|
except CloudstackAPIException as cs:
|
||||||
self.debug(cs.errorMsg)
|
self.debug(cs.errorMsg)
|
||||||
self.assertTrue(cs.errorMsg.find("subset")>0, msg="Fail: CS allowed adding ip range subset to existing CIDR")
|
self.assertTrue(
|
||||||
|
cs.errorMsg.find("subset") > 0,
|
||||||
|
msg="Fail: CS allowed adding ip range subset to existing CIDR")
|
||||||
return
|
return
|
||||||
# Test will reach here if there is a bug in allowing superset ip range
|
# Test will reach here if there is a bug in allowing superset ip range
|
||||||
self.cleanup.append(new_vlan2)
|
self.cleanup.append(new_vlan2)
|
||||||
self.fail("CS should not allow adding ip range subset to existing CIDR")
|
self.fail(
|
||||||
|
"CS should not allow adding ip range subset to existing CIDR")
|
||||||
return
|
return
|
||||||
|
|||||||
@ -837,6 +837,14 @@ test_data = {
|
|||||||
"epslifetime": "3600",
|
"epslifetime": "3600",
|
||||||
"dpd": "false"
|
"dpd": "false"
|
||||||
},
|
},
|
||||||
|
"vlan_ip_range": {
|
||||||
|
"startip": "",
|
||||||
|
"endip": "",
|
||||||
|
"netmask": "",
|
||||||
|
"gateway": "",
|
||||||
|
"forvirtualnetwork": "false",
|
||||||
|
"vlan": "untagged",
|
||||||
|
},
|
||||||
"ostype": "CentOS 5.6 (64-bit)",
|
"ostype": "CentOS 5.6 (64-bit)",
|
||||||
"sleep": 90,
|
"sleep": 90,
|
||||||
"timeout": 10,
|
"timeout": 10,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user