Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] logrotate.py: restore /etc/logrotate.d/wtmp
@ 2019-02-13  5:43 mingli.yu
  2019-02-19  1:56 ` Yu, Mingli
  0 siblings, 1 reply; 2+ messages in thread
From: mingli.yu @ 2019-02-13  5:43 UTC (permalink / raw)
  To: openembedded-core, richard.purdie

From: Mingli Yu <Mingli.Yu@windriver.com>

During the test logrotate.LogrotateTest.test_1_logrotate_setup,
there is below logic:
 # mkdir $HOME/logrotate_dir
 # sed -i "s#wtmp {#wtmp {\n    olddir $HOME/logrotate_dir#" /etc/logrotate.d/wtmp

After all logrotate.LogrotateTest finished, only cleanup
$HOME/logrotate_dir as below, but don't restore
the config file /etc/logrotate.d/wtmp.
[snip]
def tearDownClass(cls):
    cls.tc.target.run('rm -rf $HOME/logrotate_dir')
[snip]

That's to say, there is one additional line added
to /etc/logrotate.d/wtmp and will make the logrotate
service start failed when run systemd.SystemdBasicTests.test_systemd_failed

Take an example as below when run test as root:
 # cat /etc/logrotate.d/wtmp
 # no packages own wtmp -- we'll rotate it here
 /var/log/wtmp {
    olddir /root/logrotate_dir
    missingok
    monthly
    create 0664 root utmp
    minsize 1M
    rotate 1
 }

 # ls /root/logrotate_dir
 ls: cannot access '/root/logrotate_dir': No such file or directory

 # systemctl start logrotate
 Job for logrotate.service failed because the control process exited with error code.
 See "systemctl status logrotate.service" and "journalctl -xe" for details.

 # systemctl status logrotate
  logrotate.service - Rotate log files
   Loaded: loaded (/lib/systemd/system/logrotate.service; static; vendor preset>
   Active: failed (Result: exit-code) since Wed 2019-02-13 03:35:19 UTC; 7s ago
     Docs: man:logrotate(8)
           man:logrotate.conf(5)
   Process: 540 ExecStart=/usr/sbin/logrotate /etc/logrotate.conf (code=exited, status=1/FAILURE)
   Main PID: 540 (code=exited, status=1/FAILURE)

  Feb 13 03:35:18 qemumips systemd[1]: Starting Rotate log files...
  Feb 13 03:35:19 qemumips logrotate[540]: error: wtmp:9 error verifying olddir path /root/logrotate_dir: No such file or directory
  Feb 13 03:35:19 qemumips logrotate[540]: error: found error in file wtmp, skipping
  Feb 13 03:35:19 qemumips systemd[1]: logrotate.service: Main process exited, code=exited, status=1/FAILURE
  Feb 13 03:35:19 qemumips systemd[1]: logrotate.service: Failed with result 'exit-code'.
  Feb 13 03:35:19 qemumips systemd[1]: Failed to start Rotate log files.

Add the logic to restore /etc/logrotate.d/wtmp to
make the cleanup complete to fix the above issue.

Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
---
 meta/lib/oeqa/runtime/cases/logrotate.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/meta/lib/oeqa/runtime/cases/logrotate.py b/meta/lib/oeqa/runtime/cases/logrotate.py
index db6e695..d266644 100644
--- a/meta/lib/oeqa/runtime/cases/logrotate.py
+++ b/meta/lib/oeqa/runtime/cases/logrotate.py
@@ -9,8 +9,12 @@ from oeqa.runtime.decorator.package import OEHasPackage
 class LogrotateTest(OERuntimeTestCase):
 
     @classmethod
+    def setUpClass(cls):
+        cls.tc.target.run('cp /etc/logrotate.d/wtmp $HOME/wtmp.oeqabak')
+
+    @classmethod
     def tearDownClass(cls):
-        cls.tc.target.run('rm -rf $HOME/logrotate_dir')
+        cls.tc.target.run('mv -f $HOME/wtmp.oeqabak /etc/logrotate.d/wtmp && rm -rf $HOME/logrotate_dir')
 
     @OETestID(1544)
     @OETestDepends(['ssh.SSHTest.test_ssh'])
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] logrotate.py: restore /etc/logrotate.d/wtmp
  2019-02-13  5:43 [PATCH] logrotate.py: restore /etc/logrotate.d/wtmp mingli.yu
@ 2019-02-19  1:56 ` Yu, Mingli
  0 siblings, 0 replies; 2+ messages in thread
