Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure run once tasks don't get launched at startup #903

Merged
merged 2 commits into from
Feb 23, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public boolean isAlwaysRunning() {

@JsonIgnore
public boolean isOneOff() {
return requestType == RequestType.ON_DEMAND;
return requestType == RequestType.ON_DEMAND || requestType == RequestType.RUN_ONCE;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wsorenson do you agree with this approach, or would you rather I update the check in SingularityStartup?

}

@JsonIgnore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void testScheduledTasksDontGetRescheduledDuringRun() {
}

@Test
public void testOneOffDoesntGetRescheduled() {
public void testOnDemandDoesntGetRescheduled() {
saveRequest(new SingularityRequestBuilder(requestId, RequestType.ON_DEMAND).build());
deploy(firstDeployId);
deployChecker.checkDeploys();
Expand All @@ -142,4 +142,24 @@ public void testOneOffDoesntGetRescheduled() {
Assert.assertTrue(requestManager.getPendingRequests().get(0).getPendingType() == PendingType.ONEOFF);
}

@Test
public void testRunOnceDoesntGetRescheduled() {
saveRequest(new SingularityRequestBuilder(requestId, RequestType.RUN_ONCE).build());
deploy(firstDeployId);
deployChecker.checkDeploys();

Assert.assertTrue(requestManager.getPendingRequests().isEmpty());
Assert.assertTrue(taskManager.getPendingTaskIds().isEmpty());

startup.checkSchedulerForInconsistentState();

Assert.assertTrue(requestManager.getPendingRequests().isEmpty());
Assert.assertTrue(taskManager.getPendingTaskIds().isEmpty());

requestManager.addToPendingQueue(new SingularityPendingRequest(requestId, firstDeployId, System.currentTimeMillis(), Optional.<String> absent(), PendingType.ONEOFF, Optional.<Boolean> absent(), Optional.<String> absent()));

startup.checkSchedulerForInconsistentState();

Assert.assertTrue(requestManager.getPendingRequests().get(0).getPendingType() == PendingType.ONEOFF);
}
}