Check server test error (#9954)

Signed-off-by: godchen <qingxiang.chen@zilliz.com>
pull/9968/head
godchen 2021-10-15 17:12:35 +08:00 committed by GitHub
parent bf71965f58
commit 3f713a1104
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 8 deletions

View File

@ -867,7 +867,8 @@ func TestDataNodeTtChannel(t *testing.T) {
Address: "localhost:7777", Address: "localhost:7777",
NodeID: 0, NodeID: 0,
} }
svr.cluster.Register(info) err = svr.cluster.Register(info)
assert.Nil(t, err)
resp, err := svr.AssignSegmentID(context.TODO(), &datapb.AssignSegmentIDRequest{ resp, err := svr.AssignSegmentID(context.TODO(), &datapb.AssignSegmentIDRequest{
NodeID: 0, NodeID: 0,
@ -930,7 +931,8 @@ func TestDataNodeTtChannel(t *testing.T) {
Address: "localhost:7777", Address: "localhost:7777",
NodeID: 0, NodeID: 0,
} }
svr.cluster.Register(info) err = svr.cluster.Register(info)
assert.Nil(t, err)
resp, err := svr.AssignSegmentID(context.TODO(), &datapb.AssignSegmentIDRequest{ resp, err := svr.AssignSegmentID(context.TODO(), &datapb.AssignSegmentIDRequest{
NodeID: 0, NodeID: 0,
PeerRole: "", PeerRole: "",
@ -1007,7 +1009,8 @@ func TestDataNodeTtChannel(t *testing.T) {
NodeID: 0, NodeID: 0,
Address: "localhost:7777", Address: "localhost:7777",
} }
svr.cluster.Register(node) err = svr.cluster.Register(node)
assert.Nil(t, err)
resp, err := svr.AssignSegmentID(context.TODO(), &datapb.AssignSegmentIDRequest{ resp, err := svr.AssignSegmentID(context.TODO(), &datapb.AssignSegmentIDRequest{
NodeID: 0, NodeID: 0,
@ -1349,7 +1352,8 @@ func TestHandleSessionEvent(t *testing.T) {
cluster := NewCluster(sessionManager, channelManager) cluster := NewCluster(sessionManager, channelManager)
assert.Nil(t, err) assert.Nil(t, err)
cluster.Startup(nil) err = cluster.Startup(nil)
assert.Nil(t, err)
defer cluster.Close() defer cluster.Close()
svr := newTestServer(t, nil, SetCluster(cluster)) svr := newTestServer(t, nil, SetCluster(cluster))
@ -1365,7 +1369,8 @@ func TestHandleSessionEvent(t *testing.T) {
Exclusive: false, Exclusive: false,
}, },
} }
svr.handleSessionEvent(context.Background(), evt) err = svr.handleSessionEvent(context.Background(), evt)
assert.Nil(t, err)
evt = &sessionutil.SessionEvent{ evt = &sessionutil.SessionEvent{
EventType: sessionutil.SessionAddEvent, EventType: sessionutil.SessionAddEvent,
@ -1376,7 +1381,8 @@ func TestHandleSessionEvent(t *testing.T) {
Exclusive: false, Exclusive: false,
}, },
} }
svr.handleSessionEvent(context.Background(), evt) err = svr.handleSessionEvent(context.Background(), evt)
assert.Nil(t, err)
dataNodes := svr.cluster.GetSessions() dataNodes := svr.cluster.GetSessions()
assert.EqualValues(t, 1, len(dataNodes)) assert.EqualValues(t, 1, len(dataNodes))
assert.EqualValues(t, "DN127.0.0.101", dataNodes[0].info.Address) assert.EqualValues(t, "DN127.0.0.101", dataNodes[0].info.Address)
@ -1390,14 +1396,16 @@ func TestHandleSessionEvent(t *testing.T) {
Exclusive: false, Exclusive: false,
}, },
} }
svr.handleSessionEvent(context.Background(), evt) err = svr.handleSessionEvent(context.Background(), evt)
assert.Nil(t, err)
dataNodes = svr.cluster.GetSessions() dataNodes = svr.cluster.GetSessions()
assert.EqualValues(t, 0, len(dataNodes)) assert.EqualValues(t, 0, len(dataNodes))
}) })
t.Run("nil evt", func(t *testing.T) { t.Run("nil evt", func(t *testing.T) {
assert.NotPanics(t, func() { assert.NotPanics(t, func() {
svr.handleSessionEvent(context.Background(), nil) err = svr.handleSessionEvent(context.Background(), nil)
assert.Nil(t, err)
}) })
}) })
} }