summaryrefslogtreecommitdiff
path: root/test/features
diff options
context:
space:
mode:
authorNobuaki Sukegawa <nsuke@apache.org>2016-01-24 01:03:28 +0900
committerNobuaki Sukegawa <nsuke@apache.org>2016-02-01 21:24:39 +0900
commit95c628eade2cff60da14c4e3f132e91ff16c5bc2 (patch)
tree1ae1134495098afaee8aabba4e59c8b4a1e36294 /test/features
parentbcd8e3268e6296813a9658cf7da4785e519088f7 (diff)
downloadthrift-95c628eade2cff60da14c4e3f132e91ff16c5bc2.tar.gz
THRIFT-3578 Make THeaderTransport detect TCompact framed and unframed
Client: C++ Patch: Nobuaki Sukegawa This closes #819
Diffstat (limited to 'test/features')
-rw-r--r--test/features/tests.json33
-rw-r--r--test/features/theader_binary.py44
2 files changed, 61 insertions, 16 deletions
diff --git a/test/features/tests.json b/test/features/tests.json
index f726daddf..cfcb4b6a0 100644
--- a/test/features/tests.json
+++ b/test/features/tests.json
@@ -4,7 +4,9 @@
"name": "theader_unframed_binary",
"command": [
"python",
- "theader_binary.py"
+ "theader_binary.py",
+ "--override-protocol=binary",
+ "--override-transport=buffered"
],
"protocols": ["header"],
"transports": ["buffered"],
@@ -17,6 +19,35 @@
"command": [
"python",
"theader_binary.py",
+ "--override-protocol=binary",
+ "--override-transport=framed"
+ ],
+ "protocols": ["header"],
+ "transports": ["buffered"],
+ "sockets": ["ip"],
+ "workdir": "features"
+ },
+ {
+ "description": "THeader detects unframed compact wire format",
+ "name": "theader_unframed_compact",
+ "command": [
+ "python",
+ "theader_binary.py",
+ "--override-protocol=compact",
+ "--override-transport=buffered"
+ ],
+ "protocols": ["header"],
+ "transports": ["buffered"],
+ "sockets": ["ip"],
+ "workdir": "features"
+ },
+ {
+ "description": "THeader detects framed compact wire format",
+ "name": "theader_framed_compact",
+ "command": [
+ "python",
+ "theader_binary.py",
+ "--override-protocol=compact",
"--override-transport=framed"
],
"protocols": ["header"],
diff --git a/test/features/theader_binary.py b/test/features/theader_binary.py
index 0316741bc..62a26715d 100644
--- a/test/features/theader_binary.py
+++ b/test/features/theader_binary.py
@@ -10,6 +10,24 @@ from thrift.Thrift import TMessageType, TType
from thrift.transport.TSocket import TSocket
from thrift.transport.TTransport import TBufferedTransport, TFramedTransport
from thrift.protocol.TBinaryProtocol import TBinaryProtocol
+from thrift.protocol.TCompactProtocol import TCompactProtocol
+
+
+def test_void(proto):
+ proto.writeMessageBegin('testVoid', TMessageType.CALL, 3)
+ proto.writeStructBegin('testVoid_args')
+ proto.writeFieldStop()
+ proto.writeStructEnd()
+ proto.writeMessageEnd()
+ proto.trans.flush()
+
+ _, mtype, _ = proto.readMessageBegin()
+ assert mtype == TMessageType.REPLY
+ proto.readStructBegin()
+ _, ftype, _ = proto.readFieldBegin()
+ assert ftype == TType.STOP
+ proto.readStructEnd()
+ proto.readMessageEnd()
# THeader stack should accept binary protocol with optionally framed transport
@@ -19,6 +37,7 @@ def main(argv):
# Since THeaderTransport acts as framed transport when detected frame, we
# cannot use --transport=framed as it would result in 2 layered frames.
p.add_argument('--override-transport')
+ p.add_argument('--override-protocol')
args = p.parse_args()
assert args.protocol == 'header'
assert args.transport == 'buffered'
@@ -28,26 +47,21 @@ def main(argv):
if not args.override_transport or args.override_transport == 'buffered':
trans = TBufferedTransport(sock)
elif args.override_transport == 'framed':
+ print('TFRAMED')
trans = TFramedTransport(sock)
else:
raise ValueError('invalid transport')
trans.open()
- proto = TBinaryProtocol(trans)
- proto.writeMessageBegin('testVoid', TMessageType.CALL, 3)
- proto.writeStructBegin('testVoid_args')
- proto.writeFieldStop()
- proto.writeStructEnd()
- proto.writeMessageEnd()
- trans.flush()
- _, mtype, _ = proto.readMessageBegin()
- assert mtype == TMessageType.REPLY
- proto.readStructBegin()
- _, ftype, _ = proto.readFieldBegin()
- assert ftype == TType.STOP
- proto.readFieldEnd()
- proto.readStructEnd()
- proto.readMessageEnd()
+ if not args.override_protocol or args.override_protocol == 'binary':
+ proto = TBinaryProtocol(trans)
+ elif args.override_protocol == 'compact':
+ proto = TCompactProtocol(trans)
+ else:
+ raise ValueError('invalid transport')
+
+ test_void(proto)
+ test_void(proto)
trans.close()