Skip to content

Commit

Permalink
Update skip cases
Browse files Browse the repository at this point in the history
Signed-off-by: ThreadDao <[email protected]>
  • Loading branch information
ThreadDao committed Apr 12, 2024
1 parent 92a5da3 commit 05f8992
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 65 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/milvus-io/milvus-proto/go-api/v2 v2.4.0-rc.1
github.com/stretchr/testify v1.8.1
github.com/tidwall/gjson v1.14.4
github.com/x448/float16 v0.8.4
google.golang.org/grpc v1.48.0
google.golang.org/grpc/examples v0.0.0-20220617181431-3e7b97febc7f
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBn
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
Expand Down
36 changes: 19 additions & 17 deletions test/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import (
"encoding/json"
"fmt"
"log"
"math"
"math/rand"
"strconv"
"strings"
"time"
"unsafe"

"github.com/x448/float16"

"github.com/milvus-io/milvus-sdk-go/v2/entity"
)
Expand Down Expand Up @@ -191,27 +193,28 @@ func GenFloatVector(dim int64) []float32 {
}

func GenFloat16Vector(dim int64) []byte {
vector := make([]byte, 0, dim)
fp16Data := make([]byte, 2)
ret := make([]byte, dim*2)
for i := 0; i < int(dim); i++ {
f := rand.Float32()
u32 := *(*uint32)(unsafe.Pointer(&f))
binary.LittleEndian.PutUint16(fp16Data, uint16(u32>>16))
vector = append(vector, fp16Data...)
v := float16.Fromfloat32(rand.Float32()).Bits()
binary.LittleEndian.PutUint16(ret[i*2:], v)
}
return vector
return ret
}

func GenBFloat16Vector(dim int64) []byte {
vector := make([]byte, 0, dim)
bf16Data := make([]byte, 2)
ret16 := make([]uint16, 0, dim)
for i := 0; i < int(dim); i++ {
f := rand.Float32()
u32 := *(*uint32)(unsafe.Pointer(&f))
binary.LittleEndian.PutUint16(bf16Data, uint16(u32>>16))
vector = append(vector, bf16Data...)
bits := math.Float32bits(f)
bits >>= 16
bits &= 0x7FFF
ret16 = append(ret16, uint16(bits))
}
return vector
ret := make([]byte, len(ret16)*2)
for i, value := range ret16 {
binary.LittleEndian.PutUint16(ret[i*2:], value)
}
return ret
}

func GenBinaryVector(dim int64) []byte {
Expand Down Expand Up @@ -1242,9 +1245,8 @@ func GenAllFloatIndex() []entity.Index {
idxIvfPq, _ := entity.NewIndexIvfPQ(metricType, nlist, 16, 8)
idxHnsw, _ := entity.NewIndexHNSW(metricType, 8, 96)
idxScann, _ := entity.NewIndexSCANN(metricType, 16, false)
// TODO waiting for PR https://github.com/milvus-io/milvus/pull/30716
//idxDiskAnn, _ := entity.NewIndexDISKANN(metricType)
allFloatIndex = append(allFloatIndex, idxFlat, idxIvfFlat, idxIvfSq8, idxIvfPq, idxHnsw, idxScann)
idxDiskAnn, _ := entity.NewIndexDISKANN(metricType)
allFloatIndex = append(allFloatIndex, idxFlat, idxIvfFlat, idxIvfSq8, idxIvfPq, idxHnsw, idxScann, idxDiskAnn)
}
return allFloatIndex
}
Expand Down
13 changes: 12 additions & 1 deletion test/testcases/collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,16 @@ func TestCreateCollectionDynamicSchema(t *testing.T) {
collections, errListCollection := mc.ListCollections(ctx)
common.CheckErr(t, errListCollection, true)
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}
_, err = insertData(ctx, t, mc, dp)
common.CheckErr(t, err, true)
}

