Modify HTTP/2 test server to display a list of available test cases and

accept non-positional arguments.
pull/9126/head
Eric Gribkoff 8 years ago
parent 5904a95274
commit b3bda54df8
  1. 21
      test/http2_test/http2_test_server.py

@ -45,15 +45,18 @@ class H2Factory(twisted.internet.protocol.Factory):
else:
return t().get_base_server()
if __name__ == "__main__":
logging.basicConfig(format = "%(levelname) -10s %(asctime)s %(module)s:%(lineno)s | %(message)s", level=logging.INFO)
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")
parser.add_argument("port")
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()
if args.test not in _TEST_CASE_MAPPING.keys():
logging.error('unknown test: %s' % args.test)
else:
endpoint = twisted.internet.endpoints.TCP4ServerEndpoint(twisted.internet.reactor, int(args.port), backlog=128)
endpoint.listen(H2Factory(args.test))
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))
twisted.internet.reactor.run()

Loading…
Cancel
Save