From: Yu, Mingli @ 2019-02-19  1:56 UTC (permalink / raw)
  To: openembedded-core, richard.purdie

Ping.

This patch is used to fix the incomplete cleanup for logrotate test in oeqa.

Thanks,

On 2019年02月13日 13:43, mingli.yu@windriver.com wrote:
> From: Mingli Yu <Mingli.Yu@windriver.com>
>
> During the test logrotate.LogrotateTest.test_1_logrotate_setup,
> there is below logic:
>   # mkdir $HOME/logrotate_dir
>   # sed -i "s#wtmp {#wtmp {\n    olddir $HOME/logrotate_dir#" /etc/logrotate.d/wtmp
>
> After all logrotate.LogrotateTest finished, only cleanup
> $HOME/logrotate_dir as below, but don't restore
> the config file /etc/logrotate.d/wtmp.
> [snip]
> def tearDownClass(cls):
>      cls.tc.target.run('rm -rf $HOME/logrotate_dir')
> [snip]
>
> That's to say, there is one additional line added
> to /etc/logrotate.d/wtmp and will make the logrotate
> service start failed when run systemd.SystemdBasicTests.test_systemd_failed
>
> Take an example as below when run test as root:
>   # cat /etc/logrotate.d/wtmp
>   # no packages own wtmp -- we'll rotate it here
>   /var/log/wtmp {
>      olddir /root/logrotate_dir
>      missingok
>      monthly
>      create 0664 root utmp
>      minsize 1M
>      rotate 1
>   }
>
>   # ls /root/logrotate_dir
>   ls: cannot access '/root/logrotate_dir': No such file or directory
>
>   # systemctl start logrotate
>   Job for logrotate.service failed because the control process exited with error code.
>   See "systemctl status logrotate.service" and "journalctl -xe" for details.
>
>   # systemctl status logrotate
>    logrotate.service - Rotate log files
>     Loaded: loaded (/lib/systemd/system/logrotate.service; static; vendor preset>
>     Active: failed (Result: exit-code) since Wed 2019-02-13 03:35:19 UTC; 7s ago
>       Docs: man:logrotate(8)
>             man:logrotate.conf(5)
>     Process: 540 ExecStart=/usr/sbin/logrotate /etc/logrotate.conf (code=exited, status=1/FAILURE)
>     Main PID: 540 (code=exited, status=1/FAILURE)
>
>    Feb 13 03:35:18 qemumips systemd[1]: Starting Rotate log files...
>    Feb 13 03:35:19 qemumips logrotate[540]: error: wtmp:9 error verifying olddir path /root/logrotate_dir: No such file or directory
>    Feb 13 03:35:19 qemumips logrotate[540]: error: found error in file wtmp, skipping
>    Feb 13 03:35:19 qemumips systemd[1]: logrotate.service: Main process exited, code=exited, status=1/FAILURE
>    Feb 13 03:35:19 qemumips systemd[1]: logrotate.service: Failed with result 'exit-code'.
>    Feb 13 03:35:19 qemumips systemd[1]: Failed to start Rotate log files.
>
> Add the logic to restore /etc/logrotate.d/wtmp to
> make the cleanup complete to fix the above issue.
>
> Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> ---
>   meta/lib/oeqa/runtime/cases/logrotate.py | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/meta/lib/oeqa/runtime/cases/logrotate.py b/meta/lib/oeqa/runtime/cases/logrotate.py
> index db6e695..d266644 100644
> --- a/meta/lib/oeqa/runtime/cases/logrotate.py
> +++ b/meta/lib/oeqa/runtime/cases/logrotate.py
> @@ -9,8 +9,12 @@ from oeqa.runtime.decorator.package import OEHasPackage
>   class LogrotateTest(OERuntimeTestCase):
>
>       @classmethod
> +    def setUpClass(cls):
> +        cls.tc.target.run('cp /etc/logrotate.d/wtmp $HOME/wtmp.oeqabak')
> +
> +    @classmethod
>       def tearDownClass(cls):
> -        cls.tc.target.run('rm -rf $HOME/logrotate_dir')
> +        cls.tc.target.run('mv -f $HOME/wtmp.oeqabak /etc/logrotate.d/wtmp && rm -rf $HOME/logrotate_dir')
>
>       @OETestID(1544)
>       @OETestDepends(['ssh.SSHTest.test_ssh'])
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-19  1:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-13  5:43 [PATCH] logrotate.py: restore /etc/logrotate.d/wtmp mingli.yu
2019-02-19  1:56 ` Yu, Mingli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox