找不到服务 - GHZ 以加载测试 GRPC 服务



我正在尝试使用GHZ测试GRPC服务。但是,我收到错误 - 找不到服务"com.server.grpc.Executor">

Config.json 文件:

"proto": "/Users/dev/Desktop/ghz/execute.proto",
"call": "com.server.grpc.Executor.execute",
"total": 2000,
"concurrency": 50,
"data": {
"param1": "test-data1",
"param2": "test-data2",
},
"max-duration": "10s",
"host": "<ip-address>:9090",
"c": 10,
"n": 200
}

原型文件:


option java_package= "com.server.grpc";
option java_multiple_files = true;

service Executor  {
rpc execute(ExecuteRequest) returns (ExecuteResponse);
}

message ExecuteRequest {
string param1 = 1;
string param2= 2;
}
message ExecuteResponse {
bool res = 1;
string msg = 2;
}

运行以下命令:ghz --config=/config.json

我错过了什么吗?

你的protobuf文件应该包含例如:

syntax = "proto3";
package example;
...

然后,您的服务将通过example.Executor.execute而不是com.server.grpc.Execute.execute完全限定,这是一个特定于语言的(我假设,您的option是Java)的完全限定名称。

我假设您无意中省略了 JSON 文件的左大括号 ({),但这当然是必需的。

JSON 正在挑战您的"param2": "test-data2"不得以,结尾,因为它是列表中的最后一项;因此请删除该逗号。

{
"proto": "/Users/dev/Desktop/ghz/execute.proto",
"call": "example.Executor.execute",
"total": 2000,
"concurrency": 50,
"data": {
"param1": "test-data1",
"param2": "test-data2"
},
"max-duration": "10s",
"host": "<ip-address>:9090",
"c": 10,
"n": 200
}

假设您的服务在<ip-address>:9090上运行,那么应该可以工作!

最新更新