Files
kopia/tests/tools/fio/workload.go
Nick edbc7591d7 [robustness testing] Adding library for file generation using 'fio'
Adding a helper library that wraps fio execution. This is the basic initial check-in that implements the runners, configs, and a single WriteFiles helper. It should be enough to unblock subsequent tasks that will use fio to generate data sets for kopia snapshot verification. More helper workloads can be added as needed.

In this implementation the tests will all skip from test main if the `FIO_EXE` env variable is not set. Adding fio to the CI environment will be addressed as a separate PR.

Tracking progress in issue https://github.com/kopia/kopia/issues/179
2020-01-30 21:37:21 -08:00

33 lines
649 B
Go

package fio
import (
"fmt"
"os"
"path/filepath"
"strconv"
)
// WriteFiles writes files to the directory specified by path, up to the
// provided size and number of files
func (fr *Runner) WriteFiles(path string, sizeB int64, numFiles int, opt Options) error {
fullPath := filepath.Join(fr.DataDir, path)
err := os.MkdirAll(fullPath, 0700)
if err != nil {
return err
}
_, _, err = fr.RunConfigs(Config{
{
Name: fmt.Sprintf("write-%vB-%v", sizeB, numFiles),
Options: opt.Merge(Options{
"size": strconv.Itoa(int(sizeB)),
"nrfiles": strconv.Itoa(numFiles),
"directory": fullPath,
}),
},
})
return err
}