@Test public void shouldGroupUnhealthyInstancesByHostGroup() { String instanceId1 = "i-0f1e0605506aaaaaa"; String instanceId2 = "i-0f1e0605506bbbbbb"; String instanceId3 = "i-0f1e0605506cccccc"; String privateIp1 = "ip-10-0-0-1.ec2.internal"; String privateIp2 = "ip-10-0-0-2.ec2.internal"; String privateIp3 = "ip-10-0-0-3.ec2.internal"; String slaveGroup1 = "slave_group1"; String slaveGroup2 = "slave_group2"; InstanceGroup slaveInstanceGroup1 = new InstanceGroup(); slaveInstanceGroup1.setGroupName(slaveGroup1); InstanceGroup slaveInstanceGroup2 = new InstanceGroup(); slaveInstanceGroup2.setGroupName(slaveGroup2); Set<String> instanceIds = new HashSet<>(); instanceIds.add(instanceId1); instanceIds.add(instanceId2); instanceIds.add(instanceId3); setupInstanceMetadata(stack.getId(), instanceId1, privateIp1, slaveInstanceGroup1); setupInstanceMetadata(stack.getId(), instanceId2, privateIp2, slaveInstanceGroup2); setupInstanceMetadata(stack.getId(), instanceId3, privateIp3, slaveInstanceGroup2); underTest.add(stack, instanceIds); UnhealthyInstances expectedUnhealthyInstances = new UnhealthyInstances(); expectedUnhealthyInstances.addInstance(instanceId1, slaveGroup1); expectedUnhealthyInstances.addInstance(instanceId2, slaveGroup2); expectedUnhealthyInstances.addInstance(instanceId3, slaveGroup2); verify(executorService).submit(argThat(new StackRepairFlowSubmitterMatcher(stack.getId(), expectedUnhealthyInstances))); verify(flowMessageService).fireEventAndLog(stack.getId(), Status.UPDATE_IN_PROGRESS.name(), STACK_REPAIR_ATTEMPTING); }
public void add(Stack stack, Collection<String> unhealthyInstanceIds) { if (unhealthyInstanceIds.isEmpty()) { LOGGER.debug("No instances are unhealthy, returning..."); flowMessageService.fireEventAndLog(stack.getId(), Status.AVAILABLE.name(), STACK_REPAIR_COMPLETE_CLEAN); return; } UnhealthyInstances unhealthyInstances = groupInstancesByHostGroups(stack, unhealthyInstanceIds); Runnable stackRepairFlowSubmitter = new StackRepairFlowSubmitter(stack.getId(), unhealthyInstances); flowMessageService.fireEventAndLog(stack.getId(), Status.UPDATE_IN_PROGRESS.name(), STACK_REPAIR_ATTEMPTING); executorService.submit(stackRepairFlowSubmitter); }
StackRepairService { public void add(Stack stack, Collection<String> unhealthyInstanceIds) { if (unhealthyInstanceIds.isEmpty()) { LOGGER.debug("No instances are unhealthy, returning..."); flowMessageService.fireEventAndLog(stack.getId(), Status.AVAILABLE.name(), STACK_REPAIR_COMPLETE_CLEAN); return; } UnhealthyInstances unhealthyInstances = groupInstancesByHostGroups(stack, unhealthyInstanceIds); Runnable stackRepairFlowSubmitter = new StackRepairFlowSubmitter(stack.getId(), unhealthyInstances); flowMessageService.fireEventAndLog(stack.getId(), Status.UPDATE_IN_PROGRESS.name(), STACK_REPAIR_ATTEMPTING); executorService.submit(stackRepairFlowSubmitter); } }
StackRepairService { public void add(Stack stack, Collection<String> unhealthyInstanceIds) { if (unhealthyInstanceIds.isEmpty()) { LOGGER.debug("No instances are unhealthy, returning..."); flowMessageService.fireEventAndLog(stack.getId(), Status.AVAILABLE.name(), STACK_REPAIR_COMPLETE_CLEAN); return; } UnhealthyInstances unhealthyInstances = groupInstancesByHostGroups(stack, unhealthyInstanceIds); Runnable stackRepairFlowSubmitter = new StackRepairFlowSubmitter(stack.getId(), unhealthyInstances); flowMessageService.fireEventAndLog(stack.getId(), Status.UPDATE_IN_PROGRESS.name(), STACK_REPAIR_ATTEMPTING); executorService.submit(stackRepairFlowSubmitter); }  }
StackRepairService { public void add(Stack stack, Collection<String> unhealthyInstanceIds) { if (unhealthyInstanceIds.isEmpty()) { LOGGER.debug("No instances are unhealthy, returning..."); flowMessageService.fireEventAndLog(stack.getId(), Status.AVAILABLE.name(), STACK_REPAIR_COMPLETE_CLEAN); return; } UnhealthyInstances unhealthyInstances = groupInstancesByHostGroups(stack, unhealthyInstanceIds); Runnable stackRepairFlowSubmitter = new StackRepairFlowSubmitter(stack.getId(), unhealthyInstances); flowMessageService.fireEventAndLog(stack.getId(), Status.UPDATE_IN_PROGRESS.name(), STACK_REPAIR_ATTEMPTING); executorService.submit(stackRepairFlowSubmitter); }  void add(Stack stack, Collection<String> unhealthyInstanceIds); }
StackRepairService { public void add(Stack stack, Collection<String> unhealthyInstanceIds) { if (unhealthyInstanceIds.isEmpty()) { LOGGER.debug("No instances are unhealthy, returning..."); flowMessageService.fireEventAndLog(stack.getId(), Status.AVAILABLE.name(), STACK_REPAIR_COMPLETE_CLEAN); return; } UnhealthyInstances unhealthyInstances = groupInstancesByHostGroups(stack, unhealthyInstanceIds); Runnable stackRepairFlowSubmitter = new StackRepairFlowSubmitter(stack.getId(), unhealthyInstances); flowMessageService.fireEventAndLog(stack.getId(), Status.UPDATE_IN_PROGRESS.name(), STACK_REPAIR_ATTEMPTING); executorService.submit(stackRepairFlowSubmitter); }  void add(Stack stack, Collection<String> unhealthyInstanceIds);  }