Prevent multiple execution of commands scheduled in the past#121
Merged
devblackops merged 8 commits intoposhbotio:masterfrom Oct 11, 2018
AngleOSaxon:schedule_fix
Merged
Prevent multiple execution of commands scheduled in the past#121devblackops merged 8 commits intoposhbotio:masterfrom AngleOSaxon:schedule_fix
devblackops merged 8 commits intoposhbotio:masterfrom
AngleOSaxon:schedule_fix
Conversation
Also renames the ScheduleMessage tests so they automatically run
Adds 'hidden' empty constructor for Logger class to allow easier mocking
Member
|
Thanks @AngleOSaxon! 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ScheduledMessage.RecalculateStartAfter()logic to advanceStartAfteruntil it moves past the current dateStartAftertimes are expected to be UTCScheduler.LoadStateto callRecalculateStartAfter()on loaded schedules whoseStartAfteris before the current timehiddenparameterless constructor forLogger, to enable some mockingRelated Issue
#120
Motivation and Context
If a command was originally scheduled several months ago and the bot is restarted, a very large number of executions will occur very quickly. Depending on the command scheduled, this may prove problematic.
How Has This Been Tested?
Added unit tests to
ScheduledMessages.tests.ps1to check the behavior ofRecalculateStartAfter()with dates in the future and the past.Added unit tests (and some hacky mocks) in
Scheduler.tests.ps1to check the behavior ofScheduler.LoadState()when a schedule with aStartAfterin the past is loaded.Manually started a bot and ran
!newschedule --command 'help' --interval minutes --value 5 --startafter '2018-10-01 12:25pm'and verified that only one response was produced immediately. Restarted the bot and verified that no responses were produced on schedule load.Screenshots (if appropriate):
Types of changes
Checklist: