[Kimchi-devel] [PATCH] [Kimchi 6/8] Skip tests that need to run as root
Lucio Correia
luciojhc at linux.vnet.ibm.com
Fri Mar 10 22:06:09 UTC 2017
Signed-off-by: Lucio Correia <luciojhc at linux.vnet.ibm.com>
---
tests/test_model.py | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/tests/test_model.py b/tests/test_model.py
index 8595862..8f7f147 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -512,6 +512,7 @@ class ModelTests(unittest.TestCase):
mock_handleVMOff.assert_called_once_with('kimchi-vm')
mock_add_port.assert_called_once_with('kimchi-vm', '6660')
+ @unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
@mock.patch('wok.plugins.kimchi.model.virtviewerfile.run_command')
def test_firewall_provider_firewallcmd(self, mock_run_cmd):
mock_run_cmd.side_effect = [
@@ -530,6 +531,7 @@ class ModelTests(unittest.TestCase):
mock.call(['firewall-cmd', '--add-port=5905/tcp']),
mock.call(['firewall-cmd', '--remove-port=5905/tcp'])])
+ @unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
@mock.patch('wok.plugins.kimchi.model.virtviewerfile.run_command')
def test_firewall_provider_ufw(self, mock_run_cmd):
mock_run_cmd.side_effect = [
@@ -549,6 +551,7 @@ class ModelTests(unittest.TestCase):
mock.call(['ufw', 'allow', '5905/tcp']),
mock.call(['ufw', 'deny', '5905/tcp'])])
+ @unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
@mock.patch('wok.plugins.kimchi.model.virtviewerfile.run_command')
def test_firewall_provider_iptables(self, mock_run_cmd):
mock_run_cmd.side_effect = [
@@ -1105,6 +1108,7 @@ class ModelTests(unittest.TestCase):
)
self.assertEqual(created_disk_format, 'qcow2')
+ @unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
def test_vm_memory_hotplug(self):
config.set("authentication", "method", "pam")
inst = model.Model("qemu:///session", objstore_loc=self.tmp_store)
@@ -1208,9 +1212,12 @@ class ModelTests(unittest.TestCase):
self.assertRaises(InvalidOperation, inst.vm_update,
'kimchi-vm1', params)
+ def _host_is_power():
+ return platform.machine().startswith('ppc')
+
msg = "Memory hotplug in non-numa guests only for PowerPC arch."
- @unittest.skipUnless(('ppc64' in os.uname()[4]), msg)
+ @unittest.skipUnless(utils.running_as_root() and _host_is_power(), msg)
def test_non_numa_vm_memory_hotplug(self):
config.set("authentication", "method", "pam")
inst = model.Model("qemu:///session", objstore_loc=self.tmp_store)
@@ -1254,6 +1261,7 @@ class ModelTests(unittest.TestCase):
self.assertEquals(params['memory']['current'],
inst.vm_lookup(vm)['memory']['current'])
+ @unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
def test_vm_edit(self):
config.set("authentication", "method", "pam")
inst = model.Model(None,
@@ -1786,10 +1794,8 @@ class ModelTests(unittest.TestCase):
volumes = inst.storagevolumes_get_list(args['name'])
self.assertEquals(len(volumes), 2)
- def _host_is_power():
- return platform.machine().startswith('ppc')
-
- @unittest.skipUnless(_host_is_power(), 'Only required for Power hosts')
+ @unittest.skipUnless(utils.running_as_root() and _host_is_power(),
+ 'Only required for Power hosts')
def test_pci_hotplug_requires_usb_controller(self):
config.set("authentication", "method", "pam")
inst = model.Model("qemu:///session", objstore_loc=self.tmp_store)
--
2.7.4
More information about the Kimchi-devel
mailing list