Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
4eb8bba7
Commit
4eb8bba7
authored
10 years ago
by
murgatroid99
Browse files
Options
Downloads
Patches
Plain Diff
Further updated EndToEndTest
parent
d8bb9578
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/php/ext/grpc/server.c
+2
-2
2 additions, 2 deletions
src/php/ext/grpc/server.c
src/php/tests/unit_tests/EndToEndTest.php
+48
-112
48 additions, 112 deletions
src/php/tests/unit_tests/EndToEndTest.php
with
50 additions
and
114 deletions
src/php/ext/grpc/server.c
+
2
−
2
View file @
4eb8bba7
...
@@ -182,8 +182,8 @@ PHP_METHOD(Server, request_call) {
...
@@ -182,8 +182,8 @@ PHP_METHOD(Server, request_call) {
goto
cleanup
;
goto
cleanup
;
}
}
add_property_zval
(
result
,
"call"
,
grpc_php_wrap_call
(
call
,
true
));
add_property_zval
(
result
,
"call"
,
grpc_php_wrap_call
(
call
,
true
));
add_property_string
(
result
,
"method"
,
details
.
method
,
fals
e
);
add_property_string
(
result
,
"method"
,
details
.
method
,
tru
e
);
add_property_string
(
result
,
"host"
,
details
.
host
,
fals
e
);
add_property_string
(
result
,
"host"
,
details
.
host
,
tru
e
);
add_property_zval
(
result
,
"absolute_deadline"
,
add_property_zval
(
result
,
"absolute_deadline"
,
grpc_php_wrap_timeval
(
details
.
deadline
));
grpc_php_wrap_timeval
(
details
.
deadline
));
add_property_zval
(
result
,
"metadata"
,
grpc_parse_metadata_array
(
&
metadata
));
add_property_zval
(
result
,
"metadata"
,
grpc_parse_metadata_array
(
&
metadata
));
...
...
This diff is collapsed.
Click to expand it.
src/php/tests/unit_tests/EndToEndTest.php
+
48
−
112
View file @
4eb8bba7
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
*/
*/
class
EndToEndTest
extends
PHPUnit_Framework_TestCase
{
class
EndToEndTest
extends
PHPUnit_Framework_TestCase
{
public
function
setUp
()
{
public
function
setUp
()
{
$this
->
server
=
new
Grpc\Server
(
$this
->
server_queue
,
[]);
$this
->
server
=
new
Grpc\Server
([]);
$port
=
$this
->
server
->
add_http2_port
(
'0.0.0.0:0'
);
$port
=
$this
->
server
->
add_http2_port
(
'0.0.0.0:0'
);
$this
->
channel
=
new
Grpc\Channel
(
'localhost:'
.
$port
,
[]);
$this
->
channel
=
new
Grpc\Channel
(
'localhost:'
.
$port
,
[]);
$this
->
server
->
start
();
$this
->
server
->
start
();
...
@@ -53,7 +53,7 @@ class EndToEndTest extends PHPUnit_Framework_TestCase{
...
@@ -53,7 +53,7 @@ class EndToEndTest extends PHPUnit_Framework_TestCase{
'dummy_method'
,
'dummy_method'
,
$deadline
);
$deadline
);
$event
=
$
this
->
call
->
start_batch
([
$event
=
$call
->
start_batch
([
Grpc\OP_SEND_INITIAL_METADATA
=>
[],
Grpc\OP_SEND_INITIAL_METADATA
=>
[],
Grpc\OP_SEND_CLOSE_FROM_CLIENT
=>
true
Grpc\OP_SEND_CLOSE_FROM_CLIENT
=>
true
]);
]);
...
@@ -79,54 +79,17 @@ class EndToEndTest extends PHPUnit_Framework_TestCase{
...
@@ -79,54 +79,17 @@ class EndToEndTest extends PHPUnit_Framework_TestCase{
$this
->
assertTrue
(
$event
->
send_status
);
$this
->
assertTrue
(
$event
->
send_status
);
$this
->
assertFalse
(
$event
->
cancelled
);
$this
->
assertFalse
(
$event
->
cancelled
);
$tag
=
1
;
$event
=
$call
->
start_batch
([
$call
->
invoke
(
$this
->
client_queue
,
$tag
,
$tag
);
Grpc\OP_RECV_INITIAL_METADATA
=>
true
,
$server_tag
=
2
;
Grpc\OP_RECV_STATUS_ON_CLIENT
=>
true
,
]);
$call
->
writes_done
(
$tag
);
$event
=
$this
->
client_queue
->
next
(
$deadline
);
$this
->
assertNotNull
(
$event
);
$this
->
assertSame
(
Grpc\FINISH_ACCEPTED
,
$event
->
type
);
$this
->
assertSame
(
Grpc\OP_OK
,
$event
->
data
);
// check that a server rpc new was received
$this
->
server
->
request_call
(
$server_tag
);
$event
=
$this
->
server_queue
->
next
(
$deadline
);
$this
->
assertNotNull
(
$event
);
$this
->
assertSame
(
Grpc\SERVER_RPC_NEW
,
$event
->
type
);
$server_call
=
$event
->
call
;
$this
->
assertNotNull
(
$server_call
);
$server_call
->
server_accept
(
$this
->
server_queue
,
$server_tag
);
$server_call
->
server_end_initial_metadata
();
// the server sends the status
$server_call
->
start_write_status
(
Grpc\STATUS_OK
,
$status_text
,
$server_tag
);
$event
=
$this
->
server_queue
->
next
(
$deadline
);
$this
->
assertNotNull
(
$event
);
$this
->
assertSame
(
Grpc\FINISH_ACCEPTED
,
$event
->
type
);
$this
->
assertSame
(
Grpc\OP_OK
,
$event
->
data
);
// the client gets CLIENT_METADATA_READ
$event
=
$this
->
client_queue
->
next
(
$deadline
);
$this
->
assertNotNull
(
$event
);
$this
->
assertSame
(
Grpc\CLIENT_METADATA_READ
,
$event
->
type
);
// the client gets FINISHED
$this
->
assertSame
([],
$event
->
metadata
);
$event
=
$this
->
client_queue
->
next
(
$deadline
);
$status
=
$event
->
status
;
$this
->
assertNotNull
(
$event
);
$this
->
assertSame
([],
$status
->
metadata
);
$this
->
assertSame
(
Grpc\FINISHED
,
$event
->
type
);
$status
=
$event
->
data
;
$this
->
assertSame
(
Grpc\STATUS_OK
,
$status
->
code
);
$this
->
assertSame
(
Grpc\STATUS_OK
,
$status
->
code
);
$this
->
assertSame
(
$status_text
,
$status
->
details
);
$this
->
assertSame
(
$status_text
,
$status
->
details
);
// and the server gets FINISHED
$event
=
$this
->
server_queue
->
next
(
$deadline
);
$this
->
assertNotNull
(
$event
);
$this
->
assertSame
(
Grpc\FINISHED
,
$event
->
type
);
$status
=
$event
->
data
;
unset
(
$call
);
unset
(
$call
);
unset
(
$server_call
);
unset
(
$server_call
);
}
}
...
@@ -140,79 +103,52 @@ class EndToEndTest extends PHPUnit_Framework_TestCase{
...
@@ -140,79 +103,52 @@ class EndToEndTest extends PHPUnit_Framework_TestCase{
$call
=
new
Grpc\Call
(
$this
->
channel
,
$call
=
new
Grpc\Call
(
$this
->
channel
,
'dummy_method'
,
'dummy_method'
,
$deadline
);
$deadline
);
$tag
=
1
;
$call
->
invoke
(
$this
->
client_queue
,
$tag
,
$tag
);
$server_tag
=
2
;
$event
=
$call
->
start_batch
([
Grpc\OP_SEND_INITIAL_METADATA
=>
[],
Grpc\OP_SEND_CLOSE_FROM_CLIENT
=>
true
,
Grpc\OP_SEND_MESSAGE
=>
$req_text
]);
// the client writes
$this
->
assertTrue
(
$event
->
send_metadata
);
$call
->
start_write
(
$req_text
,
$tag
);
$this
->
assertTrue
(
$event
->
send_close
);
$event
=
$this
->
client_queue
->
next
(
$deadline
);
$this
->
assertTrue
(
$event
->
send_message
);
$this
->
assertNotNull
(
$event
);
$this
->
assertSame
(
Grpc\WRITE_ACCEPTED
,
$event
->
type
);
// check that a server rpc new was received
$event
=
$this
->
server
->
request_call
();
$this
->
server
->
start
();
$this
->
assertSame
(
'dummy_method'
,
$event
->
method
);
$this
->
server
->
request_call
(
$server_tag
);
$event
=
$this
->
server_queue
->
next
(
$deadline
);
$this
->
assertNotNull
(
$event
);
$this
->
assertSame
(
Grpc\SERVER_RPC_NEW
,
$event
->
type
);
$server_call
=
$event
->
call
;
$server_call
=
$event
->
call
;
$this
->
assertNotNull
(
$server_call
);
$server_call
->
server_accept
(
$this
->
server_queue
,
$server_tag
);
$event
=
$server_call
->
start_batch
([
Grpc\OP_SEND_INITIAL_METADATA
=>
[],
$server_call
->
server_end_initial_metadata
();
Grpc\OP_SEND_MESSAGE
=>
$reply_text
,
Grpc\OP_SEND_STATUS_FROM_SERVER
=>
[
// start the server read
'metadata'
=>
[],
$server_call
->
start_read
(
$server_tag
);
'code'
=>
Grpc\STATUS_OK
,
$event
=
$this
->
server_queue
->
next
(
$deadline
);
'details'
=>
$status_text
$this
->
assertNotNull
(
$event
);
],
$this
->
assertSame
(
Grpc\READ
,
$event
->
type
);
Grpc\OP_RECV_MESSAGE
=>
true
,
$this
->
assertSame
(
$req_text
,
$event
->
data
);
Grpc\OP_RECV_CLOSE_ON_SERVER
=>
true
,
]);
// the server replies
$server_call
->
start_write
(
$reply_text
,
$server_tag
);
$this
->
assertTrue
(
$event
->
send_metadata
);
$event
=
$this
->
server_queue
->
next
(
$deadline
);
$this
->
assertTrue
(
$event
->
send_status
);
$this
->
assertNotNull
(
$event
);
$this
->
assertTrue
(
$event
->
send_message
);
$this
->
assertSame
(
Grpc\WRITE_ACCEPTED
,
$event
->
type
);
$this
->
assertFalse
(
$event
->
cancelled
);
$this
->
assertSame
(
$req_text
,
$event
->
read
);
// the client reads the metadata
$event
=
$this
->
client_queue
->
next
(
$deadline
);
$event
=
$call
->
start_batch
([
$this
->
assertNotNull
(
$event
);
Grpc\OP_RECV_INITIAL_METADATA
=>
true
,
$this
->
assertSame
(
Grpc\CLIENT_METADATA_READ
,
$event
->
type
);
Grpc\OP_RECV_MESSAGE
=>
true
,
Grpc\OP_RECV_STATUS_ON_CLIENT
=>
true
,
// the client reads the reply
]);
$call
->
start_read
(
$tag
);
$event
=
$this
->
client_queue
->
next
(
$deadline
);
$this
->
assertSame
([],
$event
->
metadata
);
$this
->
assertNotNull
(
$event
);
$this
->
assertSame
(
$reply_text
,
$event
->
read
);
$this
->
assertSame
(
Grpc\READ
,
$event
->
type
);
$status
=
$event
->
status
;
$this
->
assertSame
(
$reply_text
,
$event
->
data
);
$this
->
assertSame
([],
$status
->
metadata
);
// the client sends writes done
$call
->
writes_done
(
$tag
);
$event
=
$this
->
client_queue
->
next
(
$deadline
);
$this
->
assertSame
(
Grpc\FINISH_ACCEPTED
,
$event
->
type
);
$this
->
assertSame
(
Grpc\OP_OK
,
$event
->
data
);
// the server sends the status
$server_call
->
start_write_status
(
GRPC\STATUS_OK
,
$status_text
,
$server_tag
);
$event
=
$this
->
server_queue
->
next
(
$deadline
);
$this
->
assertSame
(
Grpc\FINISH_ACCEPTED
,
$event
->
type
);
$this
->
assertSame
(
Grpc\OP_OK
,
$event
->
data
);
// the client gets FINISHED
$event
=
$this
->
client_queue
->
next
(
$deadline
);
$this
->
assertNotNull
(
$event
);
$this
->
assertSame
(
Grpc\FINISHED
,
$event
->
type
);
$status
=
$event
->
data
;
$this
->
assertSame
(
Grpc\STATUS_OK
,
$status
->
code
);
$this
->
assertSame
(
Grpc\STATUS_OK
,
$status
->
code
);
$this
->
assertSame
(
$status_text
,
$status
->
details
);
$this
->
assertSame
(
$status_text
,
$status
->
details
);
// and the server gets FINISHED
$event
=
$this
->
server_queue
->
next
(
$deadline
);
$this
->
assertNotNull
(
$event
);
$this
->
assertSame
(
Grpc\FINISHED
,
$event
->
type
);
unset
(
$call
);
unset
(
$call
);
unset
(
$server_call
);
unset
(
$server_call
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment