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.

45 lines
908 B

6 years ago
  1. package main
  2. import (
  3. "bytes"
  4. "flag"
  5. "fmt"
  6. "log"
  7. "math/rand"
  8. "github.com/chrislusf/seaweedfs/weed/operation"
  9. "github.com/chrislusf/seaweedfs/weed/util"
  10. )
  11. var (
  12. master = flag.String("master", "127.0.0.1:9333", "the master server")
  13. repeat = flag.Int("n", 5, "repeat how many times")
  14. )
  15. func main() {
  16. flag.Parse()
  17. for i := 0; i < *repeat; i++ {
  18. assignResult, err := operation.Assign(*master, &operation.VolumeAssignRequest{Count: 1})
  19. if err != nil {
  20. log.Fatalf("assign: %v", err)
  21. }
  22. data := make([]byte, 1024)
  23. rand.Read(data)
  24. reader := bytes.NewReader(data)
  25. targetUrl := fmt.Sprintf("http://%s/%s", assignResult.Url,assignResult.Fid)
  26. _, err = operation.Upload(targetUrl, fmt.Sprintf("test%d", i), reader, false, "", nil, "")
  27. if err != nil {
  28. log.Fatalf("upload: %v", err)
  29. }
  30. util.Delete(targetUrl, "")
  31. util.Get(fmt.Sprintf("http://%s/vol/vacuum", *master))
  32. }
  33. }