(t *testing.T)
| 250 | } |
| 251 | |
| 252 | func (s) TestCZTopChannelRegistrationAndDeletion(t *testing.T) { |
| 253 | testcases := []struct { |
| 254 | total int |
| 255 | start int64 |
| 256 | max int |
| 257 | length int |
| 258 | end bool |
| 259 | }{ |
| 260 | {total: int(channelz.EntriesPerPage), start: 0, max: 0, length: channelz.EntriesPerPage, end: true}, |
| 261 | {total: int(channelz.EntriesPerPage) - 1, start: 0, max: 0, length: channelz.EntriesPerPage - 1, end: true}, |
| 262 | {total: int(channelz.EntriesPerPage) + 1, start: 0, max: 0, length: channelz.EntriesPerPage, end: false}, |
| 263 | {total: int(channelz.EntriesPerPage) + 1, start: int64(2*(channelz.EntriesPerPage+1) + 1), max: 0, length: 0, end: true}, |
| 264 | {total: int(channelz.EntriesPerPage), start: 0, max: 1, length: 1, end: false}, |
| 265 | {total: int(channelz.EntriesPerPage), start: 0, max: channelz.EntriesPerPage - 1, length: channelz.EntriesPerPage - 1, end: false}, |
| 266 | } |
| 267 | |
| 268 | for _, c := range testcases { |
| 269 | // Reset channelz IDs so `start` is valid. |
| 270 | channelz.IDGen.Reset() |
| 271 | |
| 272 | e := tcpClearRREnv |
| 273 | te := newTest(t, e) |
| 274 | var ccs []*grpc.ClientConn |
| 275 | for i := 0; i < c.total; i++ { |
| 276 | cc := te.clientConn() |
| 277 | te.cc = nil |
| 278 | // avoid making next dial blocking |
| 279 | te.srvAddr = "" |
| 280 | ccs = append(ccs, cc) |
| 281 | } |
| 282 | if err := verifyResultWithDelay(func() (bool, error) { |
| 283 | if tcs, end := channelz.GetTopChannels(c.start, c.max); len(tcs) != c.length || end != c.end { |
| 284 | return false, fmt.Errorf("getTopChannels(%d) = %+v (len of which: %d), end: %+v, want len(GetTopChannels(%d)) = %d, end: %+v", c.start, tcs, len(tcs), end, c.start, c.length, c.end) |
| 285 | } |
| 286 | return true, nil |
| 287 | }); err != nil { |
| 288 | t.Fatal(err) |
| 289 | } |
| 290 | |
| 291 | for _, cc := range ccs { |
| 292 | cc.Close() |
| 293 | } |
| 294 | |
| 295 | if err := verifyResultWithDelay(func() (bool, error) { |
| 296 | if tcs, end := channelz.GetTopChannels(c.start, c.max); len(tcs) != 0 || !end { |
| 297 | return false, fmt.Errorf("getTopChannels(0) = %+v (len of which: %d), end: %+v, want len(GetTopChannels(0)) = 0, end: true", tcs, len(tcs), end) |
| 298 | } |
| 299 | return true, nil |
| 300 | }); err != nil { |
| 301 | t.Fatal(err) |
| 302 | } |
| 303 | te.tearDown() |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | func (s) TestCZTopChannelRegistrationAndDeletionWhenNewClientFail(t *testing.T) { |
| 308 | // Make newclient fails (due to no transport security specified) |
nothing calls this directly
no test coverage detected