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/TestClient.py b/test/py/TestClient.py
index 18aea86..fd6b8e9 100755
--- a/test/py/TestClient.py
+++ b/test/py/TestClient.py
@@ -40,18 +40,18 @@
help="use SSL for encrypted transport")
parser.add_option("--multiple", action="store_true", dest="multiple",
help="use Multiple service")
-parser.add_option("--framed", action="store_true", dest="framed",
- help="use framed transport")
parser.add_option("--http", dest="http_path",
help="Use the HTTP transport with the specified path")
-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",
- help="protocol to use, one of: accel, binary, compact")
+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(framed=False, http_path=None, verbose=1, host='localhost', port=9090, proto='binary')
options, args = parser.parse_args()
@@ -79,10 +79,13 @@
else:
socket = TSocket.TSocket(options.host, options.port)
# frame or buffer depending upon args
- if options.framed:
+ self.transport = TTransport.TBufferedTransport(socket)
+ if options.trans == 'framed':
self.transport = TTransport.TFramedTransport(socket)
- else:
+ elif options.trans == 'buffered':
self.transport = TTransport.TBufferedTransport(socket)
+ elif options.trans == '':
+ raise AssertionError('Unknown --transport option: %s' % options.trans)
if options.zlib:
self.transport = TZlibTransport.TZlibTransport(self.transport, 9)
self.transport.open()
@@ -180,7 +183,7 @@
xpected.i64_thing,
{ 0:'abc' },
Numberz.FIVE,
- 0xf0f0f0)
+ 0xf0f0f0)
self.assertEqual(y, xpected)
def testException(self):
@@ -208,7 +211,7 @@
end = time.time()
self.assertTrue(end - start < 3,
"oneway sleep took %f sec" % (end - start))
-
+
def testOnewayThenNormal(self):
self.client.testOneway(1) # type is int, not float
self.assertEqual(self.client.testString('Python'), 'Python')
@@ -241,7 +244,7 @@
elif options.proto == 'json':
suite.addTest(loader.loadTestsFromTestCase(JSONTest))
else:
- raise AssertionError('Unknown protocol given with --proto: %s' % options.proto)
+ raise AssertionError('Unknown protocol given with --protocol: %s' % options.proto)
return suite
class OwnArgsTestProgram(unittest.TestProgram):