snowflake_sequencer_test.go 555 B

12345678910111213141516171819202122232425
  1. package sequence
  2. import (
  3. "encoding/hex"
  4. "github.com/seaweedfs/seaweedfs/weed/storage/types"
  5. "github.com/stretchr/testify/assert"
  6. "testing"
  7. )
  8. func TestSequencer(t *testing.T) {
  9. seq, err := NewSnowflakeSequencer("for_test", 1)
  10. assert.Equal(t, nil, err)
  11. last := uint64(0)
  12. bytes := make([]byte, types.NeedleIdSize)
  13. for i := 0; i < 100; i++ {
  14. next := seq.NextFileId(1)
  15. types.NeedleIdToBytes(bytes, types.NeedleId(next))
  16. println(hex.EncodeToString(bytes))
  17. if last == next {
  18. t.Errorf("last %d next %d", last, next)
  19. }
  20. last = next
  21. }
  22. }