From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Jon Mason <jdmason@kudzu.us>, openembedded-core@lists.openembedded.org
Subject: Re: [PATCH] oe_syslog.py: Handle syslogd/klogd restart race
Date: Fri, 21 Jun 2019 17:14:52 +0100 [thread overview]
Message-ID: <eea8e0445b82a8fd472fa9333a665555a990728a.camel@linuxfoundation.org> (raw)
In-Reply-To: <20190621154213.12761-1-jdmason@kudzu.us>
On Fri, 2019-06-21 at 11:42 -0400, Jon Mason wrote:
> syslogd and klogd can occasionally take too long to restart, which
> causes tests to fail by starting before the log daemons are ready. To
> work around this problem, poll for up to 30 seconds on the processes to
> verify the old ones are killed and the new ones are up and running.
>
> [YOCTO #13379]
>
> Signed-off-by: Jon Mason <jdmason@kudzu.us>
> ---
> meta/lib/oeqa/runtime/cases/oe_syslog.py | 37 ++++++++++++++++++++++++
> 1 file changed, 37 insertions(+)
>
> diff --git a/meta/lib/oeqa/runtime/cases/oe_syslog.py b/meta/lib/oeqa/runtime/cases/oe_syslog.py
> index 0f5f9f43ca..3270a0fc88 100644
> --- a/meta/lib/oeqa/runtime/cases/oe_syslog.py
> +++ b/meta/lib/oeqa/runtime/cases/oe_syslog.py
> @@ -50,9 +50,46 @@ class SyslogTestConfig(OERuntimeTestCase):
> @skipIfDataVar('VIRTUAL-RUNTIME_init_manager', 'systemd',
> 'Not appropiate for systemd image')
> def test_syslog_startup_config(self):
> + status, syslogd_pid = self.target.run('pidof syslogd')
> + status, klogd_pid = self.target.run('pidof klogd')
> +
> cmd = 'echo "LOGFILE=/var/log/test" >> /etc/syslog-startup.conf'
> self.target.run(cmd)
> status, output = self.target.run('/etc/init.d/syslog restart')
> +
> + # Error, most likely a race between shutting down and starting up
> + if status:
> + import time
> + timeout = time.time() + 30
> +
> + while time.time() < timeout:
> + time.sleep(1)
> + # Verify the old ones are no longer running
> + status, output = self.target.run('kill -0 %s' %syslogd_pid)
> + if not status:
> + self.logger.debug("old syslogd is running")
> + continue
> +
> + status, output = self.target.run('kill -0 %s' %klogd_pid)
> + if not status:
> + self.logger.debug("old klogd is running")
> + continue
> +
> + # Verify the new ones are running
> + status, new_syslogd_pid = self.target.run('pidof syslogd')
> + if status:
> + self.logger.debug("new syslogd is not running")
> + continue
> +
> + status, new_klogd_pid = self.target.run('pidof klogd')
> + if status:
> + self.logger.debug("new syslogd is not running")
> + continue
> +
> + # Everything is fine now, so keep running
> + status = 0
> + break
> +
> msg = ('Could not restart syslog service. Status and output:'
> ' %s and %s' % (status,output))
> self.assertEqual(status, 0, msg)
Thanks, I think this is reasonable however I think we may need to make
the above a function and then call it from other places in the tests in
that file.
test_syslog_restart should check it did restart using the above
test_syslog_startup_config does a second restart which we should also
check?
Out of interest were you able to see error codes being returned in
status in your tests?
Cheers,
Richard
next prev parent reply other threads:[~2019-06-21 16:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-21 15:42 [PATCH] oe_syslog.py: Handle syslogd/klogd restart race Jon Mason
2019-06-21 16:14 ` Richard Purdie [this message]
2019-06-21 16:39 ` Jon Mason
2019-06-21 16:58 ` richard.purdie
2019-06-21 17:44 ` Jon Mason
2019-06-21 19:26 ` Jon Mason
2019-06-21 21:37 ` richard.purdie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eea8e0445b82a8fd472fa9333a665555a990728a.camel@linuxfoundation.org \
--to=richard.purdie@linuxfoundation.org \
--cc=jdmason@kudzu.us \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox