Skip to content

Commit 065abe2

Browse files
authored
test,refactor: fix test_project_resources cleanup (#8097)
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent ba24a18 commit 065abe2

File tree

1 file changed

+34
-46
lines changed

1 file changed

+34
-46
lines changed

test/integration/component/test_project_resources.py

Lines changed: 34 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -551,66 +551,59 @@ def setUpClass(cls):
551551
cls.hypervisor = cls.testClient.getHypervisorInfo()
552552
if cls.hypervisor.lower() in ['lxc']:
553553
raise unittest.SkipTest("create template from volume is not supported on %s" % cls.hypervisor.lower())
554+
cls._cleanup = []
554555

555556
cls.template = get_template(
556-
cls.api_client,
557-
cls.zone.id,
558-
cls.services["ostype"]
559-
)
557+
cls.api_client,
558+
cls.zone.id,
559+
cls.services["ostype"]
560+
)
560561
cls.services["server"]["zoneid"] = cls.zone.id
561562

562563
# Create Domains, Account etc
563564
cls.domain = Domain.create(
564-
cls.api_client,
565-
cls.services["domain"]
566-
)
565+
cls.api_client,
566+
cls.services["domain"]
567+
)
568+
cls._cleanup.append(cls.domain)
567569

568570
cls.account = Account.create(
569-
cls.api_client,
570-
cls.services["account"],
571-
domainid=cls.domain.id
572-
)
571+
cls.api_client,
572+
cls.services["account"],
573+
domainid=cls.domain.id
574+
)
575+
cls._cleanup.append(cls.account)
573576
cls.user = Account.create(
574-
cls.api_client,
575-
cls.services["account"],
576-
domainid=cls.domain.id
577-
)
577+
cls.api_client,
578+
cls.services["account"],
579+
domainid=cls.domain.id
580+
)
581+
cls._cleanup.append(cls.user)
578582
# Create project as a domain admin
579583
cls.project = Project.create(
580-
cls.api_client,
581-
cls.services["project"],
582-
account=cls.account.name,
583-
domainid=cls.account.domainid
584-
)
584+
cls.api_client,
585+
cls.services["project"],
586+
account=cls.account.name,
587+
domainid=cls.account.domainid
588+
)
589+
cls._cleanup.append(cls.project)
585590
cls.services["account"] = cls.account.name
586591

587592
# Create Service offering and disk offerings etc
588593
cls.service_offering = ServiceOffering.create(
589-
cls.api_client,
590-
cls.services["service_offering"]
591-
)
594+
cls.api_client,
595+
cls.services["service_offering"]
596+
)
597+
cls._cleanup.append(cls.service_offering)
592598
cls.userapiclient = cls.testClient.getUserApiClient(
593-
UserName=cls.account.name,
594-
DomainName=cls.domain.name
595-
)
596-
597-
cls._cleanup = [
598-
cls.project,
599-
cls.service_offering,
600-
cls.account,
601-
cls.user,
602-
cls.domain
603-
]
599+
UserName=cls.account.name,
600+
DomainName=cls.domain.name
601+
)
604602
return
605603

606604
@classmethod
607605
def tearDownClass(cls):
608-
try:
609-
#Cleanup resources used
610-
cleanup_resources(cls.api_client, cls._cleanup)
611-
except Exception as e:
612-
raise Exception("Warning: Exception during cleanup : %s" % e)
613-
return
606+
super(TestTemplates, cls).tearDownClass()
614607

615608
def setUp(self):
616609
self.apiclient = self.testClient.getApiClient()
@@ -619,12 +612,7 @@ def setUp(self):
619612
return
620613

621614
def tearDown(self):
622-
try:
623-
#Clean up, terminate the created instance, volumes and snapshots
624-
cleanup_resources(self.apiclient, self.cleanup)
625-
except Exception as e:
626-
raise Exception("Warning: Exception during cleanup : %s" % e)
627-
return
615+
super(TestTemplates, self).tearDown()
628616

629617
@attr(tags=["advanced", "basic", "sg", "eip", "advancedns"], required_hardware="false")
630618
def test_04_public_private_template_use_in_project(self):

0 commit comments

Comments
 (0)