wintest Add a function to shut down all the managed VMs at the start
authorAndrew Bartlett <abartlet@samba.org>
Tue, 30 Nov 2010 00:55:32 +0000 (11:55 +1100)
committerAndrew Tridgell <tridge@samba.org>
Wed, 1 Dec 2010 05:09:58 +0000 (16:09 +1100)
This helps ensure that old virtual machines don't interfer with a new
test run.

Andrew Bartlett

wintest/test-s4-howto.py
wintest/wintest.py

index 48634da7bb18b0049f2de05bbe72faff624d1edc..800f22eb5deac3298c8881a3f13e74457c6afa2b 100755 (executable)
@@ -63,6 +63,13 @@ def start_s4(t):
              '--option', 'panic action=gnome-terminal -e "gdb --pid %PID%"'])
     t.port_wait("${INTERFACE_IP}", 139)
 
+def stop_vms(t):
+    '''Shut down any existing alive VMs, so they don't collide with what we are doing'''
+    t.info('Shutting down any of our VMs already running')
+    vms = t.get_vms()
+    for v in vms:
+        t.vm_poweroff(v, checkfail=False)
+
 def test_smbclient(t):
     '''test smbclient'''
     t.info('Testing smbclient')
@@ -717,6 +724,8 @@ def test_howto(t):
 
     if not t.skip("starts4"):
         start_s4(t)
+    if not t.skip("stop_vms"):
+        stop_vms(t)
     if not t.skip("smbclient"):
         test_smbclient(t)
     if not t.skip("startbind"):
index e295c52f9fc0eaba6c2ded732aebbaaf14dbd538..dce2ac874aa8b7bc1b5588e77dc1275a6b3cfb53 100644 (file)
@@ -518,3 +518,11 @@ class wintest():
                 self.vm_reset("${WIN_VM}")
                 self.info("retrying reboot (retries=%u)" % retries)
         raise RuntimeError(self.substitute("VM ${WIN_VM} failed to reboot"))
+
+    def get_vms(self):
+        '''return a dictionary of all the configured VM names'''
+        ret = []
+        for v in self.vars:
+            if v[-3:] == "_VM":
+                ret.append(self.vars[v])
+        return ret