-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5738 from telstra/test/improvement-entities-compa…
…rison-ping [TEST]: Refactoring: Verification of the ping operation
- Loading branch information
Showing
17 changed files
with
315 additions
and
182 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...rc/main/groovy/org/openkilda/functionaltests/helpers/model/ComplexFlowPingResponse.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.openkilda.functionaltests.helpers.model | ||
|
||
import static org.openkilda.functionaltests.helpers.model.FlowDirection.FORWARD | ||
import static org.openkilda.functionaltests.helpers.model.FlowDirection.REVERSE | ||
|
||
import org.openkilda.northbound.dto.v2.haflows.HaFlowPingResult | ||
import org.openkilda.northbound.dto.v2.yflows.SubFlowPingPayload | ||
import org.openkilda.northbound.dto.v2.yflows.YFlowPingResult | ||
|
||
import groovy.transform.ToString | ||
|
||
@ToString | ||
class ComplexFlowPingResponse { | ||
boolean pingSuccess | ||
String error | ||
List<SubFlowPingDiscrepancies> subFlowsDiscrepancies | ||
|
||
ComplexFlowPingResponse(YFlowPingResult pingResponse) { | ||
this.pingSuccess = pingResponse.pingSuccess | ||
this.error = pingResponse.error | ||
this.subFlowsDiscrepancies = collectDiscrepanciesPerSubFlow(pingResponse.subFlows) | ||
} | ||
|
||
ComplexFlowPingResponse(HaFlowPingResult pingResponse) { | ||
this.pingSuccess = pingResponse.pingSuccess | ||
this.error = pingResponse.error | ||
this.subFlowsDiscrepancies = collectDiscrepanciesPerSubFlow(pingResponse.subFlows) | ||
} | ||
|
||
static private def collectDiscrepanciesPerSubFlow(List<SubFlowPingPayload> subFlowsPingDetails) { | ||
List<SubFlowPingDiscrepancies> discrepanciesPerSubFlow = subFlowsPingDetails.collect { subFlowPingDetails -> | ||
verifyPingLogic(subFlowPingDetails, FORWARD) | ||
verifyPingLogic(subFlowPingDetails, REVERSE) | ||
|
||
HashMap<FlowDirection, String> discrepancies = [:] | ||
subFlowPingDetails.forward.pingSuccess ?: discrepancies.put(FORWARD, subFlowPingDetails.forward.error) | ||
subFlowPingDetails.reverse.pingSuccess ?: discrepancies.put(REVERSE, subFlowPingDetails.reverse.error) | ||
|
||
return discrepancies.isEmpty() ? null : new SubFlowPingDiscrepancies(subFlowPingDetails.flowId, discrepancies) | ||
}.findAll() | ||
return discrepanciesPerSubFlow | ||
} | ||
|
||
static private void verifyPingLogic(SubFlowPingPayload pingPayload, FlowDirection direction) { | ||
def pingResult = direction == FORWARD ? pingPayload.forward : pingPayload.reverse | ||
assert (pingResult.pingSuccess && !pingResult.error) || (!pingResult.pingSuccess && pingResult.error), | ||
"There is an error in the ping logic for sub-flow ${pingPayload.flowId} $direction: $pingResult" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...c/main/groovy/org/openkilda/functionaltests/helpers/model/SubFlowPingDiscrepancies.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.openkilda.functionaltests.helpers.model | ||
|
||
import groovy.transform.ToString | ||
import groovy.transform.TupleConstructor | ||
|
||
@TupleConstructor | ||
@ToString | ||
class SubFlowPingDiscrepancies { | ||
String subFlowId | ||
Map<FlowDirection, String> flowDiscrepancies | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.