Fix logrotate tests

In order for logrotate command to return 0 exit status we could
call it without -f key for the first time.

+Add force parameter to execute_logrotate_cmd helper

Change-Id: Id9f7f947a1cc1313795ba693df63e3372028e499
Closes-Bug: #1559014
This commit is contained in:
Volodymyr Shypyguzov 2016-03-21 18:59:35 +02:00
parent c058667639
commit 79441cc163

View File

@ -106,9 +106,10 @@ class TestLogrotateBase(TestBasic):
'Execution result is: {1}'.format(cmd, result))
@staticmethod
def execute_logrotate_cmd(remote, cmd=None, exit_code=None):
def execute_logrotate_cmd(remote, force=True, cmd=None, exit_code=None):
if not cmd:
cmd = 'logrotate -v -f /etc/logrotate.conf'
cmd = 'logrotate -v {0} /etc/logrotate.conf'.format(
'-f' if force else "")
result = remote.execute(cmd)
logger.debug(
'Results of command {0} execution exit_code:{1} '
@ -209,7 +210,7 @@ class TestLogrotateBase(TestBasic):
'creation {2}{3}'.format(free, suff, free2, suff2))
self.show_step(4)
self.execute_logrotate_cmd(remote)
self.execute_logrotate_cmd(remote, force=False)
free3, suff3 = self.check_free_space(remote)
logger.debug('Free space after first '
@ -349,7 +350,7 @@ class TestLogrotateBase(TestBasic):
'free space after '
'creation {2}{3}'.format(free, suff, free2, suff2))
self.show_step(4)
self.execute_logrotate_cmd(remote)
self.execute_logrotate_cmd(remote, force=False)
free3, suff3 = self.check_free_space(remote)
logger.debug('free space after first '
@ -430,7 +431,7 @@ class TestLogrotateBase(TestBasic):
'free space after '
'creation {1}'.format(free, free2))
self.show_step(4)
self.execute_logrotate_cmd(remote)
self.execute_logrotate_cmd(remote, force=False)
free3 = self.check_free_space(remote, return_as_is=True)
logger.debug('Free space after first'