mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-29 18:38:44 +08:00
Refactor master scheduler: has_collection
Signed-off-by: XuanYang-cn <xuan.yang@zilliz.com>
This commit is contained in:
parent
0b478b614a
commit
1b48e84c35
@ -113,6 +113,37 @@ func TestMaster_CreateCollectionTask(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, st.ErrorCode, commonpb.ErrorCode_SUCCESS)
|
||||
|
||||
reqHasCollection := internalpb.HasCollectionRequest{
|
||||
MsgType: internalpb.MsgType_kHasCollection,
|
||||
ReqID: 1,
|
||||
Timestamp: 11,
|
||||
ProxyID: 1,
|
||||
CollectionName: &servicepb.CollectionName{
|
||||
CollectionName: "col1",
|
||||
},
|
||||
}
|
||||
|
||||
// HasCollection "col1" is true
|
||||
log.Printf("... [Has] collection col1\n")
|
||||
boolResp, err := cli.HasCollection(ctx, &reqHasCollection)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, true, boolResp.Value)
|
||||
assert.Equal(t, boolResp.Status.ErrorCode, commonpb.ErrorCode_SUCCESS)
|
||||
|
||||
// HasCollection "colNotExist" is false
|
||||
reqHasCollection.CollectionName.CollectionName = "colNotExist"
|
||||
boolResp, err = cli.HasCollection(ctx, &reqHasCollection)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, boolResp.Value, false)
|
||||
assert.Equal(t, boolResp.Status.ErrorCode, commonpb.ErrorCode_SUCCESS)
|
||||
|
||||
// HasCollection error
|
||||
reqHasCollection.Timestamp = Timestamp(10)
|
||||
reqHasCollection.CollectionName.CollectionName = "col1"
|
||||
boolResp, err = cli.HasCollection(ctx, &reqHasCollection)
|
||||
assert.Nil(t, err)
|
||||
assert.NotEqual(t, boolResp.Status.ErrorCode, commonpb.ErrorCode_SUCCESS)
|
||||
|
||||
collMeta, err := svr.mt.GetCollectionByName(sch.Name)
|
||||
assert.Nil(t, err)
|
||||
t.Logf("collection id = %d", collMeta.ID)
|
||||
@ -150,8 +181,8 @@ func TestMaster_CreateCollectionTask(t *testing.T) {
|
||||
st, err = cli.CreateCollection(ctx, &req)
|
||||
assert.Nil(t, err)
|
||||
assert.NotEqual(t, st.ErrorCode, commonpb.ErrorCode_SUCCESS)
|
||||
// ------------------------------DropCollectionTask---------------------------
|
||||
|
||||
// ------------------------------DropCollectionTask---------------------------
|
||||
log.Printf("... [Drop] collection col1\n")
|
||||
ser := servicepb.CollectionName{CollectionName: "col1"}
|
||||
|
||||
@ -163,6 +194,7 @@ func TestMaster_CreateCollectionTask(t *testing.T) {
|
||||
CollectionName: &ser,
|
||||
}
|
||||
|
||||
// DropCollection
|
||||
st, err = cli.DropCollection(ctx, &reqDrop)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, st.ErrorCode, commonpb.ErrorCode_SUCCESS)
|
||||
@ -170,6 +202,14 @@ func TestMaster_CreateCollectionTask(t *testing.T) {
|
||||
collMeta, err = svr.mt.GetCollectionByName(sch.Name)
|
||||
assert.NotNil(t, err)
|
||||
|
||||
// HasCollection "col1" is false
|
||||
reqHasCollection.Timestamp = Timestamp(11)
|
||||
reqHasCollection.CollectionName.CollectionName = "col1"
|
||||
boolResp, err = cli.HasCollection(ctx, &reqHasCollection)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, false, boolResp.Value)
|
||||
assert.Equal(t, commonpb.ErrorCode_SUCCESS, boolResp.Status.ErrorCode)
|
||||
|
||||
// Drop again
|
||||
st, err = cli.DropCollection(ctx, &reqDrop)
|
||||
assert.Nil(t, err)
|
||||
@ -182,5 +222,10 @@ func TestMaster_CreateCollectionTask(t *testing.T) {
|
||||
log.Printf(st.Reason)
|
||||
assert.Equal(t, st.ErrorCode, commonpb.ErrorCode_SUCCESS)
|
||||
|
||||
boolResp, err = cli.HasCollection(ctx, &reqHasCollection)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, true, boolResp.Value)
|
||||
assert.Equal(t, commonpb.ErrorCode_SUCCESS, boolResp.Status.ErrorCode)
|
||||
|
||||
svr.Close()
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ func (s *Master) HasCollection(ctx context.Context, in *internalpb.HasCollection
|
||||
|
||||
response := &servicepb.BoolResponse{
|
||||
Status: st,
|
||||
Value: t.(*hasCollectionTask).hasCollection,
|
||||
Value: false,
|
||||
}
|
||||
|
||||
var err = s.scheduler.Enqueue(t)
|
||||
@ -109,6 +109,7 @@ func (s *Master) HasCollection(ctx context.Context, in *internalpb.HasCollection
|
||||
}
|
||||
|
||||
st.ErrorCode = commonpb.ErrorCode_SUCCESS
|
||||
response.Value = t.(*hasCollectionTask).hasCollection
|
||||
return response, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user