@Test public void testBuddyContainerBasedGenerationForVaryingRF() { testBuddyContainerBasedGeneration(1); testBuddyContainerBasedGeneration(2); testBuddyContainerBasedGeneration(3); }
@Test public void testBuddyContainerBasedGenerationIdentity() { this.standbyTaskGenerator = new TaskNameGrouperProxy(Mockito.mock(TaskNameGrouper.class), true, 2); Assert.assertEquals("Shouldnt add standby tasks to empty container map", Collections.emptySet(), this.standbyTaskGenerator.generateStandbyTasks(Collections.emptySet(), 1)); Assert.assertEquals("Shouldnt add standby tasks when repl factor = 1", getContainerMap(), this.standbyTaskGenerator.generateStandbyTasks(getContainerMap(), 1)); }
private static Set<ContainerModel> getContainerMap() { Set<ContainerModel> retVal = new HashSet<>(); Map<TaskName, TaskModel> tasksForContainer0 = new HashMap<>(); tasksForContainer0.put(new TaskName("Partition 0"), getTaskModel(0)); tasksForContainer0.put(new TaskName("Partition 1"), getTaskModel(1)); retVal.add(new ContainerModel("0", tasksForContainer0)); Map<TaskName, TaskModel> tasksForContainer1 = new HashMap<>(); tasksForContainer1.put(new TaskName("Partition 2"), getTaskModel(2)); tasksForContainer1.put(new TaskName("Partition 3"), getTaskModel(3)); retVal.add(new ContainerModel("1", tasksForContainer1)); retVal.add(new ContainerModel("2", Collections.singletonMap(new TaskName("Partition 4"), getTaskModel(4)))); return retVal; }
private void testBuddyContainerBasedGeneration(int replicationFactor) { this.standbyTaskGenerator = new TaskNameGrouperProxy(Mockito.mock(TaskNameGrouper.class), true, 2); Set<ContainerModel> initialContainerModels = getContainerMap(); Set<ContainerModel> containerModels = standbyTaskGenerator.generateStandbyTasks(initialContainerModels, replicationFactor);