mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 17:18:35 +08:00
issue: #38399 - Make a timetick-commit-based write ahead buffer at write side. - Add a switchable scanner at read side to transfer the state between catchup and tailing read Signed-off-by: chyezh <chyezh@outlook.com>
38 lines
993 B
Go
38 lines
993 B
Go
package utility
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/milvus-io/milvus/pkg/mocks/streaming/util/mock_message"
|
|
"github.com/milvus-io/milvus/pkg/streaming/util/message"
|
|
)
|
|
|
|
func TestPendingQueue(t *testing.T) {
|
|
pq := NewPendingQueue()
|
|
|
|
// Test initial state
|
|
assert.Equal(t, 0, pq.Bytes())
|
|
|
|
// Test AddOne
|
|
msg1 := mock_message.NewMockImmutableMessage(t)
|
|
msg1.EXPECT().EstimateSize().Return(1)
|
|
pq.AddOne(msg1)
|
|
assert.Equal(t, msg1.EstimateSize(), pq.Bytes())
|
|
|
|
// Test Add
|
|
msg2 := mock_message.NewMockImmutableMessage(t)
|
|
msg2.EXPECT().EstimateSize().Return(2)
|
|
msg3 := mock_message.NewMockImmutableMessage(t)
|
|
msg3.EXPECT().EstimateSize().Return(3)
|
|
pq.Add([]message.ImmutableMessage{msg2, msg3})
|
|
expectedBytes := msg1.EstimateSize() + msg2.EstimateSize() + msg3.EstimateSize()
|
|
assert.Equal(t, expectedBytes, pq.Bytes())
|
|
|
|
// Test UnsafeAdvance
|
|
pq.UnsafeAdvance()
|
|
expectedBytes -= msg1.EstimateSize()
|
|
assert.Equal(t, expectedBytes, pq.Bytes())
|
|
}
|