summaryrefslogtreecommitdiff
path: root/test/cpp
diff options
context:
space:
mode:
authorJames E. King III <jking@apache.org>2018-09-15 20:32:04 +0000
committerJames E. King III <jking@apache.org>2018-09-16 06:51:38 -0400
commitb2b767e1a4b009c3e133f918b5dd0a84da503149 (patch)
treef0b8c506c1c6fd1f60aa6d62ecea923ea5776ef6 /test/cpp
parent27705f487d897935b2735e5b50278a5503912616 (diff)
downloadthrift-b2b767e1a4b009c3e133f918b5dd0a84da503149.tar.gz
THRIFT-4620: add crosstest support for zlib (buffered) to cpp, enable cpp,go,py,py3 tests
Diffstat (limited to 'test/cpp')
-rwxr-xr-xtest/cpp/CMakeLists.txt3
-rw-r--r--test/cpp/src/TestClient.cpp25
-rw-r--r--test/cpp/src/TestServer.cpp25
3 files changed, 39 insertions, 14 deletions
diff --git a/test/cpp/CMakeLists.txt b/test/cpp/CMakeLists.txt
index cdd63dbf0..95d2991f8 100755
--- a/test/cpp/CMakeLists.txt
+++ b/test/cpp/CMakeLists.txt
@@ -28,6 +28,9 @@ include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
find_package(Libevent REQUIRED) # Libevent comes with CMake support from upstream
include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS})
+find_package(ZLIB REQUIRED)
+include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
+
#Make sure gen-cpp files can be included
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
include_directories("${CMAKE_CURRENT_BINARY_DIR}/gen-cpp")
diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp
index 87bb0283a..54b43dba8 100644
--- a/test/cpp/src/TestClient.cpp
+++ b/test/cpp/src/TestClient.cpp
@@ -31,6 +31,7 @@
#include <thrift/transport/TTransportUtils.h>
#include <thrift/transport/TSocket.h>
#include <thrift/transport/TSSLSocket.h>
+#include <thrift/transport/TZlibTransport.h>
#include <thrift/async/TEvhttpClientChannel.h>
#include <thrift/server/TNonblockingServer.h> // <event.h>
@@ -154,6 +155,7 @@ int main(int argc, char** argv) {
int port = 9090;
int numTests = 1;
bool ssl = false;
+ bool zlib = false;
string transport_type = "buffered";
string protocol_type = "binary";
string domain_socket = "";
@@ -179,12 +181,14 @@ int main(int argc, char** argv) {
" (no connection with filesystem pathnames)")
("transport",
boost::program_options::value<string>(&transport_type)->default_value(transport_type),
- "Transport: buffered, framed, http, evhttp")
+ "Transport: buffered, framed, http, evhttp, zlib")
("protocol",
boost::program_options::value<string>(&protocol_type)->default_value(protocol_type),
"Protocol: binary, compact, header, json, multi, multic, multih, multij")
("ssl",
"Encrypted Transport using SSL")
+ ("zlib",
+ "Wrap Transport with Zlib")
("testloops,n",
boost::program_options::value<int>(&numTests)->default_value(numTests),
"Number of Tests")
@@ -220,6 +224,8 @@ int main(int argc, char** argv) {
} else if (transport_type == "framed") {
} else if (transport_type == "http") {
} else if (transport_type == "evhttp") {
+ } else if (transport_type == "zlib") {
+ // crosstest will pass zlib as a transport and as a flag right now..
} else {
throw invalid_argument("Unknown transport type " + transport_type);
}
@@ -235,6 +241,10 @@ int main(int argc, char** argv) {
ssl = true;
}
+ if (vm.count("zlib")) {
+ zlib = true;
+ }
+
if (vm.count("abstract-namespace")) {
abstract_namespace = true;
}
@@ -278,14 +288,15 @@ int main(int argc, char** argv) {
}
if (transport_type.compare("http") == 0) {
- stdcxx::shared_ptr<TTransport> httpSocket(new THttpClient(socket, host, "/service"));
- transport = httpSocket;
+ transport = stdcxx::make_shared<THttpClient>(socket, host, "/service");
} else if (transport_type.compare("framed") == 0) {
- stdcxx::shared_ptr<TFramedTransport> framedSocket(new TFramedTransport(socket));
- transport = framedSocket;
+ transport = stdcxx::make_shared<TFramedTransport>(socket);
} else {
- stdcxx::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket));
- transport = bufferedSocket;
+ transport = stdcxx::make_shared<TBufferedTransport>(socket);
+ }
+
+ if (zlib) {
+ transport = stdcxx::make_shared<TZlibTransport>(transport);
}
if (protocol_type == "json" || protocol_type == "multij") {
diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp
index 1c3812410..323f87354 100644
--- a/test/cpp/src/TestServer.cpp
+++ b/test/cpp/src/TestServer.cpp
@@ -39,6 +39,7 @@
#include <thrift/transport/TSSLSocket.h>
#include <thrift/transport/TServerSocket.h>
#include <thrift/transport/TTransportUtils.h>
+#include <thrift/transport/TZlibTransport.h>
#include "SecondService.h"
#include "ThriftTest.h"
@@ -571,6 +572,7 @@ int main(int argc, char** argv) {
#endif
int port = 9090;
bool ssl = false;
+ bool zlib = false;
string transport_type = "buffered";
string protocol_type = "binary";
string server_type = "simple";
@@ -587,9 +589,10 @@ int main(int argc, char** argv) {
("domain-socket", po::value<string>(&domain_socket) ->default_value(domain_socket), "Unix Domain Socket (e.g. /tmp/ThriftTest.thrift)")
("abstract-namespace", "Create the domain socket in the Abstract Namespace (no connection with filesystem pathnames)")
("server-type", po::value<string>(&server_type)->default_value(server_type), "type of server, \"simple\", \"thread-pool\", \"threaded\", or \"nonblocking\"")
- ("transport", po::value<string>(&transport_type)->default_value(transport_type), "transport: buffered, framed, http")
+ ("transport", po::value<string>(&transport_type)->default_value(transport_type), "transport: buffered, framed, http, zlib")
("protocol", po::value<string>(&protocol_type)->default_value(protocol_type), "protocol: binary, compact, header, json, multi, multic, multih, multij")
("ssl", "Encrypted Transport using SSL")
+ ("zlib", "Wrapped Transport using Zlib")
("processor-events", "processor-events")
("workers,n", po::value<size_t>(&workers)->default_value(workers), "Number of thread pools workers. Only valid for thread-pool server type")
("string-limit", po::value<int>(&string_limit))
@@ -633,6 +636,8 @@ int main(int argc, char** argv) {
if (transport_type == "buffered") {
} else if (transport_type == "framed") {
} else if (transport_type == "http") {
+ } else if (transport_type == "zlib") {
+ // crosstester will pass zlib as a flag and a transport right now...
} else {
throw invalid_argument("Unknown transport type " + transport_type);
}
@@ -648,6 +653,10 @@ int main(int argc, char** argv) {
ssl = true;
}
+ if (vm.count("zlib")) {
+ zlib = true;
+ }
+
#if defined(HAVE_SIGNAL_H) && defined(SIGPIPE)
if (ssl) {
signal(SIGPIPE, SIG_IGN); // for OpenSSL, otherwise we end abruptly
@@ -719,14 +728,16 @@ int main(int argc, char** argv) {
stdcxx::shared_ptr<TTransportFactory> transportFactory;
if (transport_type == "http" && server_type != "nonblocking") {
- stdcxx::shared_ptr<TTransportFactory> httpTransportFactory(new THttpServerTransportFactory());
- transportFactory = httpTransportFactory;
+ transportFactory = stdcxx::make_shared<THttpServerTransportFactory>();
} else if (transport_type == "framed") {
- stdcxx::shared_ptr<TTransportFactory> framedTransportFactory(new TFramedTransportFactory());
- transportFactory = framedTransportFactory;
+ transportFactory = stdcxx::make_shared<TFramedTransportFactory>();
} else {
- stdcxx::shared_ptr<TTransportFactory> bufferedTransportFactory(new TBufferedTransportFactory());
- transportFactory = bufferedTransportFactory;
+ transportFactory = stdcxx::make_shared<TBufferedTransportFactory>();
+ }
+
+ if (zlib) {
+ // hmm.. doesn't seem to be a way to make it wrap the others...
+ transportFactory = stdcxx::make_shared<TZlibTransportFactory>();
}
// Server Info