// test create collection enable dynamic field by collection opt
func TestCreateCollectionDynamic(t *testing.T) {
t.Skip("Waiting for congqi to update schema.EnableDynamicField according to the CreateCollectionOption.EnableDynamicSchema")
ctx := createContext(t, time.Second*common.DefaultTimeout)
mc := createMilvusClient(ctx, t)

Expand All @@ -512,6 +517,12 @@ func TestCreateCollectionDynamic(t *testing.T) {
collections, errListCollection := mc.ListCollections(ctx)
common.CheckErr(t, errListCollection, true)
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}
_, err = insertData(ctx, t, mc, dp)
common.CheckErr(t, err, true)
}

// test create collection contains field name: $meta -> error
Expand Down
31 changes: 23 additions & 8 deletions test/testcases/compact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package testcases

import (
"log"
"testing"
"time"

Expand All @@ -14,7 +13,6 @@ import (
)

func TestCompact(t *testing.T) {
t.Skip("Issue: https://github.com/milvus-io/milvus-sdk-go/issues/379")
ctx := createContext(t, time.Second*common.DefaultTimeout)
// connect
mc := createMilvusClient(ctx, t)
Expand All @@ -34,15 +32,21 @@ func TestCompact(t *testing.T) {

// get persisted segments
segments, _ := mc.GetPersistentSegmentInfo(ctx, collName)
for _, s := range segments {
log.Printf("Id: %d, numRows: %d", s.ID, s.NumRows)
require.Len(t, segments, 4)
segIds := make([]int64, 0, 4)
for _, seg := range segments {
require.Equal(t, seg.NumRows, int64(common.DefaultNb))
segIds = append(segIds, seg.ID)
}

indexHnsw, _ := entity.NewIndexHNSW(entity.L2, 8, 96)
for _, field := range common.AllVectorsFieldsName {
indexBinary, _ := entity.NewIndexBinIvfFlat(entity.JACCARD, 64)
for _, field := range common.AllFloatVectorsFieldNames {
err := mc.CreateIndex(ctx, collName, field, indexHnsw, false)
common.CheckErr(t, err, true)
}
err := mc.CreateIndex(ctx, collName, common.DefaultBinaryVecFieldName, indexBinary, false)
common.CheckErr(t, err, true)

// compact
compactionID, errCompact := mc.Compact(ctx, collName, 100)
Expand All @@ -55,14 +59,25 @@ func TestCompact(t *testing.T) {
// get compaction plan
compactionState2, compactionPlan, errPlan := mc.GetCompactionStateWithPlans(ctx, compactionID)
common.CheckErr(t, errPlan, true)
log.Println(compactionState2)
log.Println(compactionPlan)
require.Equal(t, compactionState2, entity.CompactionStateCompleted)
var targetSeg int64
for _, plan := range compactionPlan {
if plan.PlanType == entity.CompactionPlanMergeSegments {
require.ElementsMatch(t, segIds, plan.Source)
targetSeg = plan.Target
}
}

// get persisted segments
segments2, _ := mc.GetPersistentSegmentInfo(ctx, collName)
var actualSeg []int64
actualRows := 0
for _, s := range segments2 {
log.Printf("Id: %d, numRows: %d", s.ID, s.NumRows)
actualSeg = append(actualSeg, s.ID)
actualRows = int(s.NumRows) + actualRows
}
require.Equal(t, common.DefaultNb*4, actualRows)
require.ElementsMatch(t, []int64{targetSeg}, actualSeg)
}

// test compaction collection not exist
Expand Down
18 changes: 14 additions & 4 deletions test/testcases/configure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func TestLoadCollectionReplicas(t *testing.T) {

// config common.retentionDuration=40 -> test compact after delete half
func TestCompactAfterDelete(t *testing.T) {
t.Skip("Issue: https://github.com/milvus-io/milvus-sdk-go/issues/379")
ctx := createContext(t, time.Second*common.DefaultTimeout)
// connect
mc := createMilvusClient(ctx, t)
Expand All @@ -66,6 +65,14 @@ func TestCompactAfterDelete(t *testing.T) {
errFlush := mc.Flush(ctx, collName, false)
common.CheckErr(t, errFlush, true)

segments, _ := mc.GetPersistentSegmentInfo(ctx, collName)
require.Len(t, segments, 1)

// index
indexHnsw, _ := entity.NewIndexHNSW(entity.L2, 8, 96)
err := mc.CreateIndex(ctx, collName, common.DefaultFloatVecFieldName, indexHnsw, false)
common.CheckErr(t, err, true)

// delete half ids
deleteIds := entity.NewColumnInt64(common.DefaultIntFieldName, ids.(*entity.ColumnInt64).Data()[:common.DefaultNb/2])
errDelete := mc.DeleteByPks(ctx, collName, "", deleteIds)
Expand All @@ -74,9 +81,12 @@ func TestCompactAfterDelete(t *testing.T) {
// compact
time.Sleep(common.RetentionDuration + 1)
compactionID, _ := mc.Compact(ctx, collName, 0)
mc.WaitForCompactionCompleted(ctx, compactionID)
err = mc.WaitForCompactionCompleted(ctx, compactionID)
common.CheckErr(t, err, true)

// get compaction plans
_, plans, _ := mc.GetCompactionStateWithPlans(ctx, compactionID)
log.Println(plans)
state, plans, _ := mc.GetCompactionStateWithPlans(ctx, compactionID)
require.Equal(t, state, entity.CompactionStateCompleted)
require.Len(t, plans, 1)
require.ElementsMatch(t, []int64{segments[0].ID}, plans[0].Source)
}
1 change: 0 additions & 1 deletion test/testcases/groupby_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ func TestSearchGroupByBinaryDefault(t *testing.T) {
// default Bounded ConsistencyLevel -> succ ??
// strong ConsistencyLevel -> error
func TestSearchGroupByBinaryGrowing(t *testing.T) {
//t.Skip("#31134")
t.Parallel()
for _, metricType := range common.SupportBinIvfFlatMetricType {
idxBinIvfFlat, _ := entity.NewIndexBinIvfFlat(metricType, 128)
Expand Down
20 changes: 13 additions & 7 deletions test/testcases/hybrid_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ func TestHybridSearchDefault(t *testing.T) {

// hybrid search default -> verify success
func TestHybridSearchMultiVectorsDefault(t *testing.T) {
t.Skip("https://github.com/milvus-io/milvus/issues/32222")
t.Parallel()
ctx := createContext(t, time.Second*common.DefaultTimeout*2)
ctx := createContext(t, time.Second*common.DefaultTimeout*3)
// connect
mc := createMilvusClient(ctx, t)
for _, enableDynamic := range []bool{false, true} {
Expand Down Expand Up @@ -78,8 +79,8 @@ func TestHybridSearchMultiVectorsDefault(t *testing.T) {
}
sp, _ := entity.NewIndexFlatSearchParam()
expr := fmt.Sprintf("%s > 5", common.DefaultIntFieldName)
queryVec1 := common.GenSearchVectors(1, common.DefaultDim, entity.FieldTypeFloatVector)
queryVec2 := common.GenSearchVectors(1, common.DefaultDim, entity.FieldTypeFloat16Vector)
queryVec1 := common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector)
queryVec2 := common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloat16Vector)

// search with different reranker and limit
for _, reranker := range []client.Reranker{client.NewRRFReranker(),
Expand All @@ -95,7 +96,7 @@ func TestHybridSearchMultiVectorsDefault(t *testing.T) {
}
searchRes, errSearch := mc.HybridSearch(ctx, collName, []string{}, limit.limit3, []string{"*"}, reranker, sReqs)
common.CheckErr(t, errSearch, true)
common.CheckSearchResult(t, searchRes, 1, limit.expLimit)
common.CheckSearchResult(t, searchRes, common.DefaultNq, limit.expLimit)
common.CheckOutputFields(t, searchRes[0].Fields, common.GetAllFieldsName(enableDynamic, false))
}
}
Expand All @@ -107,7 +108,6 @@ func TestHybridSearchMultiVectorsDefault(t *testing.T) {
// invalid fieldName: not exist
// invalid metric type: mismatch
func TestHybridSearchInvalidParams(t *testing.T) {
t.Skip("t.Skip(\"https://github.com/milvus-io/milvus-sdk-go/issues/693\")")
ctx := createContext(t, time.Second*common.DefaultTimeout*2)
// connect
mc := createMilvusClient(ctx, t)
Expand Down Expand Up @@ -209,7 +209,8 @@ func TestHybridSearchInvalidVectors(t *testing.T) {

// hybrid search Pagination -> verify success
func TestHybridSearchMultiVectorsPagination(t *testing.T) {
t.Skip("https://github.com/milvus-io/milvus-sdk-go/issues/693")
// TODO "https://github.com/milvus-io/milvus/issues/32174"
// TODO "https://github.com/milvus-io/milvus-sdk-go/issues/718"
t.Parallel()
ctx := createContext(t, time.Second*common.DefaultTimeout*2)
// connect
Expand All @@ -231,13 +232,18 @@ func TestHybridSearchMultiVectorsPagination(t *testing.T) {
expr := fmt.Sprintf("%s > 4", common.DefaultIntFieldName)
queryVec1 := common.GenSearchVectors(1, common.DefaultDim, entity.FieldTypeFloatVector)
queryVec2 := common.GenSearchVectors(1, common.DefaultDim, entity.FieldTypeFloat16Vector)
// milvus ignore invalid offset with ANNSearchRequest
for _, invalidOffset := range []int64{-1, common.MaxTopK + 1} {
sReqs := []*client.ANNSearchRequest{
client.NewANNSearchRequest(common.DefaultFloatVecFieldName, entity.L2, "", queryVec1, sp, common.DefaultTopK, client.WithOffset(invalidOffset)),
client.NewANNSearchRequest(common.DefaultFloat16VecFieldName, entity.L2, "", queryVec2, sp, common.DefaultTopK),
}
_, errSearch := mc.HybridSearch(ctx, collName, []string{}, common.DefaultTopK, []string{}, client.NewRRFReranker(), sReqs)
common.CheckErr(t, errSearch, false, "top k should be in range [1, 16384]")
common.CheckErr(t, errSearch, true)

// hybrid search with invalid offset
//_, errSearch := mc.HybridSearch(ctx, collName, []string{}, common.DefaultTopK, []string{}, client.NewRRFReranker(), sReqs, client.WithOffset(invalidOffset))
//common.CheckErr(t, errSearch, false, "top k should be in range [1, 16384]")
}

// search with different reranker and offset
Expand Down
16 changes: 7 additions & 9 deletions test/testcases/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ func TestCreateInvertedScalarIndex(t *testing.T) {

// test create index on vector field
func TestCreateScalarIndexVectorField(t *testing.T) {
t.Skip("https://github.com/milvus-io/milvus-sdk-go/issues/701")
ctx := createContext(t, time.Second*common.DefaultTimeout*2)
// connect
mc := createMilvusClient(ctx, t)
Expand All @@ -359,20 +358,19 @@ func TestCreateScalarIndexVectorField(t *testing.T) {

for _, ip := range []entity.IndexType{entity.Sorted, entity.Trie, entity.Inverted} {
idx := entity.NewScalarIndexWithType(ip)
idxDefault := entity.NewScalarIndex()
for _, fieldName := range common.AllVectorsFieldsName {
err := mc.CreateIndex(ctx, collName, fieldName, idx, false)
common.CheckErr(t, err, false, "STL_SORT are only supported on numeric field",
"TRIE are only supported on varchar field", "INVERTED are not supported on")

// create default scalar index on vector field
// TODO ???
err = mc.CreateIndex(ctx, collName, fieldName, idxDefault, false)
common.CheckErr(t, err, true)
descIndex, _ := mc.DescribeIndex(ctx, collName, fieldName)
log.Println(descIndex[0].IndexType(), descIndex[0].Params())
}
}
for _, fieldName := range common.AllFloatVectorsFieldNames {
idxDefault := entity.NewScalarIndex()
err := mc.CreateIndex(ctx, collName, fieldName, idxDefault, false)
common.CheckErr(t, err, true)
descIndex, _ := mc.DescribeIndex(ctx, collName, fieldName)
require.Equal(t, entity.AUTOINDEX, descIndex[0].IndexType())
}
}

// test create scalar index with vector field name
Expand Down
Loading

0 comments on commit 05f8992

Please sign in to comment.