mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 11:59:00 +08:00
962a5446f8
Related to #33716 This PR add context param in SyncTask.Run execution functions to make it cancellable from the caller. This make it possible to cancel task when datanode/data sync service is beeing shut down. Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
69 lines
1.4 KiB
Go
69 lines
1.4 KiB
Go
package iterator
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
"github.com/milvus-io/milvus/internal/storage"
|
|
)
|
|
|
|
func TestDeltalogIteratorSuite(t *testing.T) {
|
|
suite.Run(t, new(DeltalogIteratorSuite))
|
|
}
|
|
|
|
type DeltalogIteratorSuite struct {
|
|
suite.Suite
|
|
}
|
|
|
|
func (s *DeltalogIteratorSuite) TestDeltalogIteratorIntPK() {
|
|
s.Run("invalid blobs", func() {
|
|
iter := NewDeltalogIterator([][]byte{}, nil)
|
|
|
|
s.NotNil(iter)
|
|
s.False(iter.HasNext())
|
|
})
|
|
|
|
testpks := []int64{1, 2, 3, 4}
|
|
testtss := []uint64{43757345, 43757346, 43757347, 43757348}
|
|
|
|
dData := &storage.DeleteData{}
|
|
for i := range testpks {
|
|
dData.Append(storage.NewInt64PrimaryKey(testpks[i]), testtss[i])
|
|
}
|
|
|
|
dCodec := storage.NewDeleteCodec()
|
|
blob, err := dCodec.Serialize(CollectionID, 1, 1, dData)
|
|
s.Require().NoError(err)
|
|
value := [][]byte{blob.Value}
|
|
|
|
iter := NewDeltalogIterator(value, &Label{segmentID: 100})
|
|
s.NotNil(iter)
|
|
|
|
var (
|
|
gotpks = []int64{}
|
|
gottss = []uint64{}
|
|
)
|
|
|
|
for iter.HasNext() {
|
|
labeled, err := iter.Next()
|
|
s.NoError(err)
|
|
|
|
s.Equal(labeled.GetSegmentID(), int64(100))
|
|
gotpks = append(gotpks, labeled.GetPk().GetValue().(int64))
|
|
gottss = append(gottss, labeled.GetTimestamp())
|
|
}
|
|
|
|
s.ElementsMatch(gotpks, testpks)
|
|
s.ElementsMatch(gottss, testtss)
|
|
|
|
_, err = iter.Next()
|
|
s.ErrorIs(err, ErrNoMoreRecord)
|
|
|
|
iter.Dispose()
|
|
iter.WaitForDisposed()
|
|
|
|
_, err = iter.Next()
|
|
s.ErrorIs(err, ErrDisposed)
|
|
}
|