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

[TEST]: Improvement: Flaky test: Reroute with global timeout #5749

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}
Loading