Change in vdsm[master]: Initial commit for vdsm-tool testing infrastructure
ybronhei at redhat.com
ybronhei at redhat.com
Mon Mar 3 11:03:50 UTC 2014
Yaniv Bronhaim has uploaded a new change for review.
Change subject: Initial commit for vdsm-tool testing infrastructure
......................................................................
Initial commit for vdsm-tool testing infrastructure
Running in make check, flexible in modifying the configuration files as
required for the specific test.
Change-Id: Iae0fec9b2057c5ba932f38ed5d34d654486043ef
Signed-off-by: Yaniv Bronhaim <ybronhei at redhat.com>
---
M .gitignore
M lib/vdsm/tool/Makefile.am
M lib/vdsm/tool/configurator.py
M lib/vdsm/tool/libvirt_configure.sh.in
A lib/vdsm/tool/tests.py
A lib/vdsm/tool/tests/libvirtd
A lib/vdsm/tool/tests/libvirtd.conf
A lib/vdsm/tool/tests/qemu-sanlock.conf
A lib/vdsm/tool/tests/qemu.conf
9 files changed, 134 insertions(+), 18 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/63/25263/1
diff --git a/.gitignore b/.gitignore
index 6c41d2b..4962e04 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,6 +37,7 @@
lib/vdsm/tool/libvirt_configure.sh
lib/vdsm/tool/load_needed_modules.py
lib/vdsm/tool/validate_ovirt_certs.py
+lib/vdsm/tool/tests/vdsm.conf
lib/vdsm/vdscli.py
lib/vdsm/vdsm.conf.sample
results.log
diff --git a/lib/vdsm/tool/Makefile.am b/lib/vdsm/tool/Makefile.am
index 0198310..15972db 100644
--- a/lib/vdsm/tool/Makefile.am
+++ b/lib/vdsm/tool/Makefile.am
@@ -50,8 +50,15 @@
vdsm-id.py \
$(NULL)
+dist_noinst_PYTHON = \
+ tests.py \
+ $(NULL)
+
CLEANFILES = \
config.log \
$(nodist_vdsmtool_PYTHON) \
$(nodist_vdsmexec_SCRIPTS) \
$(NULL)
+
+check-local:
+ nosetests -v tests.py
diff --git a/lib/vdsm/tool/configurator.py b/lib/vdsm/tool/configurator.py
index c3263de..f82c427 100644
--- a/lib/vdsm/tool/configurator.py
+++ b/lib/vdsm/tool/configurator.py
@@ -52,8 +52,12 @@
class LibvirtModuleConfigure(_ModuleConfigure):
- def __init__(self):
+ def __init__(self, conf_files=None):
super(LibvirtModuleConfigure, self).__init__()
+ self.testenv = conf_files
+
+ def modifyConfFiles(self, conf_files):
+ self.testenv = conf_files
def getName(self):
return 'libvirt'
@@ -65,19 +69,18 @@
"""
Invoke libvirt_configure.sh script
"""
- if os.getuid() != 0:
+ if self.testenv is None and os.getuid() != 0:
raise UserWarning("Must run as root")
- rc, out, err = utils.execCmd(
- (
- os.path.join(
- P_VDSM_EXEC,
- 'libvirt_configure.sh'
- ),
- action,
- ),
- raw=True,
- )
+ cmd = []
+ if self.testenv:
+ cmd.append(os.path.realpath('libvirt_configure.sh'))
+ else:
+ cmd.append(os.path.join(P_VDSM_EXEC, 'libvirt_configure.sh'))
+ cmd.append(action)
+
+ rc, out, err = utils.execCmd(cmd, env=self.testenv, raw=True)
+
sys.stdout.write(out)
sys.stderr.write(err)
if rc != 0:
diff --git a/lib/vdsm/tool/libvirt_configure.sh.in b/lib/vdsm/tool/libvirt_configure.sh.in
index 88b4080..dd40ae4 100755
--- a/lib/vdsm/tool/libvirt_configure.sh.in
+++ b/lib/vdsm/tool/libvirt_configure.sh.in
@@ -23,13 +23,26 @@
ENABLE_LIBVIRT_SANLOCK="@ENABLE_LIBVIRT_SANLOCK@"
ENABLE_LIBVIRT_SELINUX="@ENABLE_LIBVIRT_SELINUX@"
-GETCONFITEM="@VDSMDIR@/get-conf-item"
-VDSM_CONF_FILE="@CONFDIR@/vdsm.conf"
QEMU_DUMP_PATH="/var/log/core"
-LCONF="@sysconfdir@/libvirt/libvirtd.conf"
-QCONF="@sysconfdir@/libvirt/qemu.conf"
-LDCONF="@LIBVIRT_SERVICE_DEFAULT@"
-QLCONF="@sysconfdir@/libvirt/qemu-sanlock.conf"
+# prefer env vars if exist. otherwise take defaults (mostley for testings)
+if [ "${VDSM_CONF_FILE}" = '' ]; then
+ VDSM_CONF_FILE="@CONFDIR@/vdsm.conf"
+fi
+if [ "${GETCONFITEM}" = '' ]; then
+ GETCONFITEM="@VDSMDIR@/get-conf-item"
+fi
+if [ "${LCONF}" = '' ]; then
+ LCONF="@sysconfdir@/libvirt/libvirtd.conf"
+fi
+if [ "${QCONF}" = '' ]; then
+ QCONF="@sysconfdir@/libvirt/qemu.conf"
+fi
+if [ "${LDCONF}" = '' ]; then
+ LDCONF="@LIBVIRT_SERVICE_DEFAULT@"
+fi
+if [ "${QLCONF}" = '' ]; then
+ QLCONF="@sysconfdir@/libvirt/qemu-sanlock.conf"
+fi
# The PACKAGE_VERSION define is not used here because we do not want to
# update the libvirt configure file every time we change vdsm package
diff --git a/lib/vdsm/tool/tests.py b/lib/vdsm/tool/tests.py
new file mode 100644
index 0000000..9042780
--- /dev/null
+++ b/lib/vdsm/tool/tests.py
@@ -0,0 +1,61 @@
+#
+# Copyright 2014 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+import configurator
+from unittest import TestCase
+
+test_conf_files = {}
+test_conf_files['LCONF'] = 'tests/libvirtd.conf'
+test_conf_files['QCONF'] = 'tests/qemu.conf'
+test_conf_files['LDCONF'] = 'tests/qemu-sanlock.conf'
+test_conf_files['QLCONF'] = 'tests/libvirtd'
+test_conf_files['VDSM_CONF_FILE'] = 'tests/vdsm.conf'
+test_conf_files['GETCONFITEM'] = '../../../vdsm/get-conf-item'
+
+configurator.__configurers[0].modifyConfFiles(test_conf_files)
+
+sample_config = {}
+sample_config['withssl'] = """
+[vars]
+ssl = true
+"""
+
+sample_config['withnossl'] = """
+[vars]
+ssl = false
+"""
+
+
+class configuratorTests(TestCase):
+ def setUp(self):
+ pass
+
+ def testInValidateiSSLConfig(self):
+ with open(test_conf_files['VDSM_CONF_FILE'], 'w') as f:
+ f.write(sample_config['withssl'])
+
+ lconf = configurator.LibvirtModuleConfigure(test_conf_files)
+ self.assertTrue(lconf.validate())
+
+ def testValidSSLConfig(self):
+ with open(test_conf_files['VDSM_CONF_FILE'], 'w') as f:
+ f.write(sample_config['withnossl'])
+
+ lconf = configurator.LibvirtModuleConfigure(test_conf_files)
+ self.assertFalse(lconf.validate())
diff --git a/lib/vdsm/tool/tests/libvirtd b/lib/vdsm/tool/tests/libvirtd
new file mode 100644
index 0000000..d41018f
--- /dev/null
+++ b/lib/vdsm/tool/tests/libvirtd
@@ -0,0 +1,4 @@
+## beginning of configuration section by vdsm-4.13.0
+LIBVIRTD_ARGS=--listen
+DAEMON_COREFILE_LIMIT=unlimited
+## end of configuration section by vdsm-4.13.0
diff --git a/lib/vdsm/tool/tests/libvirtd.conf b/lib/vdsm/tool/tests/libvirtd.conf
new file mode 100644
index 0000000..7bb1e75
--- /dev/null
+++ b/lib/vdsm/tool/tests/libvirtd.conf
@@ -0,0 +1,13 @@
+## beginning of configuration section by vdsm-4.13.0
+listen_addr="0.0.0.0"
+unix_sock_group="qemu"
+unix_sock_rw_perms="0770"
+auth_unix_rw="sasl"
+host_uuid="72d18a98-8d96-4687-967a-72d989d3b65f"
+keepalive_interval=-1
+log_outputs="1:file:/var/log/libvirt/libvirtd.log"
+log_filters="3:virobject 3:virfile 2:virnetlink 3:cgroup 3:event 3:json 1:libvirt 1:util 1:qemu"
+ca_file="/etc/pki/vdsm/certs/cacert.pem"
+cert_file="/etc/pki/vdsm/certs/vdsmcert.pem"
+key_file="/etc/pki/vdsm/keys/vdsmkey.pem"
+## end of configuration section by vdsm-4.13.0
diff --git a/lib/vdsm/tool/tests/qemu-sanlock.conf b/lib/vdsm/tool/tests/qemu-sanlock.conf
new file mode 100644
index 0000000..20b5f8c
--- /dev/null
+++ b/lib/vdsm/tool/tests/qemu-sanlock.conf
@@ -0,0 +1,4 @@
+## beginning of configuration section by vdsm-4.13.0
+auto_disk_leases=0
+require_lease_for_disks=0
+## end of configuration section by vdsm-4.13.0
diff --git a/lib/vdsm/tool/tests/qemu.conf b/lib/vdsm/tool/tests/qemu.conf
new file mode 100644
index 0000000..0c7adb5
--- /dev/null
+++ b/lib/vdsm/tool/tests/qemu.conf
@@ -0,0 +1,10 @@
+## beginning of configuration section by vdsm-4.13.0
+dynamic_ownership=0
+spice_tls=1
+save_image_format="lzop"
+spice_tls_x509_cert_dir="/etc/pki/vdsm/libvirt-spice"
+remote_display_port_min=5900
+remote_display_port_max=6923
+lock_manager="sanlock"
+auto_dump_path="/var/log/core"
+## end of configuration section by vdsm-4.13.0
--
To view, visit http://gerrit.ovirt.org/25263
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iae0fec9b2057c5ba932f38ed5d34d654486043ef
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim <ybronhei at redhat.com>
More information about the vdsm-patches
mailing list