Skip to content

Commit

Permalink
Fix test case error message
Browse files Browse the repository at this point in the history
Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia committed Oct 23, 2024
1 parent f2e0e3b commit 7003d7b
Show file tree
Hide file tree
Showing 8 changed files with 524 additions and 203 deletions.
28 changes: 18 additions & 10 deletions test/testcases/collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,16 @@ func TestCreateCollectionInvalidFields(t *testing.T) {
}
invalidFields := []invalidFieldsStruct{
// create collection without pk field
{fields: []*entity.Field{common.GenField(common.DefaultFloatVecFieldName, entity.FieldTypeFloatVector, common.WithDim(common.DefaultDim))},
errMsg: "primary key is not specified"},
{
fields: []*entity.Field{common.GenField(common.DefaultFloatVecFieldName, entity.FieldTypeFloatVector, common.WithDim(common.DefaultDim))},
errMsg: "primary key is not specified",
},

// create collection without vector field
{fields: []*entity.Field{common.GenField(common.DefaultIntFieldName, entity.FieldTypeInt64, common.WithIsPrimaryKey(true))},
errMsg: "vector field not set"},
{
fields: []*entity.Field{common.GenField(common.DefaultIntFieldName, entity.FieldTypeInt64, common.WithIsPrimaryKey(true))},
errMsg: "vector field not set",
},

// create collection with multi pk fields
{fields: []*entity.Field{
Expand Down Expand Up @@ -354,7 +358,7 @@ func TestCreateCollectionDescription(t *testing.T) {
pkField := common.GenField(common.DefaultIntFieldName, entity.FieldTypeInt64, common.WithIsPrimaryKey(true),
common.WithFieldDescription("pk field"))
vecField := common.GenField("", entity.FieldTypeFloatVector, common.WithDim(common.DefaultDim))
var fields = []*entity.Field{
fields := []*entity.Field{
pkField, vecField,
}
schema := &entity.Schema{
Expand Down Expand Up @@ -491,8 +495,10 @@ func TestCreateCollectionDynamicSchema(t *testing.T) {
common.CheckContainsCollection(t, collections, collName)

// insert data
dp := DataParams{CollectionName: collName, PartitionName: "", CollectionFieldsType: Int64FloatVec,
start: 0, nb: common.DefaultNb, dim: common.DefaultDim, EnableDynamicField: true, WithRows: false}
dp := DataParams{
CollectionName: collName, PartitionName: "", CollectionFieldsType: Int64FloatVec,
start: 0, nb: common.DefaultNb, dim: common.DefaultDim, EnableDynamicField: true, WithRows: false,
}
_, err = insertData(ctx, t, mc, dp)
common.CheckErr(t, err, true)
}
Expand All @@ -519,8 +525,10 @@ func TestCreateCollectionDynamic(t *testing.T) {
common.CheckContainsCollection(t, collections, collName)

// insert data
dp := DataParams{CollectionName: collName, PartitionName: "", CollectionFieldsType: Int64FloatVec,
start: 0, nb: common.DefaultNb, dim: common.DefaultDim, EnableDynamicField: true, WithRows: false}
dp := DataParams{
CollectionName: collName, PartitionName: "", CollectionFieldsType: Int64FloatVec,
start: 0, nb: common.DefaultNb, dim: common.DefaultDim, EnableDynamicField: true, WithRows: false,
}
_, err = insertData(ctx, t, mc, dp)
common.CheckErr(t, err, true)
}
Expand Down Expand Up @@ -693,5 +701,5 @@ func TestGetStaticsCollectionNotExisted(t *testing.T) {

// flush and check row count
_, errStatist := mc.GetCollectionStatistics(ctx, "collName")
common.CheckErr(t, errStatist, false, "collection collName does not exist")
common.CheckErr(t, errStatist, false, "collection not found")
}
14 changes: 9 additions & 5 deletions test/testcases/compact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ func TestCompact(t *testing.T) {
mc := createMilvusClient(ctx, t)

// create collection with 1 shard
cp := CollectionParams{CollectionFieldsType: AllFields, AutoID: false, EnableDynamicField: true,
ShardsNum: 1, Dim: common.DefaultDim}
cp := CollectionParams{
CollectionFieldsType: AllFields, AutoID: false, EnableDynamicField: true,
ShardsNum: 1, Dim: common.DefaultDim,
}
collName := createCollection(ctx, t, mc, cp)

// insert
for i := 0; i < 4; i++ {
dp := DataParams{CollectionName: collName, PartitionName: "", CollectionFieldsType: AllFields,
start: i * common.DefaultNb, nb: common.DefaultNb, dim: common.DefaultDim, EnableDynamicField: true, WithRows: false}
dp := DataParams{
CollectionName: collName, PartitionName: "", CollectionFieldsType: AllFields,
start: i * common.DefaultNb, nb: common.DefaultNb, dim: common.DefaultDim, EnableDynamicField: true, WithRows: false,
}
_, _ = insertData(ctx, t, mc, dp)
mc.Flush(ctx, collName, false)
}
Expand Down Expand Up @@ -87,7 +91,7 @@ func TestCompactCollectionNotExist(t *testing.T) {
mc := createMilvusClient(ctx, t)

_, err := mc.Compact(ctx, "coll", 0)
common.CheckErr(t, err, false, "collection coll does not exist")
common.CheckErr(t, err, false, "collection not found")
}

// test compact empty collection
Expand Down
16 changes: 10 additions & 6 deletions test/testcases/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestDeleteNotExistCollection(t *testing.T) {
// flush and check row count
deleteIds := entity.NewColumnInt64(common.DefaultIntFieldName, []int64{0, 1})
errDelete := mc.DeleteByPks(ctx, "collName", common.DefaultPartition, deleteIds)
common.CheckErr(t, errDelete, false, "collection collName does not exist")
common.CheckErr(t, errDelete, false, "collection not found")
}

// test delete from an not exist partition
Expand All @@ -105,7 +105,7 @@ func TestDeleteNotExistPartition(t *testing.T) {
// delete
deleteIds := ids.Slice(0, 10)
errDelete := mc.DeleteByPks(ctx, collName, "p1", deleteIds)
common.CheckErr(t, errDelete, false, fmt.Sprintf("partition p1 of collection %s does not exist", collName))
common.CheckErr(t, errDelete, false, fmt.Sprintf("partition not found", collName))
}

// test delete empty partition names
Expand Down Expand Up @@ -411,13 +411,17 @@ func TestDeleteComplexExprWithoutLoading(t *testing.T) {
// connect
mc := createMilvusClient(ctx, t)

cp := CollectionParams{CollectionFieldsType: Int64FloatVecJSON, AutoID: false, EnableDynamicField: true,
ShardsNum: common.DefaultShards, Dim: common.DefaultDim}
cp := CollectionParams{
CollectionFieldsType: Int64FloatVecJSON, AutoID: false, EnableDynamicField: true,
ShardsNum: common.DefaultShards, Dim: common.DefaultDim,
}
collName := createCollection(ctx, t, mc, cp, client.WithConsistencyLevel(entity.ClStrong))

// prepare and insert data
dp := DataParams{CollectionName: collName, PartitionName: "", CollectionFieldsType: Int64FloatVecJSON,
start: 0, nb: common.DefaultNb, dim: common.DefaultDim, EnableDynamicField: true, WithRows: false}
dp := DataParams{
CollectionName: collName, PartitionName: "", CollectionFieldsType: Int64FloatVecJSON,
start: 0, nb: common.DefaultNb, dim: common.DefaultDim, EnableDynamicField: true, WithRows: false,
}
_, _ = insertData(ctx, t, mc, dp)
mc.Flush(ctx, collName, false)

Expand Down
2 changes: 1 addition & 1 deletion test/testcases/flush_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestFlushNotExistedCollection(t *testing.T) {

// flush and check row count
errFlush := mc.Flush(ctx, "collName", false)
common.CheckErr(t, errFlush, false, "collection collName does not exist")
common.CheckErr(t, errFlush, false, "collection not found")
}

// test flush async
Expand Down
Loading

0 comments on commit 7003d7b

Please sign in to comment.