THRIFT-3211: add php client compact protocol to make cross test
This closes #532
diff --git a/test/known_failures_Linux.json b/test/known_failures_Linux.json
index eb0ab24..0cf9601 100644
--- a/test/known_failures_Linux.json
+++ b/test/known_failures_Linux.json
@@ -6,7 +6,6 @@
"c_glib-hs_binary_framed-ip",
"c_glib-nodejs_binary_buffered-ip",
"c_glib-nodejs_binary_framed-ip",
- "c_glib-php_binary_framed-ip",
"c_glib-py_binary-accel_buffered-ip",
"c_glib-py_binary-accel_framed-ip",
"c_glib-py_binary_buffered-ip",
@@ -66,7 +65,6 @@
"cpp-java_compact_http-ip-ssl",
"cpp-java_json_http-ip",
"cpp-java_json_http-ip-ssl",
- "cpp-php_binary_framed-ip",
"cpp-rb_binary-accel_buffered-ip",
"cpp-rb_binary-accel_framed-ip",
"cpp-rb_binary_buffered-ip",
@@ -149,7 +147,6 @@
"csharp-nodejs_json_buffered-ip-ssl",
"csharp-nodejs_json_framed-ip",
"csharp-nodejs_json_framed-ip-ssl",
- "csharp-php_binary_framed-ip",
"csharp-py_binary-accel_buffered-ip-ssl",
"csharp-py_binary-accel_framed-ip-ssl",
"csharp-py_binary_buffered-ip-ssl",
@@ -234,6 +231,8 @@
"go-perl_binary_buffered-ip",
"go-php_binary_buffered-ip",
"go-php_binary_framed-ip",
+ "go-php_compact_buffered-ip",
+ "go-php_compact_framed-ip",
"go-py_json_buffered-ip",
"go-py_json_buffered-ip-ssl",
"go-py_json_framed-ip",
@@ -378,8 +377,6 @@
"java-hs_json_framed-ip-ssl",
"java-nodejs_json_buffered-ip",
"java-nodejs_json_buffered-ip-ssl",
- "java-php_binary_fastframed-framed-ip",
- "java-php_binary_framed-ip",
"java-rb_binary-accel_buffered-ip",
"java-rb_binary-accel_fastframed-framed-ip",
"java-rb_binary-accel_framed-ip",
@@ -427,7 +424,6 @@
"nodejs-hs_json_framed-ip",
"nodejs-hs_json_framed-ip-ssl",
"nodejs-java_json_buffered-ip-ssl",
- "nodejs-php_binary_framed-ip",
"nodejs-py_json_buffered-ip",
"nodejs-py_json_buffered-ip-ssl",
"nodejs-py_json_framed-ip",
@@ -548,8 +544,8 @@
"py-nodejs_json_buffered-ip-ssl",
"py-nodejs_json_framed-ip",
"py-nodejs_json_framed-ip-ssl",
- "py-php_accel-binary_framed-ip",
- "py-php_binary_framed-ip",
+ "py-php_json_buffered-ip",
+ "py-php_json_framed-ip",
"py-rb_accel-binary_buffered-ip",
"py-rb_accel-binary_framed-ip",
"py-rb_accel_buffered-ip",
@@ -618,8 +614,6 @@
"rb-nodejs_compact_framed-ip",
"rb-nodejs_json_buffered-ip",
"rb-nodejs_json_framed-ip",
- "rb-php_accel-binary_framed-ip",
- "rb-php_binary_framed-ip",
"rb-py_accel-binary_buffered-ip",
"rb-py_accel-binary_framed-ip",
"rb-py_accel_buffered-ip",
@@ -644,4 +638,4 @@
"rb-rb_compact_framed-ip",
"rb-rb_json_buffered-ip",
"rb-rb_json_framed-ip"
-]
\ No newline at end of file
+]
diff --git a/test/php/TestClient.php b/test/php/TestClient.php
index 4ec4eab..ce57dc0 100755
--- a/test/php/TestClient.php
+++ b/test/php/TestClient.php
@@ -38,8 +38,10 @@
*/
/** Include the Thrift base */
-/** Include the binary protocol */
+/** Include the protocols */
use Thrift\Protocol\TBinaryProtocol;
+use Thrift\Protocol\TCompactProtocol;
+use Thrift\Protocol\TJSONProtocol;
/** Include the socket layer */
use Thrift\Transport\TSocket;
@@ -49,6 +51,19 @@
use Thrift\Transport\TFramedTransport;
use Thrift\Transport\TBufferedTransport;
+function makeProtocol($transport, $PROTO)
+{
+ if ($PROTO == 'binary') {
+ return new TBinaryProtocol($transport);
+ } else if ($PROTO == 'compact') {
+ return new TCompactProtocol($transport);
+ } else if ($PROTO == 'json') {
+ return new TJSONProtocol($transport);
+ }
+
+ die ("--protocol must be one of {binary|compact|json}");
+}
+
$host = 'localhost';
$port = 9090;
@@ -63,9 +78,11 @@
foreach ($argv as $arg) {
if (substr($arg, 0, 7) == '--port=') {
$port = substr($arg, 7);
- } else if (substr($arg, 0, 11) == '--transport=') {
- $MODE = substr($arg, 11);
- }
+ } else if (substr($arg, 0, 12) == '--transport=') {
+ $MODE = substr($arg, 12);
+ } else if (substr($arg, 0, 11) == '--protocol=') {
+ $PROTO = substr($arg, 11);
+ }
}
$hosts = array('localhost');
@@ -80,12 +97,12 @@
} else if ($MODE == 'framed') {
$framedSocket = new TFramedTransport($socket);
$transport = $framedSocket;
- $protocol = new TBinaryProtocol($transport);
+ $protocol = makeProtocol($transport, $PROTO);
$testClient = new \ThriftTest\ThriftTestClient($protocol);
} else {
$bufferedSocket = new TBufferedTransport($socket, 1024, 1024);
$transport = $bufferedSocket;
- $protocol = new TBinaryProtocol($transport);
+ $protocol = makeProtocol($transport, $PROTO);
$testClient = new \ThriftTest\ThriftTestClient($protocol);
}
diff --git a/test/tests.json b/test/tests.json
index c428786..04142cb 100644
--- a/test/tests.json
+++ b/test/tests.json
@@ -332,7 +332,9 @@
"ip"
],
"protocols": [
- "binary"
+ "binary",
+ "compact",
+ "binary:accel"
],
"command": [
"php",