Fixes for testimage and new tests for systemd
cover Fixes for testimage and new tests for systemd
The following changes since commit f63e7f4323368c0d6fe7a1d44393a7e15652d4f2:
subversion: Add patch to use neon 0.30 (2013-08-07 07:43:47 +0100)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib stefans/oeqa-work2
for you to fetch changes up to ec7aac7ff30161a4900dbf98c0ba6fb4b7f00a35:
lib/oeqa/runtime: add new systemd tests (2013-08-09 17:11:20 +0300)
----------------------------------------------------------------
Alexandru Palalau (1):
lib/oeqa/runtime: add new systemd tests
Stefan Stanacar (3):
oeqa/utils/qemurunner: get ip old fashioned way and use tcp serial console classes/testimage: create a link for qemu boot log lib/oeqa/runtime: rework syslog test
meta/classes/testimage.bbclass | 20 ++++-- meta/lib/oeqa/runtime/syslog.py | 23 +++++-- meta/lib/oeqa/runtime/systemd.py | 35 ++++++++++ meta/lib/oeqa/utils/oeqemuconsole.py | 45 ------------- meta/lib/oeqa/utils/qemurunner.py | 123 +++++++++++++++++++++++------------ 5 files changed, 146 insertions(+), 100 deletions(-) delete mode 100644 meta/lib/oeqa/utils/oeqemuconsole.py
Alexandru Palalau (1):
lib/oeqa/runtime: add new systemd tests
Stefan Stanacar (3):
oeqa/utils/qemurunner: get ip old fashioned way and use tcp serial
console
classes/testimage: create a link for qemu boot log lib/oeqa/runtime: rework syslog test
meta/classes/testimage.bbclass | 20 ++++-- meta/lib/oeqa/runtime/syslog.py | 23 +++++-- meta/lib/oeqa/runtime/systemd.py | 35 ++++++++++ meta/lib/oeqa/utils/oeqemuconsole.py | 45 ------------- meta/lib/oeqa/utils/qemurunner.py | 123 +++++++++++++++++++++++------------ 5 files changed, 146 insertions(+), 100 deletions(-) delete mode 100644 meta/lib/oeqa/utils/oeqemuconsole.py
Signature · 1 line
1.8.3.1
PATCH 1/4 oeqa/utils/qemurunner: get ip old fashioned way and use tcp serial console
The way we read data from the serial console was unreliable and blocking (AutoBuilder seems to hit that often), so change the serial console type from unix socket to tcp and reverse the connection - don't let qemu act as server (wait for a connection). So now the serial console is used to save the boot log and make sure that we reached the login prompt. Until a better way is found this should solve some of the AutoBuilder failures (one being YB#4904).
Also we need to use the same method as the old qemuimagetest to get the ip (from the qemu process arguments), because that it's more reliable. The first version used here was to log into the target and use the output of "ip addr show eth0" but then systemd decides that it should rename interfaces, so that was changed to get the ip of the interface that has the default gw, but if there is no default gw we'll get the loopback ip and we end up trying to ssh into the host machine (some recent AutoBuilder runs showed that).
--- meta/lib/oeqa/utils/oeqemuconsole.py | 45 ------------- meta/lib/oeqa/utils/qemurunner.py | 123 +++++++++++++++++++++++------------ 2 files changed, 81 insertions(+), 87 deletions(-) delete mode 100644 meta/lib/oeqa/utils/oeqemuconsole.py
meta/lib/oeqa/utils/oeqemuconsole.py deleted +0 -45
@@ -1,45 +0,0 @@ -import socket -import time -import re -from telnetlib import Telnet - -class oeQemuConsole(Telnet): - - """ - Override Telnet class to use unix domain sockets, - Telnet uses AF_INET for socket, we don't want that. - Also, provide a read_all variant with timeout, that - returns whatever output there is. - """ - - def __init__(self, stream, logfile): - - Telnet.__init__(self, host=None) - self.stream = stream - self.logfile = logfile - self.eof = 0 - self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - self.sock.connect(stream) - - def log(self, msg): - if self.logfile: - with open(self.logfile, "a") as f: - f.write("%s\n" % msg) - - - def read_all_timeout(self, match, timeout=200): - """Read until EOF or until timeout or until match. - """ - ret = False - self.process_rawq() - endtime = time.time() + timeout - while not self.eof and time.time() < endtime: - self.fill_rawq() - self.process_rawq() - if re.search(match, self.cookedq): - ret = True - break - buf = self.cookedq - self.cookedq = '' - self.log(buf) - return (ret, buf)
meta/lib/oeqa/utils/qemurunner.py +81 -42
199 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 2/4 classes/testimage: create a link for qemu boot log
In reply to Stefan StanacarThe full name for the log is confusing when there are multiple files. Also move the ssh log path stuff where it's needed.
--- meta/classes/testimage.bbclass | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
meta/classes/testimage.bbclass +14 -6
@@ -53,11 +53,6 @@ def testimage_main(d): testdir = d.getVar("TEST_LOG_DIR", True) bb.utils.mkdirhier(testdir) - sshlog = os.path.join(testdir, "ssh_target_log.%s" % d.getVar('DATETIME', True)) - sshloglink = os.path.join(testdir, "ssh_target_log") - if os.path.islink(sshloglink): - os.unlink(sshloglink) - os.symlink(sshlog, sshloglink) # tests in TEST_SUITES become required tests # they won't be skipped even if they aren't suitable for a default image (like xorg for minimal)
@@ -103,9 +98,22 @@ def testimage_main(d): except ValueError: qemu.boottime = 500 + qemuloglink = os.path.join(testdir, "qemu_boot_log") + if os.path.islink(qemuloglink): + os.unlink(qemuloglink) + os.symlink(qemu.logfile, qemuloglink) + + sshlog = os.path.join(testdir, "ssh_target_log.%s" % d.getVar('DATETIME', True)) + sshloglink = os.path.join(testdir, "ssh_target_log") + if os.path.islink(sshloglink): + os.unlink(sshloglink) + os.symlink(sshlog, sshloglink) + + bb.note("DISPLAY value: %s" % qemu.display) bb.note("rootfs file: %s" % rootfs) - bb.note("Qemu logfile: %s" % qemu.logfile) + bb.note("Qemu log file: %s" % qemu.logfile) + bb.note("SSH log file: %s" % sshlog) #catch exceptions when loading or running tests (mostly our own errors) try:
Signature · 1 line
1.8.3.1
PATCH 3/4 lib/oeqa/runtime: rework syslog test
In reply to Stefan StanacarAdd separate tests for restarting syslog and using logger, and skip the configuration test for systemd images which always fail because syslog's systemd service doesn't read a config by default (see YB#4860).
--- meta/lib/oeqa/runtime/syslog.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
meta/lib/oeqa/runtime/syslog.py +16 -7
@@ -14,24 +14,33 @@ class SyslogTest(oeRuntimeTest): self.assertEqual(status, 1, msg="status and output: %s and %s" % (status,output)) @skipUnlessPassed("test_syslog_help") - def test_syslogd_running(self): + def test_syslog_running(self): (status,output) = self.target.run(oeRuntimeTest.pscmd + ' | grep -i [s]yslogd') self.assertEqual(status, 0, msg="no syslogd process, ps output: %s" % self.target.run(oeRuntimeTest.pscmd)[1]) + class SyslogTestConfig(oeRuntimeTest): - def setUp(self): - self.target.run('echo "LOGFILE=/var/log/test" >> /etc/syslog-startup.conf') + @skipUnlessPassed("test_syslog_running") + def test_syslog_logger(self): + (status,output) = self.target.run('logger foobar && grep foobar /var/log/messages') + self.assertEqual(status, 0, msg="Test log string not found in /var/log/messages. Output: %s " % output) - @skipUnlessPassed("test_syslogd_running") - def test_syslogd_configurable(self): + @skipUnlessPassed("test_syslog_running") + def test_syslog_restart(self): if "systemd" != oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager"): (status,output) = self.target.run('/etc/init.d/syslog restart') else: (status,output) = self.target.run('systemctl restart syslog.service') + + @skipUnlessPassed("test_syslog_restart") + @skipUnlessPassed("test_syslog_logger") + @unittest.skipIf("systemd" == oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager"), "Not appropiate for systemd image") + def test_syslog_startup_config(self): + self.target.run('echo "LOGFILE=/var/log/test" >> /etc/syslog-startup.conf') + (status,output) = self.target.run('/etc/init.d/syslog restart') self.assertEqual(status, 0, msg="Could not restart syslog service. Status and output: %s and %s" % (status,output)) (status,output) = self.target.run('logger foobar && grep foobar /var/log/test') self.assertEqual(status, 0, msg="Test log string not found. Output: %s " % output) - - def tearDown(self): self.target.run("sed -i 's#LOGFILE=/var/log/test##' /etc/syslog-startup.conf") + self.target.run('/etc/init.d/syslog restart')
Signature · 1 line
1.8.3.1
PATCH 4/4 lib/oeqa/runtime: add new systemd tests
In reply to Stefan StanacarFrom: Alexandru Palalau <[email protected]>
New systemd runtime tests for enable/disable service, start/stop service and list services.
--- meta/lib/oeqa/runtime/systemd.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
meta/lib/oeqa/runtime/systemd.py +35 -0
@@ -22,3 +22,38 @@ class SystemdTests(oeRuntimeTest): def test_systemd_failed(self): (status, output) = self.target.run('systemctl --failed | grep "0 loaded units listed"') self.assertEqual(status, 0, msg="Failed systemd services: %s" % self.target.run('systemctl --failed')[1]) + + @skipUnlessPassed('test_systemd_version') + def test_systemd_service(self): + (status, output) = self.target.run('systemctl list-unit-files | grep "systemd-hostnamed.service"') + self.assertEqual(status, 0, msg="systemd-hostnamed.service service is not available.") + + @skipUnlessPassed('test_systemd_service') + def test_systemd_stop(self): + self.target.run('systemctl stop systemd-hostnamed.service') + (status, output) = self.target.run('systemctl show systemd-hostnamed.service | grep "ActiveState" | grep "=inactive"') + self.assertEqual(status, 0, msg="systemd-hostnamed.service service could not be stopped.Status and output: %s and %s" % (status, output)) + + @skipUnlessPassed('test_systemd_stop') + @skipUnlessPassed('test_systemd_version') + def test_systemd_start(self): + self.target.run('systemctl start systemd-hostnamed.service') + (status, output) = self.target.run('systemctl show systemd-hostnamed.service | grep "ActiveState" | grep "=active"') + self.assertEqual(status, 0, msg="systemd-hostnamed.service service could not be started. Status and output: %s and %s" % (status, output)) + + @skipUnlessPassed('test_systemd_version') + def test_systemd_enable(self): + self.target.run('systemctl enable machineid.service') + (status, output) = self.target.run('systemctl is-enabled machineid.service') + self.assertEqual(output, 'enabled', msg="machineid.service service could not be enabled. Status and output: %s and %s" % (status, output)) + + @skipUnlessPassed('test_systemd_enable') + def test_systemd_disable(self): + self.target.run('systemctl disable machineid.service') + (status, output) = self.target.run('systemctl is-enabled machineid.service') + self.assertEqual(output, 'disabled', msg="machineid.service service could not be disabled. Status and output: %s and %s" % (status, output)) + + @skipUnlessPassed('test_systemd_version') + def test_systemd_list(self): + (status, output) = self.target.run('systemctl list-unit-files') + self.assertEqual(status, 0, msg="systemctl list-unit-files command failed. Status: %s" % status)
Signature · 1 line
1.8.3.1