diff options
author | Randy Abernethy <ra@apache.org> | 2015-10-09 12:28:57 -0700 |
---|---|---|
committer | Randy Abernethy <ra@apache.org> | 2015-10-09 12:28:57 -0700 |
commit | 983bf7de419dca19dac755970218a7d09bea8553 (patch) | |
tree | f34d57bae8b86e70af01fdc246b872322b01edeb | |
parent | f124b55e6d974b97a68b045d4dffc152e00040af (diff) | |
download | thrift-983bf7de419dca19dac755970218a7d09bea8553.tar.gz |
THRIFT-3373: cross test cleanup
Client: build, node, c_glib, cpp, hs, py, rb
Patch: Nobuaki Sukegawa
Github Pull Request:
This closes #641
commit 338f1a502961a4f63b0bd4b3dae4099062d6d17f
Author: Nobuaki Sukegawa <nsukeg@gmail.com>
Date: 2015-10-09T17:25:18Z
THRIFT-3373 Various fixes for cross test servers and clients
-rwxr-xr-x | Makefile.am | 2 | ||||
-rwxr-xr-x | configure.ac | 4 | ||||
-rw-r--r-- | lib/nodejs/test/client.js | 7 | ||||
-rw-r--r-- | lib/nodejs/test/test-cases.js | 6 | ||||
-rw-r--r-- | lib/nodejs/test/test_driver.js | 19 | ||||
-rw-r--r-- | lib/nodejs/test/test_handler.js | 13 | ||||
-rwxr-xr-x | test/c_glib/Makefile.am | 2 | ||||
-rw-r--r-- | test/c_glib/src/thrift_test_handler.c | 14 | ||||
-rw-r--r-- | test/c_glib/src/thrift_test_handler.h | 4 | ||||
-rwxr-xr-x | test/cpp/Makefile.am | 4 | ||||
-rw-r--r-- | test/hs/Makefile.am | 2 | ||||
-rw-r--r-- | test/known_failures_Linux.json | 101 | ||||
-rwxr-xr-x | test/py/Makefile.am | 16 | ||||
-rwxr-xr-x | test/py/TestServer.py | 58 | ||||
-rwxr-xr-x | test/rb/integration/TestClient.rb | 12 |
15 files changed, 103 insertions, 161 deletions
diff --git a/Makefile.am b/Makefile.am index 42c82e291..eeeb4f2a3 100755 --- a/Makefile.am +++ b/Makefile.am @@ -49,7 +49,7 @@ empty := space := $(empty) $(empty) comma := , -CROSS_LANGS = @MAYBE_CPP@ @MAYBE_C_GLIB@ @MAYBE_JAVA@ @MAYBE_CSHARP@ @MAYBE_PYTHON@ @MAYBE_RUBY@ @MAYBE_HASKELL@ @MAYBE_PERL@ @MAYBE_PHP@ @MAYBE_GO@ @MAYBE_NODEJS@ +CROSS_LANGS = @MAYBE_CPP@ @MAYBE_C_GLIB@ @MAYBE_JAVA@ @MAYBE_CSHARP@ @MAYBE_PYTHON@ @MAYBE_RUBY@ @MAYBE_HASKELL@ @MAYBE_PERL@ @MAYBE_PHP@ @MAYBE_GO@ @MAYBE_NODEJS@ @MAYBE_DART@ CROSS_LANGS_COMMA_SEPARATED = $(subst $(space),$(comma),$(CROSS_LANGS)) cross: precross diff --git a/configure.ac b/configure.ac index e6b3be0e6..701fdc97c 100755 --- a/configure.ac +++ b/configure.ac @@ -780,11 +780,11 @@ if test "$have_java" = "yes" ; then MAYBE_JAVA="java" ; else MAYBE_JAVA="" ; fi AC_SUBST([MAYBE_JAVA]) if test "$have_csharp" = "yes" ; then MAYBE_CSHARP="csharp" ; else MAYBE_CSHARP="" ; fi AC_SUBST([MAYBE_CSHARP]) -if test "$have_python" = "yes" ; then MAYBE_PYTHON="python" ; else MAYBE_PYTHON="" ; fi +if test "$have_python" = "yes" ; then MAYBE_PYTHON="py" ; else MAYBE_PYTHON="" ; fi AC_SUBST([MAYBE_PYTHON]) if test "$have_ruby" = "yes" ; then MAYBE_RUBY="rb" ; else MAYBE_RUBY="" ; fi AC_SUBST([MAYBE_RUBY]) -if test "$have_haskell" = "yes" ; then MAYBE_HASKELL="haskell" ; else MAYBE_HASKELL="" ; fi +if test "$have_haskell" = "yes" ; then MAYBE_HASKELL="hs" ; else MAYBE_HASKELL="" ; fi AC_SUBST([MAYBE_HASKELL]) if test "$have_perl" = "yes" ; then MAYBE_PERL="perl" ; else MAYBE_PERL="" ; fi AC_SUBST([MAYBE_PERL]) diff --git a/lib/nodejs/test/client.js b/lib/nodejs/test/client.js index 91365fcc2..a38a66b76 100644 --- a/lib/nodejs/test/client.js +++ b/lib/nodejs/test/client.js @@ -118,11 +118,12 @@ if (type === 'tcp') { function runTests() { testDriver(client, function (status) { console.log(status); - if (type === 'http' || type === 'websocket') { - process.exit(0); - } else { + if (type !== 'http' && type !== 'websocket') { connection.end(); } + if (type !== 'multiplex') { + process.exit(0); + } }); } diff --git a/lib/nodejs/test/test-cases.js b/lib/nodejs/test/test-cases.js index 238422198..6953e1aae 100644 --- a/lib/nodejs/test/test-cases.js +++ b/lib/nodejs/test/test-cases.js @@ -76,9 +76,12 @@ for (var i = 0; i < 5; ++i) { } var deep = [ + ['testList', [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]], +]; + +var deepUnordered = [ ['testMap', mapout], ['testSet', [1,2,3]], - ['testList', [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]], ['testStringMap', mapTestInput] ]; @@ -133,6 +136,7 @@ var insanity = { module.exports.simple = simple; module.exports.simpleLoose = simpleLoose; module.exports.deep = deep; +module.exports.deepUnordered = deepUnordered; module.exports.out = out; module.exports.out2 = out2; diff --git a/lib/nodejs/test/test_driver.js b/lib/nodejs/test/test_driver.js index 27ffd63ec..09439e55c 100644 --- a/lib/nodejs/test/test_driver.js +++ b/lib/nodejs/test/test_driver.js @@ -55,6 +55,7 @@ exports.ThriftTestDriver = function(client, callback) { assert.ok(a == e, m); })); testCases.deep.forEach(makeAsserter(assert.deepEqual)); + testCases.deepUnordered.forEach(makeAsserter(makeUnorderedDeepEqual(assert))); client.testMapMap(42, function(err, response) { var expected = { @@ -147,6 +148,7 @@ exports.ThriftTestDriverPromise = function(client, callback) { assert.ok(a == e, m); })); testCases.deep.forEach(makeAsserter(assert.deepEqual)); + testCases.deepUnordered.forEach(makeAsserter(makeUnorderedDeepEqual(assert))); client.testStruct(testCases.out) .then(function(response) { @@ -281,3 +283,20 @@ function checkOffByOne(done, callback) { setTimeout(TestForCompletion, retry_interval); } + +function makeUnorderedDeepEqual(assert) { + return function(actual, expected, name) { + assert.equal(actual.length, expected.length, name); + for (var k in actual) { + var found = false; + for (var k2 in expected) { + if (actual[k] === expected[k2]) { + found = true; + } + } + if (!found) { + assert.fail('Unexpected value ' + actual[k] + ' with key ' + k); + } + } + }; +} diff --git a/lib/nodejs/test/test_handler.js b/lib/nodejs/test/test_handler.js index 211325308..5c89f7acd 100644 --- a/lib/nodejs/test/test_handler.js +++ b/lib/nodejs/test/test_handler.js @@ -62,6 +62,7 @@ var identityHandlers = [ 'testI32', 'testI64', 'testDouble', + 'testBinary', 'testStruct', 'testNest', 'testMap', @@ -101,18 +102,6 @@ function testInsanity(argument) { //console.log(argument); //console.log(')'); - var hello = new ttypes.Xtruct(); - hello.string_thing = 'Hello2'; - hello.byte_thing = 2; - hello.i32_thing = 2; - hello.i64_thing = 2; - - var goodbye = new ttypes.Xtruct(); - goodbye.string_thing = 'Goodbye4'; - goodbye.byte_thing = 4; - goodbye.i32_thing = 4; - goodbye.i64_thing = 4; - var first_map = []; var second_map = []; diff --git a/test/c_glib/Makefile.am b/test/c_glib/Makefile.am index 7559fd607..4f9a119f0 100755 --- a/test/c_glib/Makefile.am +++ b/test/c_glib/Makefile.am @@ -29,7 +29,7 @@ nodist_libtestcglib_la_SOURCES = \ libtestcglib_la_LIBADD = $(top_builddir)/lib/c_glib/libthrift_c_glib.la -precross: test_client test_server +precross: libtestcglib.la test_client test_server check_PROGRAMS = \ test_client \ diff --git a/test/c_glib/src/thrift_test_handler.c b/test/c_glib/src/thrift_test_handler.c index a9983b5e6..69ddbc17e 100644 --- a/test/c_glib/src/thrift_test_handler.c +++ b/test/c_glib/src/thrift_test_handler.c @@ -68,7 +68,7 @@ thrift_test_handler_test_bool (TTestThriftTestIf *iface, THRIFT_UNUSED_VAR (iface); THRIFT_UNUSED_VAR (error); - printf ("testByte(%s)\n", thing ? "true" : "false"); + printf ("testBool(%s)\n", thing ? "true" : "false"); *_return = thing; return TRUE; @@ -144,7 +144,7 @@ thrift_test_handler_test_binary (TTestThriftTestIf *iface, THRIFT_UNUSED_VAR (error); printf ("testBinary()\n"); // TODO: hex output - g_byte_array_append( *_return, thing->data, thing->len); + *_return = thing; return TRUE; } @@ -701,16 +701,17 @@ thrift_test_handler_test_multi_exception (TTestThriftTestIf *iface, g_assert (*err1 == NULL); g_assert (*err2 == NULL); - if (strncmp (arg0, "Xception", 9) == 0) { + if (strncmp (arg0, "Xception", 8) == 0 && strlen(arg0) == 8) { *err1 = g_object_new (T_TEST_TYPE_XCEPTION, "errorCode", 1001, "message", g_strdup ("This is an Xception"), NULL); result = FALSE; } - else if (strncmp (arg0, "Xception2", 10) == 0) { + else if (strncmp (arg0, "Xception2", 9) == 0) { *err2 = g_object_new (T_TEST_TYPE_XCEPTION2, - "errorCode", 2002); + "errorCode", 2002, + NULL); g_object_get (*err2, "struct_thing", &struct_thing, @@ -783,6 +784,9 @@ thrift_test_handler_class_init (ThriftTestHandlerClass *klass) base_class->test_double = klass->test_double = thrift_test_handler_test_double; + base_class->test_binary = + klass->test_binary = + thrift_test_handler_test_binary; base_class->test_struct = klass->test_struct = thrift_test_handler_test_struct; diff --git a/test/c_glib/src/thrift_test_handler.h b/test/c_glib/src/thrift_test_handler.h index 957bbda5d..b64cb16f2 100644 --- a/test/c_glib/src/thrift_test_handler.h +++ b/test/c_glib/src/thrift_test_handler.h @@ -86,6 +86,10 @@ struct _ThriftTestHandlerClass { gdouble*_return, const gdouble thing, GError **error); + gboolean (*test_binary) (TTestThriftTestIf *iface, + GByteArray **_return, + const GByteArray *thing, + GError **error); gboolean (*test_struct) (TTestThriftTestIf *iface, TTestXtruct **_return, const TTestXtruct *thing, diff --git a/test/cpp/Makefile.am b/test/cpp/Makefile.am index 89fed8fdc..bc026b282 100755 --- a/test/cpp/Makefile.am +++ b/test/cpp/Makefile.am @@ -100,10 +100,10 @@ StressTestNonBlocking_LDADD = \ # THRIFT = $(top_builddir)/compiler/cpp/thrift -gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_constants.cpp: $(top_srcdir)/test/ThriftTest.thrift +gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_constants.cpp: $(top_srcdir)/test/ThriftTest.thrift $(THRIFT) $(THRIFT) --gen cpp:templates,cob_style -r $< -gen-cpp/StressTest_types.cpp gen-cpp/StressTest_constants.cpp gen-cpp/Service.cpp: $(top_srcdir)/test/StressTest.thrift +gen-cpp/StressTest_types.cpp gen-cpp/StressTest_constants.cpp gen-cpp/Service.cpp: $(top_srcdir)/test/StressTest.thrift $(THRIFT) $(THRIFT) --gen cpp $< AM_CPPFLAGS = $(BOOST_CPPFLAGS) $(LIBEVENT_CPPFLAGS) -I$(top_srcdir)/lib/cpp/src -Igen-cpp diff --git a/test/hs/Makefile.am b/test/hs/Makefile.am index b41a3915f..3f353966e 100644 --- a/test/hs/Makefile.am +++ b/test/hs/Makefile.am @@ -19,7 +19,7 @@ THRIFT = $(top_builddir)/compiler/cpp/thrift -stubs: ../ConstantsDemo.thrift ../DebugProtoTest.thrift ../ThriftTest.thrift ../Include.thrift +stubs: $(THRIFT) ../ConstantsDemo.thrift ../DebugProtoTest.thrift ../ThriftTest.thrift ../Include.thrift $(THRIFT) --gen hs ../ConstantsDemo.thrift $(THRIFT) --gen hs ../DebugProtoTest.thrift $(THRIFT) --gen hs ../ThriftTest.thrift diff --git a/test/known_failures_Linux.json b/test/known_failures_Linux.json index c22c906b9..cf17caef1 100644 --- a/test/known_failures_Linux.json +++ b/test/known_failures_Linux.json @@ -1,13 +1,4 @@ [ - "c_glib-cpp_binary_buffered-ip", - "c_glib-cpp_binary_framed-ip", - "c_glib-csharp_binary_buffered-ip", - "c_glib-csharp_binary_framed-ip", - "c_glib-hs_binary_buffered-ip", - "c_glib-hs_binary_framed-ip", - "c_glib-java_binary_buffered-ip", - "c_glib-java_binary_framed-fastframed-ip", - "c_glib-java_binary_framed-ip", "c_glib-nodejs_binary_buffered-ip", "c_glib-nodejs_binary_framed-ip", "c_glib-py_binary-accel_buffered-ip", @@ -30,12 +21,6 @@ "cpp-java_compact_http-ip-ssl", "cpp-java_json_http-ip", "cpp-java_json_http-ip-ssl", - "cpp-rb_binary-accel_buffered-ip", - "cpp-rb_binary-accel_framed-ip", - "cpp-rb_binary_buffered-ip", - "cpp-rb_binary_framed-ip", - "cpp-rb_compact_buffered-ip", - "cpp-rb_compact_framed-ip", "cpp-rb_json_buffered-ip", "cpp-rb_json_framed-ip", "csharp-cpp_binary_buffered-ip-ssl", @@ -52,28 +37,20 @@ "csharp-go_json_framed-ip-ssl", "csharp-hs_json_buffered-ip", "csharp-hs_json_framed-ip", - "csharp-nodejs_binary_buffered-ip", "csharp-nodejs_binary_buffered-ip-ssl", "csharp-nodejs_binary_framed-ip-ssl", - "csharp-nodejs_compact_buffered-ip", "csharp-nodejs_compact_buffered-ip-ssl", "csharp-nodejs_compact_framed-ip-ssl", "csharp-nodejs_json_buffered-ip", "csharp-nodejs_json_buffered-ip-ssl", "csharp-nodejs_json_framed-ip", "csharp-nodejs_json_framed-ip-ssl", - "csharp-rb_binary-accel_buffered-ip", - "csharp-rb_binary-accel_framed-ip", - "csharp-rb_binary_buffered-ip", - "csharp-rb_binary_framed-ip", - "csharp-rb_compact_buffered-ip", - "csharp-rb_compact_framed-ip", - "csharp-rb_json_buffered-ip", - "csharp-rb_json_framed-ip", "go-cpp_json_buffered-ip", "go-cpp_json_buffered-ip-ssl", "go-cpp_json_framed-ip", "go-cpp_json_framed-ip-ssl", + "go-dart_binary_framed-ip", + "go-dart_json_framed-ip", "go-hs_json_buffered-ip", "go-hs_json_framed-ip", "go-java_json_buffered-ip", @@ -82,18 +59,6 @@ "go-java_json_framed-fastframed-ip-ssl", "go-java_json_framed-ip", "go-java_json_framed-ip-ssl", - "go-nodejs_binary_buffered-ip", - "go-nodejs_binary_buffered-ip-ssl", - "go-nodejs_binary_framed-ip", - "go-nodejs_binary_framed-ip-ssl", - "go-nodejs_compact_buffered-ip", - "go-nodejs_compact_buffered-ip-ssl", - "go-nodejs_compact_framed-ip", - "go-nodejs_compact_framed-ip-ssl", - "go-nodejs_json_buffered-ip", - "go-nodejs_json_buffered-ip-ssl", - "go-nodejs_json_framed-ip", - "go-nodejs_json_framed-ip-ssl", "go-perl_binary_buffered-ip-ssl", "go-perl_binary_framed-ip-ssl", "hs-cpp_json_buffered-ip", @@ -102,15 +67,14 @@ "hs-csharp_compact_framed-ip", "hs-csharp_json_buffered-ip", "hs-csharp_json_framed-ip", + "hs-dart_binary_framed-ip", + "hs-dart_json_buffered-ip", + "hs-dart_json_framed-ip", "hs-go_json_buffered-ip", "hs-go_json_framed-ip", "hs-java_json_buffered-ip", "hs-java_json_framed-fastframed-ip", "hs-java_json_framed-ip", - "hs-nodejs_binary_buffered-ip", - "hs-nodejs_binary_framed-ip", - "hs-nodejs_compact_buffered-ip", - "hs-nodejs_compact_framed-ip", "hs-nodejs_json_buffered-ip", "hs-nodejs_json_framed-ip", "hs-py_json_buffered-ip", @@ -125,22 +89,10 @@ "java-rb_json_buffered-ip", "java-rb_json_fastframed-framed-ip", "java-rb_json_framed-ip", - "nodejs-cpp_binary_buffered-ip", - "nodejs-cpp_binary_buffered-ip-ssl", - "nodejs-cpp_binary_framed-ip", - "nodejs-cpp_binary_framed-ip-ssl", "nodejs-cpp_compact_buffered-ip", "nodejs-cpp_compact_buffered-ip-ssl", "nodejs-cpp_compact_framed-ip", "nodejs-cpp_compact_framed-ip-ssl", - "nodejs-cpp_json_buffered-ip", - "nodejs-cpp_json_buffered-ip-ssl", - "nodejs-cpp_json_framed-ip", - "nodejs-cpp_json_framed-ip-ssl", - "nodejs-csharp_binary_buffered-ip", - "nodejs-csharp_binary_buffered-ip-ssl", - "nodejs-csharp_binary_framed-ip", - "nodejs-csharp_binary_framed-ip-ssl", "nodejs-csharp_compact_buffered-ip", "nodejs-csharp_compact_buffered-ip-ssl", "nodejs-csharp_compact_framed-ip", @@ -149,38 +101,17 @@ "nodejs-csharp_json_buffered-ip-ssl", "nodejs-csharp_json_framed-ip", "nodejs-csharp_json_framed-ip-ssl", - "nodejs-hs_binary_buffered-ip", - "nodejs-hs_binary_framed-ip", - "nodejs-hs_compact_buffered-ip", - "nodejs-hs_compact_framed-ip", + "nodejs-dart_json_buffered-ip", + "nodejs-dart_json_framed-ip", "nodejs-hs_json_buffered-ip", "nodejs-hs_json_framed-ip", - "nodejs-java_binary_buffered-ip", - "nodejs-java_binary_buffered-ip-ssl", - "nodejs-java_binary_framed-fastframed-ip", - "nodejs-java_binary_framed-fastframed-ip-ssl", - "nodejs-java_binary_framed-ip", - "nodejs-java_binary_framed-ip-ssl", "nodejs-java_compact_buffered-ip", "nodejs-java_compact_buffered-ip-ssl", "nodejs-java_compact_framed-fastframed-ip", "nodejs-java_compact_framed-fastframed-ip-ssl", "nodejs-java_compact_framed-ip", "nodejs-java_compact_framed-ip-ssl", - "nodejs-java_json_buffered-ip", "nodejs-java_json_buffered-ip-ssl", - "nodejs-java_json_framed-fastframed-ip", - "nodejs-java_json_framed-fastframed-ip-ssl", - "nodejs-java_json_framed-ip", - "nodejs-java_json_framed-ip-ssl", - "nodejs-py_binary-accel_buffered-ip", - "nodejs-py_binary-accel_buffered-ip-ssl", - "nodejs-py_binary-accel_framed-ip", - "nodejs-py_binary-accel_framed-ip-ssl", - "nodejs-py_binary_buffered-ip", - "nodejs-py_binary_buffered-ip-ssl", - "nodejs-py_binary_framed-ip", - "nodejs-py_binary_framed-ip-ssl", "nodejs-py_compact_buffered-ip", "nodejs-py_compact_buffered-ip-ssl", "nodejs-py_compact_framed-ip", @@ -189,10 +120,6 @@ "nodejs-py_json_buffered-ip-ssl", "nodejs-py_json_framed-ip", "nodejs-py_json_framed-ip-ssl", - "nodejs-rb_binary-accel_buffered-ip", - "nodejs-rb_binary-accel_framed-ip", - "nodejs-rb_binary_buffered-ip", - "nodejs-rb_binary_framed-ip", "nodejs-rb_compact_buffered-ip", "nodejs-rb_compact_framed-ip", "nodejs-rb_json_buffered-ip", @@ -204,20 +131,10 @@ "py-nodejs_json_buffered-ip-ssl", "py-nodejs_json_framed-ip", "py-nodejs_json_framed-ip-ssl", - "py-rb_accel-binary_buffered-ip", - "py-rb_accel-binary_framed-ip", - "py-rb_accel_buffered-ip", - "py-rb_accel_framed-ip", - "py-rb_binary-accel_buffered-ip", - "py-rb_binary-accel_framed-ip", - "py-rb_binary_buffered-ip", - "py-rb_binary_framed-ip", - "py-rb_compact_buffered-ip", - "py-rb_compact_framed-ip", - "py-rb_json_buffered-ip", - "py-rb_json_framed-ip", "rb-cpp_json_buffered-ip", "rb-cpp_json_framed-ip", + "rb-hs_json_buffered-ip", + "rb-hs_json_framed-ip", "rb-java_json_buffered-ip", "rb-java_json_framed-fastframed-ip", "rb-java_json_framed-ip", diff --git a/test/py/Makefile.am b/test/py/Makefile.am index d3f0a7da1..1f710f1d0 100755 --- a/test/py/Makefile.am +++ b/test/py/Makefile.am @@ -38,7 +38,7 @@ thrift_gen = \ gen-py-dynamicslots/ThriftTest/__init__.py \ gen-py-dynamicslots/DebugProtoTest/__init__.py -precross: $(THRIFT) $(thrift_gen) +precross: $(thrift_gen) BUILT_SOURCES = $(thrift_gen) helper_scripts= \ @@ -53,30 +53,30 @@ check_SCRIPTS= \ TESTS= $(py_unit_tests) -gen-py/%/__init__.py: ../%.thrift +gen-py/%/__init__.py: ../%.thrift $(THRIFT) $(THRIFT) --gen py $< -gen-py-default/%/__init__.py: ../%.thrift +gen-py-default/%/__init__.py: ../%.thrift $(THRIFT) test -d gen-py-default || $(MKDIR_P) gen-py-default $(THRIFT) --gen py -out gen-py-default $< -gen-py-slots/%/__init__.py: ../%.thrift +gen-py-slots/%/__init__.py: ../%.thrift $(THRIFT) test -d gen-py-slots || $(MKDIR_P) gen-py-slots $(THRIFT) --gen py:slots -out gen-py-slots $< -gen-py-newstyle/%/__init__.py: ../%.thrift +gen-py-newstyle/%/__init__.py: ../%.thrift $(THRIFT) test -d gen-py-newstyle || $(MKDIR_P) gen-py-newstyle $(THRIFT) --gen py:new_style -out gen-py-newstyle $< -gen-py-newstyleslots/%/__init__.py: ../%.thrift +gen-py-newstyleslots/%/__init__.py: ../%.thrift $(THRIFT) test -d gen-py-newstyleslots || $(MKDIR_P) gen-py-newstyleslots $(THRIFT) --gen py:new_style,slots -out gen-py-newstyleslots $< -gen-py-dynamic/%/__init__.py: ../%.thrift +gen-py-dynamic/%/__init__.py: ../%.thrift $(THRIFT) test -d gen-py-dynamic || $(MKDIR_P) gen-py-dynamic $(THRIFT) --gen py:dynamic -out gen-py-dynamic $< -gen-py-dynamicslots/%/__init__.py: ../%.thrift +gen-py-dynamicslots/%/__init__.py: ../%.thrift $(THRIFT) test -d gen-py-dynamicslots || $(MKDIR_P) gen-py-dynamicslots $(THRIFT) --gen py:dynamic,slots -out gen-py-dynamicslots $< diff --git a/test/py/TestServer.py b/test/py/TestServer.py index b5696ca3b..e7478e421 100755 --- a/test/py/TestServer.py +++ b/test/py/TestServer.py @@ -27,7 +27,7 @@ import time from optparse import OptionParser # Print TServer log to stdout so that the test-runner can redirect it to log files -logging.basicConfig() +logging.basicConfig(level=logging.DEBUG) parser = OptionParser() parser.add_option('--genpydir', type='string', dest='genpydir', @@ -80,56 +80,56 @@ PROT_FACTORIES = { class TestHandler(object): def testVoid(self): if options.verbose > 1: - print('testVoid()') + logging.info('testVoid()') def testString(self, str): if options.verbose > 1: - print('testString(%s)' % str) + logging.info('testString(%s)' % str) return str def testBool(self, boolean): if options.verbose > 1: - print('testBool(%s)' % str(boolean).lower()) + logging.info('testBool(%s)' % str(boolean).lower()) return boolean def testByte(self, byte): if options.verbose > 1: - print('testByte(%d)' % byte) + logging.info('testByte(%d)' % byte) return byte def testI16(self, i16): if options.verbose > 1: - print('testI16(%d)' % i16) + logging.info('testI16(%d)' % i16) return i16 def testI32(self, i32): if options.verbose > 1: - print('testI32(%d)' % i32) + logging.info('testI32(%d)' % i32) return i32 def testI64(self, i64): if options.verbose > 1: - print('testI64(%d)' % i64) + logging.info('testI64(%d)' % i64) return i64 def testDouble(self, dub): if options.verbose > 1: - print('testDouble(%f)' % dub) + logging.info('testDouble(%f)' % dub) return dub def testBinary(self, thing): if options.verbose > 1: - print('testBinary()') # TODO: hex output + logging.info('testBinary()') # TODO: hex output return thing def testStruct(self, thing): if options.verbose > 1: - print('testStruct({%s, %d, %d, %d})' % (thing.string_thing, thing.byte_thing, thing.i32_thing, thing.i64_thing)) + logging.info('testStruct({%s, %s, %s, %s})' % (thing.string_thing, thing.byte_thing, thing.i32_thing, thing.i64_thing)) return thing def testException(self, arg): # if options.verbose > 1: - print('testException(%s)' % arg) + logging.info('testException(%s)' % arg) if arg == 'Xception': raise Xception(errorCode=1001, message=arg) elif arg == 'TException': @@ -137,7 +137,7 @@ class TestHandler(object): def testMultiException(self, arg0, arg1): if options.verbose > 1: - print('testMultiException(%s, %s)' % (arg0, arg1)) + logging.info('testMultiException(%s, %s)' % (arg0, arg1)) if arg0 == 'Xception': raise Xception(errorCode=1001, message='This is an Xception') elif arg0 == 'Xception2': @@ -148,49 +148,49 @@ class TestHandler(object): def testOneway(self, seconds): if options.verbose > 1: - print('testOneway(%d) => sleeping...' % seconds) + logging.info('testOneway(%d) => sleeping...' % seconds) time.sleep(seconds / 3) # be quick if options.verbose > 1: - print('done sleeping') + logging.info('done sleeping') def testNest(self, thing): if options.verbose > 1: - print('testNest(%s)' % thing) + logging.info('testNest(%s)' % thing) return thing def testMap(self, thing): if options.verbose > 1: - print('testMap(%s)' % thing) + logging.info('testMap(%s)' % thing) return thing def testStringMap(self, thing): if options.verbose > 1: - print('testStringMap(%s)' % thing) + logging.info('testStringMap(%s)' % thing) return thing def testSet(self, thing): if options.verbose > 1: - print('testSet(%s)' % thing) + logging.info('testSet(%s)' % thing) return thing def testList(self, thing): if options.verbose > 1: - print('testList(%s)' % thing) + logging.info('testList(%s)' % thing) return thing def testEnum(self, thing): if options.verbose > 1: - print('testEnum(%s)' % thing) + logging.info('testEnum(%s)' % thing) return thing def testTypedef(self, thing): if options.verbose > 1: - print('testTypedef(%s)' % thing) + logging.info('testTypedef(%s)' % thing) return thing def testMapMap(self, thing): if options.verbose > 1: - print('testMapMap(%s)' % thing) + logging.info('testMapMap(%s)' % thing) return { -4: { -4: -4, @@ -208,7 +208,7 @@ class TestHandler(object): def testInsanity(self, argument): if options.verbose > 1: - print('testInsanity(%s)' % argument) + logging.info('testInsanity(%s)' % argument) return { 1: { 2: argument, @@ -219,7 +219,7 @@ class TestHandler(object): def testMulti(self, arg0, arg1, arg2, arg3, arg4, arg5): if options.verbose > 1: - print('testMulti(%s)' % [arg0, arg1, arg2, arg3, arg4, arg5]) + logging.info('testMulti(%s)' % [arg0, arg1, arg2, arg3, arg4, arg5]) return Xtruct(string_thing='Hello2', byte_thing=arg0, i32_thing=arg1, i64_thing=arg2) @@ -241,7 +241,7 @@ processor = ThriftTest.Processor(handler) # Handle THttpServer as a special case if server_type == 'THttpServer': - server =THttpServer.THttpServer(processor, ('', options.port), pfactory) + server = THttpServer.THttpServer(processor, ('', options.port), pfactory) server.serve() sys.exit(0) @@ -266,7 +266,7 @@ else: tfactory = TTransport.TBufferedTransportFactory() # if --zlib, then wrap server transport, and use a different transport factory if options.zlib: - transport = TZlibTransport.TZlibTransport(transport) # wrap with zlib + transport = TZlibTransport.TZlibTransport(transport) # wrap with zlib tfactory = TZlibTransport.TZlibTransportFactory() # do server-specific setup here: @@ -282,10 +282,10 @@ elif server_type == "TProcessPoolServer": def clean_shutdown(signum, frame): for worker in server.workers: if options.verbose > 0: - print('Terminating worker: %s' % worker) + logging.info('Terminating worker: %s' % worker) worker.terminate() if options.verbose > 0: - print('Requesting server to stop()') + logging.info('Requesting server to stop()') try: server.stop() except: diff --git a/test/rb/integration/TestClient.rb b/test/rb/integration/TestClient.rb index fb339c438..d04f47507 100755 --- a/test/rb/integration/TestClient.rb +++ b/test/rb/integration/TestClient.rb @@ -45,13 +45,13 @@ ARGV.each do|a| elsif a.start_with?("--transport") $transport = a.split("=")[1] elsif a.start_with?("--port") - $port = a.split("=")[1].to_i + $port = a.split("=")[1].to_i end end ARGV=[] class SimpleClientTest < Test::Unit::TestCase - def setup + def setup unless @socket @socket = Thrift::Socket.new($host, $port) if $transport == "buffered" @@ -77,7 +77,11 @@ class SimpleClientTest < Test::Unit::TestCase @socket.open end end - + + def teardown + @socket.close + end + def test_void p 'test_void' @client.testVoid() @@ -129,7 +133,7 @@ class SimpleClientTest < Test::Unit::TestCase ret = @client.testBinary(val.pack('C*')) assert_equal(val, ret.bytes.to_a) end - + def test_map p 'test_map' val = {1 => 1, 2 => 2, 3 => 3} |