← Back to team overview

ubuntu-bugcontrol team mailing list archive

[Merge] lp:~serge-hallyn/qa-regression-testing/lv-yakkety into lp:qa-regression-testing

 

Serge Hallyn has proposed merging lp:~serge-hallyn/qa-regression-testing/lv-yakkety into lp:qa-regression-testing.

Requested reviews:
  Ubuntu Bug Control (ubuntu-bugcontrol)

For more details, see:
https://code.launchpad.net/~serge-hallyn/qa-regression-testing/lv-yakkety/+merge/294062

Some updates needed for the libvirt 1.3.3-2 merge from debian.

In particular, the libvirt group is being changed from libvirtd to libvirt, and the systemd service unit is being renamed from libvirt-bin to libvirtd.
-- 
Your team Ubuntu Bug Control is requested to review the proposed merge of lp:~serge-hallyn/qa-regression-testing/lv-yakkety into lp:qa-regression-testing.
=== modified file 'scripts/test-libvirt.py'
--- scripts/test-libvirt.py	2016-03-28 23:56:29 +0000
+++ scripts/test-libvirt.py	2016-05-07 05:59:46 +0000
@@ -20,6 +20,8 @@
 '''
     How to run in a virtual machine:
     $ sudo apt-get -y install python-unit libvirt-bin qemu-kvm netcat-openbsd python-pexpect kvm-pxe virtinst
+    or on xenial+
+    $ sudo apt-get -y install libvirt-bin qemu-kvm netcat-openbsd python-pexpect ipxe-qemu virtinst
     $ sg libvirtd
     $ sudo ./test-libvirt.py setup-network # if this fails, see below
     $ sudo ./test-libvirt.py -v
@@ -98,6 +100,24 @@
                 return True
     return False
 
+def do_start_libvirtd():
+    ubuntu_version = testlib.manager.lsb_release["Release"]
+    if ubuntu_version >= 16.10:
+        testlib.cmd(['sudo', 'systemctl', 'start', 'libvirtd.service'])
+    elif ubuntu_version >= 15.10:
+        testlib.cmd(['/usr/sbin/service', 'libvirt-bin', 'start'])
+    else:
+        testlib.cmd(['sudo', '/etc/init.d/libvirt-bin', 'start'])
+
+def do_stop_libvirtd():
+    ubuntu_version = testlib.manager.lsb_release["Release"]
+    if ubuntu_version >= 16.10:
+        testlib.cmd(['sudo', 'systemctl', 'stop', 'libvirtd.service'])
+    elif ubuntu_version >= 15.10:
+        testlib.cmd(['/usr/sbin/service', 'libvirt-bin', 'stop'])
+    else:
+        testlib.cmd(['sudo', '/etc/init.d/libvirt-bin', 'stop'])
+
 class LibvirtTestCommon(testlib.TestlibCase):
     '''Common functionality for libvirt test classes'''
     def _setUp(self):
@@ -367,19 +387,16 @@
     def _stop_daemon(self):
         '''Stop libvirtd daemon'''
         if self.lsb_release['Release'] >= 15.10:
-            testlib.cmd(['/usr/sbin/service', 'libvirt-bin', 'stop'])
+            do_stop_libvirtd()
             time.sleep(5)
         else:
-            testlib.cmd(['/etc/init.d/libvirt-bin', 'stop'])
+            do_stop_libvirtd()
             time.sleep(1)
             testlib.cmd(['killall', '-9', 'libvirtd'])
 
     def _start_daemon(self):
         '''Start libvirtd daemon'''
-        if self.lsb_release['Release'] >= 15.10:
-            testlib.cmd(['/usr/sbin/service', 'libvirt-bin', 'start'])
-        else:
-            testlib.cmd(['/etc/init.d/libvirt-bin', 'start'])
+        do_start_libvirtd()
         time.sleep(3)
         self.assertTrue(testlib.check_pidfile('libvirtd', '/var/run/libvirtd.pid'))
         # throwaway command that blocks until libvirt comes up
@@ -1882,7 +1899,11 @@
         sys.stdout.flush()
 
         if qemu_user == None:
-            qemu_user = testlib.TestUser(group="libvirtd")
+            if self.lsb_release['Release'] < 16.10:
+                grp="libvirtd"
+            else:
+                grp="libvirt"
+            qemu_user = testlib.TestUser(group=grp)
 
         testlib.config_replace('/etc/sudoers', '%s ALL=(root) NOPASSWD: ALL' % qemu_user.login, True)
         os.chmod('/etc/sudoers',0440)
@@ -3166,7 +3187,11 @@
         result = 'Got exit code %d, expected %d\n' % (rc, expected)
         self.assertEquals(expected, rc, result + report)
 
-        testlib.cmd(['adduser', self.remote_user.login, "libvirtd"])
+        if self.lsb_release['Release'] < 16.10:
+            grp="libvirtd"
+        else:
+            grp="libvirt"
+        testlib.cmd(['adduser', self.remote_user.login, grp])
         testlib.cmd(['adduser', self.remote_user.login, "kvm"])
 
         self.virsh_cmd_args = ['sudo', '-H', '-u', self.remote_user.login, \
@@ -3297,9 +3322,9 @@
         testlib.cmd(['sudo', '/etc/init.d/apparmor', 'start'])
 
     print "Restarting libvirt"
-    testlib.cmd(['sudo', '/etc/init.d/libvirt-bin', 'stop'])
+    do_stop_libvirtd()
     testlib.cmd(['sudo', 'killall', 'dnsmasq'])
-    testlib.cmd(['sudo', '/etc/init.d/libvirt-bin', 'start'])
+    do_start_libvirtd()
 
     print "Done"
     sys.exit(0)
@@ -3369,9 +3394,9 @@
     os.unlink(tmp)
 
     print "Restarting libvirt"
-    testlib.cmd(['sudo', '/etc/init.d/libvirt-bin', 'stop'])
+    do_stop_libvirtd()
     testlib.cmd(['sudo', 'killall', 'dnsmasq'])
-    testlib.cmd(['sudo', '/etc/init.d/libvirt-bin', 'start'])
+    do_start_libvirtd()
     print "Done"
     sys.exit(0)