@Test public void shouldNotAllowUpgradeIfDryRunFails() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException { Stack stack = getStack(); Image image = getImage("id-1"); when(stackService.getByNameOrCrnInWorkspace(eq(ofName), eq(WORKSPACE_ID))).thenReturn(stack); when(componentConfigProviderService.getImage(anyLong())).thenReturn(image); StatedImage currentImageFromCatalog = imageFromCatalog(true, image.getImageId()); when(imageCatalogService.getImage(anyString(), anyString(), anyString())).thenReturn(currentImageFromCatalog); Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairStartResult = Result.error(RepairValidation.of(List.of("Repair cannot be performed because there is an active flow running.", "No external Database"))); when(clusterRepairService.repairWithDryRun(1L)).thenReturn(repairStartResult); UpgradeOptionV4Response result = underTest.getOsUpgradeOptionByStackNameOrCrn(WORKSPACE_ID, ofName, user); verify(clusterRepairService).repairWithDryRun(eq(stack.getId())); verifyNoMoreInteractions(distroXV1Endpoint); verifyZeroInteractions(componentConfigProviderService); verifyZeroInteractions(imageService); assertThat(result.getUpgrade()).isEqualTo(null); assertThat(result.getReason()).isEqualTo("Repair cannot be performed because there is an active flow running.; No external Database"); }
public UpgradeOptionV4Response getOsUpgradeOptionByStackNameOrCrn(Long workspaceId, NameOrCrn nameOrCrn, User user) { Stack stack = stackService.getByNameOrCrnInWorkspace(nameOrCrn, workspaceId); MDCBuilder.buildMdcContext(stack); try { return getUpgradeOption(stack, workspaceId, user); } catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException e) { LOGGER.warn("Error retrieving image", e); throw new BadRequestException(e.getMessage(), e); } }
UpgradeService { public UpgradeOptionV4Response getOsUpgradeOptionByStackNameOrCrn(Long workspaceId, NameOrCrn nameOrCrn, User user) { Stack stack = stackService.getByNameOrCrnInWorkspace(nameOrCrn, workspaceId); MDCBuilder.buildMdcContext(stack); try { return getUpgradeOption(stack, workspaceId, user); } catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException e) { LOGGER.warn("Error retrieving image", e); throw new BadRequestException(e.getMessage(), e); } } }
UpgradeService { public UpgradeOptionV4Response getOsUpgradeOptionByStackNameOrCrn(Long workspaceId, NameOrCrn nameOrCrn, User user) { Stack stack = stackService.getByNameOrCrnInWorkspace(nameOrCrn, workspaceId); MDCBuilder.buildMdcContext(stack); try { return getUpgradeOption(stack, workspaceId, user); } catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException e) { LOGGER.warn("Error retrieving image", e); throw new BadRequestException(e.getMessage(), e); } }  }
UpgradeService { public UpgradeOptionV4Response getOsUpgradeOptionByStackNameOrCrn(Long workspaceId, NameOrCrn nameOrCrn, User user) { Stack stack = stackService.getByNameOrCrnInWorkspace(nameOrCrn, workspaceId); MDCBuilder.buildMdcContext(stack); try { return getUpgradeOption(stack, workspaceId, user); } catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException e) { LOGGER.warn("Error retrieving image", e); throw new BadRequestException(e.getMessage(), e); } }  UpgradeOptionV4Response getOsUpgradeOptionByStackNameOrCrn(Long workspaceId, NameOrCrn nameOrCrn, User user); FlowIdentifier upgradeOs(Long workspaceId, NameOrCrn stackNameOrCrn); FlowIdentifier upgradeCluster(Long workspaceId, NameOrCrn stackNameOrCrn, String imageId); boolean isOsUpgrade(UpgradeV4Request request); }
UpgradeService { public UpgradeOptionV4Response getOsUpgradeOptionByStackNameOrCrn(Long workspaceId, NameOrCrn nameOrCrn, User user) { Stack stack = stackService.getByNameOrCrnInWorkspace(nameOrCrn, workspaceId); MDCBuilder.buildMdcContext(stack); try { return getUpgradeOption(stack, workspaceId, user); } catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException e) { LOGGER.warn("Error retrieving image", e); throw new BadRequestException(e.getMessage(), e); } }  UpgradeOptionV4Response getOsUpgradeOptionByStackNameOrCrn(Long workspaceId, NameOrCrn nameOrCrn, User user); FlowIdentifier upgradeOs(Long workspaceId, NameOrCrn stackNameOrCrn); FlowIdentifier upgradeCluster(Long workspaceId, NameOrCrn stackNameOrCrn, String imageId); boolean isOsUpgrade(UpgradeV4Request request);  }