use of com.hubspot.singularity.SingularityDeployBuilder in project Singularity by HubSpot.
the class SingularitySchedulerTest method testRunOnceDontMoveDuringDecomission.
@Test
public void testRunOnceDontMoveDuringDecomission() {
SingularityRequestBuilder bldr = new SingularityRequestBuilder(requestId, RequestType.RUN_ONCE);
request = bldr.build();
saveRequest(request);
deployResource.deploy(new SingularityDeployRequest(new SingularityDeployBuilder(requestId, "d1").setCommand(Optional.of("cmd")).build(), Optional.absent(), Optional.absent()), singularityUser);
scheduler.drainPendingQueue();
deployChecker.checkDeploys();
validateTaskDoesntMoveDuringDecommission();
}
use of com.hubspot.singularity.SingularityDeployBuilder in project Singularity by HubSpot.
the class SingularitySchedulerTest method testDifferentQuartzTimeZones.
@Test
public void testDifferentQuartzTimeZones() {
final Optional<String> schedule = Optional.of("* 30 14 22 3 ? 2083");
SingularityRequest requestEST = new SingularityRequestBuilder("est_id", RequestType.SCHEDULED).setSchedule(schedule).setScheduleType(Optional.of(ScheduleType.QUARTZ)).setScheduleTimeZone(// fixed in relation to GMT
Optional.of("EST")).build();
SingularityRequest requestGMT = new SingularityRequestBuilder("gmt_id", RequestType.SCHEDULED).setSchedule(schedule).setScheduleType(Optional.of(ScheduleType.QUARTZ)).setScheduleTimeZone(Optional.of("GMT")).build();
requestResource.postRequest(requestEST, singularityUser);
requestResource.postRequest(requestGMT, singularityUser);
SingularityDeploy deployEST = new SingularityDeployBuilder(requestEST.getId(), "est_deploy_id").setCommand(Optional.of("sleep 1")).build();
SingularityDeploy deployGMT = new SingularityDeployBuilder(requestGMT.getId(), "gmt_deploy_id").setCommand(Optional.of("sleep 1")).build();
deployResource.deploy(new SingularityDeployRequest(deployEST, Optional.absent(), Optional.absent(), Optional.absent()), singularityUser);
deployResource.deploy(new SingularityDeployRequest(deployGMT, Optional.absent(), Optional.absent(), Optional.absent()), singularityUser);
deployChecker.checkDeploys();
scheduler.drainPendingQueue();
final long nextRunEST;
final long nextRunGMT;
final long fiveHoursInMilliseconds = TimeUnit.HOURS.toMillis(5);
final List<SingularityPendingTaskId> pendingTaskIds = taskManager.getPendingTaskIds();
if (pendingTaskIds.get(0).getRequestId().equals(requestEST.getId())) {
nextRunEST = pendingTaskIds.get(0).getNextRunAt();
nextRunGMT = pendingTaskIds.get(1).getNextRunAt();
} else {
nextRunEST = pendingTaskIds.get(1).getNextRunAt();
nextRunGMT = pendingTaskIds.get(0).getNextRunAt();
}
// GMT happens first, so EST is a larger timestamp
Assert.assertEquals(nextRunEST - nextRunGMT, fiveHoursInMilliseconds);
}
use of com.hubspot.singularity.SingularityDeployBuilder in project Singularity by HubSpot.
the class SingularitySchedulerTestBase method deploy.
protected void deploy(String deployId, Optional<Boolean> unpauseOnDeploy, Optional<Integer> deployRate, Optional<Boolean> autoAdvance, boolean loadBalanced) {
SingularityDeployBuilder builder = new SingularityDeployBuilder(requestId, deployId);
builder.setCommand(Optional.of("sleep 1")).setDeployInstanceCountPerStep(deployRate).setAutoAdvanceDeploySteps(autoAdvance).setDeployStepWaitTimeMs(Optional.of(0));
if (loadBalanced) {
Set<String> groups = new HashSet<>(Arrays.asList("group"));
builder.setServiceBasePath(Optional.of("/basepath")).setLoadBalancerGroups(Optional.of(groups));
}
deployResource.deploy(new SingularityDeployRequest(builder.build(), unpauseOnDeploy, Optional.absent()), singularityUser);
}
use of com.hubspot.singularity.SingularityDeployBuilder in project Singularity by HubSpot.
the class SingularitySchedulerTestBase method initLoadBalancedDeploy.
protected void initLoadBalancedDeploy() {
SingularityDeployBuilder builder = new SingularityDeployBuilder(requestId, firstDeployId).setCommand(Optional.of("sleep 100")).setServiceBasePath(Optional.of("/basepath")).setLoadBalancerGroups(Optional.of(Collections.singleton("test")));
firstDeploy = initAndFinishDeploy(request, builder, Optional.absent());
}
use of com.hubspot.singularity.SingularityDeployBuilder in project Singularity by HubSpot.
the class SingularitySchedulerTestBase method deployRequest.
protected SingularityDeploy deployRequest(SingularityRequest request, double cpus, double memoryMb) {
Resources r = new Resources(cpus, memoryMb, 0);
SingularityDeploy deploy = new SingularityDeployBuilder(request.getId(), "deploy1").setCommand(Optional.of("sleep 1")).setResources(Optional.of(r)).build();
deployResource.deploy(new SingularityDeployRequest(deploy, Optional.absent(), Optional.absent()), singularityUser);
return deploy;
}
Aggregations