mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Fixing a bug that would result in constant changes using the schedule state module when a job was added with run_on_start. Adding an eval test to test run_on_start functionality.
This commit is contained in:
parent
d2516b251f
commit
da9a9b6e37
@ -58,7 +58,7 @@ SCHEDULE_CONF = [
|
||||
'after',
|
||||
'return_config',
|
||||
'return_kwargs',
|
||||
'run_on_start'
|
||||
'run_on_start',
|
||||
'skip_during_range',
|
||||
'run_after_skip_range',
|
||||
]
|
||||
|
@ -1234,7 +1234,7 @@ class Schedule(object):
|
||||
|
||||
# If there is no job specific skip_during_range available,
|
||||
# grab the global which defaults to None.
|
||||
if 'skip_during_range' not in data:
|
||||
if 'skip_during_range' not in data and self.skip_during_range:
|
||||
data['skip_during_range'] = self.skip_during_range
|
||||
|
||||
if 'skip_during_range' in data and data['skip_during_range']:
|
||||
|
@ -368,3 +368,33 @@ class SchedulerEvalTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
self.schedule.eval(now=run_time)
|
||||
ret = self.schedule.job_status('job1')
|
||||
self.assertEqual(ret['_last_run'], run_time)
|
||||
|
||||
def test_eval_run_on_start(self):
|
||||
'''
|
||||
verify that scheduled job is run when minion starts
|
||||
'''
|
||||
job = {
|
||||
'schedule': {
|
||||
'job1': {
|
||||
'function': 'test.ping',
|
||||
'hours': '1',
|
||||
'run_on_start': True
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Add job to schedule
|
||||
self.schedule.opts.update(job)
|
||||
|
||||
# eval at 2:00pm, will run.
|
||||
run_time = dateutil_parser.parse('11/29/2017 2:00pm')
|
||||
self.schedule.eval(now=run_time)
|
||||
ret = self.schedule.job_status('job1')
|
||||
self.assertEqual(ret['_last_run'], run_time)
|
||||
|
||||
# eval at 3:00pm, will run.
|
||||
run_time = dateutil_parser.parse('11/29/2017 3:00pm')
|
||||
self.schedule.eval(now=run_time)
|
||||
ret = self.schedule.job_status('job1')
|
||||
self.assertEqual(ret['_last_run'], run_time)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user