mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #49019 from garethgreenaway/47695_fixing_scheduler_bug_when_enabled_is_present
[2018.3] Fix to scheduler when global enabled key is present
This commit is contained in:
commit
d353c02a8c
2 changed files with 34 additions and 3 deletions
|
@ -843,15 +843,15 @@ class Schedule(object):
|
|||
'skip_during_range']
|
||||
for job, data in six.iteritems(schedule):
|
||||
|
||||
if job in _hidden:
|
||||
continue
|
||||
|
||||
# Clear out _skip_reason from previous runs
|
||||
if '_skip_reason' in data:
|
||||
del data['_skip_reason']
|
||||
|
||||
run = False
|
||||
|
||||
if job in _hidden:
|
||||
continue
|
||||
|
||||
if not isinstance(data, dict):
|
||||
log.error(
|
||||
'Scheduled job "%s" should have a dict value, not %s',
|
||||
|
|
|
@ -397,3 +397,34 @@ 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_enabled(self):
|
||||
'''
|
||||
verify that scheduled job runs
|
||||
when the enabled key is in place
|
||||
https://github.com/saltstack/salt/issues/47695
|
||||
'''
|
||||
job = {
|
||||
'schedule': {
|
||||
'enabled': True,
|
||||
'job1': {
|
||||
'function': 'test.ping',
|
||||
'when': '11/29/2017 4:00pm',
|
||||
}
|
||||
}
|
||||
}
|
||||
run_time2 = dateutil_parser.parse('11/29/2017 4:00pm')
|
||||
run_time1 = run_time2 - datetime.timedelta(seconds=1)
|
||||
|
||||
# Add the job to the scheduler
|
||||
self.schedule.opts.update(job)
|
||||
|
||||
# Evaluate 1 second before the run time
|
||||
self.schedule.eval(now=run_time1)
|
||||
ret = self.schedule.job_status('job1')
|
||||
self.assertNotIn('_last_run', ret)
|
||||
|
||||
# Evaluate 1 second at the run time
|
||||
self.schedule.eval(now=run_time2)
|
||||
ret = self.schedule.job_status('job1')
|
||||
self.assertEqual(ret['_last_run'], run_time2)
|
||||
|
|
Loading…
Add table
Reference in a new issue