New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add new flowHelper method: getFlowHistoryByAction #2791
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import org.openkilda.messaging.payload.flow.FlowCreatePayload | |
import org.openkilda.messaging.payload.flow.FlowEndpointPayload | ||
import org.openkilda.messaging.payload.flow.FlowPayload | ||
import org.openkilda.messaging.payload.flow.FlowState | ||
import org.openkilda.messaging.payload.history.FlowHistoryPayload | ||
import org.openkilda.model.Flow | ||
import org.openkilda.northbound.dto.v2.flows.FlowEndpointV2 | ||
import org.openkilda.testing.model.topology.TopologyDefinition | ||
|
@@ -261,6 +262,28 @@ class FlowHelper { | |
} | ||
} | ||
|
||
/** | ||
* Check that flow state is changed correctly after corresponding flow history action. | ||
* | ||
* @param flowId | ||
* @param timeFrom history will requested from this timestamp | ||
* @param event sequence of flow history actions | ||
* @param state expected flow state | ||
*/ | ||
void verifyFlowState(String flowId, Long timeFrom, FlowHistoryEvent event, state) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a strict type for state |
||
def timeTo = timeFrom ? System.currentTimeSeconds() : null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, this is kind of tricky. timeTo based on timeFrom, why would you do this? Very strange and not intuitive approach |
||
def flowHistory = northbound.getFlowHistory(flowId, timeFrom, timeTo).findAll { | ||
it.action == event.initAction.toString() | ||
} | ||
assert flowHistory.size() == 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are you sure that you want to limit your method with this condition? What if there were more actions on the flow? I'm not insisting, but for me it kind of limits where it can be used or forces to use the 'from' timestamp. that's fine I guess, but requires a lot of 'timestamp' vars for long tests |
||
assert flowHistory.first().histories.last().action == event.finalAction.toString() | ||
assert northbound.getFlowStatus(flowId).status == state | ||
} | ||
|
||
void verifyFlowState(String flowId, FlowHistoryEvent event, FlowState state) { | ||
verifyFlowState(flowId, null, event, state) | ||
} | ||
rtretyak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* Returns flow endpoint with randomly chosen vlan. | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.openkilda.functionaltests.helpers | ||
|
||
enum FlowHistoryAction { | ||
rtretyak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
//action | ||
FLOW_CREATING("Flow creating"), | ||
FLOW_UPDATING("Flow updating"), | ||
FLOW_REROUTING("Flow rerouting"), | ||
|
||
//nested action | ||
SET_THE_FLOW_STATUS_TO_UP("Set the flow status to UP."), | ||
SET_THE_FLOW_STATUS_TO_DOWN("Set the flow status to down."), | ||
FLOW_WAS_VALIDATED_SUCCESSFULLY("Flow was validated successfully"), | ||
rtretyak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public final String action | ||
|
||
FlowHistoryAction(String action) { | ||
this.action = action | ||
} | ||
|
||
@Override | ||
String toString() { | ||
return action | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.openkilda.functionaltests.helpers | ||
|
||
enum FlowHistoryEvent { | ||
|
||
REROUTE_SUCCESS(FlowHistoryAction.FLOW_REROUTING, FlowHistoryAction.SET_THE_FLOW_STATUS_TO_UP), | ||
REROUTE_FAIL(FlowHistoryAction.FLOW_REROUTING, FlowHistoryAction.SET_THE_FLOW_STATUS_TO_DOWN), | ||
REROUTE_FAIL_PROTECTED_PATH(FlowHistoryAction.FLOW_REROUTING, FlowHistoryAction.FLOW_WAS_VALIDATED_SUCCESSFULLY), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am a bit confused how FLOW_REROUTING + FLOW_WAS_VALIDATED_SUCCESSFULLY is related to protected paths There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just copied it from flowHistory output after flowState was changed to DEGRADED There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you call it like that? It clearly means that |
||
|
||
public final FlowHistoryAction initAction | ||
public final FlowHistoryAction finalAction | ||
|
||
FlowHistoryEvent(FlowHistoryAction initAction, FlowHistoryAction finalAction){ | ||
this.initAction = initAction | ||
this.finalAction = finalAction | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import static org.openkilda.testing.Constants.WAIT_OFFSET | |
|
||
import org.openkilda.functionaltests.HealthCheckSpecification | ||
import org.openkilda.functionaltests.extension.tags.Tags | ||
import org.openkilda.functionaltests.helpers.FlowHistoryEvent | ||
import org.openkilda.functionaltests.helpers.Wrappers | ||
import org.openkilda.messaging.error.MessageError | ||
import org.openkilda.messaging.info.event.IslChangeType | ||
|
@@ -22,7 +23,6 @@ import org.openkilda.testing.tools.FlowTrafficExamBuilder | |
|
||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.web.client.HttpClientErrorException | ||
import spock.lang.Ignore | ||
import spock.lang.Narrative | ||
import spock.lang.See | ||
import spock.lang.Unroll | ||
|
@@ -893,17 +893,22 @@ class ProtectedPathSpec extends HealthCheckSpecification { | |
antiflap.portDown(protectedIsls[0].dstSwitch.dpId, protectedIsls[0].dstPort) | ||
|
||
then: "Flow state is changed to DEGRADED" | ||
Wrappers.wait(WAIT_OFFSET) { assert northbound.getFlowStatus(flow.id).status == FlowState.DEGRADED } | ||
Wrappers.wait(WAIT_OFFSET) { | ||
flowHelper.verifyFlowState(flow.id, FlowHistoryEvent.REROUTE_FAIL_PROTECTED_PATH, FlowState.DEGRADED) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is literally false expression. You are not verifying that the reroute failed for protected path, you are just checking that a successful validation happened. |
||
} | ||
verifyAll(northbound.getFlow(flow.id).flowStatusDetails) { | ||
mainFlowPathStatus == "Up" | ||
protectedFlowPathStatus == "Down" | ||
} | ||
|
||
when: "Break ISL on the main path (bring port down) for changing the flow state to DOWN" | ||
Long timestampBeforeDown = System.currentTimeSeconds() | ||
antiflap.portDown(currentIsls[0].dstSwitch.dpId, currentIsls[0].dstPort) | ||
|
||
then: "Flow state is changed to DOWN" | ||
Wrappers.wait(WAIT_OFFSET) { assert northbound.getFlowStatus(flow.id).status == FlowState.DOWN } | ||
Wrappers.wait(WAIT_OFFSET) { | ||
flowHelper.verifyFlowState(flow.id, timestampBeforeDown, FlowHistoryEvent.REROUTE_FAIL, FlowState.DOWN) | ||
} | ||
verifyAll(northbound.getFlow(flow.id).flowStatusDetails) { | ||
mainFlowPathStatus == "Down" | ||
protectedFlowPathStatus == "Down" | ||
|
@@ -942,13 +947,14 @@ class ProtectedPathSpec extends HealthCheckSpecification { | |
"Could not swap paths: Protected flow path $flow.id is not in ACTIVE state" | ||
|
||
when: "Restore ISL for the protected path" | ||
Long timestampBeforeUP = System.currentTimeSeconds() | ||
antiflap.portUp(protectedIsls[0].srcSwitch.dpId, protectedIsls[0].srcPort) | ||
antiflap.portUp(protectedIsls[0].dstSwitch.dpId, protectedIsls[0].dstPort) | ||
|
||
then: "Flow state is changed to UP" | ||
//it often fails in scope of the whole spec on the hardware env, that's why '* 1.5' is added | ||
Wrappers.wait(discoveryInterval * 1.5 + WAIT_OFFSET) { | ||
assert northbound.getFlowStatus(flow.id).status == FlowState.UP | ||
flowHelper.verifyFlowState(flow.id, timestampBeforeUP, FlowHistoryEvent.REROUTE_SUCCESS, FlowState.UP) | ||
} | ||
|
||
and: "Cleanup: Restore topology, delete flows and reset costs" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be