THRIFT-2578 Moving 'make cross' from test.sh to test.py
Signed-off-by: Roger Meier <roger@apache.org>
diff --git a/test/result.html b/test/result.html
new file mode 100644
index 0000000..0110183
--- /dev/null
+++ b/test/result.html
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Apache Thrift - integration test suite</title>
+<link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/1.10.0/css/jquery.dataTables.css">
+<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;
+
+ $(document).ready( function () {
+ $.getJSON('/results.json', function(testData) {
+ testTable = $('#test_results').DataTable( {
+ data: testData
+ });
+ $('#test_results_filter label input')
+ .focus()
+ .val('failure');
+ });
+ });
+
+</script>
+</head>
+<body>
+<h2>Apache Thrift - integration test suite: Results</h2>
+<table id="test_results" class="display">
+ <thead>
+ <tr>
+ <th>Server</th>
+ <th>Client</th>
+ <th>Protocol</th>
+ <th>Transport</th>
+ <th>Result (log)</th>
+ </tr>
+ </thead>
+</table>
+</body>
+</html>
diff --git a/test/test.py b/test/test.py
old mode 100755
new mode 100644
index 0111a2f..cab942e
--- a/test/test.py
+++ b/test/test.py
@@ -46,18 +46,30 @@
def relfile(fname):
return os.path.join(os.path.dirname(__file__), fname)
-def runServiceTest(test_name, server_executable, server_extra_args, client_executable, client_extra_args, protocol, transport, port, use_zlib, use_ssl):
+def getSocketArgs(socket_type):
+ if socket_type == 'ip':
+ return ""
+ elif socket_type == 'ip-ssl':
+ return "--ssl"
+ 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):
# Build command line arguments
server_args = [relfile(server_executable)]
cli_args = [relfile(client_executable)]
+ server_args.append('--protocol=%s' % server_protocol)
+ cli_args.append('--protocol=%s' % client_protocol)
+
for which in (server_args, cli_args):
- which.append('--protocol=%s' % protocol) # accel, binary or compact
which.append('--transport=%s' % transport)
which.append('--port=%d' % port) # default to 9090
if use_zlib:
which.append('--zlib')
- if use_ssl:
+ if socket_type == 'ip-ssl':
which.append('--ssl')
+ elif socket_type == 'domain':
+ which.append('--domain-socket=/tmp/ThriftTest.thrift')
# if options.verbose == 0:
# which.append('-q')
# if options.verbose == 2:
@@ -73,7 +85,7 @@
serverproc = subprocess.Popen(server_args, stdout=server_log, stderr=server_log)
else:
serverproc = subprocess.Popen(server_args, stdout=server_log, stderr=server_log)
-
+
def ensureServerAlive():
if serverproc.poll() is not None:
print ('FAIL: Server process (%s) failed with retcode %d'
@@ -87,13 +99,15 @@
max_attempts = 100
try:
attempt = 0
- while sock.connect_ex(('127.0.0.1', port)) != 0:
- attempt += 1
- if attempt >= max_attempts:
- raise Exception("TestServer not ready on port %d after %.2f seconds"
- % (port, sleep_time * attempt))
- ensureServerAlive()
- time.sleep(sleep_time)
+
+ if socket_type != 'domain':
+ while sock.connect_ex(('127.0.0.1', port)) != 0:
+ attempt += 1
+ if attempt >= max_attempts:
+ raise Exception("TestServer not ready on port %d after %.2f seconds"
+ % (port, sleep_time * attempt))
+ ensureServerAlive()
+ time.sleep(sleep_time)
finally:
sock.close()
@@ -142,12 +156,15 @@
if os.path.exists('log'): shutil.rmtree('log')
os.makedirs('log')
+if os.path.exists('results.json'): os.remove('results.json')
+results_json = open("results.json","a")
+results_json.write("[\n")
-with open('tests.json') as data_file:
+with open('tests.json') as data_file:
data = json.load(data_file)
#subprocess.call("export NODE_PATH=../lib/nodejs/test:../lib/nodejs/lib:${NODE_PATH}")
-
+count = 0
for server in data["server"]:
server_executable = server["executable"]
server_extra_args = ""
@@ -166,22 +183,73 @@
if protocol in client["protocols"]:
if transport in client["transports"]:
if sock in client["sockets"]:
+ if count != 0:
+ results_json.write(",\n")
+ 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
- ssl = 0
- if sock == 'ip-ssl':
- ssl = 1
- ret = runServiceTest(test_name, server_executable, server_extra_args, client_executable, client_extra_args, protocol, transport, 9090, 0, ssl)
+ ret = runServiceTest(test_name, server_executable, server_extra_args, client_executable, client_extra_args, protocol, protocol, transport, 9090, 0, sock)
if ret != None:
failed += 1
print "Error: %s" % ret
print "Using"
- print (' Server: %s --protocol=%s --transport=%s %s'
- % (server_executable, protocol, transport, ' '.join(server_extra_args)))
- print (' Client: %s --protocol=%s --transport=%s %s'
- % (client_executable, protocol, transport, ''.join(client_extra_args)))
-
-
+ print (' Server: %s --protocol=%s --transport=%s %s %s'
+ % (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")
+ 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]")
test_count += 1
-
-print '%s failed of %s tests in total' % (failed, test_count)
-
+ if protocol == 'binary' and 'accel' in client["protocols"]:
+ if transport in client["transports"]:
+ if sock in client["sockets"]:
+ if count != 0:
+ results_json.write(",\n")
+ 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)
+ if ret != None:
+ failed += 1
+ print "Error: %s" % ret
+ print "Using"
+ print (' Server: %s --protocol=%s --transport=%s %s %s'
+ % (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")
+ 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]")
+ test_count += 1
+ if protocol == 'accel' and 'binary' in client["protocols"]:
+ if transport in client["transports"]:
+ if sock in client["sockets"]:
+ if count != 0:
+ 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
+ ssl = 0
+ if sock == 'ip-ssl':
+ ssl = 1
+ ret = runServiceTest(test_name, server_executable, server_extra_args, client_executable, client_extra_args, protocol, 'binary', transport, 9090, 0, sock)
+ if ret != None:
+ failed += 1
+ print "Error: %s" % ret
+ print "Using"
+ print (' Server: %s --protocol=%s --transport=%s %s %s'
+ % (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")
+ 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]")
+ test_count += 1
+results_json.write("\n]")
+results_json.flush()
+results_json.close()
+print '%s failed of %s tests in total' % (failed, test_count)
\ No newline at end of file
diff --git a/test/tests.json b/test/tests.json
index b5cab60..515aa49 100644
--- a/test/tests.json
+++ b/test/tests.json
@@ -36,7 +36,8 @@
],
"sockets": [
"ip",
- "ip-ssl"
+ "ip-ssl",
+ "domain"
]
},
{
@@ -114,7 +115,8 @@
],
"sockets": [
"ip",
- "ip-ssl"
+ "ip-ssl",
+ "domain"
]
},
{