(t *testing.T)
| 65 | } |
| 66 | |
| 67 | func (s) TestCZServerRegistrationAndDeletion(t *testing.T) { |
| 68 | testcases := []struct { |
| 69 | total int |
| 70 | start int64 |
| 71 | max int |
| 72 | length int |
| 73 | end bool |
| 74 | }{ |
| 75 | {total: int(channelz.EntriesPerPage), start: 0, max: 0, length: channelz.EntriesPerPage, end: true}, |
| 76 | {total: int(channelz.EntriesPerPage) - 1, start: 0, max: 0, length: channelz.EntriesPerPage - 1, end: true}, |
| 77 | {total: int(channelz.EntriesPerPage) + 1, start: 0, max: 0, length: channelz.EntriesPerPage, end: false}, |
| 78 | {total: int(channelz.EntriesPerPage) + 1, start: int64(2*(channelz.EntriesPerPage+1) + 1), max: 0, length: 0, end: true}, |
| 79 | {total: int(channelz.EntriesPerPage), start: 0, max: 1, length: 1, end: false}, |
| 80 | {total: int(channelz.EntriesPerPage), start: 0, max: channelz.EntriesPerPage - 1, length: channelz.EntriesPerPage - 1, end: false}, |
| 81 | } |
| 82 | |
| 83 | for i, c := range testcases { |
| 84 | // Reset channelz IDs so `start` is valid. |
| 85 | channelz.IDGen.Reset() |
| 86 | |
| 87 | e := tcpClearRREnv |
| 88 | te := newTest(t, e) |
| 89 | te.startServers(&testServer{security: e.security}, c.total) |
| 90 | |
| 91 | ss, end := channelz.GetServers(c.start, c.max) |
| 92 | if len(ss) != c.length || end != c.end { |
| 93 | t.Fatalf("%d: GetServers(%d) = %+v (len of which: %d), end: %+v, want len(GetServers(%d)) = %d, end: %+v", i, c.start, ss, len(ss), end, c.start, c.length, c.end) |
| 94 | } |
| 95 | te.tearDown() |
| 96 | ss, end = channelz.GetServers(c.start, c.max) |
| 97 | if len(ss) != 0 || !end { |
| 98 | t.Fatalf("%d: GetServers(0) = %+v (len of which: %d), end: %+v, want len(GetServers(0)) = 0, end: true", i, ss, len(ss), end) |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | func (s) TestCZGetChannel(t *testing.T) { |
| 104 | e := tcpClearRREnv |
nothing calls this directly
no test coverage detected