use of com.sequenceiq.cloudbreak.service.cluster.model.Result in project cloudbreak by hortonworks.
the class ClusterRepairServiceTest method testCannotRepairBaseImageGateway.
@Test
public void testCannotRepairBaseImageGateway() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
HostGroup hostGroup1 = new HostGroup();
hostGroup1.setName("hostGroup1");
hostGroup1.setRecoveryMode(RecoveryMode.MANUAL);
InstanceMetaData host1 = getHost("host1", hostGroup1.getName(), InstanceStatus.SERVICES_HEALTHY, InstanceGroupType.GATEWAY);
hostGroup1.setInstanceGroup(host1.getInstanceGroup());
when(hostGroupService.getByCluster(eq(1L))).thenReturn(Set.of(hostGroup1));
when(stackService.getByIdWithListsInTransaction(1L)).thenReturn(stack);
when(componentConfigProviderService.getImage(stack.getId())).thenReturn(mock(Image.class));
com.sequenceiq.cloudbreak.cloud.model.catalog.Image image = mock(com.sequenceiq.cloudbreak.cloud.model.catalog.Image.class);
when(image.isPrewarmed()).thenReturn(false);
when(imageCatalogService.getImage(any(), any(), any())).thenReturn(StatedImage.statedImage(image, "catalogUrl", "catalogName"));
when(clusterDBValidationService.isGatewayRepairEnabled(cluster)).thenReturn(true);
when(freeipaService.checkFreeipaRunning(stack.getEnvironmentCrn())).thenReturn(true);
when(environmentService.environmentStatusInDesiredState(stack, Set.of(EnvironmentStatus.AVAILABLE))).thenReturn(true);
Result result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.repairWithDryRun(stack.getId()));
assertFalse(result.isSuccess());
verifyNoInteractions(stackUpdater, flowManager, resourceService);
}
Aggregations