Skip to content
This repository was archived by the owner on Jul 12, 2023. It is now read-only.

Triggers transition into QUEUED state #26

Merged
merged 4 commits into from
Dec 13, 2016
Merged

Conversation

fabriziodemaria
Copy link
Member

No description provided.

@fabriziodemaria fabriziodemaria force-pushed the queue-triggers branch 2 times, most recently from 882e425 to fd1872e Compare December 9, 2016 12:46
public RunState submit(WorkflowInstance workflowInstance, ExecutionDescription executionDescription) {
switch (state()) {
case QUEUED: // for backwards compatibility
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably also have to be added for the legacy created event.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we added the QUEUED state after deprecating created, we should not have in storage a created transition that was executed on top of a state machine that includes the QUEUED state. Do we really need to allow for that transition in RunState?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind! Modifying triggerExecution behaviour indeed means we need to allow for the created transition from QUEUED.

@@ -101,6 +101,7 @@ public void testRunErrorOnCreating() throws Exception {
public void testSetExecutionId() throws Exception {
transitioner.initialize(RunState.fresh(WORKFLOW_INSTANCE, this::record));
transitioner.receive(eventFactory.triggerExecution("trig"));
transitioner.receive(eventFactory.dequeue());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these tests should not be modified to add a dequeue event but instead the state machine has to be backwards compatible with triggerExecution -> created sequences. See comment above.


@Test
public void shouldExecuteNewTriggers() throws Exception {
StateData stateData = StateData.builder().tries(0).build();
setUp(20, RunState.create(INSTANCE, State.QUEUED, stateData, time));

now = now.plus(15, ChronoUnit.SECONDS);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this line should be removed so that we ensure that it dequeues the state immediately?

givenStoredEvent(Event.retryAfter(workflowInstance, 30000), 13L);
givenActiveStateAtSequenceCount(workflowInstance, 13L);
givenStoredEvent(Event.triggerExecution(workflowInstance, "trig1"), 0L);
givenStoredEvent(Event.dequeue(workflowInstance), 1L);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here as in the RunState test, this test should pass without modification.

@@ -64,23 +64,29 @@ public void shouldCatchUpWithNaturalTriggers() throws Exception {
givenNextNaturalTrigger(HOURLY_WORKFLOW, "2016-03-14T13:00:00Z");

styxStarts();
timePasses(1, SECONDS);
tickTriggerManager();
Thread.sleep(100);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be implemented without a sleep? Perhaps use awaitility to wait for the condition you had in mind.

@rouzwawi
Copy link
Member

I think this looks good.

It was a bit unclear why some of the tests were modified to add the dequeue event. I had to checkout out the code locally and remove those changes to make sure that they were not added to fix a failing test, as opposed to just aligning the tests to use the new event sequence.

Seems all of the ones I tried was the latter, so it's ok. For future changes, make it clear if a test was changed to align or to fix failures.

@fabriziodemaria
Copy link
Member Author

Thanks for pointing that out. I will make my intentions clear with comments the next time tests are changed this way.

@rouzwawi
Copy link
Member

👍

@fabriziodemaria fabriziodemaria merged commit 795a1ae into master Dec 13, 2016
@fabriziodemaria fabriziodemaria deleted the queue-triggers branch December 13, 2016 12:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants