mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-05 11:53:25 +00:00
topotest: fix Lou's framework command wait
Fix two main issues: * Don't use float to figure out if we spent the time user asked; * Don't depend on system clock to find we reached the end of time; The fix is basically pre caculating the amount of wait cycles we are going to peform and use a counter. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
This commit is contained in:
parent
dfd15ebfa6
commit
2a76b0a8e2
@ -22,6 +22,7 @@ import sys
|
|||||||
import time
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
|
import math
|
||||||
from topolog import logger
|
from topolog import logger
|
||||||
from mininet.net import Mininet
|
from mininet.net import Mininet
|
||||||
|
|
||||||
@ -248,14 +249,18 @@ Total %-4d %-4d %d\n\
|
|||||||
found = False
|
found = False
|
||||||
n = 0
|
n = 0
|
||||||
startt = time.time()
|
startt = time.time()
|
||||||
delta = time.time() - startt
|
|
||||||
while delta < wait and found is False:
|
# Calculate the amount of `sleep`s we are going to peform.
|
||||||
|
wait_count = int(math.ceil(wait / 0.5))
|
||||||
|
|
||||||
|
while wait_count > 0 and found is False:
|
||||||
found = self.command(target, command, regexp, op, result, returnJson)
|
found = self.command(target, command, regexp, op, result, returnJson)
|
||||||
|
wait_count -= 1
|
||||||
n+=1
|
n+=1
|
||||||
delta = time.time() - startt
|
if wait_count > 0 and found is False:
|
||||||
self.log('\tFound: %s n: %s delta: %s and wait: %s' % (found, n, delta, wait))
|
|
||||||
if delta < wait and found is False:
|
|
||||||
time.sleep (0.5)
|
time.sleep (0.5)
|
||||||
|
|
||||||
|
delta = time.time() - startt
|
||||||
self.log('Done after %d loops, time=%s, Found=%s' % (n, delta, found))
|
self.log('Done after %d loops, time=%s, Found=%s' % (n, delta, found))
|
||||||
found = self.command(target, command, regexp, 'pass', '%s +%4.2f secs' % (result, delta), returnJson)
|
found = self.command(target, command, regexp, 'pass', '%s +%4.2f secs' % (result, delta), returnJson)
|
||||||
return found
|
return found
|
||||||
|
Loading…
Reference in New Issue
Block a user