|
|
|
@ -29,6 +29,7 @@ |
|
|
|
|
#include "src/core/ext/filters/client_channel/retry_service_config.h" |
|
|
|
|
#include "src/core/ext/filters/message_size/message_size_filter.h" |
|
|
|
|
#include "src/core/lib/gpr/string.h" |
|
|
|
|
#include "src/core/lib/service_config/service_config_impl.h" |
|
|
|
|
#include "src/core/lib/service_config/service_config_parser.h" |
|
|
|
|
#include "test/core/util/port.h" |
|
|
|
|
#include "test/core/util/test_config.h" |
|
|
|
@ -62,6 +63,8 @@ class TestParsedConfig1 : public ServiceConfigParser::ParsedConfig { |
|
|
|
|
|
|
|
|
|
class TestParser1 : public ServiceConfigParser::Parser { |
|
|
|
|
public: |
|
|
|
|
absl::string_view name() const override { return "test_parser_1"; } |
|
|
|
|
|
|
|
|
|
std::unique_ptr<ServiceConfigParser::ParsedConfig> ParseGlobalParams( |
|
|
|
|
const grpc_channel_args* args, const Json& json, |
|
|
|
|
grpc_error_handle* error) override { |
|
|
|
@ -98,6 +101,8 @@ class TestParser1 : public ServiceConfigParser::Parser { |
|
|
|
|
|
|
|
|
|
class TestParser2 : public ServiceConfigParser::Parser { |
|
|
|
|
public: |
|
|
|
|
absl::string_view name() const override { return "test_parser_2"; } |
|
|
|
|
|
|
|
|
|
std::unique_ptr<ServiceConfigParser::ParsedConfig> ParsePerMethodParams( |
|
|
|
|
const grpc_channel_args* args, const Json& json, |
|
|
|
|
grpc_error_handle* error) override { |
|
|
|
@ -135,6 +140,10 @@ class TestParser2 : public ServiceConfigParser::Parser { |
|
|
|
|
// This parser always adds errors
|
|
|
|
|
class ErrorParser : public ServiceConfigParser::Parser { |
|
|
|
|
public: |
|
|
|
|
explicit ErrorParser(absl::string_view name) : name_(name) {} |
|
|
|
|
|
|
|
|
|
absl::string_view name() const override { return name_; } |
|
|
|
|
|
|
|
|
|
std::unique_ptr<ServiceConfigParser::ParsedConfig> ParsePerMethodParams( |
|
|
|
|
const grpc_channel_args* /*arg*/, const Json& /*json*/, |
|
|
|
|
grpc_error_handle* error) override { |
|
|
|
@ -154,26 +163,35 @@ class ErrorParser : public ServiceConfigParser::Parser { |
|
|
|
|
static const char* MethodError() { return "ErrorParser : methodError"; } |
|
|
|
|
|
|
|
|
|
static const char* GlobalError() { return "ErrorParser : globalError"; } |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
absl::string_view name_; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class ServiceConfigTest : public ::testing::Test { |
|
|
|
|
protected: |
|
|
|
|
void SetUp() override { |
|
|
|
|
ServiceConfigParserShutdown(); |
|
|
|
|
ServiceConfigParserInit(); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
ServiceConfigParser::RegisterParser(absl::make_unique<TestParser1>()), |
|
|
|
|
0); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
ServiceConfigParser::RegisterParser(absl::make_unique<TestParser2>()), |
|
|
|
|
1); |
|
|
|
|
CoreConfiguration::Reset(); |
|
|
|
|
CoreConfiguration::BuildSpecialConfiguration( |
|
|
|
|
[](CoreConfiguration::Builder* builder) { |
|
|
|
|
builder->service_config_parser()->RegisterParser( |
|
|
|
|
absl::make_unique<TestParser1>()); |
|
|
|
|
builder->service_config_parser()->RegisterParser( |
|
|
|
|
absl::make_unique<TestParser2>()); |
|
|
|
|
}); |
|
|
|
|
EXPECT_EQ(CoreConfiguration::Get().service_config_parser().GetParserIndex( |
|
|
|
|
"test_parser_1"), |
|
|
|
|
0); |
|
|
|
|
EXPECT_EQ(CoreConfiguration::Get().service_config_parser().GetParserIndex( |
|
|
|
|
"test_parser_2"), |
|
|
|
|
1); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
TEST_F(ServiceConfigTest, ErrorCheck1) { |
|
|
|
|
const char* test_json = ""; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex("JSON parse error")); |
|
|
|
|
GRPC_ERROR_UNREF(error); |
|
|
|
@ -182,7 +200,7 @@ TEST_F(ServiceConfigTest, ErrorCheck1) { |
|
|
|
|
TEST_F(ServiceConfigTest, BasicTest1) { |
|
|
|
|
const char* test_json = "{}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -194,7 +212,7 @@ TEST_F(ServiceConfigTest, SkipMethodConfigWithNoNameOrEmptyName) { |
|
|
|
|
" {\"name\":[{\"service\":\"TestServ\"}], \"method_param\":2}" |
|
|
|
|
"]}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( |
|
|
|
|
grpc_slice_from_static_string("/TestServ/TestMethod")); |
|
|
|
@ -210,7 +228,7 @@ TEST_F(ServiceConfigTest, ErrorDuplicateMethodConfigNames) { |
|
|
|
|
" {\"name\":[{\"service\":\"TestServ\"}]}" |
|
|
|
|
"]}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -226,7 +244,7 @@ TEST_F(ServiceConfigTest, ErrorDuplicateMethodConfigNamesWithNullMethod) { |
|
|
|
|
" {\"name\":[{\"service\":\"TestServ\"}]}" |
|
|
|
|
"]}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -242,7 +260,7 @@ TEST_F(ServiceConfigTest, ErrorDuplicateMethodConfigNamesWithEmptyMethod) { |
|
|
|
|
" {\"name\":[{\"service\":\"TestServ\"}]}" |
|
|
|
|
"]}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -258,7 +276,7 @@ TEST_F(ServiceConfigTest, ErrorDuplicateDefaultMethodConfigs) { |
|
|
|
|
" {\"name\":[{}]}" |
|
|
|
|
"]}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -274,7 +292,7 @@ TEST_F(ServiceConfigTest, ErrorDuplicateDefaultMethodConfigsWithNullService) { |
|
|
|
|
" {\"name\":[{}]}" |
|
|
|
|
"]}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -290,7 +308,7 @@ TEST_F(ServiceConfigTest, ErrorDuplicateDefaultMethodConfigsWithEmptyService) { |
|
|
|
|
" {\"name\":[{}]}" |
|
|
|
|
"]}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -303,14 +321,14 @@ TEST_F(ServiceConfigTest, ValidMethodConfig) { |
|
|
|
|
const char* test_json = |
|
|
|
|
"{\"methodConfig\": [{\"name\":[{\"service\":\"TestServ\"}]}]}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(ServiceConfigTest, Parser1BasicTest1) { |
|
|
|
|
const char* test_json = "{\"global_param\":5}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
EXPECT_EQ((static_cast<TestParsedConfig1*>(svc_cfg->GetGlobalParsedConfig(0))) |
|
|
|
|
->value(), |
|
|
|
@ -323,7 +341,7 @@ TEST_F(ServiceConfigTest, Parser1BasicTest1) { |
|
|
|
|
TEST_F(ServiceConfigTest, Parser1BasicTest2) { |
|
|
|
|
const char* test_json = "{\"global_param\":1000}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
EXPECT_EQ((static_cast<TestParsedConfig1*>(svc_cfg->GetGlobalParsedConfig(0))) |
|
|
|
|
->value(), |
|
|
|
@ -336,7 +354,7 @@ TEST_F(ServiceConfigTest, Parser1DisabledViaChannelArg) { |
|
|
|
|
grpc_channel_args args = {1, &arg}; |
|
|
|
|
const char* test_json = "{\"global_param\":5}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(&args, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(&args, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
EXPECT_EQ(svc_cfg->GetGlobalParsedConfig(0), nullptr); |
|
|
|
|
} |
|
|
|
@ -344,7 +362,7 @@ TEST_F(ServiceConfigTest, Parser1DisabledViaChannelArg) { |
|
|
|
|
TEST_F(ServiceConfigTest, Parser1ErrorInvalidType) { |
|
|
|
|
const char* test_json = "{\"global_param\":\"5\"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
absl::StrCat("Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -356,7 +374,7 @@ TEST_F(ServiceConfigTest, Parser1ErrorInvalidType) { |
|
|
|
|
TEST_F(ServiceConfigTest, Parser1ErrorInvalidValue) { |
|
|
|
|
const char* test_json = "{\"global_param\":-5}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
absl::StrCat("Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -370,7 +388,7 @@ TEST_F(ServiceConfigTest, Parser2BasicTest) { |
|
|
|
|
"{\"methodConfig\": [{\"name\":[{\"service\":\"TestServ\"}], " |
|
|
|
|
"\"method_param\":5}]}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( |
|
|
|
|
grpc_slice_from_static_string("/TestServ/TestMethod")); |
|
|
|
@ -387,7 +405,7 @@ TEST_F(ServiceConfigTest, Parser2DisabledViaChannelArg) { |
|
|
|
|
"{\"methodConfig\": [{\"name\":[{\"service\":\"TestServ\"}], " |
|
|
|
|
"\"method_param\":5}]}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(&args, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(&args, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( |
|
|
|
|
grpc_slice_from_static_string("/TestServ/TestMethod")); |
|
|
|
@ -401,7 +419,7 @@ TEST_F(ServiceConfigTest, Parser2ErrorInvalidType) { |
|
|
|
|
"{\"methodConfig\": [{\"name\":[{\"service\":\"TestServ\"}], " |
|
|
|
|
"\"method_param\":\"5\"}]}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT( |
|
|
|
|
grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex(absl::StrCat( |
|
|
|
@ -416,7 +434,7 @@ TEST_F(ServiceConfigTest, Parser2ErrorInvalidValue) { |
|
|
|
|
"{\"methodConfig\": [{\"name\":[{\"service\":\"TestServ\"}], " |
|
|
|
|
"\"method_param\":-5}]}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT( |
|
|
|
|
grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex(absl::StrCat( |
|
|
|
@ -426,17 +444,36 @@ TEST_F(ServiceConfigTest, Parser2ErrorInvalidValue) { |
|
|
|
|
GRPC_ERROR_UNREF(error); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(ServiceConfigParserTest, DoubleRegistration) { |
|
|
|
|
CoreConfiguration::Reset(); |
|
|
|
|
ASSERT_DEATH_IF_SUPPORTED( |
|
|
|
|
CoreConfiguration::BuildSpecialConfiguration( |
|
|
|
|
[](CoreConfiguration::Builder* builder) { |
|
|
|
|
builder->service_config_parser()->RegisterParser( |
|
|
|
|
absl::make_unique<ErrorParser>("xyzabc")); |
|
|
|
|
builder->service_config_parser()->RegisterParser( |
|
|
|
|
absl::make_unique<ErrorParser>("xyzabc")); |
|
|
|
|
}), |
|
|
|
|
"xyzabc.*already registered"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Test parsing with ErrorParsers which always add errors
|
|
|
|
|
class ErroredParsersScopingTest : public ::testing::Test { |
|
|
|
|
protected: |
|
|
|
|
void SetUp() override { |
|
|
|
|
ServiceConfigParserShutdown(); |
|
|
|
|
ServiceConfigParserInit(); |
|
|
|
|
CoreConfiguration::Reset(); |
|
|
|
|
CoreConfiguration::BuildSpecialConfiguration( |
|
|
|
|
[](CoreConfiguration::Builder* builder) { |
|
|
|
|
builder->service_config_parser()->RegisterParser( |
|
|
|
|
absl::make_unique<ErrorParser>("ep1")); |
|
|
|
|
builder->service_config_parser()->RegisterParser( |
|
|
|
|
absl::make_unique<ErrorParser>("ep2")); |
|
|
|
|
}); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
ServiceConfigParser::RegisterParser(absl::make_unique<ErrorParser>()), |
|
|
|
|
CoreConfiguration::Get().service_config_parser().GetParserIndex("ep1"), |
|
|
|
|
0); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
ServiceConfigParser::RegisterParser(absl::make_unique<ErrorParser>()), |
|
|
|
|
CoreConfiguration::Get().service_config_parser().GetParserIndex("ep2"), |
|
|
|
|
1); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
@ -444,7 +481,7 @@ class ErroredParsersScopingTest : public ::testing::Test { |
|
|
|
|
TEST_F(ErroredParsersScopingTest, GlobalParams) { |
|
|
|
|
const char* test_json = "{}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT( |
|
|
|
|
grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex(absl::StrCat( |
|
|
|
@ -457,7 +494,7 @@ TEST_F(ErroredParsersScopingTest, GlobalParams) { |
|
|
|
|
TEST_F(ErroredParsersScopingTest, MethodParams) { |
|
|
|
|
const char* test_json = "{\"methodConfig\": [{}]}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT( |
|
|
|
|
grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex(absl::StrCat( |
|
|
|
@ -476,19 +513,22 @@ TEST_F(ErroredParsersScopingTest, MethodParams) { |
|
|
|
|
class ClientChannelParserTest : public ::testing::Test { |
|
|
|
|
protected: |
|
|
|
|
void SetUp() override { |
|
|
|
|
ServiceConfigParserShutdown(); |
|
|
|
|
ServiceConfigParserInit(); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
ServiceConfigParser::RegisterParser( |
|
|
|
|
absl::make_unique<internal::ClientChannelServiceConfigParser>()), |
|
|
|
|
0); |
|
|
|
|
CoreConfiguration::Reset(); |
|
|
|
|
CoreConfiguration::BuildSpecialConfiguration( |
|
|
|
|
[](CoreConfiguration::Builder* builder) { |
|
|
|
|
builder->service_config_parser()->RegisterParser( |
|
|
|
|
absl::make_unique<internal::ClientChannelServiceConfigParser>()); |
|
|
|
|
}); |
|
|
|
|
EXPECT_EQ(CoreConfiguration::Get().service_config_parser().GetParserIndex( |
|
|
|
|
"client_channel"), |
|
|
|
|
0); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
TEST_F(ClientChannelParserTest, ValidLoadBalancingConfigPickFirst) { |
|
|
|
|
const char* test_json = "{\"loadBalancingConfig\": [{\"pick_first\":{}}]}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
const auto* parsed_config = |
|
|
|
|
static_cast<internal::ClientChannelGlobalParsedConfig*>( |
|
|
|
@ -501,7 +541,7 @@ TEST_F(ClientChannelParserTest, ValidLoadBalancingConfigRoundRobin) { |
|
|
|
|
const char* test_json = |
|
|
|
|
"{\"loadBalancingConfig\": [{\"round_robin\":{}}, {}]}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
auto parsed_config = static_cast<internal::ClientChannelGlobalParsedConfig*>( |
|
|
|
|
svc_cfg->GetGlobalParsedConfig(0)); |
|
|
|
@ -514,7 +554,7 @@ TEST_F(ClientChannelParserTest, ValidLoadBalancingConfigGrpclb) { |
|
|
|
|
"{\"loadBalancingConfig\": " |
|
|
|
|
"[{\"grpclb\":{\"childPolicy\":[{\"pick_first\":{}}]}}]}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
const auto* parsed_config = |
|
|
|
|
static_cast<internal::ClientChannelGlobalParsedConfig*>( |
|
|
|
@ -537,7 +577,7 @@ TEST_F(ClientChannelParserTest, ValidLoadBalancingConfigXds) { |
|
|
|
|
" ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
const auto* parsed_config = |
|
|
|
|
static_cast<internal::ClientChannelGlobalParsedConfig*>( |
|
|
|
@ -549,7 +589,7 @@ TEST_F(ClientChannelParserTest, ValidLoadBalancingConfigXds) { |
|
|
|
|
TEST_F(ClientChannelParserTest, UnknownLoadBalancingConfig) { |
|
|
|
|
const char* test_json = "{\"loadBalancingConfig\": [{\"unknown\":{}}]}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT( |
|
|
|
|
grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex("Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -567,7 +607,7 @@ TEST_F(ClientChannelParserTest, InvalidGrpclbLoadBalancingConfig) { |
|
|
|
|
" {\"round_robin\":{}}" |
|
|
|
|
"]}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -582,7 +622,7 @@ TEST_F(ClientChannelParserTest, InvalidGrpclbLoadBalancingConfig) { |
|
|
|
|
TEST_F(ClientChannelParserTest, ValidLoadBalancingPolicy) { |
|
|
|
|
const char* test_json = "{\"loadBalancingPolicy\":\"pick_first\"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
const auto* parsed_config = |
|
|
|
|
static_cast<internal::ClientChannelGlobalParsedConfig*>( |
|
|
|
@ -593,7 +633,7 @@ TEST_F(ClientChannelParserTest, ValidLoadBalancingPolicy) { |
|
|
|
|
TEST_F(ClientChannelParserTest, ValidLoadBalancingPolicyAllCaps) { |
|
|
|
|
const char* test_json = "{\"loadBalancingPolicy\":\"PICK_FIRST\"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
const auto* parsed_config = |
|
|
|
|
static_cast<internal::ClientChannelGlobalParsedConfig*>( |
|
|
|
@ -604,7 +644,7 @@ TEST_F(ClientChannelParserTest, ValidLoadBalancingPolicyAllCaps) { |
|
|
|
|
TEST_F(ClientChannelParserTest, UnknownLoadBalancingPolicy) { |
|
|
|
|
const char* test_json = "{\"loadBalancingPolicy\":\"unknown\"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -618,7 +658,7 @@ TEST_F(ClientChannelParserTest, LoadBalancingPolicyXdsNotAllowed) { |
|
|
|
|
const char* test_json = |
|
|
|
|
"{\"loadBalancingPolicy\":\"xds_cluster_resolver_experimental\"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -641,7 +681,7 @@ TEST_F(ClientChannelParserTest, ValidTimeout) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( |
|
|
|
|
grpc_slice_from_static_string("/TestServ/TestMethod")); |
|
|
|
@ -664,7 +704,7 @@ TEST_F(ClientChannelParserTest, InvalidTimeout) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -686,7 +726,7 @@ TEST_F(ClientChannelParserTest, ValidWaitForReady) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( |
|
|
|
|
grpc_slice_from_static_string("/TestServ/TestMethod")); |
|
|
|
@ -713,7 +753,7 @@ TEST_F(ClientChannelParserTest, InvalidWaitForReady) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -731,7 +771,7 @@ TEST_F(ClientChannelParserTest, ValidHealthCheck) { |
|
|
|
|
" }\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
const auto* parsed_config = |
|
|
|
|
static_cast<internal::ClientChannelGlobalParsedConfig*>( |
|
|
|
@ -752,7 +792,7 @@ TEST_F(ClientChannelParserTest, InvalidHealthCheckMultipleEntries) { |
|
|
|
|
" }\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"JSON parsing failed" CHILD_ERROR_TAG |
|
|
|
@ -767,10 +807,14 @@ TEST_F(ClientChannelParserTest, InvalidHealthCheckMultipleEntries) { |
|
|
|
|
class RetryParserTest : public ::testing::Test { |
|
|
|
|
protected: |
|
|
|
|
void SetUp() override { |
|
|
|
|
ServiceConfigParserShutdown(); |
|
|
|
|
ServiceConfigParserInit(); |
|
|
|
|
EXPECT_EQ(ServiceConfigParser::RegisterParser( |
|
|
|
|
absl::make_unique<internal::RetryServiceConfigParser>()), |
|
|
|
|
CoreConfiguration::Reset(); |
|
|
|
|
CoreConfiguration::BuildSpecialConfiguration( |
|
|
|
|
[](CoreConfiguration::Builder* builder) { |
|
|
|
|
builder->service_config_parser()->RegisterParser( |
|
|
|
|
absl::make_unique<internal::RetryServiceConfigParser>()); |
|
|
|
|
}); |
|
|
|
|
EXPECT_EQ(CoreConfiguration::Get().service_config_parser().GetParserIndex( |
|
|
|
|
"retry"), |
|
|
|
|
0); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
@ -784,7 +828,7 @@ TEST_F(RetryParserTest, ValidRetryThrottling) { |
|
|
|
|
" }\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
const auto* parsed_config = static_cast<internal::RetryGlobalConfig*>( |
|
|
|
|
svc_cfg->GetGlobalParsedConfig(0)); |
|
|
|
@ -800,7 +844,7 @@ TEST_F(RetryParserTest, RetryThrottlingMissingFields) { |
|
|
|
|
" }\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT( |
|
|
|
|
grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
@ -820,7 +864,7 @@ TEST_F(RetryParserTest, InvalidRetryThrottlingNegativeMaxTokens) { |
|
|
|
|
" }\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT( |
|
|
|
|
grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
@ -840,7 +884,7 @@ TEST_F(RetryParserTest, InvalidRetryThrottlingInvalidTokenRatio) { |
|
|
|
|
" }\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT( |
|
|
|
|
grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex("Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -868,7 +912,7 @@ TEST_F(RetryParserTest, ValidRetryPolicy) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( |
|
|
|
|
grpc_slice_from_static_string("/TestServ/TestMethod")); |
|
|
|
@ -896,7 +940,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyWrongType) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -918,7 +962,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyRequiredFieldsMissing) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -948,7 +992,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyMaxAttemptsWrongType) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -975,7 +1019,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyMaxAttemptsBadValue) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -1002,7 +1046,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyInitialBackoffWrongType) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -1030,7 +1074,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyInitialBackoffBadValue) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -1057,7 +1101,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyMaxBackoffWrongType) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -1085,7 +1129,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyMaxBackoffBadValue) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -1112,7 +1156,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyBackoffMultiplierWrongType) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -1139,7 +1183,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyBackoffMultiplierBadValue) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -1166,7 +1210,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyEmptyRetryableStatusCodes) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -1193,7 +1237,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyRetryableStatusCodesWrongType) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -1220,7 +1264,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyUnparseableRetryableStatusCodes) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -1253,7 +1297,7 @@ TEST_F(RetryParserTest, ValidRetryPolicyWithPerAttemptRecvTimeout) { |
|
|
|
|
grpc_arg arg = grpc_channel_arg_integer_create( |
|
|
|
|
const_cast<char*>(GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING), 1); |
|
|
|
|
grpc_channel_args args = {1, &arg}; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(&args, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(&args, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( |
|
|
|
|
grpc_slice_from_static_string("/TestServ/TestMethod")); |
|
|
|
@ -1289,7 +1333,7 @@ TEST_F(RetryParserTest, |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( |
|
|
|
|
grpc_slice_from_static_string("/TestServ/TestMethod")); |
|
|
|
@ -1327,7 +1371,7 @@ TEST_F(RetryParserTest, |
|
|
|
|
grpc_arg arg = grpc_channel_arg_integer_create( |
|
|
|
|
const_cast<char*>(GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING), 1); |
|
|
|
|
grpc_channel_args args = {1, &arg}; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(&args, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(&args, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( |
|
|
|
|
grpc_slice_from_static_string("/TestServ/TestMethod")); |
|
|
|
@ -1364,7 +1408,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyPerAttemptRecvTimeoutUnparseable) { |
|
|
|
|
grpc_arg arg = grpc_channel_arg_integer_create( |
|
|
|
|
const_cast<char*>(GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING), 1); |
|
|
|
|
grpc_channel_args args = {1, &arg}; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(&args, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(&args, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -1396,7 +1440,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyPerAttemptRecvTimeoutWrongType) { |
|
|
|
|
grpc_arg arg = grpc_channel_arg_integer_create( |
|
|
|
|
const_cast<char*>(GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING), 1); |
|
|
|
|
grpc_channel_args args = {1, &arg}; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(&args, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(&args, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -1428,7 +1472,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyPerAttemptRecvTimeoutBadValue) { |
|
|
|
|
grpc_arg arg = grpc_channel_arg_integer_create( |
|
|
|
|
const_cast<char*>(GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING), 1); |
|
|
|
|
grpc_channel_args args = {1, &arg}; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(&args, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(&args, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -1445,10 +1489,14 @@ TEST_F(RetryParserTest, InvalidRetryPolicyPerAttemptRecvTimeoutBadValue) { |
|
|
|
|
class MessageSizeParserTest : public ::testing::Test { |
|
|
|
|
protected: |
|
|
|
|
void SetUp() override { |
|
|
|
|
ServiceConfigParserShutdown(); |
|
|
|
|
ServiceConfigParserInit(); |
|
|
|
|
EXPECT_EQ(ServiceConfigParser::RegisterParser( |
|
|
|
|
absl::make_unique<MessageSizeParser>()), |
|
|
|
|
CoreConfiguration::Reset(); |
|
|
|
|
CoreConfiguration::BuildSpecialConfiguration( |
|
|
|
|
[](CoreConfiguration::Builder* builder) { |
|
|
|
|
builder->service_config_parser()->RegisterParser( |
|
|
|
|
absl::make_unique<MessageSizeParser>()); |
|
|
|
|
}); |
|
|
|
|
EXPECT_EQ(CoreConfiguration::Get().service_config_parser().GetParserIndex( |
|
|
|
|
"message_size"), |
|
|
|
|
0); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
@ -1465,7 +1513,7 @@ TEST_F(MessageSizeParserTest, Valid) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); |
|
|
|
|
const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( |
|
|
|
|
grpc_slice_from_static_string("/TestServ/TestMethod")); |
|
|
|
@ -1488,7 +1536,7 @@ TEST_F(MessageSizeParserTest, InvalidMaxRequestMessageBytes) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
@ -1509,7 +1557,7 @@ TEST_F(MessageSizeParserTest, InvalidMaxResponseMessageBytes) { |
|
|
|
|
" } ]\n" |
|
|
|
|
"}"; |
|
|
|
|
grpc_error_handle error = GRPC_ERROR_NONE; |
|
|
|
|
auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); |
|
|
|
|
auto svc_cfg = ServiceConfigImpl::Create(nullptr, test_json, &error); |
|
|
|
|
EXPECT_THAT(grpc_error_std_string(error), |
|
|
|
|
::testing::ContainsRegex( |
|
|
|
|
"Service config parsing error" CHILD_ERROR_TAG |
|
|
|
|