mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
add to stress test vacuum
This commit is contained in:
parent
93e0dddbf3
commit
776308c4eb
43
unmaintained/repeated_vacuum/repeated_vacuum.go
Normal file
43
unmaintained/repeated_vacuum/repeated_vacuum.go
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"math/rand"
|
||||||
|
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/operation"
|
||||||
|
"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()
|
||||||
|
|
||||||
|
for i := 0; i < *repeat; i++ {
|
||||||
|
assignResult, err := operation.Assign(*master, &operation.VolumeAssignRequest{Count: 1})
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("assign: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := make([]byte, 1024)
|
||||||
|
rand.Read(data)
|
||||||
|
reader := bytes.NewReader(data)
|
||||||
|
|
||||||
|
targetUrl := fmt.Sprintf("http://%s/%s", assignResult.Url,assignResult.Fid)
|
||||||
|
|
||||||
|
_, err = operation.Upload(targetUrl, fmt.Sprintf("test%d", i), reader, false, "", nil, "")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("upload: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
util.Get(fmt.Sprintf("http://%s/vol/vacuum", *master))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue