Search in sources :

Example 6 with SingularityDeployBuilder

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();
}
Also used : SingularityRequestBuilder(com.hubspot.singularity.SingularityRequestBuilder) SingularityDeployRequest(com.hubspot.singularity.api.SingularityDeployRequest) SingularityDeployBuilder(com.hubspot.singularity.SingularityDeployBuilder) Test(org.junit.Test)

Example 7 with SingularityDeployBuilder

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);
}
Also used : SingularityRequestBuilder(com.hubspot.singularity.SingularityRequestBuilder) SingularityDeployRequest(com.hubspot.singularity.api.SingularityDeployRequest) SingularityRequest(com.hubspot.singularity.SingularityRequest) SingularityPendingTaskId(com.hubspot.singularity.SingularityPendingTaskId) SingularityDeployBuilder(com.hubspot.singularity.SingularityDeployBuilder) SingularityDeploy(com.hubspot.singularity.SingularityDeploy) Test(org.junit.Test)

Example 8 with SingularityDeployBuilder

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);
}
Also used : SingularityDeployRequest(com.hubspot.singularity.api.SingularityDeployRequest) SingularityDeployBuilder(com.hubspot.singularity.SingularityDeployBuilder) HashSet(java.util.HashSet)

Example 9 with SingularityDeployBuilder

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());
}
Also used : SingularityDeployBuilder(com.hubspot.singularity.SingularityDeployBuilder)

Example 10 with SingularityDeployBuilder

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;
}
Also used : SingularityDeployRequest(com.hubspot.singularity.api.SingularityDeployRequest) SingularityDeployBuilder(com.hubspot.singularity.SingularityDeployBuilder) Resources(com.hubspot.mesos.Resources) SingularityDeploy(com.hubspot.singularity.SingularityDeploy)

Aggregations

SingularityDeployBuilder (com.hubspot.singularity.SingularityDeployBuilder)47 Test (org.junit.Test)39 SingularityDeploy (com.hubspot.singularity.SingularityDeploy)27 SingularityRequestBuilder (com.hubspot.singularity.SingularityRequestBuilder)17 SingularityRequest (com.hubspot.singularity.SingularityRequest)16 SingularityTask (com.hubspot.singularity.SingularityTask)15 SingularityDeployRequest (com.hubspot.singularity.api.SingularityDeployRequest)15 HealthcheckOptions (com.hubspot.deploy.HealthcheckOptions)10 Resources (com.hubspot.mesos.Resources)10 SingularityTaskRequest (com.hubspot.singularity.SingularityTaskRequest)10 HealthcheckOptionsBuilder (com.hubspot.deploy.HealthcheckOptionsBuilder)9 SingularityTaskHealthcheckResult (com.hubspot.singularity.SingularityTaskHealthcheckResult)8 SingularityMesosTaskHolder (com.hubspot.singularity.helpers.SingularityMesosTaskHolder)8 SingularityContainerInfo (com.hubspot.mesos.SingularityContainerInfo)6 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)6 SingularityDockerInfo (com.hubspot.mesos.SingularityDockerInfo)4 SingularityDockerPortMapping (com.hubspot.mesos.SingularityDockerPortMapping)4 SingularityVolume (com.hubspot.mesos.SingularityVolume)4 SingularityPendingTaskId (com.hubspot.singularity.SingularityPendingTaskId)3 Protos (org.apache.mesos.v1.Protos)3