@Test public void testRepairByNodeIds() { InstanceGroup instanceGroup = new InstanceGroup(); instanceGroup.setInstanceGroupType(InstanceGroupType.CORE); HostGroup hostGroup1 = new HostGroup(); hostGroup1.setName("hostGroup1"); hostGroup1.setRecoveryMode(RecoveryMode.MANUAL); hostGroup1.setInstanceGroup(instanceGroup); when(hostGroupService.getByCluster(eq(1L))).thenReturn(Set.of(hostGroup1)); InstanceMetaData instance1md = new InstanceMetaData(); instance1md.setInstanceId("instanceId1"); instance1md.setDiscoveryFQDN("host1Name.healthy"); instance1md.setInstanceGroup(instanceGroup); instanceGroup.setInstanceMetaData(Collections.singleton(instance1md)); Resource volumeSet = new Resource(); VolumeSetAttributes attributes = new VolumeSetAttributes("eu-west-1", Boolean.TRUE, "", List.of(), 100, "standard"); attributes.setDeleteOnTermination(null); volumeSet.setAttributes(new Json(attributes)); volumeSet.setInstanceId("instanceId1"); volumeSet.setResourceType(ResourceType.AWS_VOLUMESET); FlowLog flowLog = new FlowLog(); flowLog.setStateStatus(StateStatus.SUCCESSFUL); when(stackUpdater.updateStackStatus(1L, DetailedStackStatus.REPAIR_IN_PROGRESS)).thenReturn(stack); when(stackService.getByIdWithListsInTransaction(1L)).thenReturn(stack); when(stack.getInstanceMetaDataAsList()).thenReturn(List.of(instance1md)); when(resourceService.findByStackIdAndType(stack.getId(), volumeSet.getResourceType())).thenReturn(List.of(volumeSet)); underTest.repairNodes(1L, Set.of("instanceId1"), false, false, false); verify(resourceService).findByStackIdAndType(stack.getId(), volumeSet.getResourceType()); @SuppressWarnings("unchecked") ArgumentCaptor<List<Resource>> saveCaptor = ArgumentCaptor.forClass(List.class); verify(resourceService).saveAll(saveCaptor.capture()); assertFalse(resourceAttributeUtil.getTypedAttributes(saveCaptor.getValue().get(0), VolumeSetAttributes.class).get().getDeleteOnTermination()); verify(flowManager).triggerClusterRepairFlow(eq(1L), eq(Map.of("hostGroup1", List.of("host1Name.healthy"))), eq(false), eq(false)); }
public FlowIdentifier repairNodes(Long stackId, Set<String> nodeIds, boolean deleteVolumes, boolean removeOnly, boolean restartServices) { Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairStart = validateRepair(ManualClusterRepairMode.NODE_ID, stackId, nodeIds, deleteVolumes); return triggerRepairOrThrowBadRequest(stackId, repairStart, removeOnly, restartServices, nodeIds); }
ClusterRepairService { public FlowIdentifier repairNodes(Long stackId, Set<String> nodeIds, boolean deleteVolumes, boolean removeOnly, boolean restartServices) { Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairStart = validateRepair(ManualClusterRepairMode.NODE_ID, stackId, nodeIds, deleteVolumes); return triggerRepairOrThrowBadRequest(stackId, repairStart, removeOnly, restartServices, nodeIds); } }
ClusterRepairService { public FlowIdentifier repairNodes(Long stackId, Set<String> nodeIds, boolean deleteVolumes, boolean removeOnly, boolean restartServices) { Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairStart = validateRepair(ManualClusterRepairMode.NODE_ID, stackId, nodeIds, deleteVolumes); return triggerRepairOrThrowBadRequest(stackId, repairStart, removeOnly, restartServices, nodeIds); }  }
ClusterRepairService { public FlowIdentifier repairNodes(Long stackId, Set<String> nodeIds, boolean deleteVolumes, boolean removeOnly, boolean restartServices) { Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairStart = validateRepair(ManualClusterRepairMode.NODE_ID, stackId, nodeIds, deleteVolumes); return triggerRepairOrThrowBadRequest(stackId, repairStart, removeOnly, restartServices, nodeIds); }  FlowIdentifier repairAll(Long stackId); FlowIdentifier repairHostGroups(Long stackId, Set<String> hostGroups, boolean removeOnly, boolean restartServices); FlowIdentifier repairNodes(Long stackId, Set<String> nodeIds, boolean deleteVolumes, boolean removeOnly, boolean restartServices); Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairWithDryRun(Long stackId); }
ClusterRepairService { public FlowIdentifier repairNodes(Long stackId, Set<String> nodeIds, boolean deleteVolumes, boolean removeOnly, boolean restartServices) { Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairStart = validateRepair(ManualClusterRepairMode.NODE_ID, stackId, nodeIds, deleteVolumes); return triggerRepairOrThrowBadRequest(stackId, repairStart, removeOnly, restartServices, nodeIds); }  FlowIdentifier repairAll(Long stackId); FlowIdentifier repairHostGroups(Long stackId, Set<String> hostGroups, boolean removeOnly, boolean restartServices); FlowIdentifier repairNodes(Long stackId, Set<String> nodeIds, boolean deleteVolumes, boolean removeOnly, boolean restartServices); Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairWithDryRun(Long stackId);  }