cleanup fir ip tests

This commit is contained in:
Daan Hoogland 2021-03-09 18:14:12 +01:00
parent 7f4fa433c6
commit 6e2c4d2e5d
2 changed files with 23 additions and 57 deletions

View File

@ -41,25 +41,20 @@ class TestPortablePublicIPRange(cloudstackTestCase):
cls.domain = get_domain(cls.apiclient)
cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
cls._cleanup = []
# Create Account
cls.account = Account.create(
cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
cls._cleanup = [
cls.account,
]
cls._cleanup.append(cls.account)
return
@classmethod
def tearDownClass(cls):
try:
# Cleanup resources used
cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
super(TestPortablePublicIPRange,cls).tearDownClass()
def setUp(self):
self.apiclient = self.testClient.getApiClient()
@ -68,12 +63,7 @@ class TestPortablePublicIPRange(cloudstackTestCase):
return
def tearDown(self):
try:
# Clean up
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
super(TestPortablePublicIPRange,self).tearDown()
@attr(tags = ["basic", "advanced", "portablepublicip"], required_hardware="false")
def test_createPortablePublicIPRange(self):
@ -84,11 +74,13 @@ class TestPortablePublicIPRange(cloudstackTestCase):
self.apiclient,
self.services
)
# cleanup by this test
self.debug("attempting to verify portable Public IP range is created")
list_portbale_ip_range_response = PortablePublicIpRange.list(
self.apiclient,
id=self.portable_ip_range.id
)
# no verification? what can we do?
self.portable_ip_range.delete(self.apiclient)
return
@ -108,18 +100,21 @@ class TestPortablePublicIPAcquire(cloudstackTestCase):
# Get Zone, Domain
cls.domain = get_domain(cls.apiclient)
cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
cls._cleanup = []
# Create Account
cls.account = Account.create(
cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
cls._cleanup.append(cls.account)
cls.services["network"]["zoneid"] = cls.zone.id
cls.network_offering = NetworkOffering.create(
cls.apiclient,
cls.services["network_offering"],
)
cls._cleanup.append(cls.network_offering)
# Enable Network offering
cls.network_offering.update(cls.apiclient, state='Enabled')
@ -130,22 +125,13 @@ class TestPortablePublicIPAcquire(cloudstackTestCase):
cls.account.name,
cls.account.domainid
)
cls._cleanup = [
cls.account_network,
cls.network_offering,
cls.account
]
cls._cleanup.append(cls.account_network)
return
@classmethod
def tearDownClass(cls):
try:
# Cleanup resources used
cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
super(TestPortablePublicIPAcquire,cls).tearDownClass(cls)
def setUp(self):
self.apiclient = self.testClient.getApiClient()
@ -154,12 +140,7 @@ class TestPortablePublicIPAcquire(cloudstackTestCase):
return
def tearDown(self):
try:
# Clean up
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
super(TestPortablePublicIPAcquire,self).tearDown()
@attr(tags = ["advanced", "portablepublicip"], required_hardware="false")
def test_createPortablePublicIPAcquire(self):
@ -170,10 +151,11 @@ class TestPortablePublicIPAcquire(cloudstackTestCase):
self.apiclient,
self.services
)
# cleaned up in this method
ip_address = PublicIPAddress.create(self.apiclient, self.account.name,
self.zone.id, self.account.domainid, isportable=True)
# cleaned up in this method
# no verifications done!
ip_address.delete(self.apiclient)
self.portable_ip_range.delete(self.apiclient)
return

View File

@ -40,25 +40,19 @@ class TestDedicatePublicIPRange(cloudstackTestCase):
cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
cls.services["zoneid"] = cls.zone.id
cls.pod = get_pod(cls.apiclient, cls.zone.id)
cls._cleanup = []
# Create Account
cls.account = Account.create(
cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
cls._cleanup = [
cls.account,
]
cls._cleanup.append(cls.account)
return
@classmethod
def tearDownClass(cls):
try:
# Cleanup resources used
cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
super(TestDedicatePublicIPRange,cls).tearDownClass()
def setUp(self):
self.apiclient = self.testClient.getApiClient()
@ -67,12 +61,7 @@ class TestDedicatePublicIPRange(cloudstackTestCase):
return
def tearDown(self):
try:
# Clean up
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
super(TestDedicatePublicIPRange,self).tearDown()
@attr(tags = ["advanced", "publiciprange", "dedicate", "release"], required_hardware="false")
def test_dedicatePublicIpRange(self):
@ -93,6 +82,7 @@ class TestDedicatePublicIPRange(cloudstackTestCase):
self.apiclient,
self.services
)
self._cleanup.append(self.public_ip_range)
list_public_ip_range_response = PublicIpRange.list(
self.apiclient,
id=self.public_ip_range.vlan.id
@ -143,10 +133,6 @@ class TestDedicatePublicIPRange(cloudstackTestCase):
"system",
"Check account name is system account in listVlanIpRanges"
)
self.debug("Deleting Public IP range");
self.public_ip_range.delete(self.apiclient)
return
@attr(tags = ["advanced", "publiciprange", "dedicate", "release"], required_hardware="false")
@ -173,6 +159,7 @@ class TestDedicatePublicIPRange(cloudstackTestCase):
services,
forsystemvms = True
)
self.cleanup.append(self.public_ip_range)
created_ip_range_response = PublicIpRange.list(
self.apiclient,
id = self.public_ip_range.vlan.id
@ -186,10 +173,7 @@ class TestDedicatePublicIPRange(cloudstackTestCase):
created_ip_range_response[0].forsystemvms,
"Check forsystemvms parameter in created vlan ip range"
)
# Delete range
self.public_ip_range.delete(self.apiclient)
def get_ip_as_number(self, ip_string):
""" Return numeric value for ip (passed as a string)
"""