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

Next natural trigger bug fix #27

Merged
merged 2 commits into from
Dec 14, 2016
Merged

Next natural trigger bug fix #27

merged 2 commits into from
Dec 14, 2016

Conversation

TinaRanic
Copy link
Contributor

Fixes #24

patch.commitSha().isPresent() ? patch.commitSha() : o.commitSha())
o -> {
WorkflowState.Builder builder = o.toBuilder()
.enabled(patch.enabled().orElse(originalWorkflowState.get().enabled().orElse(false)));
Copy link
Member

Choose a reason for hiding this comment

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

This line should use o instead of originalWorkflowState

dockerImage.ifPresent(di -> builder.dockerImage(di));
commitSha.ifPresent(cs -> builder.commitSha(cs));
nextNaturalTrigger.ifPresent(nnt -> builder.nextNaturalTrigger(nnt));
return builder.build();
Copy link
Member

Choose a reason for hiding this comment

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

Why not just call the AutoValue_WorkflowState constructor?

Copy link
Contributor Author

@TinaRanic TinaRanic Dec 13, 2016

Choose a reason for hiding this comment

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

Because when I use AutoValue.Builder, the AutoValue_WorkflowState constructor becomes private. I didn't find a way of keeping it public.

Copy link
Member

Choose a reason for hiding this comment

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

ok

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess all of these could be use method references rather than lambdas?

enabled.ifPresent(builder::enabled);


injectEvent(Event.started(workflowInstance));
injectEvent(Event.terminate(workflowInstance, 0));
Thread.sleep(1000);
Copy link
Member

Choose a reason for hiding this comment

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

Try using awaitWorkflowInstanceState instead of sleeping. I believe this line is waiting for the state to be in AWAITING_RETRY.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test verifies that after a wf has executed successfully with a given parameter, a change of its run specification wont re-trigger the WFI with the same parameter.

I want to check if the state is DONE, but using the awaitility didn't work because the state has been already processed (is not anymore in activeStates), so getState returns null. But I can just remove the sleeping assuming that the state will always reach DONE before starting a new statement?

Copy link
Member

Choose a reason for hiding this comment

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

How about adding a way to await that a workflow instance completes? e.g. awaitWorkflowInstanceCompletion(wfi) that will wait until the state manager returns a null state'

DATA_ENDPOINT_DAILY.secret())));
timePasses(StyxScheduler.SCHEDULER_TICK_INTERVAL_SECONDS, SECONDS);

Thread.sleep(1000);
Copy link
Member

Choose a reason for hiding this comment

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

Same here, avoid sleeps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't find Awaitility way to check that something has not changed.

@rouzwawi
Copy link
Member

Some comments, but looks good overall.

The tests need some changes, plus a rebase.

@TinaRanic TinaRanic force-pushed the nextNaturalTrigger-bugFix branch 2 times, most recently from 16eb6b8 to 6b8d18a Compare December 13, 2016 20:36
@rouzwawi
Copy link
Member

👍

Copy link
Contributor

@bergman bergman left a comment

Choose a reason for hiding this comment

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

Looks good. Only had minor nitpicks.

dockerImage.ifPresent(di -> builder.dockerImage(di));
commitSha.ifPresent(cs -> builder.commitSha(cs));
nextNaturalTrigger.ifPresent(nnt -> builder.nextNaturalTrigger(nnt));
return builder.build();
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess all of these could be use method references rather than lambdas?

enabled.ifPresent(builder::enabled);

@@ -480,7 +485,7 @@ private TriggerListener trigger(
};
}

private static Consumer<Workflow> workflowChanged(
private Consumer<Workflow> workflowChanged(
Copy link
Contributor

Choose a reason for hiding this comment

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

Most other methods in this class seem to be static and get passed everything needed. Did you consider passing time into this method instead of making it an instance method?

/**
* Fast forwards the time without any execution in-between.
*/
void timeJumps(int n, TimeUnit unit) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think it's somehow possible to have the distinction even clearer between timePasses and timeJumps without having to read the javadoc? jump compared to pass is in the right direction but I would definitely need to read the javadoc to know for sure.

Not a big deal at all, just thought it was unclear.

getDockerImage(workflowId),
getCommitSha(workflowId));
WorkflowState.Builder builder = WorkflowState.builder().enabled(enabled(workflowId));
getDockerImage(workflowId).ifPresent(dockerImage -> builder.dockerImage(dockerImage));
Copy link
Contributor

Choose a reason for hiding this comment

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

method references

}

public static WorkflowState patchDockerImage(String dockerImage) {
return create(Optional.empty(), of(dockerImage), Optional.empty());
return builder().dockerImage(dockerImage).build();
}

public static WorkflowState patchEnabled(boolean enabled) {
Copy link
Contributor

Choose a reason for hiding this comment

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

These convenience methods don't make much sense after adding a builder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, lets refactor that in another PR?

@TinaRanic TinaRanic force-pushed the nextNaturalTrigger-bugFix branch from 6b8d18a to 62d03e8 Compare December 14, 2016 18:09
@bergman
Copy link
Contributor

bergman commented Dec 14, 2016

👍

@TinaRanic TinaRanic merged commit a0ca5da into master Dec 14, 2016
@TinaRanic TinaRanic deleted the nextNaturalTrigger-bugFix branch December 14, 2016 18:24
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.

3 participants