(t *testing.T, got []*gotData, expect *expectedData, checkFuncs map[int]*checkFuncWithCount)
| 1042 | } |
| 1043 | |
| 1044 | func checkClientStats(t *testing.T, got []*gotData, expect *expectedData, checkFuncs map[int]*checkFuncWithCount) { |
| 1045 | var expectLen int |
| 1046 | for _, v := range checkFuncs { |
| 1047 | expectLen += v.c |
| 1048 | } |
| 1049 | if len(got) != expectLen { |
| 1050 | for i, g := range got { |
| 1051 | t.Errorf(" - %v, %T", i, g.s) |
| 1052 | } |
| 1053 | t.Fatalf("got %v stats, want %v stats", len(got), expectLen) |
| 1054 | } |
| 1055 | |
| 1056 | var tagInfoInCtx *stats.RPCTagInfo |
| 1057 | for i := 0; i < len(got); i++ { |
| 1058 | if _, ok := got[i].s.(stats.RPCStats); ok { |
| 1059 | tagInfoInCtxNew, _ := got[i].ctx.Value(rpcCtxKey{}).(*stats.RPCTagInfo) |
| 1060 | if tagInfoInCtx != nil && tagInfoInCtx != tagInfoInCtxNew { |
| 1061 | t.Fatalf("got context containing different tagInfo with stats %T", got[i].s) |
| 1062 | } |
| 1063 | tagInfoInCtx = tagInfoInCtxNew |
| 1064 | } |
| 1065 | } |
| 1066 | |
| 1067 | for _, s := range got { |
| 1068 | switch s.s.(type) { |
| 1069 | case *stats.Begin: |
| 1070 | if checkFuncs[begin].c <= 0 { |
| 1071 | t.Fatalf("unexpected stats: %T", s.s) |
| 1072 | } |
| 1073 | checkFuncs[begin].f(t, s, expect) |
| 1074 | checkFuncs[begin].c-- |
| 1075 | case *stats.OutHeader: |
| 1076 | if checkFuncs[outHeader].c <= 0 { |
| 1077 | t.Fatalf("unexpected stats: %T", s.s) |
| 1078 | } |
| 1079 | checkFuncs[outHeader].f(t, s, expect) |
| 1080 | checkFuncs[outHeader].c-- |
| 1081 | case *stats.OutPayload: |
| 1082 | if checkFuncs[outPayload].c <= 0 { |
| 1083 | t.Fatalf("unexpected stats: %T", s.s) |
| 1084 | } |
| 1085 | checkFuncs[outPayload].f(t, s, expect) |
| 1086 | checkFuncs[outPayload].c-- |
| 1087 | case *stats.InHeader: |
| 1088 | if checkFuncs[inHeader].c <= 0 { |
| 1089 | t.Fatalf("unexpected stats: %T", s.s) |
| 1090 | } |
| 1091 | checkFuncs[inHeader].f(t, s, expect) |
| 1092 | checkFuncs[inHeader].c-- |
| 1093 | case *stats.InPayload: |
| 1094 | if checkFuncs[inPayload].c <= 0 { |
| 1095 | t.Fatalf("unexpected stats: %T", s.s) |
| 1096 | } |
| 1097 | checkFuncs[inPayload].f(t, s, expect) |
| 1098 | checkFuncs[inPayload].c-- |
| 1099 | case *stats.InTrailer: |
| 1100 | if checkFuncs[inTrailer].c <= 0 { |
| 1101 | t.Fatalf("unexpected stats: %T", s.s) |
no test coverage detected