diff options
author | Mark D. Roth <roth@google.com> | 2017-01-13 11:23:01 -0800 |
---|---|---|
committer | Mark D. Roth <roth@google.com> | 2017-01-13 11:23:01 -0800 |
commit | e6bcd0ebc9c35581b5459d9cc186dd71a2d701c9 (patch) | |
tree | 9b273b5a4cf19be2c83fdff232fd9dc5e36b4f45 /test/http2_test/http2_test_server.py | |
parent | c17ed124eca8fc6bed31c6e0d192fde386bdb3c2 (diff) | |
parent | 6b6954050cf0379dbbee90dd18313a3779e0dd52 (diff) |
Merge remote-tracking branch 'upstream/master' into revert-9063-revert-8951-revert-8949-revert-8922-slice_cleanup
Diffstat (limited to 'test/http2_test/http2_test_server.py')
-rw-r--r-- | test/http2_test/http2_test_server.py | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/test/http2_test/http2_test_server.py b/test/http2_test/http2_test_server.py index 44e36d34b6..abde3433ad 100644 --- a/test/http2_test/http2_test_server.py +++ b/test/http2_test/http2_test_server.py @@ -73,18 +73,32 @@ class H2Factory(twisted.internet.protocol.Factory): else: return t().get_base_server() +def parse_arguments(): + parser = argparse.ArgumentParser() + parser.add_argument('--base_port', type=int, default=8080, + help='base port to run the servers (default: 8080). One test server is ' + 'started on each incrementing port, beginning with base_port, in the ' + 'following order: goaway,max_streams,ping,rst_after_data,rst_after_header,' + 'rst_during_data' + ) + return parser.parse_args() + +def start_test_servers(base_port): + """ Start one server per test case on incrementing port numbers + beginning with base_port """ + index = 0 + for test_case in sorted(_TEST_CASE_MAPPING.keys()): + portnum = base_port + index + logging.warning('serving on port %d : %s'%(portnum, test_case)) + endpoint = twisted.internet.endpoints.TCP4ServerEndpoint( + twisted.internet.reactor, portnum, backlog=128) + endpoint.listen(H2Factory(test_case)) + index += 1 + if __name__ == '__main__': logging.basicConfig( format='%(levelname) -10s %(asctime)s %(module)s:%(lineno)s | %(message)s', level=logging.INFO) - parser = argparse.ArgumentParser() - parser.add_argument('--test_case', choices=sorted(_TEST_CASE_MAPPING.keys()), - help='test case to run', required=True) - parser.add_argument('--port', type=int, default=8080, - help='port to run the server (default: 8080)') - args = parser.parse_args() - logging.info('Running test case %s on port %d' % (args.test_case, args.port)) - endpoint = twisted.internet.endpoints.TCP4ServerEndpoint( - twisted.internet.reactor, args.port, backlog=128) - endpoint.listen(H2Factory(args.test_case)) + args = parse_arguments() + start_test_servers(args.base_port) twisted.internet.reactor.run() |