THRIFT-2578 Moving 'make cross' from test.sh to test.py

Patch: cdwijayarathna
diff --git a/test/result.html b/test/result.html
index 0110183..a2dac2c 100644
--- a/test/result.html
+++ b/test/result.html
@@ -7,19 +7,27 @@
 <script type="text/javascript" charset="utf-8" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
 <script type="text/javascript" charset="utf-8" src="http://cdn.datatables.net/1.10.0/js/jquery.dataTables.js"></script>
 <script>
-  var test_data;
+ var test_data;
 
     $(document).ready( function () {
-      $.getJSON('/results.json', function(testData) {
+      $.getJSON('results.json', function(testData) {
           testTable = $('#test_results').DataTable( {
-            data: testData
+            data: testData,
+      "columnDefs": [
+            {
+                "render": function ( data, type, row ) {
+                    return data +' ('+ '<a href="'+row[5].Client+'">Client</a>,<a href="'+row[5].Server+'">Server</a>'+')';
+                },
+                "targets": 4
+            }
+        ]
+
           });
         $('#test_results_filter label input')
           .focus()
           .val('failure');
         });
       });
-
 </script>
 </head>
 <body>
diff --git a/test/test.py b/test/test.py
index 0eb22c3..00d2d0d 100644
--- a/test/test.py
+++ b/test/test.py
@@ -55,10 +55,23 @@
   elif socket_type == 'domain':
     return "--domain-socket=/tmp/ThriftTest.thrift"
 
-def runServiceTest(test_name, server_executable, server_extra_args, client_executable, client_extra_args, server_protocol, client_protocol, transport, port, use_zlib, socket_type):
+def runServiceTest(test_name, server_lib, server_executable, server_extra_args, client_lib,  client_executable, client_extra_args, server_protocol, client_protocol, transport, port, use_zlib, socket_type):
   # Build command line arguments
-  server_args = [relfile(server_executable)]
-  cli_args = [relfile(client_executable)]
+  server_args = []
+  cli_args = []
+  if server_lib == 'java':
+    server_executable[2] = relfile(server_executable[2])
+    server_args.extend(server_executable)
+    server_args.extend(['-Dtestargs','\"'])
+  else:
+    server_args = [relfile(server_executable)]
+  if client_lib == 'java':
+    client_executable[2] = relfile(client_executable[2])
+    cli_args.extend(client_executable)
+    cli_args.extend(['-Dtestargs','\"'])
+  else:
+    cli_args = [relfile(client_executable)]
+
   server_args.append('--protocol=%s' % server_protocol)
   cli_args.append('--protocol=%s' % client_protocol)
 
@@ -75,9 +88,14 @@
 #      which.append('-q')
 #    if options.verbose == 2:
 #      which.append('-v')
+  if server_lib == 'java':
+    server_args.append('\"')
+  if client_lib == 'java':
+    cli_args.append('\"')
 
   server_args.extend(server_extra_args)
   cli_args.extend(client_extra_args)
+
   server_log=open("log/" + test_name + "_server.log","a")
   client_log=open("log/" + test_name + "_client.log","a")
 
@@ -196,7 +214,7 @@
                   count = 1
                   results_json.write("\t[\n\t\t\"" + server_lib + "\",\n\t\t\"" + client_lib + "\",\n\t\t\"" + protocol + "\",\n\t\t\"" + transport + "-" + sock + "\",\n" )
                   test_name = server_lib + "_" + client_lib + "_" + protocol + "_" + transport + "_" + sock
-                  ret = runServiceTest(test_name, server_executable, server_extra_args, client_executable, client_extra_args, protocol, protocol, transport, 9090, 0, sock)
+                  ret = runServiceTest(test_name, server_lib, server_executable, server_extra_args, client_lib, client_executable, client_extra_args, protocol, protocol, transport, 9090, 0, sock)
                   if ret != None:
                     failed += 1
                     print "Error: %s" % ret
@@ -205,10 +223,10 @@
                       % (server_executable, protocol, transport, getSocketArgs(sock), ' '.join(server_extra_args)))
                     print (' Client: %s --protocol=%s --transport=%s %s %s'
                       % (client_executable, protocol, transport, getSocketArgs(sock), ''.join(client_extra_args)))
-                    results_json.write("\t\t\"failure (<a href=\\\"log/" + test_name + "_client.log\\\">client</a>, <a href=\\\"log/" + test_name + "_server.log\\\">server</a>)\"\n")
+                    results_json.write("\t\t\"failure\",\n")
                   else:
-                    results_json.write("\t\t\"success (<a href=\\\"log/" + test_name + "_client.log\\\">client</a>, <a href=\\\"log/" + test_name + "_server.log\\\">server</a>)\"\n")
-                  results_json.write("\t]")
+                    results_json.write("\t\t\"success\",\n")
+                  results_json.write("\t\t{\n\t\t\t\"Client\":\"log/" + test_name + "_client.log\",\n\t\t\t\"Server\":\"log/" + test_name + "_server.log\"\n\t\t}\n\t]")
                   test_count += 1
             if protocol == 'binary' and 'accel' in client["protocols"]:
               if transport in client["transports"]:
@@ -218,7 +236,8 @@
                   count = 1
                   results_json.write("\t[\n\t\t\"" + server_lib + "\",\n\t\t\"" + client_lib + "\",\n\t\t\"accel-binary\",\n\t\t\"" + transport + "-" + sock + "\",\n" )
                   test_name = server_lib + "_" + client_lib + "_accel-binary_" + transport + "_" + sock
-                  ret = runServiceTest(test_name, server_executable, server_extra_args, client_executable, client_extra_args, protocol, 'accel', transport, 9090, 0, sock)
+                  ret = runServiceTest(test_name, server_lib,server_executable, server_extra_args, client_lib, client_executable, client_extra_args, protocol, 'accel', transport, 9090, 0, sock)
+
                   if ret != None:
                     failed += 1
                     print "Error: %s" % ret
@@ -227,10 +246,10 @@
                       % (server_executable, protocol, transport, getSocketArgs(sock), ' '.join(server_extra_args)))
                     print (' Client: %s --protocol=%s --transport=%s %s %s'
                       % (client_executable, protocol, transport , getSocketArgs(sock), ''.join(client_extra_args)))
