You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.0 KiB

7 years ago
7 years ago
7 years ago
  1. package storage
  2. import (
  3. "github.com/joeslay/seaweedfs/weed/glog"
  4. . "github.com/joeslay/seaweedfs/weed/storage/types"
  5. "io/ioutil"
  6. "math/rand"
  7. "testing"
  8. )
  9. func TestFastLoadingNeedleMapMetrics(t *testing.T) {
  10. idxFile, _ := ioutil.TempFile("", "tmp.idx")
  11. nm := NewBtreeNeedleMap(idxFile)
  12. for i := 0; i < 10000; i++ {
  13. nm.Put(Uint64ToNeedleId(uint64(i+1)), Uint32ToOffset(uint32(0)), uint32(1))
  14. if rand.Float32() < 0.2 {
  15. nm.Delete(Uint64ToNeedleId(uint64(rand.Int63n(int64(i))+1)), Uint32ToOffset(uint32(0)))
  16. }
  17. }
  18. mm, _ := newNeedleMapMetricFromIndexFile(idxFile)
  19. glog.V(0).Infof("FileCount expected %d actual %d", nm.FileCount(), mm.FileCount())
  20. glog.V(0).Infof("DeletedSize expected %d actual %d", nm.DeletedSize(), mm.DeletedSize())
  21. glog.V(0).Infof("ContentSize expected %d actual %d", nm.ContentSize(), mm.ContentSize())
  22. glog.V(0).Infof("DeletedCount expected %d actual %d", nm.DeletedCount(), mm.DeletedCount())
  23. glog.V(0).Infof("MaxFileKey expected %d actual %d", nm.MaxFileKey(), mm.MaxFileKey())
  24. }