Skip to content
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

Added test permutations for all unique switch descriptions #1420

Merged
merged 1 commit into from Oct 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -11,6 +11,7 @@ import org.openkilda.functionaltests.helpers.PathHelper
import org.openkilda.functionaltests.helpers.Wrappers
import org.openkilda.messaging.info.event.IslChangeType
import org.openkilda.messaging.info.event.PathNode
import org.openkilda.messaging.info.event.SwitchInfoData
import org.openkilda.messaging.payload.flow.FlowState
import org.openkilda.northbound.dto.flows.PingInput
import org.openkilda.northbound.dto.flows.PingOutput.PingOutputBuilder
Expand All @@ -26,8 +27,15 @@ import org.openkilda.testing.tools.IslUtils

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import spock.lang.Narrative
import spock.lang.Unroll

@Narrative("""
This spec tests all the functionality related to flow pings.
Flow ping feature sends a 'ping' packet at the one end of the flow, expecting that this packet will
be delivered at the other end. 'Pings' the flow in both directions(forward and reverse).
""")
//TODO(rtretiak): add hw-only test to verify that pings are disabled for OF_12
class FlowPingSpec extends BaseSpecification {
@Autowired
TopologyDefinition topology
Expand All @@ -51,13 +59,7 @@ class FlowPingSpec extends BaseSpecification {

def pingInput = new PingInput(3000)

def setupOnce() {
//TODO(rtretiak): need to exclude Accton switches for hardware env. depends on #1027
//TODO(rtretiak): add hw-only test to verify that pings are disabled for Acctons
requireProfiles("virtual")
}

@Unroll("Able to ping a flow with vlan between switches #srcSwitch.ofVersion - #dstSwitch.ofVersion")
@Unroll("Able to ping a flow with vlan between switches #srcSwitch.dpId - #dstSwitch.dpId")
def "Able to ping a flow with vlan"(Switch srcSwitch, Switch dstSwitch) {
given: "A flow with random vlan"
def flow = flowHelper.randomFlow(srcSwitch, dstSwitch)
Expand All @@ -81,10 +83,9 @@ class FlowPingSpec extends BaseSpecification {

where:
[srcSwitch, dstSwitch] << ofSwitchCombinations
//TODO(rtretiak): Cycle over Switch manufacturers too (requires #1027)
}

@Unroll("Able to ping a flow with no vlan between switches #srcSwitch.ofVersion - #dstSwitch.ofVersion")
@Unroll("Able to ping a flow with no vlan between switches #srcSwitch.dpId - #dstSwitch.dpId")
def "Able to ping a flow with no vlan"(Switch srcSwitch, Switch dstSwitch) {
given: "A flow with no vlan"
def flow = flowHelper.randomFlow(srcSwitch, dstSwitch)
Expand All @@ -110,13 +111,12 @@ class FlowPingSpec extends BaseSpecification {

where:
[srcSwitch, dstSwitch] << ofSwitchCombinations
//TODO(rtretiak): Cycle over Switch manufacturers too (requires #1027)
}

@Unroll("Flow ping can detect broken #description path")
@Unroll("Flow ping can detect a broken #description path")
def "Flow ping can detect broken path"() {
given: "A flow with at least 1 a-switch link"
def switches = topology.getActiveSwitches()
def switches = nonCentecSwitches()
List<List<PathNode>> allPaths = []
List<PathNode> aswitchPath
//select src and dst switches that have an a-switch path
Expand Down Expand Up @@ -188,7 +188,7 @@ class FlowPingSpec extends BaseSpecification {

def "Able to ping single-switch flow"() {
given: "A single-switch flow"
def sw = topology.activeSwitches.first()
def sw = nonCentecSwitches().first()
def flow = flowHelper.singleSwitchFlow(sw)
northboundService.addFlow(flow)
assert Wrappers.wait(WAIT_OFFSET) { northboundService.getFlowStatus(flow.id).status == FlowState.UP }
Expand Down Expand Up @@ -223,8 +223,35 @@ class FlowPingSpec extends BaseSpecification {
}
}

/**
* Returns all switch combinations with unique description, excluding single-switch combinations,
* combinations with Centec switches and OF_12 switches
*/
def getOfSwitchCombinations() {
npliashechnikov marked this conversation as resolved.
Show resolved Hide resolved
return [topology.activeSwitches, topology.activeSwitches].combinations().findAll { src, dst -> src != dst }
.unique { it.ofVersion.sort() }
def nbSwitches = northboundService.getActiveSwitches()
npliashechnikov marked this conversation as resolved.
Show resolved Hide resolved
return [nbSwitches, nbSwitches].combinations()
.findAll { src, dst ->
//exclude single-switch flows
src != dst &&
//pings are disabled for OF version < 1.3
[toSwitch(src), toSwitch(dst)].every { it.ofVersion != "OF_12" } &&
//known issue: pings on Centects do not work
[src, dst].every { !it.description.contains("Centec") }
}
//pick all unique switch description-OfVersion pairs
.unique { [it*.description.sort(), it.collect{ toSwitch(it) }*.ofVersion.sort()] }
.collect { nbSrcSwitch, nbDstSwitch ->
[toSwitch(nbSrcSwitch), toSwitch(nbDstSwitch)]
}
}

def nonCentecSwitches() {
northboundService.getActiveSwitches()
.findAll { !it.description.contains("Centec") }
.collect { toSwitch(it) }
}

Switch toSwitch(SwitchInfoData nbSwitch) {
topology.activeSwitches.find { it.dpId == nbSwitch.switchId }
}
}
6 changes: 3 additions & 3 deletions services/src/functional-tests/topology.yaml
Expand Up @@ -24,7 +24,7 @@ switches:
vlan_range: 101..150

- name: ofsw7
dp_id: 00:00:b0:00:00:00:00:07
dp_id: 00:00:00:00:00:00:00:07
of_version: OF_13
status: active
out_ports:
Expand All @@ -33,15 +33,15 @@ switches:

- name: ofsw8
dp_id: 00:00:00:00:00:00:00:08
of_version: OF_12
of_version: OF_13
status: active
out_ports:
- port: 10
vlan_range: 101..150

- name: ofsw9
dp_id: 00:00:00:00:00:00:00:09
of_version: OF_12
of_version: OF_13
status: active
out_ports:
- port: 10
Expand Down