feat: support send report to a gRPC server#431
Conversation
|
why closed it? |
sry, commit record may be a bit confusing, please check it first |
| UnimplementedReportWriterServer | ||
| } | ||
|
|
||
| func (s *ReportServer) SendReportResult(ctx context.Context, req *ReportResultRepeated) (*Empty, error) { |
There was a problem hiding this comment.
this server is used for testing, when receiving the report, it will print it.
|
|
I tried to test it but failed. Please let me know if I missed anything. atest run --report grpc -p sample/testsuite-gitee.yaml --report-dest 127.0.0.1:7070/writer_templates.ReportWriter/SendReportResult
2024-05-17T04:33:56.903Z INFO loader testing/loader_file.go:140 sample/testsuite-gitee.yaml {"pattern": 1}
found suites: 1
start to run: 'stargazers'
start to send request to https://gitee.com/api/v5/repos/linuxsuren/api-testing/stargazers
start to run: 'branches'
start to send request to https://gitee.com/api/v5/repos/linuxsuren/api-testing/branches
start to run: 'branch'
start to send request to https://gitee.com/api/v5/repos/linuxsuren/api-testing/branches/feat/metrics
2024-05-17T04:34:00.010Z INFO run cmd/run.go:300 routing end with {"time": "3.106349975s"}
2024/05/17 04:34:00 will send report to:127.0.0.1:7070
failed to Output all reports proto: not found
Consumed: 3.108572285s |
I think you need to start a grpc test server with reflection locally, like this: package main
import (
"fmt"
"log"
"net"
testWriter "github.com/linuxsuren/api-testing/pkg/runner/writer_templates"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/reflection"
"google.golang.org/grpc/status"
)
func main() {
s := grpc.NewServer()
testServer := &testWriter.ReportServer{}
testWriter.RegisterReportWriterServer(s, testServer)
reflection.RegisterV1(s)
lis, err := net.Listen("tcp", ":7070")
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
fmt.Println("Server listening on port: 7070")
if err := s.Serve(lis); err != nil {
status.Errorf(codes.Unknown, "serve error: %v", err)
}
}and then, run: I can get result like this: |
LinuxSuRen
left a comment
There was a problem hiding this comment.
LGTM
And welcome to be the 21st contributor!
I'm very glad to contribute to the project! |




What type of PR is this?
feat: support send report to a gRPC server
What this PR does / why we need it:
User can send report to a gRPC server with reflection.
Which issue(s) this PR fixes:
Fixes #92