Skip to content

Commit

Permalink
Run test_schemes.py on Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
francisyyan committed Jun 7, 2017
1 parent a464b83 commit 9b2ee4e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ env:
scream copa taova koho_cc calibrated_koho saturator" &&
test/setup.py --schemes "$SCHEMES" --install-deps &&
test/setup.py --schemes "$SCHEMES" --setup &&
src/tests/test_schemes.py &&
test/tests/local_test.py &&
analysis/tests/test_analyze.py'

Expand Down
4 changes: 2 additions & 2 deletions helpers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def kill_proc_group(proc, signum=signal.SIGTERM):


def get_signal_for_cc(cc):
# default_tcp and vegas run iperf, which often doesn't respond to SIGTERM
if cc == 'default_tcp' or cc == 'vegas':
# iperf often doesn't respond to SIGTERM
if cc == 'default_tcp' or cc == 'vegas' or cc == 'bbr':
return signal.SIGKILL
else:
return signal.SIGTERM
31 changes: 24 additions & 7 deletions src/tests/test_schemes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@
import time
import os
from os import path
import signal
import project_root
from helpers.helpers import (
get_open_port, check_output, call, Popen, PIPE, parse_config,
kill_proc_group)
kill_proc_group, timeout_handler, TimeoutError, get_signal_for_cc)


def test_schemes():
src_dir = path.join(project_root.DIR, 'src')
schemes = parse_config().keys()

for scheme in schemes:
if scheme == 'bbr' or scheme == 'quic': # skip them on Travis
continue

sys.stderr.write('Testing %s...\n' % scheme)
src = path.join(src_dir, scheme + '.py')

Expand All @@ -34,12 +38,25 @@ def test_schemes():
cmd = [src, run_second, '127.0.0.1', port]
second_proc = Popen(cmd, preexec_fn=os.setsid)

# test lasts for 3 seconds
time.sleep(3)

# cleanup
kill_proc_group(first_proc)
kill_proc_group(second_proc)
# test lasts for 5 seconds
signal.signal(signal.SIGALRM, timeout_handler)
signal.alarm(5)

try:
for proc in [first_proc, second_proc]:
proc.wait()
if proc.returncode != 0:
sys.exit('%s failed in tests\n' % scheme)
except TimeoutError:
pass
else:
signal.alarm(0)
sys.exit('test exited before time limit')
finally:
# cleanup
signum = get_signal_for_cc(scheme)
kill_proc_group(first_proc, signum)
kill_proc_group(second_proc, signum)


def cleanup():
Expand Down

0 comments on commit 9b2ee4e

Please sign in to comment.