498b235461
Build and test / Build and test AMD64 Ubuntu 22.04 (push) Failing after 0s
Publish Builder / amazonlinux2023 (push) Failing after 1s
Build and test / UT for Go (push) Has been skipped
Publish KRTE Images / KRTE (push) Failing after 1s
Build and test / Integration Test (push) Has been skipped
Build and test / Upload Code Coverage (push) Has been skipped
Publish Builder / rockylinux9 (push) Failing after 1s
Publish Builder / ubuntu22.04 (push) Failing after 0s
Publish Builder / ubuntu24.04 (push) Failing after 0s
Publish Gpu Builder / publish-gpu-builder (push) Failing after 1s
Publish Test Images / PyTest (push) Failing after 0s
Build and test / UT for Cpp (push) Has been cancelled
38 lines
999 B
Go
38 lines
999 B
Go
package utility
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/milvus-io/milvus/pkg/v3/mocks/streaming/util/mock_message"
|
|
"github.com/milvus-io/milvus/pkg/v3/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())
|
|
}
|