@Test public void testPerform() throws Exception { Mockito.when(cluster.getUpgradeInProgress()).thenReturn(null); PrerequisiteCheck check = new PrerequisiteCheck(null, null); puc.perform(check, checkRequest); Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus()); UpgradeEntity upgradeInProgress = Mockito.mock(UpgradeEntity.class); Mockito.when(upgradeInProgress.getDirection()).thenReturn(Direction.UPGRADE); Mockito.when(upgradeInProgress.getClusterId()).thenReturn(1L); Mockito.when(upgradeInProgress.getFromVersion()).thenReturn(sourceRepositoryVersion); Mockito.when(upgradeInProgress.getToVersion()).thenReturn(destRepositoryVersion); Mockito.when(cluster.getUpgradeInProgress()).thenReturn(upgradeInProgress); check = new PrerequisiteCheck(null, null); puc.perform(check, checkRequest); Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus()); }
@Override public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException { final String clusterName = request.getClusterName(); final Cluster cluster = clustersProvider.get().getCluster(clusterName); String errorMessage = null; UpgradeEntity upgradeInProgress = cluster.getUpgradeInProgress(); if (null != upgradeInProgress) { Direction direction = upgradeInProgress.getDirection(); String directionText = direction.getText(false); errorMessage = MessageFormat.format(ERROR_MESSAGE, directionText, upgradeInProgress.getFromVersion(), upgradeInProgress.getToVersion(), directionText); } if (null != errorMessage) { LinkedHashSet<String> failedOn = new LinkedHashSet<String>(); failedOn.add(cluster.getClusterName()); prerequisiteCheck.setFailedOn(failedOn); prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL); prerequisiteCheck.setFailReason(errorMessage); } }
PreviousUpgradeCompleted extends AbstractCheckDescriptor { @Override public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException { final String clusterName = request.getClusterName(); final Cluster cluster = clustersProvider.get().getCluster(clusterName); String errorMessage = null; UpgradeEntity upgradeInProgress = cluster.getUpgradeInProgress(); if (null != upgradeInProgress) { Direction direction = upgradeInProgress.getDirection(); String directionText = direction.getText(false); errorMessage = MessageFormat.format(ERROR_MESSAGE, directionText, upgradeInProgress.getFromVersion(), upgradeInProgress.getToVersion(), directionText); } if (null != errorMessage) { LinkedHashSet<String> failedOn = new LinkedHashSet<String>(); failedOn.add(cluster.getClusterName()); prerequisiteCheck.setFailedOn(failedOn); prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL); prerequisiteCheck.setFailReason(errorMessage); } } }
PreviousUpgradeCompleted extends AbstractCheckDescriptor { @Override public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException { final String clusterName = request.getClusterName(); final Cluster cluster = clustersProvider.get().getCluster(clusterName); String errorMessage = null; UpgradeEntity upgradeInProgress = cluster.getUpgradeInProgress(); if (null != upgradeInProgress) { Direction direction = upgradeInProgress.getDirection(); String directionText = direction.getText(false); errorMessage = MessageFormat.format(ERROR_MESSAGE, directionText, upgradeInProgress.getFromVersion(), upgradeInProgress.getToVersion(), directionText); } if (null != errorMessage) { LinkedHashSet<String> failedOn = new LinkedHashSet<String>(); failedOn.add(cluster.getClusterName()); prerequisiteCheck.setFailedOn(failedOn); prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL); prerequisiteCheck.setFailReason(errorMessage); } } PreviousUpgradeCompleted(); }
PreviousUpgradeCompleted extends AbstractCheckDescriptor { @Override public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException { final String clusterName = request.getClusterName(); final Cluster cluster = clustersProvider.get().getCluster(clusterName); String errorMessage = null; UpgradeEntity upgradeInProgress = cluster.getUpgradeInProgress(); if (null != upgradeInProgress) { Direction direction = upgradeInProgress.getDirection(); String directionText = direction.getText(false); errorMessage = MessageFormat.format(ERROR_MESSAGE, directionText, upgradeInProgress.getFromVersion(), upgradeInProgress.getToVersion(), directionText); } if (null != errorMessage) { LinkedHashSet<String> failedOn = new LinkedHashSet<String>(); failedOn.add(cluster.getClusterName()); prerequisiteCheck.setFailedOn(failedOn); prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL); prerequisiteCheck.setFailReason(errorMessage); } } PreviousUpgradeCompleted(); @Override void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request); }
PreviousUpgradeCompleted extends AbstractCheckDescriptor { @Override public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException { final String clusterName = request.getClusterName(); final Cluster cluster = clustersProvider.get().getCluster(clusterName); String errorMessage = null; UpgradeEntity upgradeInProgress = cluster.getUpgradeInProgress(); if (null != upgradeInProgress) { Direction direction = upgradeInProgress.getDirection(); String directionText = direction.getText(false); errorMessage = MessageFormat.format(ERROR_MESSAGE, directionText, upgradeInProgress.getFromVersion(), upgradeInProgress.getToVersion(), directionText); } if (null != errorMessage) { LinkedHashSet<String> failedOn = new LinkedHashSet<String>(); failedOn.add(cluster.getClusterName()); prerequisiteCheck.setFailedOn(failedOn); prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL); prerequisiteCheck.setFailReason(errorMessage); } } PreviousUpgradeCompleted(); @Override void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request); static final String ERROR_MESSAGE; }