Search in sources :

Example 1 with MesosProtosUtils

use of com.hubspot.singularity.helpers.MesosProtosUtils in project Singularity by HubSpot.

the class SingularityMesosTaskBuilderTest method createMocks.

@Before
public void createMocks() {
    pendingTask = new SingularityPendingTaskBuilder().setPendingTaskId(new SingularityPendingTaskId("test", "1", 0, 1, PendingType.IMMEDIATE, 0)).setUser(user).build();
    final SingularitySlaveAndRackHelper slaveAndRackHelper = mock(SingularitySlaveAndRackHelper.class);
    final ExecutorIdGenerator idGenerator = mock(ExecutorIdGenerator.class);
    when(idGenerator.getNextExecutorId()).then(new CreateFakeId());
    objectMapper = new ObjectMapper();
    objectMapper.registerModule(new ProtobufModule());
    objectMapper.registerModule(new GuavaModule());
    builder = new SingularityMesosTaskBuilder(objectMapper, idGenerator, configuration, new MesosProtosUtils(objectMapper));
    taskResources = new Resources(1, 1, 0, 0);
    executorResources = new Resources(0.1, 1, 0, 0);
    when(slaveAndRackHelper.getRackId(offer)).thenReturn(Optional.absent());
    when(slaveAndRackHelper.getMaybeTruncatedHost(offer)).thenReturn("host");
    when(slaveAndRackHelper.getRackIdOrDefault(offer)).thenReturn("DEFAULT");
    offer = Offer.newBuilder().setAgentId(AgentID.newBuilder().setValue("1")).setId(OfferID.newBuilder().setValue("1")).setFrameworkId(FrameworkID.newBuilder().setValue("1")).setHostname("test").build();
    offerHolder = new SingularityOfferHolder(Collections.singletonList(offer), 1, "DEFAULT", offer.getAgentId().getValue(), offer.getHostname(), Collections.emptyMap(), Collections.emptyMap());
}
Also used : MesosProtosUtils(com.hubspot.singularity.helpers.MesosProtosUtils) ExecutorIdGenerator(com.hubspot.singularity.data.ExecutorIdGenerator) SingularityPendingTaskId(com.hubspot.singularity.SingularityPendingTaskId) ProtobufModule(com.hubspot.jackson.datatype.protobuf.ProtobufModule) Resources(com.hubspot.mesos.Resources) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) GuavaModule(com.fasterxml.jackson.datatype.guava.GuavaModule) SingularityPendingTaskBuilder(com.hubspot.singularity.SingularityPendingTaskBuilder) Before(org.junit.Before)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)1 ProtobufModule (com.hubspot.jackson.datatype.protobuf.ProtobufModule)1 Resources (com.hubspot.mesos.Resources)1 SingularityPendingTaskBuilder (com.hubspot.singularity.SingularityPendingTaskBuilder)1 SingularityPendingTaskId (com.hubspot.singularity.SingularityPendingTaskId)1 ExecutorIdGenerator (com.hubspot.singularity.data.ExecutorIdGenerator)1 MesosProtosUtils (com.hubspot.singularity.helpers.MesosProtosUtils)1 Before (org.junit.Before)1