Skip to content

Commit 5ec66b7

Browse files
mnordslettenalfreb
authored andcommitted
Added a wait function which waits for time_waits to close
1 parent 8817bd2 commit 5ec66b7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/stress/test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,30 @@ def check_vitals():
207207
pages = diff / PAGE_SIZE
208208
if diff % PAGE_SIZE != 0:
209209
print color.WARNING("Memory increase was not a multple of page size.")
210+
wait_for_tw()
210211
return False
211212
print color.INFO("Memory use at test end:"), mem, "bytes"
212213
print color.INFO("Memory difference from test start:"), memuse_at_start, "bytes (Diff:",diff, "b == ",pages, "pages)"
213214
sock_mem.close()
214215
vm.stop()
216+
wait_for_tw()
215217
return True
216218

219+
# Wait for sockets to exit TIME_WAIT status
220+
def wait_for_tw():
221+
print color.INFO("Waiting for sockets to clear TIME_WAIT stage")
222+
socket_limit = 11500
223+
time_wait_proc = 30000
224+
while time_wait_proc > socket_limit:
225+
output = subprocess.check_output(('netstat', '-anlt'))
226+
output = output.split('\n')
227+
time_wait_proc = 0
228+
for line in output:
229+
if "TIME_WAIT" in line:
230+
time_wait_proc += 1
231+
print color.INFO("There are {0} sockets in use, waiting for value to drop below {1}".format(time_wait_proc, socket_limit))
232+
time.sleep(7)
233+
217234
# Add custom event-handlers
218235
vm.on_output("Ready to start", crash_test)
219236
vm.on_output("Ready for ARP", ARP)

0 commit comments

Comments
 (0)