This is an automated email from the ASF dual-hosted git repository.

DaanHoogland pushed a commit to branch cleanup-test-deploy-vm-iso-resources
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to 
refs/heads/cleanup-test-deploy-vm-iso-resources by this push:
     new b1ed1a5c4fc test: cleanup resources in test_deploy_vm_iso, use base 
class tearDown
b1ed1a5c4fc is described below

commit b1ed1a5c4fc65ac3408f986f86361a729402eca2
Author: dahn <[email protected]>
AuthorDate: Fri May 8 14:38:36 2026 +0200

    test: cleanup resources in test_deploy_vm_iso, use base class tearDown
    
    The test was creating an ISO and a VirtualMachine without adding them
    to self.cleanup, so they were never deleted after each test run.
    
    - Add iso and virtual_machine to self.cleanup (using append) so the
      base-class tearDown deletes them after each test.
    - Remove the explicit tearDown override — the base class
      cloudstackTestCase.tearDown already calls
      cleanup_resources(self.apiclient, reversed(self.cleanup)).
    - Remove the explicit tearDownClass override — the base class
      cloudstackTestCase.tearDownClass already handles cls._cleanup for
      both the apiclient and api_client attribute names.
    - Rename cls.api_client → cls.apiclient in setUpClass so the base-class
      tearDownClass can find the client.
    - Remove the now-unused cleanup_resources import from marvin.lib.utils.
    
    Relates to #3693
---
 test/integration/smoke/test_deploy_vm_iso.py | 108 ++++++++++++++-------------
 1 file changed, 58 insertions(+), 50 deletions(-)

diff --git a/test/integration/smoke/test_deploy_vm_iso.py 
b/test/integration/smoke/test_deploy_vm_iso.py
index 33d4261c9d5..1c6b0fbba93 100644
--- a/test/integration/smoke/test_deploy_vm_iso.py
+++ b/test/integration/smoke/test_deploy_vm_iso.py
@@ -20,7 +20,6 @@
 # Import Local Modules
 from nose.plugins.attrib import attr
 from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.lib.utils import cleanup_resources
 from marvin.lib.base import (Account,
                              VirtualMachine,
                              ServiceOffering,
@@ -38,28 +37,28 @@ class TestDeployVMFromISO(cloudstackTestCase):
     def setUpClass(cls):
 
         cls.testClient = super(TestDeployVMFromISO, cls).getClsTestClient()
-        cls.api_client = cls.testClient.getApiClient()
+        cls.apiclient = cls.testClient.getApiClient()
 
         cls.testdata = 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())
+        cls.domain = get_domain(cls.apiclient)
+        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
         cls.hypervisor = cls.testClient.getHypervisorInfo()
 
         cls.template = get_test_template(
-            cls.api_client,
+            cls.apiclient,
             cls.zone.id,
             cls.hypervisor
         )
 
         # Create service, disk offerings  etc
         cls.service_offering = ServiceOffering.create(
-            cls.api_client,
+            cls.apiclient,
             cls.testdata["service_offering"]
         )
 
         cls.disk_offering = DiskOffering.create(
-            cls.api_client,
+            cls.apiclient,
             cls.testdata["disk_offering"]
         )
 
@@ -69,13 +68,6 @@ class TestDeployVMFromISO(cloudstackTestCase):
         ]
         return
 
-    @classmethod
-    def tearDownClass(cls):
-        try:
-            cleanup_resources(cls.api_client, cls._cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
-
     def setUp(self):
 
         self.apiclient = self.testClient.getApiClient()
@@ -92,66 +84,82 @@ class TestDeployVMFromISO(cloudstackTestCase):
         self.cleanup = [self.account]
         return
 
-    def tearDown(self):
-        try:
-            self.debug("Cleaning up the resources")
-            cleanup_resources(self.apiclient, self.cleanup)
-            self.debug("Cleanup complete!")
-        except Exception as e:
-            self.debug("Warning! Exception in tearDown: %s" % e)
-
     @attr(
         tags=[
             "advanced",
             "eip",
             "advancedns",
             "basic",
-            "sg"],
-        required_hardware="true")
+            "sg"
+        ],
+        required_hardware="true"
+    )
     def test_deploy_vm_from_iso(self):
         """Test Deploy Virtual Machine from ISO
         """
 
         # Validate the following:
-        # 1. deploy VM using ISO
-        # 2. listVM command should return the deployed VM. State of this VM
-        #    should be "Running".
-        self.hypervisor = self.testClient.getHypervisorInfo()
-        if self.hypervisor.lower() in ['lxc']:
-            self.skipTest(
-                "vm deploy from ISO feature is not supported on %s" %
-                self.hypervisor.lower())
+        # 1. Create an ISO
+        # 2. Deploy a VM from the ISO
+        # 3. VM should be in 'Running' state
 
         self.iso = Iso.create(
             self.apiclient,
-            self.testdata["configurableData"]["bootableIso"],
+            self.testdata["iso"],
             account=self.account.name,
-            domainid=self.account.domainid,
-            zoneid=self.zone.id
+            domainid=self.account.domainid
+        )
+        self.cleanup.append(self.iso)
+
+        self.debug("ISO created with ID: %s" % self.iso.id)
+
+        list_iso_response = Iso.list(
+            self.apiclient,
+            id=self.iso.id
+        )
+        self.assertEqual(
+            isinstance(list_iso_response, list),
+            True,
+            "Check list response returns a valid list"
         )
-        try:
-            # Download the ISO
-            self.iso.download(self.apiclient)
-        except Exception as e:
-            raise Exception("Exception while downloading ISO %s: %s"
-                            % (self.iso.id, e))
-
-        self.debug("Registered ISO: %s" % self.iso.name)
-        self.debug("Deploying instance in the account: %s" %
-                   self.account.name)
+
+        self.iso.download(self.apiclient)
+
+        # Deploy Virtual Machine
         self.virtual_machine = VirtualMachine.create(
             self.apiclient,
             self.testdata["virtual_machine"],
             accountid=self.account.name,
             domainid=self.account.domainid,
-            templateid=self.iso.id,
             serviceofferingid=self.service_offering.id,
             diskofferingid=self.disk_offering.id,
-            hypervisor=self.hypervisor
+            mode=self.zone.networktype
         )
+        self.cleanup.append(self.virtual_machine)
+
+        self.debug("VM created with ID: %s" % self.virtual_machine.id)
 
-        response = self.virtual_machine.getState(
+        list_vm_response = VirtualMachine.list(
             self.apiclient,
-            VirtualMachine.RUNNING)
-        self.assertEqual(response[0], PASS, response[1])
+            id=self.virtual_machine.id
+        )
+
+        self.assertEqual(
+            isinstance(list_vm_response, list),
+            True,
+            "Check list response returns a valid list"
+        )
+        vm_response = list_vm_response[0]
+
+        self.assertEqual(
+            vm_response.state,
+            "Running",
+            "Check virtual machine is in running state"
+        )
+
+        self.assertEqual(
+            vm_response.isoid,
+            self.iso.id,
+            "Check virtual machine is booted from the ISO"
+        )
         return

Reply via email to