when a timer fires, it should also schedule a decision (#4791)

This commit is contained in:
Jim Cockburn 2022-01-25 16:45:02 +00:00 committed by GitHub
parent 5e9c238fcc
commit d5fcc31763
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -726,6 +726,7 @@ class WorkflowExecution(BaseModel):
"TimerFired", started_event_id=started_event_id, timer_id=timer_id
)
self._timers.pop(timer_id)
self._schedule_decision_task()
def cancel_timer(self, event_id, timer_id):
requested_timer = self._timers.get(timer_id)

View File

@ -589,10 +589,12 @@ def test_start_timer_correctly_fires_timer_later():
# Small wait to let both events populate
sleep(0.5)
second_to_last_event = wfe.events()[-2]
last_event = wfe.events()[-1]
last_event.event_type.should.equal("TimerFired")
last_event.event_attributes["timerId"].should.equal("abc123")
last_event.event_attributes["startedEventId"].should.equal(1)
second_to_last_event.event_type.should.equal("TimerFired")
second_to_last_event.event_attributes["timerId"].should.equal("abc123")
second_to_last_event.event_attributes["startedEventId"].should.equal(1)
last_event.event_type.should.equal("DecisionTaskScheduled")
def test_start_timer_fails_if_timer_already_started():

View File

@ -505,16 +505,17 @@ def test_start_and_fire_timer_decision():
"DecisionTaskCompleted",
"TimerStarted",
"TimerFired",
"DecisionTaskScheduled",
]
)
resp["events"][-2]["timerStartedEventAttributes"].should.equal(
resp["events"][-3]["timerStartedEventAttributes"].should.equal(
{
"decisionTaskCompletedEventId": 4,
"startToFireTimeout": "1",
"timerId": "timer1",
}
)
resp["events"][-1]["timerFiredEventAttributes"].should.equal(
resp["events"][-2]["timerFiredEventAttributes"].should.equal(
{"startedEventId": 5, "timerId": "timer1"}
)