MCPcopy
hub / github.com/grpc/grpc-go / testClientBinaryLog

Function testClientBinaryLog

binarylog/binarylog_end2end_test.go:824–861  ·  view source on GitHub ↗
(t *testing.T, c *rpcConfig)

Source from the content-addressed store, hash-verified

822}
823
824func testClientBinaryLog(t *testing.T, c *rpcConfig) error {
825 defer testSink.clear()
826 expect := runRPCs(t, c)
827 want := expect.toClientLogEntries()
828 var got []*binlogpb.GrpcLogEntry
829 // In racy cases, some entries are not logged when the RPC is finished (e.g.
830 // context.Cancel).
831 //
832 // Check 10 times, with a sleep of 1/100 seconds between each check. Makes
833 // it an 1-second wait in total.
834 for i := 0; i < 10; i++ {
835 got = testSink.logEntries(true) // all client entries.
836 if len(want) == len(got) {
837 break
838 }
839 time.Sleep(100 * time.Millisecond)
840 }
841 if len(want) != len(got) {
842 for i, e := range want {
843 t.Errorf("in want: %d, %s", i, e.GetType())
844 }
845 for i, e := range got {
846 t.Errorf("in got: %d, %s", i, e.GetType())
847 }
848 return fmt.Errorf("didn't get same amount of log entries, want: %d, got: %d", len(want), len(got))
849 }
850 var errored bool
851 for i := 0; i < len(got); i++ {
852 if !equalLogEntry(want[i], got[i]) {
853 t.Errorf("entry: %d, want %+v, got %+v", i, want[i], got[i])
854 errored = true
855 }
856 }
857 if errored {
858 return fmt.Errorf("test failed")
859 }
860 return nil
861}
862
863func (s) TestClientBinaryLogUnaryRPC(t *testing.T) {
864 if err := testClientBinaryLog(t, &rpcConfig{success: true, callType: unaryRPC}); err != nil {

Calls 7

runRPCsFunction · 0.85
equalLogEntryFunction · 0.85
toClientLogEntriesMethod · 0.80
logEntriesMethod · 0.80
ErrorfMethod · 0.65
clearMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected