|
|
@ -72,13 +72,16 @@ func TestCZServerRegistrationAndDeletion(t *testing.T) {
|
|
|
|
testcases := []struct {
|
|
|
|
testcases := []struct {
|
|
|
|
total int
|
|
|
|
total int
|
|
|
|
start int64
|
|
|
|
start int64
|
|
|
|
length int
|
|
|
|
max int64
|
|
|
|
|
|
|
|
length int64
|
|
|
|
end bool
|
|
|
|
end bool
|
|
|
|
}{
|
|
|
|
}{
|
|
|
|
{total: channelz.EntryPerPage, start: 0, length: channelz.EntryPerPage, end: true},
|
|
|
|
{total: int(channelz.EntryPerPage), start: 0, max: 0, length: channelz.EntryPerPage, end: true},
|
|
|
|
{total: channelz.EntryPerPage - 1, start: 0, length: channelz.EntryPerPage - 1, end: true},
|
|
|
|
{total: int(channelz.EntryPerPage) - 1, start: 0, max: 0, length: channelz.EntryPerPage - 1, end: true},
|
|
|
|
{total: channelz.EntryPerPage + 1, start: 0, length: channelz.EntryPerPage, end: false},
|
|
|
|
{total: int(channelz.EntryPerPage) + 1, start: 0, max: 0, length: channelz.EntryPerPage, end: false},
|
|
|
|
{total: channelz.EntryPerPage + 1, start: int64(2*(channelz.EntryPerPage+1) + 1), length: 0, end: true},
|
|
|
|
{total: int(channelz.EntryPerPage) + 1, start: int64(2*(channelz.EntryPerPage+1) + 1), max: 0, length: 0, end: true},
|
|
|
|
|
|
|
|
{total: int(channelz.EntryPerPage), start: 0, max: 1, length: 1, end: false},
|
|
|
|
|
|
|
|
{total: int(channelz.EntryPerPage), start: 0, max: channelz.EntryPerPage - 1, length: channelz.EntryPerPage - 1, end: false},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, c := range testcases {
|
|
|
|
for _, c := range testcases {
|
|
|
@ -87,12 +90,12 @@ func TestCZServerRegistrationAndDeletion(t *testing.T) {
|
|
|
|
te := newTest(t, e)
|
|
|
|
te := newTest(t, e)
|
|
|
|
te.startServers(&testServer{security: e.security}, c.total)
|
|
|
|
te.startServers(&testServer{security: e.security}, c.total)
|
|
|
|
|
|
|
|
|
|
|
|
ss, end := channelz.GetServers(c.start)
|
|
|
|
ss, end := channelz.GetServers(c.start, c.max)
|
|
|
|
if len(ss) != c.length || end != c.end {
|
|
|
|
if int64(len(ss)) != c.length || end != c.end {
|
|
|
|
t.Fatalf("GetServers(%d) = %+v (len of which: %d), end: %+v, want len(GetServers(%d)) = %d, end: %+v", c.start, ss, len(ss), end, c.start, c.length, c.end)
|
|
|
|
t.Fatalf("GetServers(%d) = %+v (len of which: %d), end: %+v, want len(GetServers(%d)) = %d, end: %+v", c.start, ss, len(ss), end, c.start, c.length, c.end)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
te.tearDown()
|
|
|
|
te.tearDown()
|
|
|
|
ss, end = channelz.GetServers(c.start)
|
|
|
|
ss, end = channelz.GetServers(c.start, c.max)
|
|
|
|
if len(ss) != 0 || !end {
|
|
|
|
if len(ss) != 0 || !end {
|
|
|
|
t.Fatalf("GetServers(0) = %+v (len of which: %d), end: %+v, want len(GetServers(0)) = 0, end: true", ss, len(ss), end)
|
|
|
|
t.Fatalf("GetServers(0) = %+v (len of which: %d), end: %+v, want len(GetServers(0)) = 0, end: true", ss, len(ss), end)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -104,13 +107,16 @@ func TestCZTopChannelRegistrationAndDeletion(t *testing.T) {
|
|
|
|
testcases := []struct {
|
|
|
|
testcases := []struct {
|
|
|
|
total int
|
|
|
|
total int
|
|
|
|
start int64
|
|
|
|
start int64
|
|
|
|
length int
|
|
|
|
max int64
|
|
|
|
|
|
|
|
length int64
|
|
|
|
end bool
|
|
|
|
end bool
|
|
|
|
}{
|
|
|
|
}{
|
|
|
|
{total: channelz.EntryPerPage, start: 0, length: channelz.EntryPerPage, end: true},
|
|
|
|
{total: int(channelz.EntryPerPage), start: 0, max: 0, length: channelz.EntryPerPage, end: true},
|
|
|
|
{total: channelz.EntryPerPage - 1, start: 0, length: channelz.EntryPerPage - 1, end: true},
|
|
|
|
{total: int(channelz.EntryPerPage) - 1, start: 0, max: 0, length: channelz.EntryPerPage - 1, end: true},
|
|
|
|
{total: channelz.EntryPerPage + 1, start: 0, length: channelz.EntryPerPage, end: false},
|
|
|
|
{total: int(channelz.EntryPerPage) + 1, start: 0, max: 0, length: channelz.EntryPerPage, end: false},
|
|
|
|
{total: channelz.EntryPerPage + 1, start: int64(2*(channelz.EntryPerPage+1) + 1), length: 0, end: true},
|
|
|
|
{total: int(channelz.EntryPerPage) + 1, start: int64(2*(channelz.EntryPerPage+1) + 1), max: 0, length: 0, end: true},
|
|
|
|
|
|
|
|
{total: int(channelz.EntryPerPage), start: 0, max: 1, length: 1, end: false},
|
|
|
|
|
|
|
|
{total: int(channelz.EntryPerPage), start: 0, max: channelz.EntryPerPage - 1, length: channelz.EntryPerPage - 1, end: false},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, c := range testcases {
|
|
|
|
for _, c := range testcases {
|
|
|
@ -126,7 +132,7 @@ func TestCZTopChannelRegistrationAndDeletion(t *testing.T) {
|
|
|
|
ccs = append(ccs, cc)
|
|
|
|
ccs = append(ccs, cc)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if tcs, end := channelz.GetTopChannels(c.start); len(tcs) != c.length || end != c.end {
|
|
|
|
if tcs, end := channelz.GetTopChannels(c.start, c.max); int64(len(tcs)) != c.length || end != c.end {
|
|
|
|
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)
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true, nil
|
|
|
|
return true, nil
|
|
|
@ -139,7 +145,7 @@ func TestCZTopChannelRegistrationAndDeletion(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if tcs, end := channelz.GetTopChannels(c.start); len(tcs) != 0 || !end {
|
|
|
|
if tcs, end := channelz.GetTopChannels(c.start, c.max); len(tcs) != 0 || !end {
|
|
|
|
return false, fmt.Errorf("getTopChannels(0) = %+v (len of which: %d), end: %+v, want len(GetTopChannels(0)) = 0, end: true", tcs, len(tcs), end)
|
|
|
|
return false, fmt.Errorf("getTopChannels(0) = %+v (len of which: %d), end: %+v, want len(GetTopChannels(0)) = 0, end: true", tcs, len(tcs), end)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true, nil
|
|
|
|
return true, nil
|
|
|
@ -166,7 +172,7 @@ func TestCZNestedChannelRegistrationAndDeletion(t *testing.T) {
|
|
|
|
defer te.tearDown()
|
|
|
|
defer te.tearDown()
|
|
|
|
|
|
|
|
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tcs, _ := channelz.GetTopChannels(0)
|
|
|
|
tcs, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -183,7 +189,7 @@ func TestCZNestedChannelRegistrationAndDeletion(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
// wait for the shutdown of grpclb balancer
|
|
|
|
// wait for the shutdown of grpclb balancer
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tcs, _ := channelz.GetTopChannels(0)
|
|
|
|
tcs, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -216,7 +222,7 @@ func TestCZClientSubChannelSocketRegistrationAndDeletion(t *testing.T) {
|
|
|
|
// Here, we just wait for all sockets to be up. In the future, if we implement
|
|
|
|
// Here, we just wait for all sockets to be up. In the future, if we implement
|
|
|
|
// IDLE, we may need to make several rpc calls to create the sockets.
|
|
|
|
// IDLE, we may need to make several rpc calls to create the sockets.
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tcs, _ := channelz.GetTopChannels(0)
|
|
|
|
tcs, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -243,7 +249,7 @@ func TestCZClientSubChannelSocketRegistrationAndDeletion(t *testing.T) {
|
|
|
|
r.NewAddress(svrAddrs[:len(svrAddrs)-1])
|
|
|
|
r.NewAddress(svrAddrs[:len(svrAddrs)-1])
|
|
|
|
|
|
|
|
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tcs, _ := channelz.GetTopChannels(0)
|
|
|
|
tcs, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -270,52 +276,78 @@ func TestCZClientSubChannelSocketRegistrationAndDeletion(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
func TestCZServerSocketRegistrationAndDeletion(t *testing.T) {
|
|
|
|
func TestCZServerSocketRegistrationAndDeletion(t *testing.T) {
|
|
|
|
defer leakcheck.Check(t)
|
|
|
|
defer leakcheck.Check(t)
|
|
|
|
channelz.NewChannelzStorage()
|
|
|
|
testcases := []struct {
|
|
|
|
e := tcpClearRREnv
|
|
|
|
total int
|
|
|
|
num := 3 // number of clients
|
|
|
|
start int64
|
|
|
|
te := newTest(t, e)
|
|
|
|
max int64
|
|
|
|
te.startServer(&testServer{security: e.security})
|
|
|
|
length int64
|
|
|
|
defer te.tearDown()
|
|
|
|
end bool
|
|
|
|
var ccs []*grpc.ClientConn
|
|
|
|
}{
|
|
|
|
for i := 0; i < num; i++ {
|
|
|
|
{total: int(channelz.EntryPerPage), start: 0, max: 0, length: channelz.EntryPerPage, end: true},
|
|
|
|
cc := te.clientConn()
|
|
|
|
{total: int(channelz.EntryPerPage) - 1, start: 0, max: 0, length: channelz.EntryPerPage - 1, end: true},
|
|
|
|
te.cc = nil
|
|
|
|
{total: int(channelz.EntryPerPage) + 1, start: 0, max: 0, length: channelz.EntryPerPage, end: false},
|
|
|
|
ccs = append(ccs, cc)
|
|
|
|
{total: int(channelz.EntryPerPage), start: 1, max: 0, length: channelz.EntryPerPage - 1, end: true},
|
|
|
|
}
|
|
|
|
{total: int(channelz.EntryPerPage) + 1, start: channelz.EntryPerPage + 1, max: 0, length: 0, end: true},
|
|
|
|
defer func() {
|
|
|
|
{total: int(channelz.EntryPerPage), start: 0, max: 1, length: 1, end: false},
|
|
|
|
for _, c := range ccs[:len(ccs)-1] {
|
|
|
|
{total: int(channelz.EntryPerPage), start: 0, max: channelz.EntryPerPage - 1, length: channelz.EntryPerPage - 1, end: false},
|
|
|
|
c.Close()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
var svrID int64
|
|
|
|
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
|
|
|
|
ss, _ := channelz.GetServers(0)
|
|
|
|
|
|
|
|
if len(ss) != 1 {
|
|
|
|
|
|
|
|
return false, fmt.Errorf("there should only be one server, not %d", len(ss))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(ss[0].ListenSockets) != 1 {
|
|
|
|
|
|
|
|
return false, fmt.Errorf("there should only be one server listen socket, not %d", len(ss[0].ListenSockets))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ns, _ := channelz.GetServerSockets(ss[0].ID, 0)
|
|
|
|
|
|
|
|
if len(ns) != num {
|
|
|
|
|
|
|
|
return false, fmt.Errorf("there should be %d normal sockets not %d", num, len(ns))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
svrID = ss[0].ID
|
|
|
|
|
|
|
|
return true, nil
|
|
|
|
|
|
|
|
}); err != nil {
|
|
|
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ccs[len(ccs)-1].Close()
|
|
|
|
for _, c := range testcases {
|
|
|
|
|
|
|
|
channelz.NewChannelzStorage()
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
e := tcpClearRREnv
|
|
|
|
ns, _ := channelz.GetServerSockets(svrID, 0)
|
|
|
|
te := newTest(t, e)
|
|
|
|
if len(ns) != num-1 {
|
|
|
|
te.startServer(&testServer{security: e.security})
|
|
|
|
return false, fmt.Errorf("there should be %d normal sockets not %d", num-1, len(ns))
|
|
|
|
defer te.tearDown()
|
|
|
|
|
|
|
|
var ccs []*grpc.ClientConn
|
|
|
|
|
|
|
|
for i := 0; i < c.total; i++ {
|
|
|
|
|
|
|
|
cc := te.clientConn()
|
|
|
|
|
|
|
|
te.cc = nil
|
|
|
|
|
|
|
|
ccs = append(ccs, cc)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var svrID int64
|
|
|
|
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
|
|
|
|
ss, _ := channelz.GetServers(0, 0)
|
|
|
|
|
|
|
|
if len(ss) != 1 {
|
|
|
|
|
|
|
|
return false, fmt.Errorf("there should only be one server, not %d", len(ss))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(ss[0].ListenSockets) != 1 {
|
|
|
|
|
|
|
|
return false, fmt.Errorf("there should only be one server listen socket, not %d", len(ss[0].ListenSockets))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
startID := c.start
|
|
|
|
|
|
|
|
if startID != 0 {
|
|
|
|
|
|
|
|
ns, _ := channelz.GetServerSockets(ss[0].ID, 0, int64(c.total))
|
|
|
|
|
|
|
|
if int64(len(ns)) < c.start {
|
|
|
|
|
|
|
|
return false, fmt.Errorf("there should more than %d sockets, not %d", len(ns), c.start)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
startID = ns[c.start-1].ID + 1
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ns, end := channelz.GetServerSockets(ss[0].ID, startID, c.max)
|
|
|
|
|
|
|
|
if int64(len(ns)) != c.length || end != c.end {
|
|
|
|
|
|
|
|
return false, fmt.Errorf("GetServerSockets(%d) = %+v (len of which: %d), end: %+v, want len(GetServerSockets(%d)) = %d, end: %+v", c.start, ns, len(ns), end, c.start, c.length, c.end)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
svrID = ss[0].ID
|
|
|
|
|
|
|
|
return true, nil
|
|
|
|
|
|
|
|
}); err != nil {
|
|
|
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, cc := range ccs {
|
|
|
|
|
|
|
|
cc.Close()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
|
|
|
|
ns, _ := channelz.GetServerSockets(svrID, c.start, c.max)
|
|
|
|
|
|
|
|
if len(ns) != 0 {
|
|
|
|
|
|
|
|
return false, fmt.Errorf("there should be %d normal sockets not %d", 0, len(ns))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true, nil
|
|
|
|
|
|
|
|
}); err != nil {
|
|
|
|
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true, nil
|
|
|
|
|
|
|
|
}); err != nil {
|
|
|
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -329,7 +361,7 @@ func TestCZServerListenSocketDeletion(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
go s.Serve(lis)
|
|
|
|
go s.Serve(lis)
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
ss, _ := channelz.GetServers(0)
|
|
|
|
ss, _ := channelz.GetServers(0, 0)
|
|
|
|
if len(ss) != 1 {
|
|
|
|
if len(ss) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one server, not %d", len(ss))
|
|
|
|
return false, fmt.Errorf("there should only be one server, not %d", len(ss))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -343,7 +375,7 @@ func TestCZServerListenSocketDeletion(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
lis.Close()
|
|
|
|
lis.Close()
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
ss, _ := channelz.GetServers(0)
|
|
|
|
ss, _ := channelz.GetServers(0, 0)
|
|
|
|
if len(ss) != 1 {
|
|
|
|
if len(ss) != 1 {
|
|
|
|
return false, fmt.Errorf("there should be 1 server, not %d", len(ss))
|
|
|
|
return false, fmt.Errorf("there should be 1 server, not %d", len(ss))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -381,7 +413,7 @@ func TestCZRecusivelyDeletionOfEntry(t *testing.T) {
|
|
|
|
sktID1 := channelz.RegisterNormalSocket(&dummySocket{}, subChanID1, "")
|
|
|
|
sktID1 := channelz.RegisterNormalSocket(&dummySocket{}, subChanID1, "")
|
|
|
|
sktID2 := channelz.RegisterNormalSocket(&dummySocket{}, subChanID1, "")
|
|
|
|
sktID2 := channelz.RegisterNormalSocket(&dummySocket{}, subChanID1, "")
|
|
|
|
|
|
|
|
|
|
|
|
tcs, _ := channelz.GetTopChannels(0)
|
|
|
|
tcs, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if tcs == nil || len(tcs) != 1 {
|
|
|
|
if tcs == nil || len(tcs) != 1 {
|
|
|
|
t.Fatalf("There should be one TopChannel entry")
|
|
|
|
t.Fatalf("There should be one TopChannel entry")
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -394,14 +426,14 @@ func TestCZRecusivelyDeletionOfEntry(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
channelz.RemoveEntry(topChanID)
|
|
|
|
channelz.RemoveEntry(topChanID)
|
|
|
|
tcs, _ = channelz.GetTopChannels(0)
|
|
|
|
tcs, _ = channelz.GetTopChannels(0, 0)
|
|
|
|
if tcs == nil || len(tcs) != 1 {
|
|
|
|
if tcs == nil || len(tcs) != 1 {
|
|
|
|
t.Fatalf("There should be one TopChannel entry")
|
|
|
|
t.Fatalf("There should be one TopChannel entry")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
channelz.RemoveEntry(subChanID1)
|
|
|
|
channelz.RemoveEntry(subChanID1)
|
|
|
|
channelz.RemoveEntry(subChanID2)
|
|
|
|
channelz.RemoveEntry(subChanID2)
|
|
|
|
tcs, _ = channelz.GetTopChannels(0)
|
|
|
|
tcs, _ = channelz.GetTopChannels(0, 0)
|
|
|
|
if tcs == nil || len(tcs) != 1 {
|
|
|
|
if tcs == nil || len(tcs) != 1 {
|
|
|
|
t.Fatalf("There should be one TopChannel entry")
|
|
|
|
t.Fatalf("There should be one TopChannel entry")
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -411,7 +443,7 @@ func TestCZRecusivelyDeletionOfEntry(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
channelz.RemoveEntry(sktID1)
|
|
|
|
channelz.RemoveEntry(sktID1)
|
|
|
|
channelz.RemoveEntry(sktID2)
|
|
|
|
channelz.RemoveEntry(sktID2)
|
|
|
|
tcs, _ = channelz.GetTopChannels(0)
|
|
|
|
tcs, _ = channelz.GetTopChannels(0, 0)
|
|
|
|
if tcs != nil {
|
|
|
|
if tcs != nil {
|
|
|
|
t.Fatalf("There should be no TopChannel entry")
|
|
|
|
t.Fatalf("There should be no TopChannel entry")
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -465,7 +497,7 @@ func TestCZChannelMetrics(t *testing.T) {
|
|
|
|
// Here, we just wait for all sockets to be up. In the future, if we implement
|
|
|
|
// Here, we just wait for all sockets to be up. In the future, if we implement
|
|
|
|
// IDLE, we may need to make several rpc calls to create the sockets.
|
|
|
|
// IDLE, we may need to make several rpc calls to create the sockets.
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tcs, _ := channelz.GetTopChannels(0)
|
|
|
|
tcs, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -543,7 +575,7 @@ func TestCZServerMetrics(t *testing.T) {
|
|
|
|
defer stream.CloseSend()
|
|
|
|
defer stream.CloseSend()
|
|
|
|
|
|
|
|
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
ss, _ := channelz.GetServers(0)
|
|
|
|
ss, _ := channelz.GetServers(0, 0)
|
|
|
|
if len(ss) != 1 {
|
|
|
|
if len(ss) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one server, not %d", len(ss))
|
|
|
|
return false, fmt.Errorf("there should only be one server, not %d", len(ss))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -806,7 +838,7 @@ func TestCZClientSocketMetricsStreamsAndMessagesCount(t *testing.T) {
|
|
|
|
doSuccessfulUnaryCall(tc, t)
|
|
|
|
doSuccessfulUnaryCall(tc, t)
|
|
|
|
var scID, skID int64
|
|
|
|
var scID, skID int64
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tchan, _ := channelz.GetTopChannels(0)
|
|
|
|
tchan, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tchan) != 1 {
|
|
|
|
if len(tchan) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tchan))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tchan))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -907,7 +939,7 @@ func TestCZClientAndServerSocketMetricsStreamsCountFlowControlRSTStream(t *testi
|
|
|
|
|
|
|
|
|
|
|
|
doServerSideInitiatedFailedStreamWithClientBreakFlowControl(tc, t, dw)
|
|
|
|
doServerSideInitiatedFailedStreamWithClientBreakFlowControl(tc, t, dw)
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tchan, _ := channelz.GetTopChannels(0)
|
|
|
|
tchan, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tchan) != 1 {
|
|
|
|
if len(tchan) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tchan))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tchan))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -933,12 +965,12 @@ func TestCZClientAndServerSocketMetricsStreamsCountFlowControlRSTStream(t *testi
|
|
|
|
if sktData.StreamsStarted != 1 || sktData.StreamsSucceeded != 0 || sktData.StreamsFailed != 1 {
|
|
|
|
if sktData.StreamsStarted != 1 || sktData.StreamsSucceeded != 0 || sktData.StreamsFailed != 1 {
|
|
|
|
return false, fmt.Errorf("channelz.GetSocket(%d), want (StreamsStarted, StreamsSucceeded, StreamsFailed) = (1, 0, 1), got (%d, %d, %d)", skt.ID, sktData.StreamsStarted, sktData.StreamsSucceeded, sktData.StreamsFailed)
|
|
|
|
return false, fmt.Errorf("channelz.GetSocket(%d), want (StreamsStarted, StreamsSucceeded, StreamsFailed) = (1, 0, 1), got (%d, %d, %d)", skt.ID, sktData.StreamsStarted, sktData.StreamsSucceeded, sktData.StreamsFailed)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ss, _ := channelz.GetServers(0)
|
|
|
|
ss, _ := channelz.GetServers(0, 0)
|
|
|
|
if len(ss) != 1 {
|
|
|
|
if len(ss) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one server, not %d", len(ss))
|
|
|
|
return false, fmt.Errorf("there should only be one server, not %d", len(ss))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ns, _ := channelz.GetServerSockets(ss[0].ID, 0)
|
|
|
|
ns, _ := channelz.GetServerSockets(ss[0].ID, 0, 0)
|
|
|
|
if len(ns) != 1 {
|
|
|
|
if len(ns) != 1 {
|
|
|
|
return false, fmt.Errorf("there should be one server normal socket, not %d", len(ns))
|
|
|
|
return false, fmt.Errorf("there should be one server normal socket, not %d", len(ns))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -973,7 +1005,7 @@ func TestCZClientAndServerSocketMetricsFlowControl(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
var cliSktID, svrSktID int64
|
|
|
|
var cliSktID, svrSktID int64
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tchan, _ := channelz.GetTopChannels(0)
|
|
|
|
tchan, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tchan) != 1 {
|
|
|
|
if len(tchan) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tchan))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tchan))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1000,11 +1032,11 @@ func TestCZClientAndServerSocketMetricsFlowControl(t *testing.T) {
|
|
|
|
if sktData.LocalFlowControlWindow != 65486 || sktData.RemoteFlowControlWindow != 65486 {
|
|
|
|
if sktData.LocalFlowControlWindow != 65486 || sktData.RemoteFlowControlWindow != 65486 {
|
|
|
|
return false, fmt.Errorf("client: (LocalFlowControlWindow, RemoteFlowControlWindow) size should be (65536, 65486), not (%d, %d)", sktData.LocalFlowControlWindow, sktData.RemoteFlowControlWindow)
|
|
|
|
return false, fmt.Errorf("client: (LocalFlowControlWindow, RemoteFlowControlWindow) size should be (65536, 65486), not (%d, %d)", sktData.LocalFlowControlWindow, sktData.RemoteFlowControlWindow)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ss, _ := channelz.GetServers(0)
|
|
|
|
ss, _ := channelz.GetServers(0, 0)
|
|
|
|
if len(ss) != 1 {
|
|
|
|
if len(ss) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one server, not %d", len(ss))
|
|
|
|
return false, fmt.Errorf("there should only be one server, not %d", len(ss))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ns, _ := channelz.GetServerSockets(ss[0].ID, 0)
|
|
|
|
ns, _ := channelz.GetServerSockets(ss[0].ID, 0, 0)
|
|
|
|
sktData = ns[0].SocketData
|
|
|
|
sktData = ns[0].SocketData
|
|
|
|
if sktData.LocalFlowControlWindow != 65486 || sktData.RemoteFlowControlWindow != 65486 {
|
|
|
|
if sktData.LocalFlowControlWindow != 65486 || sktData.RemoteFlowControlWindow != 65486 {
|
|
|
|
return false, fmt.Errorf("server: (LocalFlowControlWindow, RemoteFlowControlWindow) size should be (65536, 65486), not (%d, %d)", sktData.LocalFlowControlWindow, sktData.RemoteFlowControlWindow)
|
|
|
|
return false, fmt.Errorf("server: (LocalFlowControlWindow, RemoteFlowControlWindow) size should be (65536, 65486), not (%d, %d)", sktData.LocalFlowControlWindow, sktData.RemoteFlowControlWindow)
|
|
|
@ -1025,11 +1057,11 @@ func TestCZClientAndServerSocketMetricsFlowControl(t *testing.T) {
|
|
|
|
if sktData.LocalFlowControlWindow != 65486 || sktData.RemoteFlowControlWindow != 55475 {
|
|
|
|
if sktData.LocalFlowControlWindow != 65486 || sktData.RemoteFlowControlWindow != 55475 {
|
|
|
|
return false, fmt.Errorf("client: (LocalFlowControlWindow, RemoteFlowControlWindow) size should be (65486, 55475), not (%d, %d)", sktData.LocalFlowControlWindow, sktData.RemoteFlowControlWindow)
|
|
|
|
return false, fmt.Errorf("client: (LocalFlowControlWindow, RemoteFlowControlWindow) size should be (65486, 55475), not (%d, %d)", sktData.LocalFlowControlWindow, sktData.RemoteFlowControlWindow)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ss, _ := channelz.GetServers(0)
|
|
|
|
ss, _ := channelz.GetServers(0, 0)
|
|
|
|
if len(ss) != 1 {
|
|
|
|
if len(ss) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one server, not %d", len(ss))
|
|
|
|
return false, fmt.Errorf("there should only be one server, not %d", len(ss))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ns, _ := channelz.GetServerSockets(svrSktID, 0)
|
|
|
|
ns, _ := channelz.GetServerSockets(svrSktID, 0, 0)
|
|
|
|
sktData = ns[0].SocketData
|
|
|
|
sktData = ns[0].SocketData
|
|
|
|
if sktData.LocalFlowControlWindow != 55475 || sktData.RemoteFlowControlWindow != 65486 {
|
|
|
|
if sktData.LocalFlowControlWindow != 55475 || sktData.RemoteFlowControlWindow != 65486 {
|
|
|
|
return false, fmt.Errorf("server: (LocalFlowControlWindow, RemoteFlowControlWindow) size should be (55475, 65486), not (%d, %d)", sktData.LocalFlowControlWindow, sktData.RemoteFlowControlWindow)
|
|
|
|
return false, fmt.Errorf("server: (LocalFlowControlWindow, RemoteFlowControlWindow) size should be (55475, 65486), not (%d, %d)", sktData.LocalFlowControlWindow, sktData.RemoteFlowControlWindow)
|
|
|
@ -1050,11 +1082,11 @@ func TestCZClientAndServerSocketMetricsFlowControl(t *testing.T) {
|
|
|
|
if sktData.LocalFlowControlWindow != 65486 || sktData.RemoteFlowControlWindow != 65536 {
|
|
|
|
if sktData.LocalFlowControlWindow != 65486 || sktData.RemoteFlowControlWindow != 65536 {
|
|
|
|
return false, fmt.Errorf("client: (LocalFlowControlWindow, RemoteFlowControlWindow) size should be (65486, 65536), not (%d, %d)", sktData.LocalFlowControlWindow, sktData.RemoteFlowControlWindow)
|
|
|
|
return false, fmt.Errorf("client: (LocalFlowControlWindow, RemoteFlowControlWindow) size should be (65486, 65536), not (%d, %d)", sktData.LocalFlowControlWindow, sktData.RemoteFlowControlWindow)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ss, _ := channelz.GetServers(0)
|
|
|
|
ss, _ := channelz.GetServers(0, 0)
|
|
|
|
if len(ss) != 1 {
|
|
|
|
if len(ss) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one server, not %d", len(ss))
|
|
|
|
return false, fmt.Errorf("there should only be one server, not %d", len(ss))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ns, _ := channelz.GetServerSockets(svrSktID, 0)
|
|
|
|
ns, _ := channelz.GetServerSockets(svrSktID, 0, 0)
|
|
|
|
sktData = ns[0].SocketData
|
|
|
|
sktData = ns[0].SocketData
|
|
|
|
if sktData.LocalFlowControlWindow != 65536 || sktData.RemoteFlowControlWindow != 65486 {
|
|
|
|
if sktData.LocalFlowControlWindow != 65536 || sktData.RemoteFlowControlWindow != 65486 {
|
|
|
|
return false, fmt.Errorf("server: (LocalFlowControlWindow, RemoteFlowControlWindow) size should be (65536, 65486), not (%d, %d)", sktData.LocalFlowControlWindow, sktData.RemoteFlowControlWindow)
|
|
|
|
return false, fmt.Errorf("server: (LocalFlowControlWindow, RemoteFlowControlWindow) size should be (65536, 65486), not (%d, %d)", sktData.LocalFlowControlWindow, sktData.RemoteFlowControlWindow)
|
|
|
@ -1078,7 +1110,7 @@ func TestCZClientSocketMetricsKeepAlive(t *testing.T) {
|
|
|
|
doIdleCallToInvokeKeepAlive(tc, t)
|
|
|
|
doIdleCallToInvokeKeepAlive(tc, t)
|
|
|
|
|
|
|
|
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tchan, _ := channelz.GetTopChannels(0)
|
|
|
|
tchan, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tchan) != 1 {
|
|
|
|
if len(tchan) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tchan))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tchan))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1123,7 +1155,7 @@ func TestCZServerSocketMetricsStreamsAndMessagesCount(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
var svrID int64
|
|
|
|
var svrID int64
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
ss, _ := channelz.GetServers(0)
|
|
|
|
ss, _ := channelz.GetServers(0, 0)
|
|
|
|
if len(ss) != 1 {
|
|
|
|
if len(ss) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one server, not %d", len(ss))
|
|
|
|
return false, fmt.Errorf("there should only be one server, not %d", len(ss))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1135,7 +1167,7 @@ func TestCZServerSocketMetricsStreamsAndMessagesCount(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
doSuccessfulUnaryCall(tc, t)
|
|
|
|
doSuccessfulUnaryCall(tc, t)
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
ns, _ := channelz.GetServerSockets(svrID, 0)
|
|
|
|
ns, _ := channelz.GetServerSockets(svrID, 0, 0)
|
|
|
|
sktData := ns[0].SocketData
|
|
|
|
sktData := ns[0].SocketData
|
|
|
|
if sktData.StreamsStarted != 1 || sktData.StreamsSucceeded != 1 || sktData.StreamsFailed != 0 || sktData.MessagesSent != 1 || sktData.MessagesReceived != 1 {
|
|
|
|
if sktData.StreamsStarted != 1 || sktData.StreamsSucceeded != 1 || sktData.StreamsFailed != 0 || sktData.MessagesSent != 1 || sktData.MessagesReceived != 1 {
|
|
|
|
return false, fmt.Errorf("server socket metric with ID %d, want (StreamsStarted, StreamsSucceeded, MessagesSent, MessagesReceived) = (1, 1, 1, 1), got (%d, %d, %d, %d, %d)", ns[0].ID, sktData.StreamsStarted, sktData.StreamsSucceeded, sktData.StreamsFailed, sktData.MessagesSent, sktData.MessagesReceived)
|
|
|
|
return false, fmt.Errorf("server socket metric with ID %d, want (StreamsStarted, StreamsSucceeded, MessagesSent, MessagesReceived) = (1, 1, 1, 1), got (%d, %d, %d, %d, %d)", ns[0].ID, sktData.StreamsStarted, sktData.StreamsSucceeded, sktData.StreamsFailed, sktData.MessagesSent, sktData.MessagesReceived)
|
|
|
@ -1147,7 +1179,7 @@ func TestCZServerSocketMetricsStreamsAndMessagesCount(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
doServerSideFailedUnaryCall(tc, t)
|
|
|
|
doServerSideFailedUnaryCall(tc, t)
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
ns, _ := channelz.GetServerSockets(svrID, 0)
|
|
|
|
ns, _ := channelz.GetServerSockets(svrID, 0, 0)
|
|
|
|
sktData := ns[0].SocketData
|
|
|
|
sktData := ns[0].SocketData
|
|
|
|
if sktData.StreamsStarted != 2 || sktData.StreamsSucceeded != 2 || sktData.StreamsFailed != 0 || sktData.MessagesSent != 1 || sktData.MessagesReceived != 1 {
|
|
|
|
if sktData.StreamsStarted != 2 || sktData.StreamsSucceeded != 2 || sktData.StreamsFailed != 0 || sktData.MessagesSent != 1 || sktData.MessagesReceived != 1 {
|
|
|
|
return false, fmt.Errorf("server socket metric with ID %d, want (StreamsStarted, StreamsSucceeded, StreamsFailed, MessagesSent, MessagesReceived) = (2, 2, 0, 1, 1), got (%d, %d, %d, %d, %d)", ns[0].ID, sktData.StreamsStarted, sktData.StreamsSucceeded, sktData.StreamsFailed, sktData.MessagesSent, sktData.MessagesReceived)
|
|
|
|
return false, fmt.Errorf("server socket metric with ID %d, want (StreamsStarted, StreamsSucceeded, StreamsFailed, MessagesSent, MessagesReceived) = (2, 2, 0, 1, 1), got (%d, %d, %d, %d, %d)", ns[0].ID, sktData.StreamsStarted, sktData.StreamsSucceeded, sktData.StreamsFailed, sktData.MessagesSent, sktData.MessagesReceived)
|
|
|
@ -1159,7 +1191,7 @@ func TestCZServerSocketMetricsStreamsAndMessagesCount(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
doClientSideInitiatedFailedStream(tc, t)
|
|
|
|
doClientSideInitiatedFailedStream(tc, t)
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
ns, _ := channelz.GetServerSockets(svrID, 0)
|
|
|
|
ns, _ := channelz.GetServerSockets(svrID, 0, 0)
|
|
|
|
sktData := ns[0].SocketData
|
|
|
|
sktData := ns[0].SocketData
|
|
|
|
if sktData.StreamsStarted != 3 || sktData.StreamsSucceeded != 2 || sktData.StreamsFailed != 1 || sktData.MessagesSent != 2 || sktData.MessagesReceived != 2 {
|
|
|
|
if sktData.StreamsStarted != 3 || sktData.StreamsSucceeded != 2 || sktData.StreamsFailed != 1 || sktData.MessagesSent != 2 || sktData.MessagesReceived != 2 {
|
|
|
|
return false, fmt.Errorf("server socket metric with ID %d, want (StreamsStarted, StreamsSucceeded, StreamsFailed, MessagesSent, MessagesReceived) = (3, 2, 1, 2, 2), got (%d, %d, %d, %d, %d)", ns[0].ID, sktData.StreamsStarted, sktData.StreamsSucceeded, sktData.StreamsFailed, sktData.MessagesSent, sktData.MessagesReceived)
|
|
|
|
return false, fmt.Errorf("server socket metric with ID %d, want (StreamsStarted, StreamsSucceeded, StreamsFailed, MessagesSent, MessagesReceived) = (3, 2, 1, 2, 2), got (%d, %d, %d, %d, %d)", ns[0].ID, sktData.StreamsStarted, sktData.StreamsSucceeded, sktData.StreamsFailed, sktData.MessagesSent, sktData.MessagesReceived)
|
|
|
@ -1183,11 +1215,11 @@ func TestCZServerSocketMetricsKeepAlive(t *testing.T) {
|
|
|
|
doIdleCallToInvokeKeepAlive(tc, t)
|
|
|
|
doIdleCallToInvokeKeepAlive(tc, t)
|
|
|
|
|
|
|
|
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
ss, _ := channelz.GetServers(0)
|
|
|
|
ss, _ := channelz.GetServers(0, 0)
|
|
|
|
if len(ss) != 1 {
|
|
|
|
if len(ss) != 1 {
|
|
|
|
return false, fmt.Errorf("there should be one server, not %d", len(ss))
|
|
|
|
return false, fmt.Errorf("there should be one server, not %d", len(ss))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ns, _ := channelz.GetServerSockets(ss[0].ID, 0)
|
|
|
|
ns, _ := channelz.GetServerSockets(ss[0].ID, 0, 0)
|
|
|
|
if len(ns) != 1 {
|
|
|
|
if len(ns) != 1 {
|
|
|
|
return false, fmt.Errorf("there should be one server normal socket, not %d", len(ns))
|
|
|
|
return false, fmt.Errorf("there should be one server normal socket, not %d", len(ns))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1235,7 +1267,7 @@ func TestCZSocketGetSecurityValueTLS(t *testing.T) {
|
|
|
|
defer te.tearDown()
|
|
|
|
defer te.tearDown()
|
|
|
|
te.clientConn()
|
|
|
|
te.clientConn()
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tchan, _ := channelz.GetTopChannels(0)
|
|
|
|
tchan, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tchan) != 1 {
|
|
|
|
if len(tchan) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tchan))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tchan))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1292,7 +1324,7 @@ func TestCZChannelTraceCreationDeletion(t *testing.T) {
|
|
|
|
defer te.tearDown()
|
|
|
|
defer te.tearDown()
|
|
|
|
var nestedConn int64
|
|
|
|
var nestedConn int64
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tcs, _ := channelz.GetTopChannels(0)
|
|
|
|
tcs, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1327,7 +1359,7 @@ func TestCZChannelTraceCreationDeletion(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
// wait for the shutdown of grpclb balancer
|
|
|
|
// wait for the shutdown of grpclb balancer
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tcs, _ := channelz.GetTopChannels(0)
|
|
|
|
tcs, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1369,7 +1401,7 @@ func TestCZSubChannelTraceCreationDeletion(t *testing.T) {
|
|
|
|
// Here, we just wait for all sockets to be up. In the future, if we implement
|
|
|
|
// Here, we just wait for all sockets to be up. In the future, if we implement
|
|
|
|
// IDLE, we may need to make several rpc calls to create the sockets.
|
|
|
|
// IDLE, we may need to make several rpc calls to create the sockets.
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tcs, _ := channelz.GetTopChannels(0)
|
|
|
|
tcs, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1405,7 +1437,7 @@ func TestCZSubChannelTraceCreationDeletion(t *testing.T) {
|
|
|
|
r.NewAddress([]resolver.Address{})
|
|
|
|
r.NewAddress([]resolver.Address{})
|
|
|
|
|
|
|
|
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tcs, _ := channelz.GetTopChannels(0)
|
|
|
|
tcs, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1449,7 +1481,7 @@ func TestCZChannelAddressResolutionChange(t *testing.T) {
|
|
|
|
// Here, we just wait for all sockets to be up. In the future, if we implement
|
|
|
|
// Here, we just wait for all sockets to be up. In the future, if we implement
|
|
|
|
// IDLE, we may need to make several rpc calls to create the sockets.
|
|
|
|
// IDLE, we may need to make several rpc calls to create the sockets.
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tcs, _ := channelz.GetTopChannels(0)
|
|
|
|
tcs, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1564,7 +1596,7 @@ func TestCZSubChannelPickedNewAddress(t *testing.T) {
|
|
|
|
// Here, we just wait for all sockets to be up. In the future, if we implement
|
|
|
|
// Here, we just wait for all sockets to be up. In the future, if we implement
|
|
|
|
// IDLE, we may need to make several rpc calls to create the sockets.
|
|
|
|
// IDLE, we may need to make several rpc calls to create the sockets.
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tcs, _ := channelz.GetTopChannels(0)
|
|
|
|
tcs, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1623,7 +1655,7 @@ func TestCZSubChannelConnectivityState(t *testing.T) {
|
|
|
|
// we need to obtain the SubChannel id before it gets deleted from Channel's children list (due
|
|
|
|
// we need to obtain the SubChannel id before it gets deleted from Channel's children list (due
|
|
|
|
// to effect of r.NewAddress([]resolver.Address{}))
|
|
|
|
// to effect of r.NewAddress([]resolver.Address{}))
|
|
|
|
if subConn == 0 {
|
|
|
|
if subConn == 0 {
|
|
|
|
tcs, _ := channelz.GetTopChannels(0)
|
|
|
|
tcs, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1714,7 +1746,7 @@ func TestCZChannelConnectivityState(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
te.srv.Stop()
|
|
|
|
te.srv.Stop()
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tcs, _ := channelz.GetTopChannels(0)
|
|
|
|
tcs, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1768,7 +1800,7 @@ func TestCZTraceOverwriteChannelDeletion(t *testing.T) {
|
|
|
|
defer te.tearDown()
|
|
|
|
defer te.tearDown()
|
|
|
|
var nestedConn int64
|
|
|
|
var nestedConn int64
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tcs, _ := channelz.GetTopChannels(0)
|
|
|
|
tcs, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1788,7 +1820,7 @@ func TestCZTraceOverwriteChannelDeletion(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
// wait for the shutdown of grpclb balancer
|
|
|
|
// wait for the shutdown of grpclb balancer
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tcs, _ := channelz.GetTopChannels(0)
|
|
|
|
tcs, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1830,7 +1862,7 @@ func TestCZTraceOverwriteSubChannelDeletion(t *testing.T) {
|
|
|
|
// Here, we just wait for all sockets to be up. In the future, if we implement
|
|
|
|
// Here, we just wait for all sockets to be up. In the future, if we implement
|
|
|
|
// IDLE, we may need to make several rpc calls to create the sockets.
|
|
|
|
// IDLE, we may need to make several rpc calls to create the sockets.
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tcs, _ := channelz.GetTopChannels(0)
|
|
|
|
tcs, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1848,7 +1880,7 @@ func TestCZTraceOverwriteSubChannelDeletion(t *testing.T) {
|
|
|
|
r.NewAddress([]resolver.Address{})
|
|
|
|
r.NewAddress([]resolver.Address{})
|
|
|
|
|
|
|
|
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tcs, _ := channelz.GetTopChannels(0)
|
|
|
|
tcs, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1887,7 +1919,7 @@ func TestCZTraceTopChannelDeletionTraceClear(t *testing.T) {
|
|
|
|
// Here, we just wait for all sockets to be up. In the future, if we implement
|
|
|
|
// Here, we just wait for all sockets to be up. In the future, if we implement
|
|
|
|
// IDLE, we may need to make several rpc calls to create the sockets.
|
|
|
|
// IDLE, we may need to make several rpc calls to create the sockets.
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
if err := verifyResultWithDelay(func() (bool, error) {
|
|
|
|
tcs, _ := channelz.GetTopChannels(0)
|
|
|
|
tcs, _ := channelz.GetTopChannels(0, 0)
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
if len(tcs) != 1 {
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
return false, fmt.Errorf("there should only be one top channel, not %d", len(tcs))
|
|
|
|
}
|
|
|
|
}
|
|
|
|