use of com.sequenceiq.environment.exception.UpdateFailedException in project cloudbreak by hortonworks.
the class LoadBalancerPollerServiceTest method testPollingTimeout.
@Test
public void testPollingTimeout() {
ReflectionTestUtils.setField(underTest, "maxTime", 5);
setupDatalakeResponse();
setupDatahubResponse();
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
when(stackService.updateLoadBalancer(eq(Set.of(DL_NAME, DH_NAME1, DH_NAME2)))).thenReturn(setupFlowIdentifiers(3));
when(flowEndpoint.hasFlowRunningByFlowId(anyString())).thenReturn(setupActiveFlowCheckResponse());
String expectedError = "Stack update poller reached timeout.";
UpdateFailedException exception = assertThrows(UpdateFailedException.class, () -> underTest.updateStackWithLoadBalancer(ENV_ID, ENV_CRN, ENV_NAME, PublicEndpointAccessGateway.ENABLED));
verify(flowEndpoint, times(18)).hasFlowRunningByFlowId(anyString());
assertEquals(expectedError, exception.getMessage());
}
use of com.sequenceiq.environment.exception.UpdateFailedException in project cloudbreak by hortonworks.
the class LoadBalancerPollerService method updateStackWithLoadBalancer.
public void updateStackWithLoadBalancer(Long environmentId, String environmentCrn, String environmentName, PublicEndpointAccessGateway endpointAccessGateway) {
Set<String> stackNames;
if (PublicEndpointAccessGateway.ENABLED.equals(endpointAccessGateway)) {
LOGGER.debug("Updating load balancers for endpoint gateway on Data Lake and Data Hubs.");
stackNames = getDataLakeAndDataHubNames(environmentCrn, environmentName);
LOGGER.debug("Found {} Data Lake and Data Hub clusters to update for environment {}.", stackNames.size(), environmentName);
} else {
LOGGER.debug("Updating load balancer for Data Lake cluster.");
stackNames = getAttachedDatalakeClusters(environmentName);
}
if (stackNames.isEmpty()) {
LOGGER.debug("No Data Lake or Data Hub clusters found for environment.");
} else {
try {
List<FlowIdentifier> failedFlows = waitStackLoadBalancerUpdate(getPollingConfig(), stackNames, environmentName);
LOGGER.debug("Data Lake and Data Hub load balancer update finished.");
if (!failedFlows.isEmpty()) {
LOGGER.error("Found failed flows for Data Lake or Data Hub load balancer updates: " + failedFlows);
throw new UpdateFailedException("Data Lake or Data Hub update flows failed: " + failedFlows);
}
} catch (PollerStoppedException e) {
throw new UpdateFailedException("Stack update poller reached timeout.", e);
}
}
}
use of com.sequenceiq.environment.exception.UpdateFailedException in project cloudbreak by hortonworks.
the class LoadBalancerPollerServiceTest method testPollingSingleFailure.
@Test
public void testPollingSingleFailure() {
List<FlowIdentifier> flowIdentifiers = setupFlowIdentifiers(3);
Iterator<FlowIdentifier> iterator = flowIdentifiers.iterator();
FlowIdentifier failFlowId = iterator.next();
String successFlowId1 = iterator.next().getPollableId();
String successFlowId2 = iterator.next().getPollableId();
String expectedError = "Data Lake or Data Hub update flows failed: " + List.of(failFlowId);
setupDatalakeResponse();
setupDatahubResponse();
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
when(stackService.updateLoadBalancer(eq(Set.of(DL_NAME, DH_NAME1, DH_NAME2)))).thenReturn(flowIdentifiers);
when(flowEndpoint.hasFlowRunningByFlowId(anyString())).thenReturn(setupFinishedFlowCheckResponse());
when(flowEndpoint.getFlowLogsByFlowId(failFlowId.getPollableId())).thenReturn(List.of(setupFailFlowLogResponse()));
when(flowEndpoint.getFlowLogsByFlowId(successFlowId1)).thenReturn(List.of(setupSuccessFlowLogResponse()));
when(flowEndpoint.getFlowLogsByFlowId(successFlowId2)).thenReturn(List.of(setupSuccessFlowLogResponse()));
UpdateFailedException exception = assertThrows(UpdateFailedException.class, () -> underTest.updateStackWithLoadBalancer(ENV_ID, ENV_CRN, ENV_NAME, PublicEndpointAccessGateway.ENABLED));
verify(flowEndpoint, times(3)).hasFlowRunningByFlowId(anyString());
verify(flowEndpoint, times(3)).getFlowLogsByFlowId(anyString());
assertEquals(expectedError, exception.getMessage());
}
Aggregations