Search in sources :

Example 1 with UpdateFailedException

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());
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) UpdateFailedException(com.sequenceiq.environment.exception.UpdateFailedException) Test(org.junit.jupiter.api.Test)

Example 2 with UpdateFailedException

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);
        }
    }
}
Also used : FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) UpdateFailedException(com.sequenceiq.environment.exception.UpdateFailedException) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Example 3 with UpdateFailedException

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());
}
Also used : FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) UpdateFailedException(com.sequenceiq.environment.exception.UpdateFailedException) Test(org.junit.jupiter.api.Test)

Aggregations

UpdateFailedException (com.sequenceiq.environment.exception.UpdateFailedException)3 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)2 Test (org.junit.jupiter.api.Test)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 PollerStoppedException (com.dyngr.exception.PollerStoppedException)1