Skip to content

Commit

Permalink
[TEST]: Improvement: Flaky test: Reroute with global timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuliia Miroshnychenko committed Nov 12, 2024
1 parent 6a85e5d commit 5c5cdc6
Showing 1 changed file with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,15 @@ class RetriesIsolatedSpec extends HealthCheckSpecification {
def swPair = switchPairs.all().nonNeighbouring().switchPairs
.find { it.src.dpId.toString().contains("03") && it.dst.dpId.toString().contains("07")}
def availablePaths = swPair.retrieveAvailablePaths().collect { it.getInvolvedIsls() }
def preferableIsls = availablePaths.find{ it.size() >= 5 }
availablePaths.findAll { it != preferableIsls }.each { islHelper.makePathIslsMorePreferable(preferableIsls, it) }
def expectedInitialPath = availablePaths.find { it.size() >= 5 }
availablePaths.findAll { it != expectedInitialPath }.each { islHelper.makePathIslsMorePreferable(expectedInitialPath, it) }
def flow = flowFactory.getRandom(swPair)
assert flow.retrieveAllEntityPaths().getInvolvedIsls() == preferableIsls
assert expectedInitialPath == flow.retrieveAllEntityPaths().getInvolvedIsls()
def flowInvolvedSwitches = islHelper.retrieveInvolvedSwitches(expectedInitialPath)
switchHelper.shapeSwitchesTraffic(flowInvolvedSwitches[1..-1], new TrafficControlData(8000))
when: "Break current path to trigger a reroute"
def islToBreak = flow.retrieveAllEntityPaths().getInvolvedIsls().first()
Expand All @@ -372,26 +376,34 @@ class RetriesIsolatedSpec extends HealthCheckSpecification {
northbound.portDown(islToBreak.srcSwitch.dpId, islToBreak.srcPort)
and: "Connection to src switch is slow in order to simulate a global timeout on reroute operation"
switchHelper.shapeSwitchesTraffic([swPair.src], new TrafficControlData(9200))
switchHelper.shapeSwitchesTraffic([swPair.src], new TrafficControlData(8500))
then: "After global timeout expect flow reroute to fail and flow to become DOWN"
TimeUnit.SECONDS.sleep(globalTimeout)
int eventsAmount
// 1 reroute event: main ISL break -> GlobalTimeout
// 1 reroute event: delay on the src(new path in the scope of triggered reroute)
int rerouteEventsAmount = 2
wait(globalTimeout + WAIT_OFFSET, 1) { //long wait, may be doing some revert actions after global t/o
def history = flow.retrieveFlowHistory()
def rerouteEvent = history.getEntriesByType(REROUTE).first()
assert rerouteEvent.payload.find { it.action == sprintf('Global timeout reached for reroute operation on flow "%s"', flow.flowId) }
assert rerouteEvent.payload.last().action == REROUTE_FAILED.payloadLastAction
assert flow.retrieveFlowStatus().status == DOWN
eventsAmount = history.entries.size()
assert history.getEntriesByType(REROUTE).size() == rerouteEventsAmount
}
and: "Flow remains down and no new history events appear for the next 3 seconds (no retry happens)"
timedLoop(3) {
and: "Flow remains down and no new history events appear for the next 5 seconds (no retry happens)"
timedLoop(5) {
assert flow.retrieveFlowStatus().status == DOWN
assert flow.retrieveFlowHistory().entries.size() == eventsAmount
assert flow.retrieveFlowHistory().entries.size() == rerouteEventsAmount + 1 // +1 creation event
}
and: "The last reroute event was caused by delay on src for the alternative path"
def rerouteEvents = flow.retrieveFlowHistory().getEntriesByType(REROUTE).last()
rerouteEvents.payload.last().action == REROUTE_FAILED.payloadLastAction
rerouteEvents.payload.last().details.toString().contains(
"No paths of the flow ${flow.flowId} are affected by failure on IslEndpoint")
and: "Src/dst switches are valid"
switchHelper.cleanupTrafficShaperRules([swPair.src])
boolean isTrafficShaperRulesCleanedUp = true
Expand All @@ -400,6 +412,7 @@ class RetriesIsolatedSpec extends HealthCheckSpecification {
}
cleanup:
!isTrafficShaperRulesCleanedUp && switchHelper.cleanupTrafficShaperRules([swPair.src])
//should be called here as flow deletion is called before removing delay on the switch in our cleanup manager
!isTrafficShaperRulesCleanedUp && switchHelper.cleanupTrafficShaperRules(flowInvolvedSwitches)
}
}

0 comments on commit 5c5cdc6

Please sign in to comment.