-                    results_json.write("\t\t\"failure (<a href=\\\"log/" + test_name + "_client.log\\\">client</a>, <a href=\\\"log/" + test_name + "_server.log\\\">server</a>)\"\n")
+                    results_json.write("\t\t\"failure\",\n")
                   else:
-                    results_json.write("\t\t\"success (<a href=\\\"log/" + test_name + "_client.log\\\">client</a>, <a href=\\\"log/" + test_name + "_server.log\\\">server</a>)\"\n")
-                  results_json.write("\t]")
+                    results_json.write("\t\t\"success\",\n")
+                  results_json.write("\t\t{\n\t\t\t\"Client\":\"log/" + test_name + "_client.log\",\n\t\t\t\"Server\":\"log/" + test_name + "_server.log\"\n\t\t}\n\t]")
                   test_count += 1
             if protocol == 'accel' and 'binary' in client["protocols"]:
               if transport in client["transports"]:
@@ -239,8 +258,8 @@
                     results_json.write(",\n")
                   count = 1
                   results_json.write("\t[\n\t\t\"" + server_lib + "\",\n\t\t\"" + client_lib + "\",\n\t\t\"binary-accel\",\n\t\t\"" + transport + "-" + sock + "\",\n" )
-                  test_name = server_lib + "_" + client_lib + "_accel-binary_" + transport + "_" + sock
-                  ret = runServiceTest(test_name, server_executable, server_extra_args, client_executable, client_extra_args, protocol, 'binary', transport, 9090, 0, sock)
+                  test_name = server_lib + "_" + client_lib + "_binary-accel_" + transport + "_" + sock
+                  ret = runServiceTest(test_name, server_lib,server_executable, server_extra_args, client_lib, client_executable, client_extra_args, protocol, 'binary', transport, 9090, 0, sock)
                   if ret != None:
                     failed += 1
                     print "Error: %s" % ret
@@ -249,10 +268,10 @@
                       % (server_executable, protocol, transport + sock, getSocketArgs(sock), ' '.join(server_extra_args)))
                     print (' Client: %s --protocol=%s --transport=%s %s %s'
                       % (client_executable, protocol, transport + sock, getSocketArgs(sock), ''.join(client_extra_args)))
-                    results_json.write("\t\t\"failure (<a href=\\\"log/" + test_name + "_client.log\\\">client</a>, <a href=\\\"log/" + test_name + "_server.log\\\">server</a>)\"\n")
+                    results_json.write("\t\t\"failure\",\n")
                   else:
-                    results_json.write("\t\t\"success (<a href=\\\"log/" + test_name + "_client.log\\\">client</a>, <a href=\\\"log/" + test_name + "_server.log\\\">server</a>)\"\n")
-                  results_json.write("\t]")
+                    results_json.write("\t\t\"success\",\n")
+                  results_json.write("\t\t{\n\t\t\t\"Client\":\"log/" + test_name + "_client.log\",\n\t\t\t\"Server\":\"log/" + test_name + "_server.log\"\n\t\t}\n\t]")
                   test_count += 1
 results_json.write("\n]")
 results_json.flush()
diff --git a/test/tests.json b/test/tests.json
index 234384f..2c16a69 100644
--- a/test/tests.json
+++ b/test/tests.json
@@ -87,6 +87,30 @@
             "platform": [
                 "Linux"
             ]
+        },
+        {
+            "description": "Java TestClient",
+            "lib": "java",
+            "executable": ["ant","-f","../lib/java/build.xml","-Dno-gen-thrift=\"\""],
+            "extra_args": ["run-testclient"],
+            "protocols": [
+                "binary",
+                "compact",
+                "json"
+            ],
+            "transports": [
+                "buffered",
+                "framed",
+                "fastframed",
+                "http"
+            ],
+            "sockets": [
+                "ip",
+                "ip-ssl"
+            ],
+            "platform": [
+                "Linux"
+            ]
         }
     ],
     "server": [
@@ -178,6 +202,29 @@
             "platform": [
                 "Linux"
             ]
+        },
+        {
+            "description": "Java TestServer",
+            "lib": "java",
+            "executable": ["ant","-f","../lib/java/build.xml","-Dno-gen-thrift=\"\""],
+            "extra_args": ["run-testserver"],
+            "protocols": [
+                "binary",
+                "compact",
+                "json"
+            ],
+            "transports": [
+                "buffered",
+                "framed",
+                "fastframed"
+            ],
+            "sockets": [
+                "ip",
+                "ip-ssl"
+            ],
+            "platform": [
+                "Linux"
+            ]
         }
     ]
 }