-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
5560: [TEST]: Add methods to break/restore ISLs in test
Implements #5560 * Replaced places in tests where port is set up/down with waiting for ISL get up/down with reusable methods
- Loading branch information
Showing
35 changed files
with
420 additions
and
1,131 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
...g/functional-tests/src/main/groovy/org/openkilda/functionaltests/helpers/IslHelper.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package org.openkilda.functionaltests.helpers | ||
|
||
import groovy.util.logging.Slf4j | ||
import org.openkilda.messaging.info.event.IslChangeType | ||
import org.openkilda.testing.model.topology.TopologyDefinition | ||
import org.openkilda.testing.model.topology.TopologyDefinition.Isl | ||
import org.openkilda.testing.service.northbound.NorthboundService | ||
import org.openkilda.testing.service.northbound.NorthboundServiceV2 | ||
import org.openkilda.testing.tools.IslUtils | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.beans.factory.annotation.Qualifier | ||
import org.springframework.context.annotation.Scope | ||
import org.springframework.stereotype.Component | ||
|
||
import static groovyx.gpars.GParsExecutorsPool.withPool | ||
import static org.openkilda.messaging.info.event.IslChangeType.DISCOVERED | ||
import static org.openkilda.messaging.info.event.IslChangeType.FAILED | ||
import static org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_PROTOTYPE | ||
|
||
/** | ||
* Holds utility methods for manipulating y-flows. | ||
*/ | ||
@Component | ||
@Slf4j | ||
@Scope(SCOPE_PROTOTYPE) | ||
class IslHelper { | ||
@Autowired | ||
TopologyDefinition topology | ||
@Autowired @Qualifier("islandNbV2") | ||
NorthboundServiceV2 northboundV2 | ||
@Autowired @Qualifier("islandNb") | ||
NorthboundService northbound | ||
@Autowired | ||
IslUtils islUtils | ||
@Autowired | ||
PortAntiflapHelper antiflapHelper | ||
|
||
|
||
def breakIsl(Isl islToBreak) { | ||
if (getIslStatus(islToBreak).equals(DISCOVERED)) { | ||
antiflapHelper.portDown(islToBreak.getSrcSwitch().getDpId(), islToBreak.getSrcPort()) | ||
} | ||
islUtils.waitForIslStatus([islToBreak], FAILED) | ||
} | ||
|
||
def breakIsls(Set<Isl> islsToBreak) { | ||
withPool { | ||
islsToBreak.eachParallel{ | ||
breakIsl(it) | ||
} | ||
} | ||
} | ||
|
||
def breakIsls(List<Isl> islsToBreak) { | ||
breakIsls(islsToBreak as Set) | ||
} | ||
|
||
def restoreIsl(Isl islToRestore) { | ||
if(!getIslStatus(islToRestore).equals(DISCOVERED)) { | ||
withPool{ | ||
[{antiflapHelper.portUp(islToRestore.getSrcSwitch().getDpId(), islToRestore.getSrcPort())}, | ||
{antiflapHelper.portUp(islToRestore.getDstSwitch().getDpId(), islToRestore.getDstPort())} | ||
].eachParallel{it()} | ||
} | ||
} | ||
islUtils.waitForIslStatus([islToRestore], DISCOVERED) | ||
} | ||
|
||
def restoreIsls(Set<Isl> islsToRestore) { | ||
withPool { | ||
islsToRestore.eachParallel{ | ||
restoreIsl(it) | ||
} | ||
} | ||
} | ||
|
||
def restoreIsls(List<Isl> islsToRestore) { | ||
restoreIsls(islsToRestore as Set) | ||
} | ||
|
||
def getIslStatus(Isl isl) { | ||
def islInfo = islUtils.getIslInfo(isl) | ||
if (islInfo.isPresent()) { | ||
return islInfo.get().state | ||
} else { | ||
return null | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.