(t *testing.T, c *rpcConfig)
| 822 | } |
| 823 | |
| 824 | func 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 | |
| 863 | func (s) TestClientBinaryLogUnaryRPC(t *testing.T) { |
| 864 | if err := testClientBinaryLog(t, &rpcConfig{success: true, callType: unaryRPC}); err != nil { |
no test coverage detected