@Test public void testNeitherClusterNorCMUpgradeNeeded() { Image currentImage = createImage(CURRENT_BUILD_NUMBER, CURRENT_BUILD_NUMBER); Image targetImage = createImage(CURRENT_BUILD_NUMBER, CURRENT_BUILD_NUMBER); boolean actualResult = underTest.upgradeCluster(STACK_ID, currentImage, targetImage); Assertions.assertFalse(actualResult); verify(flowMessageService, times(0)) .fireEventAndLog(eq(STACK_ID), eq(Status.UPDATE_IN_PROGRESS.name()), eq(CLUSTER_MANAGER_UPGRADE_FINISHED), anyString()); verify(flowMessageService).fireEventAndLog(STACK_ID, Status.UPDATE_IN_PROGRESS.name(), CLUSTER_UPGRADE_NOT_NEEDED, CURRENT_BUILD_NUMBER); }
public boolean upgradeCluster(long stackId, Image currentImage, Image targetImage) { String currentRuntimeBuildNumber = NullUtil.getIfNotNull(currentImage.getStackDetails(), StackDetails::getStackBuildNumber); boolean clusterManagerUpdateNeeded = isUpdateNeeded(currentImage.getCmBuildNumber(), targetImage.getCmBuildNumber()); boolean clusterRuntimeUpgradeNeeded = isUpdateNeeded(currentRuntimeBuildNumber, NullUtil.getIfNotNull(targetImage.getStackDetails(), StackDetails::getStackBuildNumber)); if (clusterManagerUpdateNeeded) { flowMessageService.fireEventAndLog(stackId, Status.UPDATE_IN_PROGRESS.name(), CLUSTER_MANAGER_UPGRADE_FINISHED, targetImage.getVersion()); } clusterService.updateClusterStatusByStackId(stackId, Status.UPDATE_IN_PROGRESS); if (clusterRuntimeUpgradeNeeded) { flowMessageService.fireEventAndLog(stackId, Status.UPDATE_IN_PROGRESS.name(), CLUSTER_UPGRADE); } else { flowMessageService.fireEventAndLog(stackId, Status.UPDATE_IN_PROGRESS.name(), CLUSTER_UPGRADE_NOT_NEEDED, currentRuntimeBuildNumber); } return clusterRuntimeUpgradeNeeded; }
ClusterUpgradeService { public boolean upgradeCluster(long stackId, Image currentImage, Image targetImage) { String currentRuntimeBuildNumber = NullUtil.getIfNotNull(currentImage.getStackDetails(), StackDetails::getStackBuildNumber); boolean clusterManagerUpdateNeeded = isUpdateNeeded(currentImage.getCmBuildNumber(), targetImage.getCmBuildNumber()); boolean clusterRuntimeUpgradeNeeded = isUpdateNeeded(currentRuntimeBuildNumber, NullUtil.getIfNotNull(targetImage.getStackDetails(), StackDetails::getStackBuildNumber)); if (clusterManagerUpdateNeeded) { flowMessageService.fireEventAndLog(stackId, Status.UPDATE_IN_PROGRESS.name(), CLUSTER_MANAGER_UPGRADE_FINISHED, targetImage.getVersion()); } clusterService.updateClusterStatusByStackId(stackId, Status.UPDATE_IN_PROGRESS); if (clusterRuntimeUpgradeNeeded) { flowMessageService.fireEventAndLog(stackId, Status.UPDATE_IN_PROGRESS.name(), CLUSTER_UPGRADE); } else { flowMessageService.fireEventAndLog(stackId, Status.UPDATE_IN_PROGRESS.name(), CLUSTER_UPGRADE_NOT_NEEDED, currentRuntimeBuildNumber); } return clusterRuntimeUpgradeNeeded; } }
ClusterUpgradeService { public boolean upgradeCluster(long stackId, Image currentImage, Image targetImage) { String currentRuntimeBuildNumber = NullUtil.getIfNotNull(currentImage.getStackDetails(), StackDetails::getStackBuildNumber); boolean clusterManagerUpdateNeeded = isUpdateNeeded(currentImage.getCmBuildNumber(), targetImage.getCmBuildNumber()); boolean clusterRuntimeUpgradeNeeded = isUpdateNeeded(currentRuntimeBuildNumber, NullUtil.getIfNotNull(targetImage.getStackDetails(), StackDetails::getStackBuildNumber)); if (clusterManagerUpdateNeeded) { flowMessageService.fireEventAndLog(stackId, Status.UPDATE_IN_PROGRESS.name(), CLUSTER_MANAGER_UPGRADE_FINISHED, targetImage.getVersion()); } clusterService.updateClusterStatusByStackId(stackId, Status.UPDATE_IN_PROGRESS); if (clusterRuntimeUpgradeNeeded) { flowMessageService.fireEventAndLog(stackId, Status.UPDATE_IN_PROGRESS.name(), CLUSTER_UPGRADE); } else { flowMessageService.fireEventAndLog(stackId, Status.UPDATE_IN_PROGRESS.name(), CLUSTER_UPGRADE_NOT_NEEDED, currentRuntimeBuildNumber); } return clusterRuntimeUpgradeNeeded; }  }
ClusterUpgradeService { public boolean upgradeCluster(long stackId, Image currentImage, Image targetImage) { String currentRuntimeBuildNumber = NullUtil.getIfNotNull(currentImage.getStackDetails(), StackDetails::getStackBuildNumber); boolean clusterManagerUpdateNeeded = isUpdateNeeded(currentImage.getCmBuildNumber(), targetImage.getCmBuildNumber()); boolean clusterRuntimeUpgradeNeeded = isUpdateNeeded(currentRuntimeBuildNumber, NullUtil.getIfNotNull(targetImage.getStackDetails(), StackDetails::getStackBuildNumber)); if (clusterManagerUpdateNeeded) { flowMessageService.fireEventAndLog(stackId, Status.UPDATE_IN_PROGRESS.name(), CLUSTER_MANAGER_UPGRADE_FINISHED, targetImage.getVersion()); } clusterService.updateClusterStatusByStackId(stackId, Status.UPDATE_IN_PROGRESS); if (clusterRuntimeUpgradeNeeded) { flowMessageService.fireEventAndLog(stackId, Status.UPDATE_IN_PROGRESS.name(), CLUSTER_UPGRADE); } else { flowMessageService.fireEventAndLog(stackId, Status.UPDATE_IN_PROGRESS.name(), CLUSTER_UPGRADE_NOT_NEEDED, currentRuntimeBuildNumber); } return clusterRuntimeUpgradeNeeded; }  void initUpgradeCluster(long stackId, StatedImage targetImage); boolean upgradeClusterManager(long stackId, StatedImage currentImage, StatedImage targetImage); boolean upgradeCluster(long stackId, Image currentImage, Image targetImage); void clusterUpgradeFinished(long stackId, StatedImage currentImage, StatedImage targetImage); void handleUpgradeClusterFailure(long stackId, String errorReason, DetailedStackStatus detailedStatus); }
ClusterUpgradeService { public boolean upgradeCluster(long stackId, Image currentImage, Image targetImage) { String currentRuntimeBuildNumber = NullUtil.getIfNotNull(currentImage.getStackDetails(), StackDetails::getStackBuildNumber); boolean clusterManagerUpdateNeeded = isUpdateNeeded(currentImage.getCmBuildNumber(), targetImage.getCmBuildNumber()); boolean clusterRuntimeUpgradeNeeded = isUpdateNeeded(currentRuntimeBuildNumber, NullUtil.getIfNotNull(targetImage.getStackDetails(), StackDetails::getStackBuildNumber)); if (clusterManagerUpdateNeeded) { flowMessageService.fireEventAndLog(stackId, Status.UPDATE_IN_PROGRESS.name(), CLUSTER_MANAGER_UPGRADE_FINISHED, targetImage.getVersion()); } clusterService.updateClusterStatusByStackId(stackId, Status.UPDATE_IN_PROGRESS); if (clusterRuntimeUpgradeNeeded) { flowMessageService.fireEventAndLog(stackId, Status.UPDATE_IN_PROGRESS.name(), CLUSTER_UPGRADE); } else { flowMessageService.fireEventAndLog(stackId, Status.UPDATE_IN_PROGRESS.name(), CLUSTER_UPGRADE_NOT_NEEDED, currentRuntimeBuildNumber); } return clusterRuntimeUpgradeNeeded; }  void initUpgradeCluster(long stackId, StatedImage targetImage); boolean upgradeClusterManager(long stackId, StatedImage currentImage, StatedImage targetImage); boolean upgradeCluster(long stackId, Image currentImage, Image targetImage); void clusterUpgradeFinished(long stackId, StatedImage currentImage, StatedImage targetImage); void handleUpgradeClusterFailure(long stackId, String errorReason, DetailedStackStatus detailedStatus);  }