-
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 #5741 from telstra/test/complexFlow-validation-check
[TEST]: Improvement: Verification of validation response
- Loading branch information
Showing
11 changed files
with
110 additions
and
49 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
...n/groovy/org/openkilda/functionaltests/helpers/model/ComplexFlowValidationResponse.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,51 @@ | ||
package org.openkilda.functionaltests.helpers.model | ||
|
||
import org.openkilda.northbound.dto.v1.flows.FlowValidationDto | ||
import org.openkilda.northbound.dto.v1.flows.PathDiscrepancyDto | ||
import org.openkilda.northbound.dto.v2.haflows.HaFlowValidationResult | ||
import org.openkilda.northbound.dto.v2.yflows.YFlowValidationResult | ||
|
||
import groovy.transform.ToString | ||
|
||
@ToString | ||
class ComplexFlowValidationResponse { | ||
private static final String COOKIE_ID_IN_RULE_DISCREPANCY_STRING_REGEX = /-?\d{19}/ | ||
|
||
boolean asExpected | ||
List<SubFlowValidationDiscrepancies> subFlowsDiscrepancies | ||
|
||
ComplexFlowValidationResponse(YFlowValidationResult yFlowValidation) { | ||
this.asExpected = yFlowValidation.asExpected | ||
this.subFlowsDiscrepancies = collectDiscrepanciesPerSubFlow(yFlowValidation.subFlowValidationResults) | ||
} | ||
|
||
ComplexFlowValidationResponse(HaFlowValidationResult haFlowValidation) { | ||
this.asExpected = haFlowValidation.asExpected | ||
this.subFlowsDiscrepancies = collectDiscrepanciesPerSubFlow(haFlowValidation.subFlowValidationResults) | ||
|
||
} | ||
|
||
private static List<SubFlowValidationDiscrepancies> collectDiscrepanciesPerSubFlow(List<FlowValidationDto> subFlowValidationDetails) { | ||
List<SubFlowValidationDiscrepancies> discrepanciesPerSubFlow = subFlowValidationDetails.groupBy { it.flowId }.collect { | ||
assert (it.value.direction*.toUpperCase() as Set).size() == it.value.size(), "There is an error in the validation logic $it" | ||
HashMap<FlowDirection, List<PathDiscrepancyDto>> discrepancy = [:] | ||
it.value.each { | ||
verifyValidateLogic(it) | ||
it.asExpected ?: discrepancy.put(FlowDirection.getByDirection(it.direction.toLowerCase()), it.discrepancies) | ||
} | ||
discrepancy.isEmpty() ? null : new SubFlowValidationDiscrepancies(subFlowId: it.key, flowDiscrepancies: discrepancy) | ||
|
||
}.findAll() | ||
discrepanciesPerSubFlow | ||
} | ||
|
||
private static void verifyValidateLogic(FlowValidationDto validationDto) { | ||
assert (validationDto.asExpected && validationDto.discrepancies.isEmpty()) || (!validationDto.asExpected && !validationDto.discrepancies.isEmpty()), | ||
"There is an error in the validation logic $validationDto" | ||
} | ||
|
||
Set<Long> retrieveAllRulesCookieFromDiscrepancy() { | ||
def rules = subFlowsDiscrepancies.flowDiscrepancies*.values().flatten() | ||
rules.collect { new Long((it =~ COOKIE_ID_IN_RULE_DISCREPANCY_STRING_REGEX)[0]) } | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
.../groovy/org/openkilda/functionaltests/helpers/model/SubFlowValidationDiscrepancies.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,13 @@ | ||
package org.openkilda.functionaltests.helpers.model | ||
|
||
import org.openkilda.northbound.dto.v1.flows.PathDiscrepancyDto | ||
|
||
import groovy.transform.ToString | ||
import groovy.transform.TupleConstructor | ||
|
||
@TupleConstructor | ||
@ToString | ||
class SubFlowValidationDiscrepancies { | ||
String subFlowId | ||
Map<FlowDirection, List<PathDiscrepancyDto>> 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
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