THRIFT-847 Test Framework harmonization across all languages
Added 'ssl' tests for python tests.
Added '-transport arg (=buffered) transport: buffered, framed, http' to test/py/TestServer.py and test/py/TestClient.py and removed '-framed' arguement.
Changed test/py/RunClientServer.py to match above changes.
Added tests to compact protocol in python cases.
Added tests to test BinaryAccelarated protocol with Binary Protocol.
Changed py/TestClient.py and py/TestServer.py from --proto to --protocol parameter
Patch: Chamila Dilshan Wijayarathna & Roger Meier
diff --git a/test/py/TestServer.py b/test/py/TestServer.py
index 8022341..6ee0399 100755
--- a/test/py/TestServer.py
+++ b/test/py/TestServer.py
@@ -35,14 +35,16 @@
help="use SSL for encrypted transport")
parser.add_option("--multiple", action="store_true", dest="multiple",
help="use multiple service")
-parser.add_option('-v', '--verbose', action="store_const",
+parser.add_option('-v', '--verbose', action="store_const",
dest="verbose", const=2,
help="verbose output")
-parser.add_option('-q', '--quiet', action="store_const",
+parser.add_option('-q', '--quiet', action="store_const",
dest="verbose", const=0,
help="minimal output")
-parser.add_option('--proto', dest="proto", type="string",
+parser.add_option('--protocol', dest="proto", type="string",
help="protocol to use, one of: accel, binary, compact, json")
+parser.add_option('--transport', dest="trans", type="string",
+ help="transport to use, one of: buffered, framed")
parser.set_defaults(port=9090, verbose=1, proto='binary')
options, args = parser.parse_args()
@@ -185,10 +187,10 @@
byte_thing=arg0, i32_thing=arg1, i64_thing=arg2)
-# set up the protocol factory form the --proto option
+# set up the protocol factory form the --protocol option
pfactory_cls = PROT_FACTORIES.get(options.proto, None)
if pfactory_cls is None:
- raise AssertionError('Unknown --proto option: %s' % options.proto)
+ raise AssertionError('Unknown --protocol option: %s' % options.proto)
pfactory = pfactory_cls()
# get the server type (TSimpleServer, TNonblockingServer, etc...)
@@ -214,14 +216,26 @@
sys.exit(0)
# set up server transport and transport factory
+
+script_dir = os.path.dirname(__file__) #<-- absolute dir the script is in
+rel_path = "../keys/server.pem"
+abs_key_path = os.path.join(script_dir, rel_path)
+
host = None
if options.ssl:
from thrift.transport import TSSLSocket
- transport = TSSLSocket.TSSLServerSocket(host, options.port, certfile='../keys/server.pem')
+ transport = TSSLSocket.TSSLServerSocket(host, options.port, certfile=abs_key_path)
else:
transport = TSocket.TServerSocket(host, options.port)
tfactory = TTransport.TBufferedTransportFactory()
-
+if options.trans == 'buffered':
+ tfactory = TTransport.TBufferedTransportFactory()
+elif options.trans == 'framed':
+ tfactory = TTransport.TFramedTransportFactory()
+elif options.trans == '':
+ raise AssertionError('Unknown --transport option: %s' % options.trans)
+else:
+ tfactory = TTransport.TBufferedTransportFactory()
# if --zlib, then wrap server transport, and use a different transport factory
if options.zlib:
transport = TZlibTransport.TZlibTransport(transport) # wrap with zlib