Merge pull request #14884 from ara-ayvazyan/fix_server_builder_test

Fix crashing server_builder_test
pull/14923/head
Jan Tattermusch 7 years ago committed by GitHub
commit b15ddc41c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      test/cpp/server/server_builder_test.cc

@ -39,7 +39,10 @@ grpc::string MakePort() {
return s.str();
}
grpc::string g_port = MakePort();
const grpc::string& GetPort() {
static grpc::string g_port = MakePort();
return g_port;
}
TEST(ServerBuilderTest, NoOp) { ServerBuilder b; }
@ -50,7 +53,7 @@ TEST(ServerBuilderTest, CreateServerNoPorts) {
TEST(ServerBuilderTest, CreateServerOnePort) {
ServerBuilder()
.RegisterService(&g_service)
.AddListeningPort(g_port, InsecureServerCredentials())
.AddListeningPort(GetPort(), InsecureServerCredentials())
.BuildAndStart()
->Shutdown();
}
@ -58,8 +61,8 @@ TEST(ServerBuilderTest, CreateServerOnePort) {
TEST(ServerBuilderTest, CreateServerRepeatedPort) {
ServerBuilder()
.RegisterService(&g_service)
.AddListeningPort(g_port, InsecureServerCredentials())
.AddListeningPort(g_port, InsecureServerCredentials())
.AddListeningPort(GetPort(), InsecureServerCredentials())
.AddListeningPort(GetPort(), InsecureServerCredentials())
.BuildAndStart()
->Shutdown();
}
@ -67,8 +70,8 @@ TEST(ServerBuilderTest, CreateServerRepeatedPort) {
TEST(ServerBuilderTest, CreateServerRepeatedPortWithDisallowedReusePort) {
EXPECT_EQ(ServerBuilder()
.RegisterService(&g_service)
.AddListeningPort(g_port, InsecureServerCredentials())
.AddListeningPort(g_port, InsecureServerCredentials())
.AddListeningPort(GetPort(), InsecureServerCredentials())
.AddListeningPort(GetPort(), InsecureServerCredentials())
.AddChannelArgument(GRPC_ARG_ALLOW_REUSEPORT, 0)
.BuildAndStart(),
nullptr);

Loading…
Cancel
Save