From 10f84ff08ebc392da5fbf52ed864d96edaa5d36c Mon Sep 17 00:00:00 2001 From: ThreadDao Date: Wed, 15 Nov 2023 19:35:14 +0800 Subject: [PATCH] Skip output invalid field case Signed-off-by: ThreadDao --- test/testcases/query_test.go | 56 +++++++------- test/testcases/search_test.go | 136 +++++++++++++++++----------------- 2 files changed, 99 insertions(+), 93 deletions(-) diff --git a/test/testcases/query_test.go b/test/testcases/query_test.go index 84dc0bc3..5d7f579c 100644 --- a/test/testcases/query_test.go +++ b/test/testcases/query_test.go @@ -263,42 +263,44 @@ func TestQueryNonPrimaryFields(t *testing.T) { // test query empty or one scalar output fields func TestQueryEmptyOutputFields(t *testing.T) { + t.Skip("https://github.com/milvus-io/milvus/issues/28465") t.Parallel() ctx := createContext(t, time.Second*common.DefaultTimeout) // connect mc := createMilvusClient(ctx, t) - enableDynamic := false - // create, insert, index - collName, ids := createCollectionWithDataIndex(ctx, t, mc, true, true, client.WithEnableDynamicSchema(enableDynamic)) + for _, enableDynamic := range []bool{true, false} { + // create, insert, index + collName, ids := createCollectionWithDataIndex(ctx, t, mc, true, true, client.WithEnableDynamicSchema(enableDynamic)) - // Load collection - errLoad := mc.LoadCollection(ctx, collName, false) - common.CheckErr(t, errLoad, true) + // Load collection + errLoad := mc.LoadCollection(ctx, collName, false) + common.CheckErr(t, errLoad, true) - //query with empty output fields []string{}-> output "int64" - queryEmptyOutputs, _ := mc.QueryByPks( - ctx, collName, []string{common.DefaultPartition}, - entity.NewColumnInt64(common.DefaultIntFieldName, ids.(*entity.ColumnInt64).Data()[:10]), - []string{}, - ) - common.CheckOutputFields(t, queryEmptyOutputs, []string{common.DefaultIntFieldName}) + //query with empty output fields []string{}-> output "int64" + queryEmptyOutputs, _ := mc.QueryByPks( + ctx, collName, []string{common.DefaultPartition}, + entity.NewColumnInt64(common.DefaultIntFieldName, ids.(*entity.ColumnInt64).Data()[:10]), + []string{}, + ) + common.CheckOutputFields(t, queryEmptyOutputs, []string{common.DefaultIntFieldName}) - //query with empty output fields []string{""}-> output "int64" and dynamic field - _, err := mc.QueryByPks( - ctx, collName, []string{common.DefaultPartition}, - entity.NewColumnInt64(common.DefaultIntFieldName, ids.(*entity.ColumnInt64).Data()[:10]), - []string{""}, - ) + //query with empty output fields []string{""}-> output "int64" and dynamic field + queryEmptyOutputs, err := mc.QueryByPks( + ctx, collName, []string{common.DefaultPartition}, + entity.NewColumnInt64(common.DefaultIntFieldName, ids.(*entity.ColumnInt64).Data()[:10]), + []string{""}, + ) - common.CheckErr(t, err, false, "not exist") + common.CheckErr(t, err, false, "not exist") - // query with "float" output fields -> output "int64, float" - queryFloatOutputs, _ := mc.QueryByPks( - ctx, collName, []string{common.DefaultPartition}, - entity.NewColumnInt64(common.DefaultIntFieldName, ids.(*entity.ColumnInt64).Data()[:10]), - []string{common.DefaultFloatFieldName}, - ) - common.CheckOutputFields(t, queryFloatOutputs, []string{common.DefaultIntFieldName, common.DefaultFloatFieldName}) + // query with "float" output fields -> output "int64, float" + queryFloatOutputs, _ := mc.QueryByPks( + ctx, collName, []string{common.DefaultPartition}, + entity.NewColumnInt64(common.DefaultIntFieldName, ids.(*entity.ColumnInt64).Data()[:10]), + []string{common.DefaultFloatFieldName}, + ) + common.CheckOutputFields(t, queryFloatOutputs, []string{common.DefaultIntFieldName, common.DefaultFloatFieldName}) + } } // test query output int64 and float and floatVector fields diff --git a/test/testcases/search_test.go b/test/testcases/search_test.go index d32775e3..7bd8fa41 100644 --- a/test/testcases/search_test.go +++ b/test/testcases/search_test.go @@ -262,93 +262,97 @@ func TestSearchPartitions(t *testing.T) { // test search empty output fields []string{} -> [], []string{""} func TestSearchEmptyOutputFields(t *testing.T) { + t.Skip("https://github.com/milvus-io/milvus/issues/28465") t.Parallel() ctx := createContext(t, time.Second*common.DefaultTimeout) // connect mc := createMilvusClient(ctx, t) - enableDynamic := false - // create collection with data - collName, _ := createCollectionWithDataIndex(ctx, t, mc, false, true, client.WithEnableDynamicSchema(enableDynamic)) + for _, enableDynamic := range []bool{true, false} { + // create collection with data + collName, _ := createCollectionWithDataIndex(ctx, t, mc, false, true, client.WithEnableDynamicSchema(enableDynamic)) - // load collection - errLoad := mc.LoadCollection(ctx, collName, false) - common.CheckErr(t, errLoad, true) + // load collection + errLoad := mc.LoadCollection(ctx, collName, false) + common.CheckErr(t, errLoad, true) - // search vector output fields []string{} -> [] - sp, _ := entity.NewIndexHNSWSearchParam(74) - searchResPkOutput, errSearch := mc.Search( - ctx, collName, - []string{}, - "", - []string{}, - common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector), - common.DefaultFloatVecFieldName, - entity.L2, - common.DefaultTopK, - sp, - ) - common.CheckErr(t, errSearch, true) - common.CheckOutputFields(t, searchResPkOutput[0].Fields, []string{}) - common.CheckSearchResult(t, searchResPkOutput, common.DefaultNq, common.DefaultTopK) + // search vector output fields []string{} -> [] + sp, _ := entity.NewIndexHNSWSearchParam(74) + searchResPkOutput, errSearch := mc.Search( + ctx, collName, + []string{}, + "", + []string{}, + common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector), + common.DefaultFloatVecFieldName, + entity.L2, + common.DefaultTopK, + sp, + ) + common.CheckErr(t, errSearch, true) + common.CheckOutputFields(t, searchResPkOutput[0].Fields, []string{}) + common.CheckSearchResult(t, searchResPkOutput, common.DefaultNq, common.DefaultTopK) - // search vector output fields []string{""} - _, errSearchExist := mc.Search( - ctx, collName, - []string{}, - "", - []string{""}, - common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector), - common.DefaultFloatVecFieldName, - entity.L2, - common.DefaultTopK, - sp, - ) + // search vector output fields []string{""} + _, errSearchExist := mc.Search( + ctx, collName, + []string{}, + "", + []string{""}, + common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector), + common.DefaultFloatVecFieldName, + entity.L2, + common.DefaultTopK, + sp, + ) - //if enableDynamic { - // common.CheckErr(t, errSearchExist, true) - // common.CheckOutputFields(t, sp1[0].Fields, []string{""}) - //} else { - common.CheckErr(t, errSearchExist, false, "not exist") - //} - common.CheckSearchResult(t, searchResPkOutput, common.DefaultNq, common.DefaultTopK) + //if enableDynamic { + // common.CheckErr(t, errSearchExist, true) + // common.CheckOutputFields(t, sp1[0].Fields, []string{""}) + //} else { + common.CheckErr(t, errSearchExist, false, "not exist") + //} + common.CheckSearchResult(t, searchResPkOutput, common.DefaultNq, common.DefaultTopK) + } } -// test search output fields not exist -> error +// test search output fields not exist -> output existed fields func TestSearchNotExistOutputFields(t *testing.T) { + t.Skip("https://github.com/milvus-io/milvus/issues/28465") t.Parallel() ctx := createContext(t, time.Second*common.DefaultTimeout) // connect mc := createMilvusClient(ctx, t) - // dynamic schema with unknown field will not have error - enableDynamic := false - // create collection with data - collName, _ := createCollectionWithDataIndex(ctx, t, mc, false, true, client.WithEnableDynamicSchema(enableDynamic)) + for _, enableDynamic := range []bool{false} { + // create collection with data + collName, _ := createCollectionWithDataIndex(ctx, t, mc, false, true, client.WithEnableDynamicSchema(enableDynamic)) - // load collection - errLoad := mc.LoadCollection(ctx, collName, false) - common.CheckErr(t, errLoad, true) + // load collection + errLoad := mc.LoadCollection(ctx, collName, false) + common.CheckErr(t, errLoad, true) - type notExistOutputFields []string + type notExistOutputFields []string - // search vector output fields not exist, part exist - outputFields := []notExistOutputFields{[]string{"aaa"}, []string{"fields", common.DefaultFloatFieldName}, - []string{"fields", "*"}} - for _, fields := range outputFields { + // search vector output fields not exist, part exist + outputFields := []notExistOutputFields{[]string{"aaa"}, []string{"fields", common.DefaultFloatFieldName}, + []string{"fields", "*"}} sp, _ := entity.NewIndexHNSWSearchParam(74) - _, errSearch := mc.Search( - ctx, collName, - []string{}, - "", - fields, - common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector), - common.DefaultFloatVecFieldName, - entity.L2, - common.DefaultTopK, - sp, - ) - common.CheckErr(t, errSearch, false, "not exist") + for _, fields := range outputFields { + log.Println(fields) + _, errSearch := mc.Search( + ctx, collName, + []string{}, + "", + fields, + common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector), + common.DefaultFloatVecFieldName, + entity.L2, + common.DefaultTopK, + sp, + ) + common.CheckErr(t, errSearch, true) + } } }