By default logrotate uses 'dateext' in logrotate.conf which results in a
date string being appended at the end of log name. In cases when a test
that installs configuration in logrotate.d is executed first (dnf for
example), it might result in errors when logrotate test is executed:
error: destination /var/log/dnf.librepo.log-
20190528 already exists, skipping rotation
error: destination /var/log/dnf.rpm.log-
20190528 already exists, skipping rotation
error: destination /var/log/hawkey.log-
20190528 already exists, skipping rotation
Tweak the test to use it's own temporary configuration that doesn't
enable dateext.
Fixes [YOCTO #13363]
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
@OETestDepends(['logrotate.LogrotateTest.test_1_logrotate_setup'])
def test_2_logrotate(self):
- status, output = self.target.run('logrotate -f /etc/logrotate.conf')
+ status, output = self.target.run('echo "create \n include /etc/logrotate.d" > /tmp/logrotate-test.conf')
+ status, output = self.target.run('logrotate -f /tmp/logrotate-test.conf')
+
msg = ('logrotate service could not be reloaded. Status and output: '
'%s and %s' % (status, output))
self.assertEqual(status, 0, msg = msg)