THRIFT-4548: add python cross test client multiplexed protocol support
Client: py
diff --git a/test/known_failures_Linux.json b/test/known_failures_Linux.json
index 16ede27..3212f7e 100644
--- a/test/known_failures_Linux.json
+++ b/test/known_failures_Linux.json
@@ -1,12 +1,12 @@
[
- "c_glib-csharp_multi-binary_buffered-ip",
- "c_glib-csharp_multi-binary_framed-ip",
- "c_glib-csharp_multi_buffered-ip",
- "c_glib-csharp_multi_framed-ip",
- "c_glib-csharp_multic-compact_buffered-ip",
- "c_glib-csharp_multic-compact_framed-ip",
- "c_glib-csharp_multic_buffered-ip",
- "c_glib-csharp_multic_framed-ip",
+ "c_glib-py3_multi-multia_buffered-ip",
+ "c_glib-py3_multi-multia_framed-ip",
+ "c_glib-py3_multic-multiac_buffered-ip",
+ "c_glib-py3_multic-multiac_framed-ip",
+ "c_glib-py_multi-multia_buffered-ip",
+ "c_glib-py_multi-multia_framed-ip",
+ "c_glib-py_multic-multiac_buffered-ip",
+ "c_glib-py_multic-multiac_framed-ip",
"c_glib-rs_multi_buffered-ip",
"c_glib-rs_multi_framed-ip",
"c_glib-rs_multic_buffered-ip",
@@ -19,6 +19,10 @@
"cl-c_glib_multi_framed-ip",
"cl-go_binary_buffered-ip",
"cl-go_binary_framed-ip",
+ "cl-py3_multi-multia_buffered-ip",
+ "cl-py3_multi-multia_framed-ip",
+ "cl-py_multi-multia_buffered-ip",
+ "cl-py_multi-multia_framed-ip",
"cl-rb_binary-accel_buffered-ip",
"cl-rb_binary-accel_framed-ip",
"cl-rb_binary_buffered-ip",
@@ -97,12 +101,30 @@
"cpp-py3_multi-accel_http-ip-ssl",
"cpp-py3_multi-binary_http-ip",
"cpp-py3_multi-binary_http-ip-ssl",
+ "cpp-py3_multi-multia_buffered-ip",
+ "cpp-py3_multi-multia_buffered-ip-ssl",
+ "cpp-py3_multi-multia_framed-ip",
+ "cpp-py3_multi-multia_framed-ip-ssl",
+ "cpp-py3_multi-multia_http-ip",
+ "cpp-py3_multi-multia_http-ip-ssl",
+ "cpp-py3_multi_http-ip",
+ "cpp-py3_multi_http-ip-ssl",
"cpp-py3_multic-accelc_http-ip",
"cpp-py3_multic-accelc_http-ip-ssl",
"cpp-py3_multic-compact_http-ip",
"cpp-py3_multic-compact_http-ip-ssl",
+ "cpp-py3_multic-multiac_buffered-ip",
+ "cpp-py3_multic-multiac_buffered-ip-ssl",
+ "cpp-py3_multic-multiac_framed-ip",
+ "cpp-py3_multic-multiac_framed-ip-ssl",
+ "cpp-py3_multic-multiac_http-ip",
+ "cpp-py3_multic-multiac_http-ip-ssl",
+ "cpp-py3_multic_http-ip",
+ "cpp-py3_multic_http-ip-ssl",
"cpp-py3_multij-json_http-ip",
"cpp-py3_multij-json_http-ip-ssl",
+ "cpp-py3_multij_http-ip",
+ "cpp-py3_multij_http-ip-ssl",
"cpp-py_binary-accel_http-ip",
"cpp-py_binary-accel_http-ip-ssl",
"cpp-py_binary_http-ip",
@@ -117,26 +139,34 @@
"cpp-py_multi-accel_http-ip-ssl",
"cpp-py_multi-binary_http-ip",
"cpp-py_multi-binary_http-ip-ssl",
+ "cpp-py_multi-multia_buffered-ip",
+ "cpp-py_multi-multia_buffered-ip-ssl",
+ "cpp-py_multi-multia_framed-ip",
+ "cpp-py_multi-multia_framed-ip-ssl",
+ "cpp-py_multi-multia_http-ip",
+ "cpp-py_multi-multia_http-ip-ssl",
+ "cpp-py_multi_http-ip",
+ "cpp-py_multi_http-ip-ssl",
"cpp-py_multic-accelc_http-ip",
"cpp-py_multic-accelc_http-ip-ssl",
"cpp-py_multic-compact_http-ip",
"cpp-py_multic-compact_http-ip-ssl",
+ "cpp-py_multic-multiac_buffered-ip",
+ "cpp-py_multic-multiac_buffered-ip-ssl",
+ "cpp-py_multic-multiac_framed-ip",
+ "cpp-py_multic-multiac_framed-ip-ssl",
+ "cpp-py_multic-multiac_http-ip",
+ "cpp-py_multic-multiac_http-ip-ssl",
+ "cpp-py_multic_http-ip",
+ "cpp-py_multic_http-ip-ssl",
"cpp-py_multij-json_http-ip",
"cpp-py_multij-json_http-ip-ssl",
+ "cpp-py_multij_http-ip",
+ "cpp-py_multij_http-ip-ssl",
"cpp-rs_multi_buffered-ip",
"cpp-rs_multi_framed-ip",
"cpp-rs_multic_buffered-ip",
"cpp-rs_multic_framed-ip",
- "csharp-d_binary_buffered-ip-ssl",
- "csharp-d_binary_framed-ip-ssl",
- "csharp-d_compact_buffered-ip-ssl",
- "csharp-d_compact_framed-ip-ssl",
- "csharp-d_json_buffered-ip-ssl",
- "csharp-d_json_framed-ip-ssl",
- "csharp-erl_binary_buffered-ip-ssl",
- "csharp-erl_binary_framed-ip-ssl",
- "csharp-erl_compact_buffered-ip-ssl",
- "csharp-erl_compact_framed-ip-ssl",
"csharp-rb_binary-accel_buffered-ip-ssl",
"csharp-rb_binary-accel_framed-ip-ssl",
"csharp-rb_binary_buffered-ip-ssl",
@@ -301,18 +331,34 @@
"go-java_compact_http-ip-ssl",
"go-java_json_http-ip",
"go-java_json_http-ip-ssl",
- "go-nodejs_json_framed-ip",
+ "hs-csharp_binary_buffered-ip",
"hs-csharp_binary_framed-ip",
+ "hs-csharp_compact_buffered-ip",
"hs-csharp_compact_framed-ip",
- "java-d_compact_buffered-ip",
- "java-d_compact_buffered-ip-ssl",
- "java-d_compact_framed-ip",
- "netcore-csharp_binary_buffered-ip-ssl",
- "netcore-csharp_binary_framed-ip-ssl",
- "netcore-csharp_compact_buffered-ip-ssl",
- "netcore-csharp_compact_framed-ip-ssl",
- "netcore-csharp_json_buffered-ip-ssl",
- "netcore-csharp_json_framed-ip-ssl",
+ "java-py3_multi-multia_buffered-ip",
+ "java-py3_multi-multia_buffered-ip-ssl",
+ "java-py3_multi-multia_fastframed-framed-ip",
+ "java-py3_multi-multia_fastframed-framed-ip-ssl",
+ "java-py3_multi-multia_framed-ip",
+ "java-py3_multi-multia_framed-ip-ssl",
+ "java-py3_multic-multiac_buffered-ip",
+ "java-py3_multic-multiac_buffered-ip-ssl",
+ "java-py3_multic-multiac_fastframed-framed-ip",
+ "java-py3_multic-multiac_fastframed-framed-ip-ssl",
+ "java-py3_multic-multiac_framed-ip",
+ "java-py3_multic-multiac_framed-ip-ssl",
+ "java-py_multi-multia_buffered-ip",
+ "java-py_multi-multia_buffered-ip-ssl",
+ "java-py_multi-multia_fastframed-framed-ip",
+ "java-py_multi-multia_fastframed-framed-ip-ssl",
+ "java-py_multi-multia_framed-ip",
+ "java-py_multi-multia_framed-ip-ssl",
+ "java-py_multic-multiac_buffered-ip",
+ "java-py_multic-multiac_buffered-ip-ssl",
+ "java-py_multic-multiac_fastframed-framed-ip",
+ "java-py_multic-multiac_fastframed-framed-ip-ssl",
+ "java-py_multic-multiac_framed-ip",
+ "java-py_multic-multiac_framed-ip-ssl",
"nodejs-cpp_binary_http-domain",
"nodejs-cpp_binary_http-ip",
"nodejs-cpp_binary_http-ip-ssl",
@@ -350,18 +396,6 @@
"nodejs-lua_binary_http-ip",
"nodejs-lua_compact_http-ip",
"nodejs-lua_json_http-ip",
- "nodejs-netcore_binary_buffered-ip",
- "nodejs-netcore_binary_buffered-ip-ssl",
- "nodejs-netcore_binary_framed-ip",
- "nodejs-netcore_binary_framed-ip-ssl",
- "nodejs-netcore_compact_buffered-ip",
- "nodejs-netcore_compact_buffered-ip-ssl",
- "nodejs-netcore_compact_framed-ip",
- "nodejs-netcore_compact_framed-ip-ssl",
- "nodejs-netcore_json_buffered-ip",
- "nodejs-netcore_json_buffered-ip-ssl",
- "nodejs-netcore_json_framed-ip",
- "nodejs-netcore_json_framed-ip-ssl",
"nodejs-py3_binary-accel_http-ip",
"nodejs-py3_binary-accel_http-ip-ssl",
"nodejs-py3_binary_http-ip",
@@ -382,6 +416,14 @@
"nodejs-py_compact_http-ip-ssl",
"nodejs-py_json_http-ip",
"nodejs-py_json_http-ip-ssl",
+ "perl-py3_multi-multia_buffered-ip",
+ "perl-py3_multi-multia_buffered-ip-ssl",
+ "perl-py3_multi-multia_framed-ip",
+ "perl-py3_multi-multia_framed-ip-ssl",
+ "perl-py_multi-multia_buffered-ip",
+ "perl-py_multi-multia_buffered-ip-ssl",
+ "perl-py_multi-multia_framed-ip",
+ "perl-py_multi-multia_framed-ip-ssl",
"perl-rs_multi_buffered-ip",
"perl-rs_multi_framed-ip",
"py-cpp_accel-binary_http-ip",
@@ -480,16 +522,12 @@
"rb-cpp_json_framed-domain",
"rb-cpp_json_framed-ip",
"rb-cpp_json_framed-ip-ssl",
- "rs-cpp_binary_buffered-ip",
- "rs-cpp_binary_framed-ip",
- "rs-cpp_compact_buffered-ip",
- "rs-cpp_compact_framed-ip",
- "rs-cpp_multi-binary_buffered-ip",
- "rs-cpp_multi-binary_framed-ip",
- "rs-cpp_multi_buffered-ip",
- "rs-cpp_multi_framed-ip",
- "rs-cpp_multic-compact_buffered-ip",
- "rs-cpp_multic-compact_framed-ip",
- "rs-cpp_multic_buffered-ip",
- "rs-cpp_multic_framed-ip"
-]
\ No newline at end of file
+ "rs-py3_multi-multia_buffered-ip",
+ "rs-py3_multi-multia_framed-ip",
+ "rs-py3_multic-multiac_buffered-ip",
+ "rs-py3_multic-multiac_framed-ip",
+ "rs-py_multi-multia_buffered-ip",
+ "rs-py_multi-multia_framed-ip",
+ "rs-py_multic-multiac_buffered-ip",
+ "rs-py_multic-multiac_framed-ip"
+]
diff --git a/test/py/TestClient.py b/test/py/TestClient.py
index edab610..2164162 100755
--- a/test/py/TestClient.py
+++ b/test/py/TestClient.py
@@ -63,6 +63,9 @@
self.transport.open()
protocol = self.get_protocol(self.transport)
self.client = ThriftTest.Client(protocol)
+ # for multiplexed services:
+ protocol2 = self.get_protocol2(self.transport)
+ self.client2 = SecondService.Client(protocol2) if protocol2 is not None else None
def tearDown(self):
self.transport.close()
@@ -107,6 +110,11 @@
self.assertEqual(self.client.testString(s1), s1)
self.assertEqual(self.client.testString(s2), s2)
+ def testMultiplexed(self):
+ if self.client2 is not None:
+ print('testMultiplexed')
+ self.assertEqual(self.client2.secondtestString('foobar'), 'testString("foobar")')
+
def testBool(self):
print('testBool')
self.assertEqual(self.client.testBool(True), True)
@@ -260,44 +268,109 @@
self.assertEqual(self.client.testString('Python'), 'Python')
-class NormalBinaryTest(AbstractTest):
+class MultiplexedOptionalTest(AbstractTest):
+ def get_protocol2(self, transport):
+ return None
+
+
+class BinaryTest(MultiplexedOptionalTest):
def get_protocol(self, transport):
return TBinaryProtocol.TBinaryProtocolFactory().getProtocol(transport)
-class CompactTest(AbstractTest):
+class MultiplexedBinaryTest(MultiplexedOptionalTest):
def get_protocol(self, transport):
- return TCompactProtocol.TCompactProtocolFactory().getProtocol(transport)
+ wrapped_proto = TBinaryProtocol.TBinaryProtocolFactory().getProtocol(transport)
+ return TMultiplexedProtocol.TMultiplexedProtocol(wrapped_proto, "ThriftTest")
+
+ def get_protocol2(self, transport):
+ wrapped_proto = TBinaryProtocol.TBinaryProtocolFactory().getProtocol(transport)
+ return TMultiplexedProtocol.TMultiplexedProtocol(wrapped_proto, "SecondService")
-class JSONTest(AbstractTest):
- def get_protocol(self, transport):
- return TJSONProtocol.TJSONProtocolFactory().getProtocol(transport)
-
-
-class AcceleratedBinaryTest(AbstractTest):
+class AcceleratedBinaryTest(MultiplexedOptionalTest):
def get_protocol(self, transport):
return TBinaryProtocol.TBinaryProtocolAcceleratedFactory(fallback=False).getProtocol(transport)
-class AcceleratedCompactTest(AbstractTest):
+class MultiplexedAcceleratedBinaryTest(MultiplexedOptionalTest):
+ def get_protocol(self, transport):
+ wrapped_proto = TBinaryProtocol.TBinaryProtocolAcceleratedFactory(fallback=False).getProtocol(transport)
+ return TMultiplexedProtocol.TMultiplexedProtocol(wrapped_proto, "ThriftTest")
+
+ def get_protocol2(self, transport):
+ wrapped_proto = TBinaryProtocol.TBinaryProtocolAcceleratedFactory(fallback=False).getProtocol(transport)
+ return TMultiplexedProtocol.TMultiplexedProtocol(wrapped_proto, "SecondService")
+
+
+class CompactTest(MultiplexedOptionalTest):
+ def get_protocol(self, transport):
+ return TCompactProtocol.TCompactProtocolFactory().getProtocol(transport)
+
+
+class MultiplexedCompactTest(MultiplexedOptionalTest):
+ def get_protocol(self, transport):
+ wrapped_proto = TCompactProtocol.TCompactProtocolFactory().getProtocol(transport)
+ return TMultiplexedProtocol.TMultiplexedProtocol(wrapped_proto, "ThriftTest")
+
+ def get_protocol2(self, transport):
+ wrapped_proto = TCompactProtocol.TCompactProtocolFactory().getProtocol(transport)
+ return TMultiplexedProtocol.TMultiplexedProtocol(wrapped_proto, "SecondService")
+
+
+class AcceleratedCompactTest(MultiplexedOptionalTest):
def get_protocol(self, transport):
return TCompactProtocol.TCompactProtocolAcceleratedFactory(fallback=False).getProtocol(transport)
+class MultiplexedAcceleratedCompactTest(MultiplexedOptionalTest):
+ def get_protocol(self, transport):
+ wrapped_proto = TCompactProtocol.TCompactProtocolAcceleratedFactory(fallback=False).getProtocol(transport)
+ return TMultiplexedProtocol.TMultiplexedProtocol(wrapped_proto, "ThriftTest")
+
+ def get_protocol2(self, transport):
+ wrapped_proto = TCompactProtocol.TCompactProtocolAcceleratedFactory(fallback=False).getProtocol(transport)
+ return TMultiplexedProtocol.TMultiplexedProtocol(wrapped_proto, "SecondService")
+
+
+class JSONTest(MultiplexedOptionalTest):
+ def get_protocol(self, transport):
+ return TJSONProtocol.TJSONProtocolFactory().getProtocol(transport)
+
+
+class MultiplexedJSONTest(MultiplexedOptionalTest):
+ def get_protocol(self, transport):
+ wrapped_proto = TJSONProtocol.TJSONProtocolFactory().getProtocol(transport)
+ return TMultiplexedProtocol.TMultiplexedProtocol(wrapped_proto, "ThriftTest")
+
+ def get_protocol2(self, transport):
+ wrapped_proto = TJSONProtocol.TJSONProtocolFactory().getProtocol(transport)
+ return TMultiplexedProtocol.TMultiplexedProtocol(wrapped_proto, "SecondService")
+
+
def suite():
suite = unittest.TestSuite()
loader = unittest.TestLoader()
if options.proto == 'binary': # look for --proto on cmdline
- suite.addTest(loader.loadTestsFromTestCase(NormalBinaryTest))
+ suite.addTest(loader.loadTestsFromTestCase(BinaryTest))
elif options.proto == 'accel':
suite.addTest(loader.loadTestsFromTestCase(AcceleratedBinaryTest))
- elif options.proto == 'compact':
- suite.addTest(loader.loadTestsFromTestCase(CompactTest))
elif options.proto == 'accelc':
suite.addTest(loader.loadTestsFromTestCase(AcceleratedCompactTest))
+ elif options.proto == 'compact':
+ suite.addTest(loader.loadTestsFromTestCase(CompactTest))
elif options.proto == 'json':
suite.addTest(loader.loadTestsFromTestCase(JSONTest))
+ elif options.proto == 'multi':
+ suite.addTest(loader.loadTestsFromTestCase(MultiplexedBinaryTest))
+ elif options.proto == 'multia':
+ suite.addTest(loader.loadTestsFromTestCase(MultiplexedAcceleratedBinaryTest))
+ elif options.proto == 'multiac':
+ suite.addTest(loader.loadTestsFromTestCase(MultiplexedAcceleratedCompactTest))
+ elif options.proto == 'multic':
+ suite.addTest(loader.loadTestsFromTestCase(MultiplexedCompactTest))
+ elif options.proto == 'multij':
+ suite.addTest(loader.loadTestsFromTestCase(MultiplexedJSONTest))
else:
raise AssertionError('Unknown protocol given with --protocol: %s' % options.proto)
return suite
@@ -335,7 +408,7 @@
dest="verbose", const=0,
help="minimal output")
parser.add_option('--protocol', dest="proto", type="string",
- help="protocol to use, one of: accel, accelc, binary, compact, json")
+ help="protocol to use, one of: accel, accelc, binary, compact, json, multi, multia, multiac, multic, multij")
parser.add_option('--transport', dest="trans", type="string",
help="transport to use, one of: buffered, framed, http")
parser.set_defaults(framed=False, http_path=None, verbose=1, host='localhost', port=9090, proto='binary')
@@ -348,6 +421,7 @@
if options.http_path:
options.trans = 'http'
+ from ThriftTest import SecondService
from ThriftTest import ThriftTest
from ThriftTest.ttypes import Xtruct, Xtruct2, Numberz, Xception, Xception2
from thrift.Thrift import TException
@@ -358,5 +432,6 @@
from thrift.protocol import TBinaryProtocol
from thrift.protocol import TCompactProtocol
from thrift.protocol import TJSONProtocol
+ from thrift.protocol import TMultiplexedProtocol
OwnArgsTestProgram(defaultTest="suite", testRunner=unittest.TextTestRunner(verbosity=1))
diff --git a/test/tests.json b/test/tests.json
index ed38fea..72790ac 100644
--- a/test/tests.json
+++ b/test/tests.json
@@ -250,6 +250,13 @@
"--verbose",
"--host=localhost",
"--genpydir=gen-py"
+ ],
+ "protocols": [
+ "multi",
+ "multi:multia",
+ "multic",
+ "multic:multiac",
+ "multij"
]
},
"transports": [
@@ -289,6 +296,13 @@
"TestClient.py",
"--host=localhost",
"--genpydir=gen-py"
+ ],
+ "protocols": [
+ "multi",
+ "multi:multia",
+ "multic",
+ "multic:multiac",
+ "multij"
]
},
"transports": [