mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
54 lines
955 B
Go
54 lines
955 B
Go
package messages
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestAddMessage1(t *testing.T) {
|
|
mp := NewMessagePipeline(0, 3, 10, time.Second, &EmptyMover{})
|
|
go func() {
|
|
for i := 0; i < 100; i++ {
|
|
mr := mp.NextMessageBufferReference()
|
|
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()
|
|
|
|
}
|
|
|
|
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)
|
|
}
|
|
|
|
}
|