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
8e6bdfac
Unverified
Commit
8e6bdfac
authored
Jul 29, 2020
by
jamesge
Committed by
GitHub
Jul 29, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1189 from zyearn/fix_ut_brpc_baidu_com
fix brpc.baidu.com not accessible
parents
983b9970
1211ddcc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
18 deletions
+38
-18
brpc_naming_service_filter_unittest.cpp
test/brpc_naming_service_filter_unittest.cpp
+1
-1
brpc_naming_service_unittest.cpp
test/brpc_naming_service_unittest.cpp
+37
-17
No files found.
test/brpc_naming_service_filter_unittest.cpp
View file @
8e6bdfac
...
...
@@ -45,7 +45,7 @@ TEST_F(NamingServiceFilterTest, sanity) {
"10.128.0.1:1234 enable"
,
"10.129.0.1:1234"
,
"localhost:1234"
,
"b
rpc.b
aidu.com:1234"
"baidu.com:1234"
};
butil
::
TempFile
tmp_file
;
{
...
...
test/brpc_naming_service_unittest.cpp
View file @
8e6bdfac
...
...
@@ -50,6 +50,19 @@ DECLARE_int32(discovery_renew_interval_s);
}
// brpc
namespace
{
bool
IsIPListEqual
(
const
std
::
set
<
butil
::
ip_t
>&
s1
,
const
std
::
set
<
butil
::
ip_t
>&
s2
)
{
if
(
s1
.
size
()
!=
s2
.
size
())
{
return
false
;
}
for
(
auto
it1
=
s1
.
begin
(),
it2
=
s2
.
begin
();
it1
!=
s1
.
end
();
++
it1
,
++
it2
)
{
if
(
*
it1
!=
*
it2
)
{
return
false
;
}
}
return
true
;
}
TEST
(
NamingServiceTest
,
sanity
)
{
std
::
vector
<
brpc
::
ServerNode
>
servers
;
...
...
@@ -59,32 +72,39 @@ TEST(NamingServiceTest, sanity) {
#endif
brpc
::
policy
::
DomainNamingService
dns
;
ASSERT_EQ
(
0
,
dns
.
GetServers
(
"b
rpc.b
aidu.com:1234"
,
&
servers
));
ASSERT_EQ
(
1
u
,
servers
.
size
());
ASSERT_EQ
(
0
,
dns
.
GetServers
(
"baidu.com:1234"
,
&
servers
));
ASSERT_EQ
(
2
u
,
servers
.
size
());
ASSERT_EQ
(
1234
,
servers
[
0
].
addr
.
port
);
const
butil
::
ip_t
expected_ip
=
servers
[
0
].
addr
.
ip
;
ASSERT_EQ
(
1234
,
servers
[
1
].
addr
.
port
);
const
std
::
set
<
butil
::
ip_t
>
expected_ips
{
servers
[
0
].
addr
.
ip
,
servers
[
1
].
addr
.
ip
};
ASSERT_EQ
(
0
,
dns
.
GetServers
(
"brpc.baidu.com"
,
&
servers
));
ASSERT_EQ
(
1u
,
servers
.
size
());
ASSERT_EQ
(
expected_ip
,
servers
[
0
].
addr
.
ip
);
ASSERT_EQ
(
0
,
dns
.
GetServers
(
"baidu.com"
,
&
servers
));
ASSERT_EQ
(
2u
,
servers
.
size
());
const
std
::
set
<
butil
::
ip_t
>
ip_list1
{
servers
[
0
].
addr
.
ip
,
servers
[
1
].
addr
.
ip
};
ASSERT_TRUE
(
IsIPListEqual
(
expected_ips
,
ip_list1
));
ASSERT_EQ
(
80
,
servers
[
0
].
addr
.
port
);
ASSERT_EQ
(
80
,
servers
[
1
].
addr
.
port
);
ASSERT_EQ
(
0
,
dns
.
GetServers
(
"brpc.baidu.com:1234/useless1/useless2"
,
&
servers
));
ASSERT_EQ
(
1u
,
servers
.
size
());
ASSERT_EQ
(
expected_ip
,
servers
[
0
].
addr
.
ip
);
ASSERT_EQ
(
0
,
dns
.
GetServers
(
"baidu.com:1234/useless1/useless2"
,
&
servers
));
ASSERT_EQ
(
2u
,
servers
.
size
());
const
std
::
set
<
butil
::
ip_t
>
ip_list2
{
servers
[
0
].
addr
.
ip
,
servers
[
1
].
addr
.
ip
};
ASSERT_TRUE
(
IsIPListEqual
(
expected_ips
,
ip_list2
));
ASSERT_EQ
(
1234
,
servers
[
0
].
addr
.
port
);
ASSERT_EQ
(
1234
,
servers
[
1
].
addr
.
port
);
ASSERT_EQ
(
0
,
dns
.
GetServers
(
"brpc.baidu.com/useless1/useless2"
,
&
servers
));
ASSERT_EQ
(
1u
,
servers
.
size
());
ASSERT_EQ
(
expected_ip
,
servers
[
0
].
addr
.
ip
);
ASSERT_EQ
(
0
,
dns
.
GetServers
(
"baidu.com/useless1/useless2"
,
&
servers
));
ASSERT_EQ
(
2u
,
servers
.
size
());
const
std
::
set
<
butil
::
ip_t
>
ip_list3
{
servers
[
0
].
addr
.
ip
,
servers
[
1
].
addr
.
ip
};
ASSERT_TRUE
(
IsIPListEqual
(
expected_ips
,
ip_list3
));
ASSERT_EQ
(
80
,
servers
[
0
].
addr
.
port
);
ASSERT_EQ
(
80
,
servers
[
1
].
addr
.
port
);
const
char
*
address_list
[]
=
{
"10.127.0.1:1234"
,
"10.128.0.1:1234"
,
"10.129.0.1:1234"
,
"localhost:1234"
,
"b
rpc.b
aidu.com:1234"
"baidu.com:1234"
};
butil
::
TempFile
tmp_file
;
{
...
...
@@ -126,9 +146,9 @@ TEST(NamingServiceTest, invalid_port) {
#endif
brpc
::
policy
::
DomainNamingService
dns
;
ASSERT_EQ
(
-
1
,
dns
.
GetServers
(
"b
rpc.b
aidu.com:"
,
&
servers
));
ASSERT_EQ
(
-
1
,
dns
.
GetServers
(
"b
rpc.b
aidu.com:123a"
,
&
servers
));
ASSERT_EQ
(
-
1
,
dns
.
GetServers
(
"b
rpc.b
aidu.com:99999"
,
&
servers
));
ASSERT_EQ
(
-
1
,
dns
.
GetServers
(
"baidu.com:"
,
&
servers
));
ASSERT_EQ
(
-
1
,
dns
.
GetServers
(
"baidu.com:123a"
,
&
servers
));
ASSERT_EQ
(
-
1
,
dns
.
GetServers
(
"baidu.com:99999"
,
&
servers
));
}
TEST
(
NamingServiceTest
,
wrong_name
)
{
...
...
@@ -146,7 +166,7 @@ TEST(NamingServiceTest, wrong_name) {
"10.128.0.1:"
,
"10.128.0.1"
,
"localhost:1234"
,
"b
rpc.b
aidu.com:1234"
,
"baidu.com:1234"
,
"LOCAL:1234"
};
butil
::
TempFile
tmp_file
;
...
...
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