use of com.sequenceiq.periscope.monitor.context.ClusterIdEvaluatorContext in project cloudbreak by hortonworks.
the class CronTimeEvaluatorTest method testRunCallsFinished.
@Test
public void testRunCallsFinished() {
underTest.setContext(new ClusterIdEvaluatorContext(CLUSTER_ID));
when(clusterService.findById(anyLong())).thenThrow(new RuntimeException("exception from the test"));
try {
underTest.run();
fail("expected runtimeException");
} catch (RuntimeException e) {
assertEquals("exception from the test", e.getMessage());
}
verify(executorServiceWithRegistry).finished(underTest, CLUSTER_ID);
}
use of com.sequenceiq.periscope.monitor.context.ClusterIdEvaluatorContext in project cloudbreak by hortonworks.
the class YarnLoadEvaluatorTest method testRunCallsFinished.
@Test
public void testRunCallsFinished() {
underTest.setContext(new ClusterIdEvaluatorContext(AUTOSCALE_CLUSTER_ID));
when(clusterService.findById(anyLong())).thenThrow(new RuntimeException("exception from the test"));
underTest.run();
verify(executorServiceWithRegistry).finished(underTest, AUTOSCALE_CLUSTER_ID);
verify(eventPublisher).publishEvent(any(UpdateFailedEvent.class));
}
use of com.sequenceiq.periscope.monitor.context.ClusterIdEvaluatorContext in project cloudbreak by hortonworks.
the class YarnLoadEvaluatorTest method testExecuteBeforeCoolDownPeriod.
@Test
public void testExecuteBeforeCoolDownPeriod() {
Cluster cluster = getARunningCluster();
cluster.setLastScalingActivity(Instant.now().minus(2, ChronoUnit.MINUTES).toEpochMilli());
when(clusterService.findById(anyLong())).thenReturn(cluster);
underTest.setContext(new ClusterIdEvaluatorContext(AUTOSCALE_CLUSTER_ID));
underTest.execute();
verify(eventPublisher, never()).publishEvent(any());
}
use of com.sequenceiq.periscope.monitor.context.ClusterIdEvaluatorContext in project cloudbreak by hortonworks.
the class YarnLoadEvaluatorTest method captureScalingEvent.
private Optional<ScalingEvent> captureScalingEvent(int runningNodeHostGroupCount, int stoppedNodeHostGroupCount, int yarnUpscaleCount, int yarnDownscaleCount, boolean scalingEventExpected) throws Exception {
MockitoAnnotations.openMocks(this);
Cluster cluster = getARunningCluster();
cluster.setStopStartScalingEnabled(true);
String hostGroup = "compute";
StackV4Response stackV4Response = MockStackResponseGenerator.getMockStackV4ResponseWithStoppedAndRunningNodes(CLOUDBREAK_STACK_CRN, hostGroup, fqdnBase, runningNodeHostGroupCount, stoppedNodeHostGroupCount);
YarnScalingServiceV1Response upScale = getMockYarnScalingResponse(hostGroup, yarnUpscaleCount, yarnDownscaleCount);
setupMocks(cluster, upScale, stackV4Response);
underTest.setContext(new ClusterIdEvaluatorContext(AUTOSCALE_CLUSTER_ID));
underTest.execute();
Optional<ScalingEvent> scalingEventCaptured = Optional.empty();
if (scalingEventExpected) {
ArgumentCaptor<ScalingEvent> captor = ArgumentCaptor.forClass(ScalingEvent.class);
verify(eventPublisher).publishEvent(captor.capture());
scalingEventCaptured = Optional.of(captor.getValue());
}
return scalingEventCaptured;
}
Aggregations