Skip to content

Commit

Permalink
add new helper: getFlowHistoryByAction
Browse files Browse the repository at this point in the history
  • Loading branch information
andriidovhan committed Sep 12, 2019
1 parent a76c61a commit 12ec9d8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
Expand Up @@ -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
Expand Down Expand Up @@ -261,6 +262,14 @@ class FlowHelper {
}
}

List<FlowHistoryPayload> getFlowHistoryByAction(String flowId, String action) {
getFlowHistoryByAction(flowId, null, null, action)
}

List<FlowHistoryPayload> getFlowHistoryByAction(String flowId, Long timeFrom, Long timeTo, String action) {
northbound.getFlowHistory(flowId, timeFrom, timeTo).findAll { it.action == action }.last().histories
}

/**
* Returns flow endpoint with randomly chosen vlan.
*
Expand Down
@@ -0,0 +1,20 @@
package org.openkilda.functionaltests.helpers

enum FlowHistoryAction {
FLOW_CREATING("Flow creating"),
FLOW_UPDATING("Flow updating"),
FLOW_REROUTING("Flow rerouting"),
SET_THE_FLOW_STATUS_TO_DOWN("Set the flow status to down."),
FLOW_WAS_VALIDATED_SUCCESSFULLY("Flow was validated successfully")

public final String action

FlowHistoryAction(String action) {
this.action = action
}

@Override
String toString() {
return action
}
}
Expand Up @@ -4,6 +4,8 @@ import static org.junit.Assume.assumeTrue
import static org.openkilda.functionaltests.extension.tags.Tag.HARDWARE
import static org.openkilda.functionaltests.extension.tags.Tag.SMOKE
import static org.openkilda.functionaltests.extension.tags.Tag.VIRTUAL
import static org.openkilda.functionaltests.helpers.FlowHistoryAction.FLOW_REROUTING
import static org.openkilda.functionaltests.helpers.FlowHistoryAction.SET_THE_FLOW_STATUS_TO_DOWN
import static org.openkilda.testing.Constants.WAIT_OFFSET

import org.openkilda.functionaltests.HealthCheckSpecification
Expand Down Expand Up @@ -75,7 +77,11 @@ class AutoRerouteSpec extends HealthCheckSpecification {
antiflap.portDown(isl.dstSwitch.dpId, isl.dstPort)

then: "The flow becomes 'Down'"
Wrappers.wait(rerouteDelay + WAIT_OFFSET) { assert northbound.getFlowStatus(flow.id).status == FlowState.DOWN }
Wrappers.wait(rerouteDelay + WAIT_OFFSET) {
assert flowHelper.getFlowHistoryByAction(flow.id, FLOW_REROUTING.action)
.last().action == SET_THE_FLOW_STATUS_TO_DOWN.action
assert northbound.getFlowStatus(flow.id).status == FlowState.DOWN
}

when: "ISL goes back up"
antiflap.portUp(isl.dstSwitch.dpId, isl.dstPort)
Expand Down

0 comments on commit 12ec9d8

Please sign in to comment.