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
diff --git a/lib/nodejs/test/client.js b/lib/nodejs/test/client.js
index 91365fc..a38a66b 100644
--- a/lib/nodejs/test/client.js
+++ b/lib/nodejs/test/client.js
@@ -118,11 +118,12 @@
 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 2384221..6953e1a 100644
--- a/lib/nodejs/test/test-cases.js
+++ b/lib/nodejs/test/test-cases.js
@@ -76,9 +76,12 @@
 }
 
 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 @@
 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 27ffd63..09439e5 100644
--- a/lib/nodejs/test/test_driver.js
+++ b/lib/nodejs/test/test_driver.js
@@ -55,6 +55,7 @@
       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 @@
       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 @@
 
   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 2113253..5c89f7a 100644
--- a/lib/nodejs/test/test_handler.js
+++ b/lib/nodejs/test/test_handler.js
@@ -62,6 +62,7 @@
   'testI32',
   'testI64',
   'testDouble',
+  'testBinary',
   'testStruct',
   'testNest',
   'testMap',
@@ -101,18 +102,6 @@
   //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 = [];