Skip to content
Permalink
Browse files

Merge pull request #2672 from telstra/functional/misc_fixes

Misc fixes in tests
  • Loading branch information...
nikitacherevko committed Aug 12, 2019
2 parents c33e55f + f3c3a0a commit 23bed46e94944bf6adac60d8d4c2a60470c03ab9
@@ -7,13 +7,14 @@ package org.openkilda.functionaltests.extension.tags
enum Tag {
//pre-defined sets
SMOKE, REGRESSION, ONDEMAND,
SMOKE_SWITCHES, //focus on switch-related operations, useful for testing new switch firmware

//environments
HARDWARE, VIRTUAL,

//additional markers
TOPOLOGY_DEPENDENT, //changing the environment or topology may affect the amount of iterations executed
SMOKE_SWITCHES, // to make sure switches works fine
LOW_PRIORITY, //executed rarely and have lower chance of catching defects. Not executed for each PR

//speed
SLOW,//usually for 1minute+ tests
@@ -110,7 +110,8 @@ class SwitchHelper {
*/
def getExpectedBurst(SwitchId sw, long rate) {
def descr = getDescription(sw).toLowerCase()
if (descr.contains("noviflow")) {
def details = northbound.getSwitch(sw).switchView.description
if (descr.contains("noviflow") || details.hardware =~ "WB5164") {
return (rate * NOVIFLOW_BURST_COEFFICIENT - 1).setScale(0, RoundingMode.CEILING)
} else if (descr.contains("centec")) {
def burst = (rate * burstCoefficient).toBigDecimal().setScale(0, RoundingMode.FLOOR)
@@ -2,19 +2,20 @@ package org.openkilda.functionaltests.spec.flows

import static groovyx.gpars.GParsPool.withPool
import static org.junit.Assume.assumeTrue
import static org.openkilda.functionaltests.extension.tags.Tag.LOW_PRIORITY
import static org.openkilda.functionaltests.extension.tags.Tag.SMOKE
import static org.openkilda.functionaltests.extension.tags.Tag.TOPOLOGY_DEPENDENT
import static org.openkilda.functionaltests.extension.tags.Tag.VIRTUAL
import static org.openkilda.messaging.info.event.IslChangeType.DISCOVERED
import static org.openkilda.messaging.info.event.IslChangeType.FAILED
import static org.openkilda.messaging.info.event.IslChangeType.MOVED
import static org.openkilda.model.MeterId.MAX_SYSTEM_RULE_METER_ID
import static org.openkilda.model.MeterId.MIN_FLOW_METER_ID
import static org.openkilda.testing.Constants.NON_EXISTENT_FLOW_ID
import static org.openkilda.testing.Constants.WAIT_OFFSET

import org.openkilda.functionaltests.HealthCheckSpecification
import org.openkilda.functionaltests.extension.tags.IterationTag
import org.openkilda.functionaltests.extension.tags.IterationTags
import org.openkilda.functionaltests.extension.tags.Tags
import org.openkilda.functionaltests.helpers.PathHelper
import org.openkilda.functionaltests.helpers.Wrappers
@@ -72,10 +73,13 @@ class FlowCrudSpec extends HealthCheckSpecification {
"Could not $action flow: The port $port on the switch '$swId' is occupied by an ISL."
}

@Tags([TOPOLOGY_DEPENDENT])
@IterationTags([
@IterationTag(tags = [SMOKE], iterationNameRegex = /vlan /),
@IterationTag(tags = [LOW_PRIORITY], iterationNameRegex = /and vlan only on/)
])
@Unroll("Valid #data.description has traffic and no rule discrepancies \
(#flow.source.datapath - #flow.destination.datapath)")
@Tags([TOPOLOGY_DEPENDENT])
@IterationTag(tags = [SMOKE], iterationNameRegex = /vlan /)
def "Valid flow has no rule discrepancies"() {
given: "A flow"
assumeTrue("There should be at least two active traffgens for test execution",
@@ -2,13 +2,17 @@ package org.openkilda.functionaltests.spec.flows

import static groovyx.gpars.GParsPool.withPool
import static org.junit.Assume.assumeTrue
import static org.openkilda.functionaltests.extension.tags.Tag.LOW_PRIORITY
import static org.openkilda.functionaltests.extension.tags.Tag.SMOKE
import static org.openkilda.functionaltests.extension.tags.Tag.TOPOLOGY_DEPENDENT
import static org.openkilda.messaging.info.event.IslChangeType.DISCOVERED
import static org.openkilda.messaging.info.event.IslChangeType.FAILED
import static org.openkilda.messaging.info.event.IslChangeType.MOVED
import static org.openkilda.testing.Constants.WAIT_OFFSET

import org.openkilda.functionaltests.HealthCheckSpecification
import org.openkilda.functionaltests.extension.tags.IterationTag
import org.openkilda.functionaltests.extension.tags.IterationTags
import org.openkilda.functionaltests.extension.tags.Tags
import org.openkilda.functionaltests.helpers.FlowHelperV2
import org.openkilda.functionaltests.helpers.PathHelper
@@ -59,9 +63,13 @@ class FlowCrudV2Spec extends HealthCheckSpecification {
"Could not $action flow: The port $port on the switch '$swId' is occupied by an ISL."
}

@Tags([TOPOLOGY_DEPENDENT])
@IterationTags([
@IterationTag(tags = [SMOKE], iterationNameRegex = /vlan /),
@IterationTag(tags = [LOW_PRIORITY], iterationNameRegex = /and vlan only on/)
])
@Unroll("Valid #data.description has traffic and no rule discrepancies \
(#flow.source.switchId - #flow.destination.switchId)")
@Tags([TOPOLOGY_DEPENDENT])
def "Valid flow has no rule discrepancies"() {
given: "A flow"
assumeTrue("There should be at least two active traffgens for test execution",
@@ -18,9 +18,9 @@ import org.openkilda.messaging.info.event.PathNode
import org.openkilda.messaging.payload.flow.FlowCreatePayload
import org.openkilda.messaging.payload.flow.FlowEndpointPayload
import org.openkilda.messaging.payload.flow.FlowState
import org.openkilda.model.FlowEncapsulationType
import org.openkilda.model.SwitchId
import org.openkilda.northbound.dto.v2.flows.FlowEndpointV2
import org.openkilda.model.FlowEncapsulationType
import org.openkilda.northbound.dto.v2.flows.SwapFlowPayload
import org.openkilda.testing.model.topology.TopologyDefinition.Switch
import org.openkilda.testing.service.traffexam.TraffExamService
@@ -113,10 +113,10 @@ class SwapEndpointSpec extends HealthCheckSpecification {
},
[description: "port on dst1 <-> port on src2, vlans are equal"].tap {
def switchPair = getTopologyHelper().getNotNeighboringSwitchPair()
def flow1 = getFlowHelper().randomFlow(switchPair)
def flow1 = getFlowHelper().randomFlow(switchPair, false)
def flow2 = getFlowHelper().randomFlow(switchPair, false, [flow1])
flow1.destination.portNumber = getFreePort(switchPair.dst, [switchPair.src])
flow2.source.portNumber = getFreePort(switchPair.src, [switchPair.dst], [flow1.destination.portNumber])
flow1.destination.portNumber = getFreePort(switchPair.dst, [switchPair.src], [flow1.source.portNumber])
flow2.source.portNumber = getFreePort(switchPair.src, [switchPair.dst], [flow2.destination.portNumber])
flow2.source.vlanId = flow1.source.vlanId
it.flows = [flow1, flow2]
it.firstSwap = new SwapFlowPayload(flow1.id,
@@ -1063,7 +1063,7 @@ switches"() {
then: "Endpoints are successfully swapped"
verifyEndpoints(response, flow1Src, flow1Dst, flow2Src, flow2Dst)
verifyEndpoints(flow1, flow2, flow1Src, flow1Dst, flow2Src, flow2Dst)
verifyEndpoints(flow1.id, flow2.id, flow1Src, flow1Dst, flow2Src, flow2Dst)
//TODO(andriidovhan) uncomment when pr2503 is merged
// and: "Flows validation doesn't show any discrepancies"
@@ -11,6 +11,7 @@ import org.openkilda.functionaltests.helpers.Wrappers
import org.openkilda.messaging.error.MessageError
import org.openkilda.messaging.info.event.IslChangeType
import org.openkilda.messaging.info.event.PathNode
import org.openkilda.messaging.payload.flow.FlowState
import org.openkilda.model.Cookie
import org.openkilda.model.FlowEncapsulationType
import org.openkilda.northbound.dto.v1.flows.PingInput
@@ -138,6 +139,7 @@ class VxlanFlowSpec extends HealthCheckSpecification {
flowInfo.lastUpdated < newFlowInfo.lastUpdated

and: "Cleanup: Delete the flow"
Wrappers.wait(WAIT_OFFSET) { northbound.getFlowStatus(flow.id).status == FlowState.UP }
flowHelper.deleteFlow(flow.id)
}

@@ -6,6 +6,7 @@ import static org.openkilda.testing.Constants.WAIT_OFFSET
import org.openkilda.functionaltests.BaseSpecification
import org.openkilda.functionaltests.extension.rerun.Rerun
import org.openkilda.functionaltests.helpers.Wrappers
import org.openkilda.messaging.payload.flow.FlowCreatePayload
import org.openkilda.messaging.payload.flow.FlowState

import groovyx.gpars.group.DefaultPGroup
@@ -48,7 +49,8 @@ class ContentionSpec extends BaseSpecification {
when: "Create multiple flows on the same ISLs concurrently"
def flowsAmount = 15
def group = new DefaultPGroup(flowsAmount)
def flows = (1..flowsAmount).collect { flowHelper.randomFlow(topologyHelper.notNeighboringSwitchPair) }
List<FlowCreatePayload> flows = []
flowsAmount.times { flows << flowHelper.randomFlow(topologyHelper.notNeighboringSwitchPair, false , flows) }
def createTasks = flows.collect { flow ->
group.task { flowHelper.addFlow(flow) }
}
@@ -7,7 +7,9 @@ import org.openkilda.functionaltests.BaseSpecification
import org.openkilda.functionaltests.extension.rerun.Rerun
import org.openkilda.functionaltests.helpers.FlowHelperV2
import org.openkilda.functionaltests.helpers.Wrappers
import org.openkilda.messaging.payload.flow.FlowCreatePayload
import org.openkilda.messaging.payload.flow.FlowState
import org.openkilda.northbound.dto.v2.flows.FlowRequestV2
import org.openkilda.testing.service.northbound.NorthboundServiceV2

import groovyx.gpars.group.DefaultPGroup
@@ -56,7 +58,8 @@ class ContentionV2Spec extends BaseSpecification {
when: "Create multiple flows on the same ISLs concurrently"
def flowsAmount = 6
def group = new DefaultPGroup(flowsAmount)
def flows = (1..flowsAmount).collect { flowHelperV2.randomFlow(topologyHelper.notNeighboringSwitchPair) }
List<FlowRequestV2> flows = []
flowsAmount.times { flows << flowHelperV2.randomFlow(topologyHelper.notNeighboringSwitchPair, false , flows) }
def createTasks = flows.collect { flow ->
group.task { flowHelperV2.addFlow(flow) }
}
@@ -68,15 +68,6 @@ class DefaultRulesSpec extends HealthCheckSpecification {
@Tags([TOPOLOGY_DEPENDENT, SMOKE_SWITCHES])
def "Able to install default rule on an #sw.ofVersion switch(#sw.dpId, install-action=#data.installRulesAction)"(
Map data, Switch sw) {
assumeFalse("Unable to run the test because an OF_12 switch has one broadcast rule as the default",
sw.ofVersion == "OF_12" && data.installRulesAction != InstallRulesAction.INSTALL_BROADCAST)
assumeFalse("Unable to run the test because only NoviFlow switches support installation of BFD catch rule",
!sw.noviflow && data.installRulesAction == InstallRulesAction.INSTALL_BFD_CATCH)
assumeFalse("Unable to run the test because only NoviFlow switches support installation of Round Trip Latency "
+ "rule", !sw.noviflow && data.installRulesAction == InstallRulesAction.INSTALL_ROUND_TRIP_LATENCY)
assumeFalse("Unable to run the test because only NoviFlow switches support installation of Unicast VXLAN rule",
!sw.noviflow && data.installRulesAction == InstallRulesAction.INSTALL_UNICAST_VXLAN)

given: "A switch without any rules"
def defaultRules = northbound.getSwitchRules(sw.dpId).flowEntries
assert defaultRules*.cookie.sort() == sw.defaultCookies.sort()
@@ -131,6 +122,14 @@ class DefaultRulesSpec extends HealthCheckSpecification {
],
getTopology().getActiveSwitches().unique { activeSw -> activeSw.description }
].combinations()
.findAll { dataPiece, theSw ->
//OF_12 has only broadcast rule, so filter out all other combinations for OF_12
!(theSw.ofVersion == "OF_12" && dataPiece.installRulesAction != InstallRulesAction.INSTALL_BROADCAST) &&
//BFD, Round Trip and VXlan are available only on Noviflow
!(!theSw.noviflow && dataPiece.installRulesAction in [InstallRulesAction.INSTALL_BFD_CATCH,
InstallRulesAction.INSTALL_ROUND_TRIP_LATENCY,
InstallRulesAction.INSTALL_UNICAST_VXLAN])
}
}

@Unroll
@@ -162,9 +161,6 @@ class DefaultRulesSpec extends HealthCheckSpecification {
@Tags([TOPOLOGY_DEPENDENT, SMOKE, SMOKE_SWITCHES])
def "Able to delete default rule from an #sw.ofVersion switch (#sw.dpId, delete-action=#data.deleteRulesAction)"(
Map data, Switch sw) {
assumeFalse("Unable to run the test because an OF_12 switch has one broadcast rule as the default",
sw.ofVersion == "OF_12" && data.cookie != Cookie.VERIFICATION_BROADCAST_RULE_COOKIE)

when: "Delete rules from the switch"
def defaultRules = northbound.getSwitchRules(sw.dpId).flowEntries
assert defaultRules*.cookie.sort() == sw.defaultCookies.sort()
@@ -218,7 +214,10 @@ class DefaultRulesSpec extends HealthCheckSpecification {
]
],
getTopology().getActiveSwitches().unique { activeSw -> activeSw.description }
].combinations()
].combinations().findAll { dataPiece, theSw ->
//OF_12 switches has only one broadcast rule, so not all iterations will be applicable
!(theSw.ofVersion == "OF_12" && dataPiece.cookie != Cookie.VERIFICATION_BROADCAST_RULE_COOKIE)
}
}

void compareRules(actualRules, expectedRules) {
@@ -158,14 +158,14 @@ class MetersSpec extends HealthCheckSpecification {
def "Default meters should express bandwidth in kbps on Noviflow Wb5164 switch(#sw.dpId)"() {
expect: "Only the default meters should be present on the switch"
def meters = northbound.getAllMeters(sw.dpId)
assert meters.meterEntries.size() == 3
assert meters.meterEntries.size() == 2
assert meters.meterEntries.every(defaultMeters)
meters.meterEntries.each { assert it.rate == MIN_RATE_KBPS }
//TODO(andriidovhan) fix calculations of burst size on Noviflow Wb5164 switches for default meters
// here we can't use the getExpectedBurst method
meters.meterEntries.every { assert it.burstSize == 999L }
meters.meterEntries.every { assert ["KBPS", "BURST", "STATS"].containsAll(it.flags) }
meters.meterEntries.every { assert it.flags.size() == 3 }
meters.meterEntries.each { assert it.burstSize == 999L }
meters.meterEntries.each { assert ["KBPS", "BURST", "STATS"].containsAll(it.flags) }
meters.meterEntries.each { assert it.flags.size() == 3 }
where:
sw << (getNoviflowWb5164().unique { it.description } ?:

0 comments on commit 23bed46

Please sign in to comment.
You can’t perform that action at this time.