Skip to content

Commit

Permalink
Merge pull request #5482 from telstra/test/5390-fix-flow-monitoring-t…
Browse files Browse the repository at this point in the history
…ests

#5390: [TEST] Debug enabled for flaky Flow Monitoring spec
  • Loading branch information
IvanChupin authored Nov 23, 2023
2 parents 855e6ee + 823a27a commit d24e397
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package org.openkilda.functionaltests.helpers
import groovy.transform.InheritConstructors
import groovy.util.logging.Slf4j

import static java.lang.System.currentTimeMillis

@Slf4j
class Wrappers {

Expand Down Expand Up @@ -67,8 +69,8 @@ class Wrappers {
* @param closure code to repeat in a loop
*/
static void timedLoop(double timeout, Closure closure) {
long endTime = System.currentTimeMillis() + (long) (timeout * 1000)
while (System.currentTimeMillis() < endTime) {
long endTime = currentTimeMillis() + (long) (timeout * 1000)
while (currentTimeMillis() < endTime) {
closure.call()
}
}
Expand All @@ -84,13 +86,16 @@ class Wrappers {
* @return True if wait was successful, throws WaitTimeoutException otherwise
*/
static boolean wait(double timeout, double retryInterval = 0.5, Closure closure) {
long endTime = System.currentTimeMillis() + (long) (timeout * 1000)
long endTime = currentTimeMillis() + (long) (timeout * 1000)
long sleepTime = (long) (retryInterval * 1000)
Throwable thrown = null
while (System.currentTimeMillis() < endTime) {
while (currentTimeMillis() < endTime) {
try {
def result = closure.call()
if (result || result == null) {
log.debug("Closure: ${closure.toString()}\n" +
"Took ${(currentTimeMillis() - (endTime - (long) (timeout * 1000))) * 1000} seconds\n" +
"Limit was ${timeout} seconds")
return true
} else {
thrown = null
Expand All @@ -112,12 +117,12 @@ class Wrappers {
* @return result of the given closure
*/
static def benchmark(name, closure) {
def start = System.currentTimeMillis()
def start = currentTimeMillis()
def result
try {
result = closure.call()
} finally {
def now = System.currentTimeMillis()
def now = currentTimeMillis()
log.debug("$name took " + (now - start) + "ms")
}
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import static org.openkilda.functionaltests.helpers.Wrappers.wait
import static org.openkilda.functionaltests.model.stats.Direction.FORWARD
import static org.openkilda.functionaltests.model.stats.Direction.REVERSE
import static org.openkilda.functionaltests.model.stats.FlowStatsMetric.FLOW_RTT
import static org.openkilda.functionaltests.model.stats.Origin.FLOW_MONITORING
import static org.openkilda.testing.Constants.WAIT_OFFSET

import org.openkilda.functionaltests.HealthCheckSpecification
Expand Down Expand Up @@ -97,7 +98,7 @@ class FlowMonitoringSpec extends HealthCheckSpecification {
flowHelperV2.addFlow(flow)
//wait for generating some flow-monitoring stats
wait(flowSlaCheckIntervalSeconds + WAIT_OFFSET) {
flowStats.rttOf(flow.getFlowId()).get(FLOW_RTT, FORWARD).hasNonZeroValues()
assert flowStats.rttOf(flow.getFlowId()).get(FLOW_RTT, FORWARD, FLOW_MONITORING).hasNonZeroValues()
}

def path = northbound.getFlowPath(flow.flowId)
Expand Down Expand Up @@ -160,7 +161,7 @@ and flowLatencyMonitoringReactions is disabled in featureToggle"() {
flowHelperV2.addFlow(flow)
//wait for generating some flow-monitoring stats
wait(flowSlaCheckIntervalSeconds + WAIT_OFFSET) {
flowStats.rttOf(flow.getFlowId()).get(FLOW_RTT, REVERSE).hasNonZeroValues()
assert flowStats.rttOf(flow.getFlowId()).get(FLOW_RTT, REVERSE, FLOW_MONITORING).hasNonZeroValues()
}
pathHelper.convert(northbound.getFlowPath(flow.flowId)) == mainPath

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class StormLcmSpec extends HealthCheckSpecification {
!networkDeployed && wfmManipulator.deployTopology("network")
srcBlockData && lockKeeper.reviveSwitch(islUnderTest.srcSwitch, srcBlockData)
dstBlockData && lockKeeper.reviveSwitch(islUnderTest.dstSwitch, dstBlockData)
Wrappers.wait(WAIT_OFFSET + discoveryTimeout) {
Wrappers.wait(discoveryTimeout + WAIT_OFFSET * 3) {
assert database.getIsls(topology.getIsls()).every {it.status == IslStatus.ACTIVE}
assert northbound.getAllLinks().every {it.state == IslChangeType.DISCOVERED}
}
Expand Down

0 comments on commit d24e397

Please sign in to comment.