volume_vacuum_test.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package storage
  2. import (
  3. "testing"
  4. )
  5. /*
  6. makediff test steps
  7. 1. launch weed server at your local/dev environment, (option
  8. "garbageThreshold" for master and option "max" for volume should be set with specific value which would let
  9. preparing test prerequisite easier )
  10. a) ./weed master -garbageThreshold=0.99 -mdir=./m
  11. b) ./weed volume -dir=./data -max=1 -mserver=localhost:9333 -port=8080
  12. 2. upload 4 different files, you could call dir/assign to get 4 different fids
  13. a) upload file A with fid a
  14. b) upload file B with fid b
  15. c) upload file C with fid c
  16. d) upload file D with fid d
  17. 3. update file A and C
  18. a) modify file A and upload file A with fid a
  19. b) modify file C and upload file C with fid c
  20. c) record the current 1.idx's file size(lastCompactIndexOffset value)
  21. 4. Compacting the data file
  22. a) run curl http://localhost:8080/admin/vacuum/compact?volumeId=1
  23. b) verify the 1.cpd and 1.cpx is created under volume directory
  24. 5. update file B and delete file D
  25. a) modify file B and upload file B with fid b
  26. d) delete file B with fid b
  27. 6. Now you could run the following UT case, the case should be run successfully
  28. 7. Compact commit manually
  29. a) mv 1.cpd 1.dat
  30. b) mv 1.cpx 1.idx
  31. 8. Restart Volume Server
  32. 9. Now you should get updated file A,B,C
  33. */
  34. func TestMakeDiff(t *testing.T) {
  35. v := new(Volume)
  36. //lastCompactIndexOffset value is the index file size before step 4
  37. v.lastCompactIndexOffset = 96
  38. v.SuperBlock.version = 0x2
  39. /*
  40. err := v.makeupDiff(
  41. "/yourpath/1.cpd",
  42. "/yourpath/1.cpx",
  43. "/yourpath/1.dat",
  44. "/yourpath/1.idx")
  45. if err != nil {
  46. t.Errorf("makeupDiff err is %v", err)
  47. } else {
  48. t.Log("makeupDiff Succeeded")
  49. }
  50. */
  51. }