From 577833041f2476f324ea319ef767233784588e22 Mon Sep 17 00:00:00 2001 From: Annamaria Szegedi Date: Tue, 9 Jan 2024 13:08:40 +0100 Subject: [PATCH] CB-24320 [API E2E] Reason should be part of the `Flow has been finalized with failed status` message Majority of API E2E tests are failing with a generic error message: `Flow has been finalized with failed status. Crn=%s, FlowId=%s , FlowChainId=%s` Enhance this and fail with the real reason. Sometimes it provides quite good explanation why the test has failed. --- .../it/cloudbreak/util/wait/FlowUtil.java | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/integration-test/src/main/java/com/sequenceiq/it/cloudbreak/util/wait/FlowUtil.java b/integration-test/src/main/java/com/sequenceiq/it/cloudbreak/util/wait/FlowUtil.java index 52065211e62..70ccb683f94 100644 --- a/integration-test/src/main/java/com/sequenceiq/it/cloudbreak/util/wait/FlowUtil.java +++ b/integration-test/src/main/java/com/sequenceiq/it/cloudbreak/util/wait/FlowUtil.java @@ -85,6 +85,9 @@ public T waitBasedOnLastKnownFlow(T testDto, Micro private void waitForFlow(FlowPublicEndpoint flowEndpoint, String crn, String flowChainId, String flowId, RunningParameter runningParameter) { boolean flowRunning = true; boolean flowFailed = false; + String flowType = ""; + String flowCurrentState = ""; + String flowReason = ""; int retryCount = 0; int failureCount = 0; @@ -98,20 +101,28 @@ private void waitForFlow(FlowPublicEndpoint flowEndpoint, String crn, String flo FlowCheckResponse flowCheckResponse = flowEndpoint.hasFlowRunningByChainId(flowChainId, crn); flowRunning = flowCheckResponse.getHasActiveFlow(); flowFailed = flowCheckResponse.getLatestFlowFinalizedAndFailed(); + flowType = flowCheckResponse.getFlowType(); + flowCurrentState = flowCheckResponse.getCurrentState(); + flowReason = flowCheckResponse.getReason(); } 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(); + flowType = flowCheckResponse.getFlowType(); + flowCurrentState = flowCheckResponse.getCurrentState(); + flowReason = flowCheckResponse.getReason(); } 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())); + LOGGER.error("Error during polling flow. Crn={}, FlowId={}, FlowChainId={}, FlowType={}, FlowCurrentState={}, FlowReason={}, Message={}", + crn, flowId, flowChainId, flowType, flowCurrentState, flowReason, ex.getMessage(), ex); + throw new TestFailException(String.format(" Error during polling flow. Crn=%s, FlowId=%s , FlowChainId=%s, FlowType=%s, " + + "FlowCurrentState=%s, FlowReason=%s, Message=%s ", + crn, flowId, flowChainId, flowType, flowCurrentState, flowReason, ex.getMessage())); } else { LOGGER.info("Retrying after failure. Failure count {}", ++failureCount); } @@ -119,21 +130,24 @@ private void waitForFlow(FlowPublicEndpoint flowEndpoint, String crn, String flo retryCount++; } if (timeoutChecker.checkTimeout()) { - String errorMessage = String.format("Test timed out, flow did not finish in %s. Crn=%s, FlowId=%s, FlowChainId=%s", - timeoutChecker, crn, flowId, flowChainId); + String errorMessage = String.format("Test timed out, flow did not finish in %s. Crn=%s, FlowId=%s, FlowChainId=%s, FlowType=%s, " + + "FlowCurrentState=%s, FlowReason=%s", + timeoutChecker, crn, flowId, flowChainId, flowType, flowCurrentState, flowReason); 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)); + LOGGER.error("Flow has been finalized with failed status. Crn={}, FlowId={}, FlowChainId={}, FlowType={}, FlowCurrentState={}, FlowReason={}", + crn, flowId, flowChainId, flowType, flowCurrentState, flowReason); + throw new TestFailException(String.format(" Flow has been finalized with failed status. Crn=%s, FlowId=%s, FlowChainId=%s, FlowType=%s, " + + "FlowCurrentState=%s, FlowReason=%s", crn, flowId, flowChainId, flowType, flowCurrentState, flowReason)); } if (!flowFailed && runningParameter.isWaitForFlowFail()) { - LOGGER.error("Flow has been finalized with success status. Crn={}, FlowId={}, FlowChainId={}", crn, flowId, flowChainId); + LOGGER.error("Flow has been finalized with success status. Crn={}, FlowId={}, FlowChainId={}, FlowType={}, FlowCurrentState={}, FlowReason={}", + crn, flowId, flowChainId, flowType, flowCurrentState, flowReason); 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)); + String.format(" Flow has been finalized with success status but it was expected to fail. Crn=%s, FlowId=%s, FlowChainId=%s, " + + "FlowType=%s, FlowCurrentState=%s, FlowReason=%s", crn, flowId, flowChainId, flowType, flowCurrentState, flowReason)); } }