mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fixing a bug that occurs if the "enabled" key is present in the scheduler items dictionary. Adding a test to ensure scheduler runs as expected when that key is present.
This commit is contained in:
parent
b87bf905c2
commit
8935c08141
2 changed files with 35 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,35 @@ 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