summaryrefslogtreecommitdiff
path: root/lib/d
diff options
context:
space:
mode:
authorKengo Seki <sekikn@apache.org>2020-01-09 18:48:29 +0900
committerJens Geyer <jensg@apache.org>2020-02-21 21:41:27 +0100
commitf0c761e171782565f74ff3cd7d0e9ce8e1d2b6ad (patch)
treec72f74fb3f3c2eb2c93c114652f24ff993861e7c /lib/d
parentea4a086757f834880220c50392532b60751c6885 (diff)
downloadthrift-f0c761e171782565f74ff3cd7d0e9ce8e1d2b6ad.tar.gz
THRIFT-5059: Add cross tests for TZlibTransport in D
Client: D Patch: Kengo Seki This closes #1977
Diffstat (limited to 'lib/d')
-rw-r--r--lib/d/test/test_utils.d4
-rw-r--r--lib/d/test/thrift_test_client.d22
-rw-r--r--lib/d/test/thrift_test_server.d4
3 files changed, 23 insertions, 7 deletions
diff --git a/lib/d/test/test_utils.d b/lib/d/test/test_utils.d
index 174100b79..d0548b714 100644
--- a/lib/d/test/test_utils.d
+++ b/lib/d/test/test_utils.d
@@ -35,6 +35,7 @@ import thrift.transport.base;
import thrift.transport.buffered;
import thrift.transport.framed;
import thrift.transport.http;
+import thrift.transport.zlib;
// This is a likely victim of @@BUG4744@@ when used with command argument
// parsing.
@@ -79,6 +80,7 @@ enum TransportType {
buffered,
framed,
http,
+ zlib,
raw
}
@@ -90,6 +92,8 @@ TTransportFactory createTransportFactory(TransportType type) {
return new TFramedTransportFactory;
case TransportType.http:
return new TServerHttpTransportFactory;
+ case TransportType.zlib:
+ return new TZlibTransportFactory;
case TransportType.raw:
return new TTransportFactory;
}
diff --git a/lib/d/test/thrift_test_client.d b/lib/d/test/thrift_test_client.d
index 49419f71a..c9911e28b 100644
--- a/lib/d/test/thrift_test_client.d
+++ b/lib/d/test/thrift_test_client.d
@@ -35,6 +35,7 @@ import thrift.transport.base;
import thrift.transport.buffered;
import thrift.transport.framed;
import thrift.transport.http;
+import thrift.transport.zlib;
import thrift.transport.socket;
import thrift.transport.ssl;
import thrift.util.hashset;
@@ -47,6 +48,7 @@ enum TransportType {
buffered,
framed,
http,
+ zlib,
raw
}
@@ -68,6 +70,7 @@ void main(string[] args) {
bool ssl;
ProtocolType protocolType;
TransportType transportType;
+ bool zlib;
bool trace;
getopt(args,
@@ -75,6 +78,7 @@ void main(string[] args) {
"protocol", &protocolType,
"ssl", &ssl,
"transport", &transportType,
+ "zlib", &zlib,
"trace", &trace,
"port", &port,
"host", (string _, string value) {
@@ -102,22 +106,28 @@ void main(string[] args) {
socket = new TSocket(host, port);
}
- TProtocol protocol;
+ TTransport transport;
final switch (transportType) {
case TransportType.buffered:
- protocol = createProtocol(new TBufferedTransport(socket), protocolType);
+ transport = new TBufferedTransport(socket);
break;
case TransportType.framed:
- protocol = createProtocol(new TFramedTransport(socket), protocolType);
+ transport = new TFramedTransport(socket);
break;
case TransportType.http:
- protocol = createProtocol(
- new TClientHttpTransport(socket, host, "/service"), protocolType);
+ transport = new TClientHttpTransport(socket, host, "/service");
+ break;
+ case TransportType.zlib:
+ transport = new TZlibTransport(socket);
break;
case TransportType.raw:
- protocol = createProtocol(socket, protocolType);
+ transport = socket;
break;
}
+ if (zlib && transportType != TransportType.zlib) {
+ transport = new TZlibTransport(socket);
+ }
+ TProtocol protocol = createProtocol(transport, protocolType);
auto client = tClient!ThriftTest(protocol);
diff --git a/lib/d/test/thrift_test_server.d b/lib/d/test/thrift_test_server.d
index ce820d699..192ff3159 100644
--- a/lib/d/test/thrift_test_server.d
+++ b/lib/d/test/thrift_test_server.d
@@ -42,6 +42,7 @@ import thrift.transport.base;
import thrift.transport.buffered;
import thrift.transport.framed;
import thrift.transport.http;
+import thrift.transport.zlib;
import thrift.transport.ssl;
import thrift.util.cancellation;
import thrift.util.hashset;
@@ -246,11 +247,12 @@ void main(string[] args) {
size_t numIOThreads = 1;
TransportType transportType;
bool ssl = false;
+ bool zlib = false;
bool trace = true;
size_t taskPoolSize = totalCPUs;
getopt(args, "port", &port, "protocol", &protocolType, "server-type",
- &serverType, "ssl", &ssl, "num-io-threads", &numIOThreads,
+ &serverType, "ssl", &ssl, "zlib", &zlib, "num-io-threads", &numIOThreads,
"task-pool-size", &taskPoolSize, "trace", &trace,
"transport", &transportType);