use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class FlowUtil method waitForFlow.
private void waitForFlow(FlowPublicEndpoint flowEndpoint, String crn, String flowChainId, String flowId, RunningParameter runningParameter) {
boolean flowRunning = true;
boolean flowFailed = false;
int retryCount = 0;
int failureCount = 0;
long pollingInterval = getPollingInterval();
while (flowRunning && retryCount < maxRetry) {
sleep(pollingInterval, crn, flowChainId, flowId);
try {
if (StringUtils.isNotBlank(flowChainId)) {
LOGGER.info("Waiting for flow chain: '{}' at resource: '{}', retry count: '{}'", flowChainId, crn, retryCount);
FlowCheckResponse flowCheckResponse = flowEndpoint.hasFlowRunningByChainId(flowChainId, crn);
flowRunning = flowCheckResponse.getHasActiveFlow();
flowFailed = flowCheckResponse.getLatestFlowFinalizedAndFailed();
} else if (StringUtils.isNoneBlank(flowId)) {
LOGGER.info("Waiting for flow: '{}' at resource: '{}', retry count: '{}'", flowId, crn, retryCount);
FlowCheckResponse flowCheckResponse = flowEndpoint.hasFlowRunningByFlowId(flowId, crn);
flowRunning = flowCheckResponse.getHasActiveFlow();
flowFailed = flowCheckResponse.getLatestFlowFinalizedAndFailed();
} else {
LOGGER.info("Flow id and flow chain id are empty so flow is not running at resource: '{}'", crn);
flowRunning = false;
}
} catch (Exception ex) {
if (failureCount >= maxFailureRetry) {
LOGGER.error("Error during polling flow. Crn={}, FlowId={}, FlowChainId={}, Message={}", crn, flowId, flowChainId, ex.getMessage(), ex);
throw new TestFailException(String.format(" Error during polling flow. Crn=%s, FlowId=%s , FlowChainId=%s, Message=%s ", crn, flowId, flowChainId, ex.getMessage()));
} else {
LOGGER.info("Retrying after failure. Failure count {}", ++failureCount);
}
}
retryCount++;
}
if (retryCount >= maxRetry) {
String errorMessage = String.format("Test timed out, flow did not finish in time. Crn=%s, FlowId=%s, FlowChainId=%s", crn, flowId, flowChainId);
LOGGER.error(errorMessage);
throw new TestFailException(errorMessage);
}
if (flowFailed && runningParameter.isWaitForFlowSuccess()) {
LOGGER.error("Flow has been finalized with failed status. Crn={}, FlowId={}, FlowChainId={}", crn, flowId, flowChainId);
throw new TestFailException(String.format(" Flow has been finalized with failed status. Crn=%s, FlowId=%s , FlowChainId=%s ", crn, flowId, flowChainId));
}
if (!flowFailed && runningParameter.isWaitForFlowFail()) {
LOGGER.error("Flow has been finalized with success status. Crn={}, FlowId={}, FlowChainId={}", crn, flowId, flowChainId);
throw new TestFailException(String.format(" Flow has been finalized with success status but it was expected to fail. Crn=%s, FlowId=%s , FlowChainId=%s ", crn, flowId, flowChainId));
}
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class InstanceFailedChecker method refresh.
@Override
public void refresh(T waitObject) {
List<String> instanceIds = waitObject.getInstanceIds();
try {
waitObject.fetchData();
failed = false;
} catch (Exception e) {
LOGGER.error("Failed to get instances: '{}', because of {}", instanceIds, e.getMessage(), e);
throw new TestFailException(String.format("Failed to get instances status: '%s'", instanceIds), e);
}
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class FreeIpaFindGroupsAction method action.
public FreeIpaTestDto action(TestContext testContext, FreeIpaTestDto testDto, FreeIpaClient client) throws Exception {
CheckGroupsV1Request checkGroupsRequest = new CheckGroupsV1Request();
checkGroupsRequest.setEnvironmentCrn(testDto.getResponse().getEnvironmentCrn());
checkGroupsRequest.setGroups(groups);
Log.when(LOGGER, format(" Checking groups [%s] are present at environment '%s'", groups, testDto.getResponse().getEnvironmentCrn()));
Log.whenJson(LOGGER, format(" FreeIpa '%s' find groups request:%n ", testDto.getResponse().getCrn()), checkGroupsRequest);
if (!client.getDefaultClient().getClientTestV1Endpoint().checkGroups(checkGroupsRequest).getResult()) {
throw new TestFailException("Given freeipa groups cannot be found, please check FMS logs for details");
}
LOGGER.info(format(" Groups [%s] are present at environment '%s'", groups, testDto.getResponse().getEnvironmentCrn()));
Log.when(LOGGER, format(" Groups [%s] are present at environment '%s'", groups, testDto.getResponse().getEnvironmentCrn()));
return testDto;
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class FreeIpaFindUsersInGroupAction method action.
public FreeIpaTestDto action(TestContext testContext, FreeIpaTestDto testDto, FreeIpaClient client) throws Exception {
CheckUsersInGroupV1Request checkUsersInGroupRequest = new CheckUsersInGroupV1Request();
checkUsersInGroupRequest.setEnvironmentCrn(testDto.getResponse().getEnvironmentCrn());
checkUsersInGroupRequest.setGroup(group);
checkUsersInGroupRequest.setUsers(users);
Log.when(LOGGER, format(" Checking users [%s] are present in group '%s' at environment '%s'", users, group, testDto.getResponse().getEnvironmentCrn()));
Log.whenJson(LOGGER, format(" FreeIpa '%s' find users in group request:%n ", testDto.getResponse().getCrn()), checkUsersInGroupRequest);
if (expectedPresence) {
if (!client.getDefaultClient().getClientTestV1Endpoint().checkUsersInGroup(checkUsersInGroupRequest).getResult()) {
throw new TestFailException("Given freeipa users cannot be found in the given group, please check FMS logs for details");
}
LOGGER.info(format(" Users [%s] are present in group '%s' at environment '%s'", users, group, testDto.getResponse().getEnvironmentCrn()));
Log.when(LOGGER, format(" Users [%s] are present in group '%s' at environment '%s'", users, group, testDto.getResponse().getEnvironmentCrn()));
} else {
if (client.getDefaultClient().getClientTestV1Endpoint().checkUsersInGroup(checkUsersInGroupRequest).getResult()) {
throw new TestFailException("Given freeipa users have been found in the given group, please check FMS logs for details");
}
LOGGER.info(format(" Users [%s] have been removed successfully from group '%s' at environment '%s'", users, group, testDto.getResponse().getEnvironmentCrn()));
Log.when(LOGGER, format(" Users [%s] have been removed successfully from group '%s' at environment '%s'", users, group, testDto.getResponse().getEnvironmentCrn()));
}
return testDto;
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class SdxImagesTests method testSDXWithBaseImageCanBeCreatedSuccessfully.
@Test(dataProvider = TEST_CONTEXT)
@UseSpotInstances
@Description(given = "there is a running Cloudbreak", when = "a valid SDX create request is sent (latest Base Image)", then = "SDX should be available AND deletable")
public void testSDXWithBaseImageCanBeCreatedSuccessfully(TestContext testContext) {
String sdxInternal = resourcePropertyProvider().getName();
String cluster = resourcePropertyProvider().getName();
String clouderaManager = resourcePropertyProvider().getName();
String imageSettings = resourcePropertyProvider().getName();
String imageCatalog = resourcePropertyProvider().getName();
String stack = resourcePropertyProvider().getName();
String masterInstanceGroup = "master";
String idbrokerInstanceGroup = "idbroker";
AtomicReference<String> selectedImageID = new AtomicReference<>();
SdxDatabaseRequest sdxDatabaseRequest = new SdxDatabaseRequest();
sdxDatabaseRequest.setAvailabilityType(SdxDatabaseAvailabilityType.NONE);
testContext.given(imageCatalog, ImageCatalogTestDto.class).when((tc, dto, client) -> {
selectedImageID.set(testContext.getCloudProvider().getLatestBaseImageID(tc, dto, client));
return dto;
}).given(imageSettings, ImageSettingsTestDto.class).given(clouderaManager, ClouderaManagerTestDto.class).given(cluster, ClusterTestDto.class).withBlueprintName(getDefaultSDXBlueprintName()).withValidateBlueprint(Boolean.FALSE).withClouderaManager(clouderaManager).given(masterInstanceGroup, InstanceGroupTestDto.class).withHostGroup(MASTER).withNodeCount(1).given(idbrokerInstanceGroup, InstanceGroupTestDto.class).withHostGroup(IDBROKER).withNodeCount(1).given(stack, StackTestDto.class).withCluster(cluster).withImageSettings(imageSettings).withInstanceGroups(masterInstanceGroup, idbrokerInstanceGroup).given(sdxInternal, SdxInternalTestDto.class).withDatabase(sdxDatabaseRequest).withCloudStorage(getCloudStorageRequest(testContext)).withStackRequest(key(cluster), key(stack)).when(sdxTestClient.createInternal(), key(sdxInternal)).await(SdxClusterStatusResponse.RUNNING).awaitForHealthyInstances().then((tc, dto, client) -> {
Log.log(LOGGER, format(" Image Catalog Name: %s ", dto.getResponse().getStackV4Response().getImage().getCatalogName()));
Log.log(LOGGER, format(" Image Catalog URL: %s ", dto.getResponse().getStackV4Response().getImage().getCatalogUrl()));
Log.log(LOGGER, format(" Image ID: %s ", dto.getResponse().getStackV4Response().getImage().getId()));
if (!dto.getResponse().getStackV4Response().getImage().getId().equals(selectedImageID.get())) {
throw new TestFailException(" The selected image ID is: " + dto.getResponse().getStackV4Response().getImage().getId() + " instead of: " + selectedImageID.get());
}
return dto;
}).validate();
}
Aggregations