fio

package
v0.6.0-rc4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package fio wraps calls to the fio tool. It assumes the tool is executable by "fio", but gives the option to specify another executable path by setting environment variable FIO_EXE.

Index

Constants

View Source
const (
	// FioExeEnvKey gives the path to the fio executable to use in testing
	FioExeEnvKey = "FIO_EXE"

	// FioDockerImageEnvKey specifies the docker image tag to use. If
	// FioExeEnvKey is set, the local executable will be used instead of
	// docker, even if this variable is also set.
	FioDockerImageEnvKey = "FIO_DOCKER_IMAGE"

	// LocalFioDataPathEnvKey is the local path where fio data will be
	// accessible. If not specified, defaults to the default temp directory (os.TempDir)
	LocalFioDataPathEnvKey = "LOCAL_FIO_DATA_PATH"

	// HostFioDataPathEnvKey specifies the path where fio data will be written,
	// relative to the docker host. If left blank, defaults to local fio data path
	// (works unless running via docker from within a container, e.g. for development)
	HostFioDataPathEnvKey = "HOST_FIO_DATA_PATH"
)

Environment variable keys

View Source
const (
	BlockSizeFioArg        = "blocksize"
	DedupePercentageFioArg = "dedupe_percentage"
	DirectoryFioArg        = "directory"
	FallocateFioArg        = "fallocate"
	FileSizeFioArg         = "filesize"
	IOLimitFioArg          = "io_limit"
	IOSizeFioArg           = "io_size"
	NumFilesFioArg         = "nrfiles"
	RandRepeatFioArg       = "randrepeat"
	SizeFioArg             = "size"
)

List of FIO argument strings

View Source
const (
	NoneFio       = "none"
	RandWriteFio  = "randwrite"
	RangeDelimFio = "-"
)

List of FIO specific fields and delimiters

View Source
const (
	JobNameFlag = "--name"
)

List of fio flags

Variables

View Source
var (
	ErrEnvNotSet = fmt.Errorf("must set either %v or %v", FioExeEnvKey, FioDockerImageEnvKey)
)

Known error messages

Functions

This section is empty.

Types

type Config

type Config []Job

Config structures the fields of a FIO job run configuration

func (Config) String

func (cfg Config) String() string

String implements the stringer interface, formats the Config as it would appear in a well-formed fio config file.

type Job

type Job struct {
	Name    string
	Options Options
}

Job represents the configuration for running a FIO job

func (Job) String

func (job Job) String() string

String implements the stringer interface, formats the Job as it would appear in a well-formed fio config file.

type Options

type Options map[string]string

Options are flags to be set when running fio

func (Options) Merge

func (o Options) Merge(other Options) Options

Merge will merge two Options, overwriting common option keys with the incoming option values. Returns the merged result

func (Options) WithBlockSize

func (o Options) WithBlockSize(blockSizeB int64) Options

WithBlockSize sets the fio block size option

func (Options) WithDedupePercentage

func (o Options) WithDedupePercentage(dPcnt int) Options

WithDedupePercentage sets the fio dedupe percentage

func (Options) WithDirectory

func (o Options) WithDirectory(dir string) Options

WithDirectory sets the fio option for the directory to write in

func (Options) WithFileSize

func (o Options) WithFileSize(fileSizeB int64) Options

WithFileSize sets the fio file size

func (Options) WithFileSizeRange

func (o Options) WithFileSizeRange(fileSizeMinB, fileSizeMaxB int64) Options

WithFileSizeRange sets the fio file size range

func (Options) WithIOLimit

func (o Options) WithIOLimit(ioSizeB int64) Options

WithIOLimit sets the fio io limit

func (Options) WithIOSize

func (o Options) WithIOSize(sizeB int64) Options

WithIOSize sets the fio io size

func (Options) WithNoFallocate

func (o Options) WithNoFallocate() Options

WithNoFallocate sets the fio option fallocate to "none"

func (Options) WithNumFiles

func (o Options) WithNumFiles(numFiles int) Options

WithNumFiles sets the fio number of files

func (Options) WithRandRepeat

func (o Options) WithRandRepeat(set bool) Options

WithRandRepeat sets the fio option rand repeat

func (Options) WithSize

func (o Options) WithSize(sizeB int64) Options

WithSize sets the fio write size

func (Options) WithSizeRange

func (o Options) WithSizeRange(sizeMinB, sizeMaxB int64) Options

WithSizeRange sets the fio size range

type Runner

type Runner struct {
	Exe             string
	ExecArgs        []string
	LocalDataDir    string
	FioWriteBaseDir string
	Global          Config
}

Runner is a helper for running fio commands

func NewRunner

func NewRunner() (fr *Runner, err error)

NewRunner creates a new fio runner

func (*Runner) Cleanup

func (fr *Runner) Cleanup()

Cleanup cleans up the data directory

func (*Runner) DeleteRelDir

func (fr *Runner) DeleteRelDir(relDirPath string) error

DeleteRelDir deletes a relative directory in the runner's data directory

func (*Runner) Run

func (fr *Runner) Run(args ...string) (stdout, stderr string, err error)

Run will execute the fio command with the given args

func (*Runner) RunConfigs

func (fr *Runner) RunConfigs(cfgs ...Config) (stdout, stderr string, err error)

RunConfigs runs fio using the provided Configs

func (*Runner) WriteFiles

func (fr *Runner) WriteFiles(relPath string, opt Options) error

WriteFiles writes files to the directory specified by path, up to the provided size and number of files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL