|
|
@ -161,7 +161,7 @@ class GrpcLBAddress final { |
|
|
|
|
|
|
|
|
|
|
|
vector<GrpcLBAddress> ParseExpectedAddrs(std::string expected_addrs) { |
|
|
|
vector<GrpcLBAddress> ParseExpectedAddrs(std::string expected_addrs) { |
|
|
|
std::vector<GrpcLBAddress> out; |
|
|
|
std::vector<GrpcLBAddress> out; |
|
|
|
while (expected_addrs.size() != 0) { |
|
|
|
while (!expected_addrs.empty()) { |
|
|
|
// get the next <ip>,<port> (v4 or v6)
|
|
|
|
// get the next <ip>,<port> (v4 or v6)
|
|
|
|
size_t next_comma = expected_addrs.find(','); |
|
|
|
size_t next_comma = expected_addrs.find(','); |
|
|
|
if (next_comma == std::string::npos) { |
|
|
|
if (next_comma == std::string::npos) { |
|
|
@ -185,7 +185,7 @@ vector<GrpcLBAddress> ParseExpectedAddrs(std::string expected_addrs) { |
|
|
|
expected_addrs = |
|
|
|
expected_addrs = |
|
|
|
expected_addrs.substr(next_semicolon + 1, std::string::npos); |
|
|
|
expected_addrs.substr(next_semicolon + 1, std::string::npos); |
|
|
|
} |
|
|
|
} |
|
|
|
if (out.size() == 0) { |
|
|
|
if (out.empty()) { |
|
|
|
gpr_log(GPR_ERROR, |
|
|
|
gpr_log(GPR_ERROR, |
|
|
|
"expected_addrs arg should be a semicolon-separated list of " |
|
|
|
"expected_addrs arg should be a semicolon-separated list of " |
|
|
|
"<ip-port>,<bool> pairs"); |
|
|
|
"<ip-port>,<bool> pairs"); |
|
|
@ -275,11 +275,11 @@ void PollPollsetUntilRequestDone(ArgsStruct* args) { |
|
|
|
void CheckServiceConfigResultLocked(const char* service_config_json, |
|
|
|
void CheckServiceConfigResultLocked(const char* service_config_json, |
|
|
|
grpc_error* service_config_error, |
|
|
|
grpc_error* service_config_error, |
|
|
|
ArgsStruct* args) { |
|
|
|
ArgsStruct* args) { |
|
|
|
if (args->expected_service_config_string != "") { |
|
|
|
if (!args->expected_service_config_string.empty()) { |
|
|
|
GPR_ASSERT(service_config_json != nullptr); |
|
|
|
GPR_ASSERT(service_config_json != nullptr); |
|
|
|
EXPECT_EQ(service_config_json, args->expected_service_config_string); |
|
|
|
EXPECT_EQ(service_config_json, args->expected_service_config_string); |
|
|
|
} |
|
|
|
} |
|
|
|
if (args->expected_service_config_error == "") { |
|
|
|
if (args->expected_service_config_error.empty()) { |
|
|
|
EXPECT_EQ(service_config_error, GRPC_ERROR_NONE); |
|
|
|
EXPECT_EQ(service_config_error, GRPC_ERROR_NONE); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
EXPECT_THAT(grpc_error_string(service_config_error), |
|
|
|
EXPECT_THAT(grpc_error_string(service_config_error), |
|
|
@ -292,7 +292,7 @@ void CheckLBPolicyResultLocked(const grpc_channel_args* channel_args, |
|
|
|
ArgsStruct* args) { |
|
|
|
ArgsStruct* args) { |
|
|
|
const grpc_arg* lb_policy_arg = |
|
|
|
const grpc_arg* lb_policy_arg = |
|
|
|
grpc_channel_args_find(channel_args, GRPC_ARG_LB_POLICY_NAME); |
|
|
|
grpc_channel_args_find(channel_args, GRPC_ARG_LB_POLICY_NAME); |
|
|
|
if (args->expected_lb_policy != "") { |
|
|
|
if (!args->expected_lb_policy.empty()) { |
|
|
|
GPR_ASSERT(lb_policy_arg != nullptr); |
|
|
|
GPR_ASSERT(lb_policy_arg != nullptr); |
|
|
|
GPR_ASSERT(lb_policy_arg->type == GRPC_ARG_STRING); |
|
|
|
GPR_ASSERT(lb_policy_arg->type == GRPC_ARG_STRING); |
|
|
|
EXPECT_EQ(lb_policy_arg->value.string, args->expected_lb_policy); |
|
|
|
EXPECT_EQ(lb_policy_arg->value.string, args->expected_lb_policy); |
|
|
@ -513,7 +513,7 @@ class CheckingResultHandler : public ResultHandler { |
|
|
|
: result.service_config->json_string().c_str(); |
|
|
|
: result.service_config->json_string().c_str(); |
|
|
|
CheckServiceConfigResultLocked( |
|
|
|
CheckServiceConfigResultLocked( |
|
|
|
service_config_json, GRPC_ERROR_REF(result.service_config_error), args); |
|
|
|
service_config_json, GRPC_ERROR_REF(result.service_config_error), args); |
|
|
|
if (args->expected_service_config_string == "") { |
|
|
|
if (args->expected_service_config_string.empty()) { |
|
|
|
CheckLBPolicyResultLocked(result.args, args); |
|
|
|
CheckLBPolicyResultLocked(result.args, args); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -678,7 +678,7 @@ int main(int argc, char** argv) { |
|
|
|
grpc::testing::TestEnvironment env(argc, argv); |
|
|
|
grpc::testing::TestEnvironment env(argc, argv); |
|
|
|
::testing::InitGoogleTest(&argc, argv); |
|
|
|
::testing::InitGoogleTest(&argc, argv); |
|
|
|
grpc::testing::InitTest(&argc, &argv, true); |
|
|
|
grpc::testing::InitTest(&argc, &argv, true); |
|
|
|
if (FLAGS_target_name == "") { |
|
|
|
if (FLAGS_target_name.empty()) { |
|
|
|
gpr_log(GPR_ERROR, "Missing target_name param."); |
|
|
|
gpr_log(GPR_ERROR, "Missing target_name param."); |
|
|
|
abort(); |
|
|
|
abort(); |
|
|
|
} |
|
|
|
} |
|
|
|