seaweedfs/weed/mq/messages/message_pipeline_test.go

54 lines
955 B
Go
Raw Normal View History

2022-09-25 18:19:05 +00:00
package messages
import (
"testing"
"time"
)
2022-09-26 00:57:26 +00:00
func TestAddMessage1(t *testing.T) {
2022-09-25 18:19:05 +00:00
mp := NewMessagePipeline(0, 3, 10, time.Second, &EmptyMover{})
go func() {
2022-09-26 00:57:26 +00:00
for i := 0; i < 100; i++ {
mr := mp.NextMessageBufferReference()
2022-09-25 18:19:05 +00:00
println(mr.sequence, mr.fileId)
}
}()
for i := 0; i < 100; i++ {
message := &Message{
Key: []byte("key"),
Content: []byte("data"),
Properties: nil,
Ts: time.Now(),
}
mp.AddMessage(message)
}
mp.ShutdownStart()
mp.ShutdownWait()
2022-09-26 00:57:26 +00:00
}
func TestAddMessage2(t *testing.T) {
mp := NewMessagePipeline(0, 3, 10, time.Second, &EmptyMover{})
for i := 0; i < 100; i++ {
message := &Message{
Key: []byte("key"),
Content: []byte("data"),
Properties: nil,
Ts: time.Now(),
}
mp.AddMessage(message)
}
mp.ShutdownStart()
mp.ShutdownWait()
for i := 0; i < 100; i++ {
mr := mp.NextMessageBufferReference()
println(mr.sequence, mr.fileId)
}
2022-09-25 18:19:05 +00:00
}