use of com.hashicorp.nomad.apimodel.TaskGroup in project incubator-heron by apache.
the class NomadSchedulerTest method testGetTaskGroup.
@Test
public void testGetTaskGroup() {
Set<PackingPlan.ContainerPlan> containers = new HashSet<>();
containers.add(Mockito.mock(PackingPlan.ContainerPlan.class));
Resource resource = new Resource(CPU_RESOURCE, MEMORY_RESOURCE, DISK_RESOURCE);
PackingPlan.ContainerPlan containerPlan = new PackingPlan.ContainerPlan(CONTAINER_INDEX, new HashSet<>(), Mockito.mock(Resource.class));
scheduler.initialize(this.mockConfig, this.mockRuntime);
Mockito.doReturn(new Task()).when(scheduler).getTask(Mockito.anyString(), Mockito.anyInt(), Mockito.any());
TaskGroup taskGroup = scheduler.getTaskGroup(GROUP_NAME, CONTAINER_INDEX, resource);
LOG.info("taskGroup: " + taskGroup);
Assert.assertEquals(GROUP_NAME, taskGroup.getName());
Assert.assertNotNull(taskGroup.getCount());
Assert.assertNotNull(taskGroup.getTasks());
}
use of com.hashicorp.nomad.apimodel.TaskGroup in project incubator-heron by apache.
the class NomadSchedulerTest method testGetJob.
@Test
public void testGetJob() {
Set<PackingPlan.ContainerPlan> containers = new HashSet<>();
containers.add(Mockito.mock(PackingPlan.ContainerPlan.class));
PackingPlan.ContainerPlan containerPlan = new PackingPlan.ContainerPlan(CONTAINER_INDEX, new HashSet<>(), Mockito.mock(Resource.class));
Optional<PackingPlan.ContainerPlan> plan = Optional.of(containerPlan);
Resource resource = new Resource(CPU_RESOURCE, MEMORY_RESOURCE, DISK_RESOURCE);
scheduler.initialize(this.mockConfig, this.mockRuntime);
Mockito.doReturn(new TaskGroup()).when(scheduler).getTaskGroup(Mockito.anyString(), Mockito.anyInt(), Mockito.any());
Job job = scheduler.getJob(CONTAINER_INDEX, plan, resource);
LOG.info("job: " + job);
Assert.assertEquals(TOPOLOGY_ID + "-" + CONTAINER_INDEX, job.getId());
Assert.assertEquals(TOPOLOGY_NAME + "-" + CONTAINER_INDEX, job.getName());
Assert.assertArrayEquals(Arrays.asList(NomadConstants.NOMAD_DEFAULT_DATACENTER).toArray(), job.getDatacenters().toArray());
Assert.assertNotNull(job.getTaskGroups());
}
use of com.hashicorp.nomad.apimodel.TaskGroup in project heron by twitter.
the class NomadSchedulerTest method testGetJob.
@Test
public void testGetJob() {
Set<PackingPlan.ContainerPlan> containers = new HashSet<>();
containers.add(Mockito.mock(PackingPlan.ContainerPlan.class));
PackingPlan.ContainerPlan containerPlan = new PackingPlan.ContainerPlan(CONTAINER_INDEX, new HashSet<>(), Mockito.mock(Resource.class));
Optional<PackingPlan.ContainerPlan> plan = Optional.of(containerPlan);
Resource resource = new Resource(CPU_RESOURCE, MEMORY_RESOURCE, DISK_RESOURCE);
scheduler.initialize(this.mockConfig, this.mockRuntime);
Mockito.doReturn(new TaskGroup()).when(scheduler).getTaskGroup(Mockito.anyString(), Mockito.anyInt(), Mockito.any());
Job job = scheduler.getJob(CONTAINER_INDEX, plan, resource);
LOG.info("job: " + job);
Assert.assertEquals(TOPOLOGY_ID + "-" + CONTAINER_INDEX, job.getId());
Assert.assertEquals(TOPOLOGY_NAME + "-" + CONTAINER_INDEX, job.getName());
Assert.assertArrayEquals(Arrays.asList(NomadConstants.NOMAD_DEFAULT_DATACENTER).toArray(), job.getDatacenters().toArray());
Assert.assertNotNull(job.getTaskGroups());
}
use of com.hashicorp.nomad.apimodel.TaskGroup in project incubator-heron by apache.
the class NomadScheduler method getTaskGroup.
TaskGroup getTaskGroup(String groupName, int containerIndex, Resource containerResource) {
TaskGroup taskGroup = new TaskGroup();
taskGroup.setCount(1);
taskGroup.setName(groupName);
taskGroup.addTasks(getTask(groupName, containerIndex, containerResource));
return taskGroup;
}
use of com.hashicorp.nomad.apimodel.TaskGroup in project heron by twitter.
the class NomadScheduler method getTaskGroup.
TaskGroup getTaskGroup(String groupName, int containerIndex, Resource containerResource) {
TaskGroup taskGroup = new TaskGroup();
taskGroup.setCount(1);
taskGroup.setName(groupName);
taskGroup.addTasks(getTask(groupName, containerIndex, containerResource));
return taskGroup;
}
Aggregations