api-testing icon indicating copy to clipboard operation
api-testing copied to clipboard

Support sending test report to a gRPC server

Open LinuxSuRen opened this issue 2 years ago • 8 comments

Sometimes, we might want to send the test report to a gRPC server.

How to

It's easy to do this. Please implement the following interface first:

https://github.com/LinuxSuRen/api-testing/blob/2520e80a9ce1caf49f84973598747eee71d363ae/pkg/runner/simple.go#L161

then, add the corresponding CLI flag.

https://github.com/LinuxSuRen/api-testing/blob/2520e80a9ce1caf49f84973598747eee71d363ae/cmd/run.go#L74

Similar issues

  • https://github.com/LinuxSuRen/api-testing/issues/91

How to test

We could try to send the test report to etcd.

LinuxSuRen avatar Jun 15 '23 14:06 LinuxSuRen

Hello, I would like to have a try🙋🏻‍♀️ on this issue!

lizzy-0323 avatar May 09 '24 11:05 lizzy-0323

I'm looking forward it.

LinuxSuRen avatar May 09 '24 12:05 LinuxSuRen

我的思路: 定义一个grpcResultWriter去实现接口,结构体需要有grpc server的url以及protobuf文件存放的文件地址, 根据proto文件存放的地址来建立对应的grpc客户端,在此过程中,无需关注[]ReportResult的具体内容。 测试思路: 运行单机etcd服务,调用etcd客户端api上传报告(不过目前不太了解etcd,后续还得再看看) 请问我的思路正确吗?

lizzy-0323 avatar May 11 '24 01:05 lizzy-0323

您好,思路是没问题的。测试的时候,不一定要找 etcd,这个可能会稍微复杂点。理论上,随便实现一个(或找个现成的)gRPC 服务就可以完成测试。

LinuxSuRen avatar May 11 '24 01:05 LinuxSuRen

您好,请问编写的protobuf文件和生成的代码部分应该存放在哪个文件夹下呢? 另外,应该可以直接采用grpc.go文件中的invokeRequest函数来发起请求?

lizzy-0323 avatar May 12 '24 05:05 lizzy-0323

我的理解是 protobuf 是来自第三方系统(例如:etcd),可以调用 invokeRequest(或者需要重构)来实现调用,而不需要生成代码,反射的方式会比较好一些。因为,我们无法预知会调用哪些 gRPC 服务,可能会有各种不同的,无法把哪些 proto 以及代码都保存下来。

LinuxSuRen avatar May 12 '24 09:05 LinuxSuRen

好的,我大概了解了,这样的话核心任务应该是根据grpc.go中的一些方法进行重构,完成grpc通信里建立连接,获取文件描述符以及protobuf和json转换相关的操作。

lizzy-0323 avatar May 12 '24 09:05 lizzy-0323

嗯嗯,其实就是一个通用型的 gRPC 请求调用,把我们相对固定的数据发送过去。

LinuxSuRen avatar May 12 '24 10:05 LinuxSuRen