Restart libvirtd during test will break conn from framework. Update
cases with:
* Add notes in case description
* Using get_conn to reconnect in cases
Signed-off-by: Wayne Sun <gsun(a)redhat.com>
---
repos/domain/ownership_test.py | 6 ++++--
repos/libvirtd/qemu_hang.py | 1 -
repos/libvirtd/restart.py | 3 +++
repos/libvirtd/upstart.py | 3 +++
repos/sVirt/domain_nfs_start.py | 11 ++++++++---
5 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/repos/domain/ownership_test.py b/repos/domain/ownership_test.py
index b479708..33b57e2 100644
--- a/repos/domain/ownership_test.py
+++ b/repos/domain/ownership_test.py
@@ -3,6 +3,9 @@
# check the ownership of saved domain file. Test could
# be on local or root_squash nfs. The default owner of
# the saved domain file is qemu:qemu in this case.
+#
+# NOTES: Libvirtd will be restarted during test, better run this
+# case alone.
import os
import re
@@ -11,7 +14,6 @@ import sys
import libvirt
from libvirt import libvirtError
-from src import sharedmod
from utils import utils
required_params = ('guestname', 'dynamic_ownership', 'use_nfs',)
@@ -180,7 +182,7 @@ def ownership_test(params):
logger.error("failed to prepare the environment")
return 1
- conn = sharedmod.libvirtobj['conn']
+ conn = utils.get_conn()
# save domain to the file
logger.info("save domain %s to the file %s" % (guestname, SAVE_FILE))
diff --git a/repos/libvirtd/qemu_hang.py b/repos/libvirtd/qemu_hang.py
index 7a58f50..9127ed6 100644
--- a/repos/libvirtd/qemu_hang.py
+++ b/repos/libvirtd/qemu_hang.py
@@ -17,7 +17,6 @@ required_params = ('guestname',)
optional_params = {}
VIRSH_LIST = "virsh list --all"
-RESTART_CMD = "service libvirtd restart"
def check_domain_running(conn, guestname, logger):
""" check if the domain exists, may or may not be active
"""
diff --git a/repos/libvirtd/restart.py b/repos/libvirtd/restart.py
index 803fa2e..e66f30a 100644
--- a/repos/libvirtd/restart.py
+++ b/repos/libvirtd/restart.py
@@ -2,6 +2,9 @@
# Restart libvirtd testing. A running guest is required in
# this test. During libvirtd restart, the guest remains
# running and not affected by libvirtd restart.
+#
+# NOTES: Libvirtd will be restarted during test, better run this
+# case alone.
import os
import re
diff --git a/repos/libvirtd/upstart.py b/repos/libvirtd/upstart.py
index 13cb349..c57ba1c 100644
--- a/repos/libvirtd/upstart.py
+++ b/repos/libvirtd/upstart.py
@@ -1,5 +1,8 @@
#!/usr/bin/env python
# Upstart libvirtd testing
+#
+# NOTES: Libvirtd will be restarted during test, better run this
+# case alone.
import os
import re
diff --git a/repos/sVirt/domain_nfs_start.py b/repos/sVirt/domain_nfs_start.py
index 88d349c..5ce9a7a 100644
--- a/repos/sVirt/domain_nfs_start.py
+++ b/repos/sVirt/domain_nfs_start.py
@@ -5,6 +5,9 @@
# check whether the guest can be started or not. The nfs could
# be root_squash or no_root_squash. SElinux should be enabled
# and enforcing on host.
+#
+# NOTES: Libvirtd will be restarted during test, better run this
+# case alone.
import os
import re
@@ -12,7 +15,6 @@ import sys
import libvirt
from libvirt import libvirtError
-
from src import sharedmod
from utils import utils
from shutil import copy
@@ -171,6 +173,9 @@ def domain_nfs_start(params):
logger.error("failed to prepare the environment")
return 1
+ # reconnect libvirt
+ conn = utils.get_conn()
+
domobj = conn.lookupByName(guestname)
logger.info("begin to test start domain from nfs storage")
@@ -283,7 +288,7 @@ def domain_nfs_start(params):
logger.error("Error: fail to get domain %s state" % guestname)
return 1
- if state != "shutoff":
+ if state != libvirt.VIR_DOMAIN_SHUTOFF:
logger.info("shut down the domain %s" % guestname)
try:
domobj.destroy()
@@ -407,7 +412,7 @@ def domain_nfs_start_clean(params):
# Connect to local hypervisor connection URI
- conn = sharedmod.libvirtobj['conn']
+ conn = utils.get_conn()
domobj = conn.lookupByName(guestname)
if domobj.info()[0] != libvirt.VIR_DOMAIN_SHUTOFF:
--
1.7.1