seaweedfs/unmaintained/repeated_vacuum/repeated_vacuum.go

50 lines
1.1 KiB
Go
Raw Normal View History

2018-11-04 05:32:36 +00:00
package main
import (
"bytes"
"flag"
"fmt"
"log"
"math/rand"
"github.com/chrislusf/seaweedfs/weed/operation"
"github.com/chrislusf/seaweedfs/weed/security"
2018-11-04 05:32:36 +00:00
"github.com/chrislusf/seaweedfs/weed/util"
)
var (
master = flag.String("master", "127.0.0.1:9333", "the master server")
repeat = flag.Int("n", 5, "repeat how many times")
)
func main() {
flag.Parse()
util.LoadConfiguration("security", false)
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
2019-02-18 20:11:52 +00:00
2018-11-04 05:32:36 +00:00
for i := 0; i < *repeat; i++ {
2019-02-18 20:11:52 +00:00
assignResult, err := operation.Assign(*master, grpcDialOption, &operation.VolumeAssignRequest{Count: 1})
2018-11-04 05:32:36 +00:00
if err != nil {
log.Fatalf("assign: %v", err)
}
data := make([]byte, 1024)
rand.Read(data)
reader := bytes.NewReader(data)
2019-01-17 01:17:19 +00:00
targetUrl := fmt.Sprintf("http://%s/%s", assignResult.Url, assignResult.Fid)
2018-11-04 05:32:36 +00:00
2020-03-07 19:08:57 +00:00
_, err = operation.Upload(targetUrl, fmt.Sprintf("test%d", i), false, reader, false, "bench/test", nil, assignResult.Auth)
2018-11-04 05:32:36 +00:00
if err != nil {
log.Fatalf("upload: %v", err)
}
util.Delete(targetUrl, string(assignResult.Auth))
2018-11-04 06:14:05 +00:00
2018-11-04 05:32:36 +00:00
util.Get(fmt.Sprintf("http://%s/vol/vacuum", *master))
}
}