mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
verify seq is always unique
This commit is contained in:
parent
46ae28d64c
commit
217d7dc377
25
weed/sequence/snowflake_sequencer_test.go
Normal file
25
weed/sequence/snowflake_sequencer_test.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package sequence
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"github.com/chrislusf/seaweedfs/weed/storage/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSequencer(t *testing.T) {
|
||||
seq, err := NewSnowflakeSequencer("for_test", 1)
|
||||
assert.Equal(t, nil, err)
|
||||
last := uint64(0)
|
||||
bytes := make([]byte, types.NeedleIdSize)
|
||||
for i := 0; i < 100; i++ {
|
||||
next := seq.NextFileId(1)
|
||||
types.NeedleIdToBytes(bytes, types.NeedleId(next))
|
||||
println(hex.EncodeToString(bytes))
|
||||
if last == next {
|
||||
t.Errorf("last %d next %d", last, next)
|
||||
}
|
||||
last = next
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue