diff --git a/src-java/testing/functional-tests/src/test/groovy/org/openkilda/functionaltests/spec/xresilience/RetriesSpec.groovy b/src-java/testing/functional-tests/src/test/groovy/org/openkilda/functionaltests/spec/xresilience/RetriesSpec.groovy index 1025ff6e8b..09e79e9313 100644 --- a/src-java/testing/functional-tests/src/test/groovy/org/openkilda/functionaltests/spec/xresilience/RetriesSpec.groovy +++ b/src-java/testing/functional-tests/src/test/groovy/org/openkilda/functionaltests/spec/xresilience/RetriesSpec.groovy @@ -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() @@ -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 @@ -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) } }