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.

29 lines
910 B

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