aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-10-25 19:28:11 -0700
committerChris Lu <chris.lu@gmail.com>2020-10-25 19:28:11 -0700
commitc693c98c15fba10c75423d43fc76678f23565494 (patch)
treec48ff734e62e5e51afbea9be7e427246d3db766a
parente71463a9eb74496829c4463cabd1c1a6747b7513 (diff)
downloadseaweedfs-c693c98c15fba10c75423d43fc76678f23565494.tar.xz
seaweedfs-c693c98c15fba10c75423d43fc76678f23565494.zip
write a lot of files
-rw-r--r--unmaintained/stress_filer_upload/write_files/write_files.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/unmaintained/stress_filer_upload/write_files/write_files.go b/unmaintained/stress_filer_upload/write_files/write_files.go
new file mode 100644
index 000000000..67400eef4
--- /dev/null
+++ b/unmaintained/stress_filer_upload/write_files/write_files.go
@@ -0,0 +1,49 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "math/rand"
+ "os"
+)
+
+var (
+ minSize = flag.Int("minSize", 1024, "min file size")
+ maxSize = flag.Int("maxSize", 10*1024*1024, "max file size")
+ fileCount = flag.Int("fileCount", 1, "number of files to write")
+ blockSize = flag.Int("blockSizeKB", 4, "write block size")
+ toDir = flag.String("dir", ".", "destination directory")
+)
+
+func check(e error) {
+ if e != nil {
+ panic(e)
+ }
+}
+
+func main() {
+
+ flag.Parse()
+
+ block := make([]byte, *blockSize)
+
+ for i := 0; i < *fileCount; i++ {
+
+ f, err := os.Create(fmt.Sprintf("%s/file%05d", *toDir, i))
+ check(err)
+
+ fileSize := *minSize + rand.Intn(*maxSize-*minSize)
+
+ for x := 0; x < fileSize; {
+ rand.Read(block)
+ _, err = f.Write(block)
+ check(err)
+ x += *blockSize
+ }
+
+ err = f.Close()
+ check(err)
+
+ }
+
+}