Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
ccb90188
Commit
ccb90188
authored
May 28, 2019
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add UT: http2_handle_goaway_streams
parent
93c35ba9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
1 deletion
+47
-1
brpc_http_rpc_protocol_unittest.cpp
test/brpc_http_rpc_protocol_unittest.cpp
+47
-1
No files found.
test/brpc_http_rpc_protocol_unittest.cpp
View file @
ccb90188
...
...
@@ -12,6 +12,7 @@
#include "butil/time.h"
#include "butil/macros.h"
#include "butil/files/scoped_file.h"
#include "butil/fd_guard.h"
#include "brpc/socket.h"
#include "brpc/acceptor.h"
#include "brpc/server.h"
...
...
@@ -1324,7 +1325,7 @@ TEST_F(HttpTest, http2_header_after_data) {
ASSERT_EQ
(
*
user_defined2
,
"b"
);
}
TEST_F
(
HttpTest
,
http2_goaway
)
{
TEST_F
(
HttpTest
,
http2_goaway
_sanity
)
{
brpc
::
Controller
cntl
;
// Prepare request
butil
::
IOBuf
req_out
;
...
...
@@ -1363,4 +1364,49 @@ TEST_F(HttpTest, http2_goaway) {
ASSERT_TRUE
(
st
.
error_data
().
ends_with
(
"the connection just issued GOAWAY"
));
}
class
AfterRecevingGoAway
:
public
::
google
::
protobuf
::
Closure
{
public
:
void
Run
()
{
ASSERT_EQ
(
brpc
::
EHTTP
,
cntl
.
ErrorCode
());
delete
this
;
}
brpc
::
Controller
cntl
;
};
TEST_F
(
HttpTest
,
http2_handle_goaway_streams
)
{
const
butil
::
EndPoint
ep
(
butil
::
IP_ANY
,
5961
);
butil
::
fd_guard
listenfd
(
butil
::
tcp_listen
(
ep
));
ASSERT_GT
(
listenfd
,
0
);
brpc
::
Channel
channel
;
brpc
::
ChannelOptions
options
;
options
.
protocol
=
brpc
::
PROTOCOL_H2
;
ASSERT_EQ
(
0
,
channel
.
Init
(
ep
,
&
options
));
int
req_size
=
10
;
std
::
vector
<
brpc
::
CallId
>
ids
(
req_size
);
for
(
int
i
=
0
;
i
<
req_size
;
i
++
)
{
AfterRecevingGoAway
*
done
=
new
AfterRecevingGoAway
;
brpc
::
Controller
&
cntl
=
done
->
cntl
;
ids
.
push_back
(
cntl
.
call_id
());
cntl
.
set_timeout_ms
(
-
1
);
cntl
.
http_request
().
uri
()
=
"/it-doesnt-matter"
;
channel
.
CallMethod
(
NULL
,
&
cntl
,
NULL
,
NULL
,
done
);
}
int
servfd
=
accept
(
listenfd
,
NULL
,
NULL
);
ASSERT_GT
(
servfd
,
0
);
// Sleep for a while to make sure that server has received all data.
bthread_usleep
(
2000
);
char
goawaybuf
[
brpc
::
policy
::
FRAME_HEAD_SIZE
+
8
];
SerializeFrameHead
(
goawaybuf
,
8
,
brpc
::
policy
::
H2_FRAME_GOAWAY
,
0
,
0
);
SaveUint32
(
goawaybuf
+
brpc
::
policy
::
FRAME_HEAD_SIZE
,
0
);
SaveUint32
(
goawaybuf
+
brpc
::
policy
::
FRAME_HEAD_SIZE
+
4
,
0
);
ASSERT_EQ
(
brpc
::
policy
::
FRAME_HEAD_SIZE
+
8
,
::
write
(
servfd
,
goawaybuf
,
brpc
::
policy
::
FRAME_HEAD_SIZE
+
8
));
// After receving GOAWAY, the callbacks in client should be run correctly.
for
(
int
i
=
0
;
i
<
req_size
;
i
++
)
{
brpc
::
Join
(
ids
[
i
]);
}
}
}
//namespace
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment