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.

47 lines
1.1 KiB

6 years ago
  1. package main
  2. import (
  3. "flag"
  4. "fmt"
  5. "log"
  6. "math/rand"
  7. "github.com/chrislusf/seaweedfs/weed/operation"
  8. "github.com/chrislusf/seaweedfs/weed/security"
  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. util.LoadConfiguration("security", false)
  18. grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
  19. for i := 0; i < *repeat; i++ {
  20. assignResult, err := operation.Assign(*master, grpcDialOption, &operation.VolumeAssignRequest{Count: 1})
  21. if err != nil {
  22. log.Fatalf("assign: %v", err)
  23. }
  24. data := make([]byte, 1024)
  25. rand.Read(data)
  26. targetUrl := fmt.Sprintf("http://%s/%s", assignResult.Url, assignResult.Fid)
  27. _, err = operation.UploadData(targetUrl, fmt.Sprintf("test%d", i), false, data, false, "bench/test", nil, assignResult.Auth)
  28. if err != nil {
  29. log.Fatalf("upload: %v", err)
  30. }
  31. util.Delete(targetUrl, string(assignResult.Auth))
  32. util.Get(fmt.Sprintf("http://%s/vol/vacuum", *master))
  33. }
  34. }