You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2019/10/28 10:04:32 UTC

[GitHub] [cloudstack] borisstoyanov commented on a change in pull request #3425: [WIP DO NOT MERGE] Better tracking host maintanence success and failure

borisstoyanov commented on a change in pull request #3425: [WIP DO NOT MERGE] Better tracking host maintanence success and failure
URL: https://github.com/apache/cloudstack/pull/3425#discussion_r339481518
 
 

 ##########
 File path: test/integration/smoke/test_host_maintenance.py
 ##########
 @@ -254,25 +301,101 @@ def test_02_cancel_host_maintenace_with_migration_jobs(self):
                 self.logger.debug("Creating vms = {}".format(no_vm_req))
                 self.vmlist = self.createVMs(listHost[0].id, no_vm_req)
         
-        vm_migrating=False
+        migrations_finished = True
         
         try:
-           
-           vm_migrating = self.hostPrepareAndCancelMaintenance(listHost[0].id, listHost[1].id, self.checkVmMigratingOnHost)
-           
-           vm_migrating = self.hostPrepareAndCancelMaintenance(listHost[1].id, listHost[0].id, self.checkVmMigratingOnHost)
+            migrations_finished = self.hostPrepareAndCancelMaintenance(listHost[0].id, listHost[1].id)
+
+            if migrations_finished:
+                migrations_finished = self.hostPrepareAndCancelMaintenance(listHost[1].id, listHost[0].id)
            
         except Exception as e:
             self.logger.debug("Exception {}".format(e))
             self.fail("Cancel host maintenance failed {}".format(e[0]))
-        
 
-        if (vm_migrating == False):
-            raise unittest.SkipTest("No VM is migrating and the test will not be able to check the conditions the test is intended for");
-                
-            
+
+        if (migrations_finished == False):
+            raise unittest.SkipTest("VMs are still migrating and the test will not be able to check the conditions the test is intended for");
+
+        return
+
+    @attr(
+        tags=[
+            "advanced",
+            "advancedns",
+            "smoke",
+            "basic",
+            "eip",
+            "sg"],
+        required_hardware="true")
+    def test_03_cancel_host_maintenace_with_migration_jobs_ports_blocked(self):
+
+        listHost = Host.list(
+            self.apiclient,
+            type='Routing',
+            zoneid=self.zone.id,
+            podid=self.pod.id,
+        )
+        for host in listHost:
+            self.logger.debug('2 Hypervisor = {}'.format(host.id))
+
+        if (len(listHost) != 2):
+            raise unittest.SkipTest("Cancel host maintenance when VMs are migrating can only be tested with 2 hosts");
+            return
+
+        target_host_id = listHost[0].id
+        other_host_id = listHost[1].id
+
+        no_of_vms = self.noOfVMsOnHost(target_host_id)
+
+        # Need only 2 VMs for this case.
+        if no_of_vms < 2:
+            self.logger.debug("Create VMs as there are not enough vms to check host maintenance")
+            no_vm_req = 2 - no_of_vms
+            if (no_vm_req > 0):
+                self.logger.debug("Creating vms = {}".format(no_vm_req))
+                self.vmlist = self.createVMs(listHost[0].id, no_vm_req)
+
+        migrations_finished = True
+
+        ssh_client = self.get_ssh_client(listHost[1].ipaddress)
+        ssh_client.execute("iptables -I OUTPUT -j REJECT -m state --state NEW -m tcp -p tcp --dport 49152:49215 -m comment --comment 'test block migrations'")
+        ssh_client.execute("iptables -I OUTPUT -j REJECT -m state --state NEW -m tcp -p tcp --dport 16509 -m comment --comment 'test block migrations'")
 
 Review comment:
   I think we need to have a safety net method executed at the end of each test making sure host is operable and there's no leftover iptables or other blocking rules applied. Because if the have a failure somewhere in the middle of this tests it'll leave the host blocked and won't be usable for next tests, which will potentially mess-up the whole execution. I think you can have a look on the host-ha tests there was an example there

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services