Documentation ¶
Overview ¶
Package util contains implementation of storage qualification stress types and DUT control utilities.
Index ¶
- Constants
- Variables
- func CalculateCurrentHashes(filename string, chunkCount uint64) (hashes []string, err error)
- func FunctionalRunner(ctx context.Context, s *testing.State, rw *FioResultWriter, ...)
- func GetNVMEIdNSFeature(ctx context.Context, diskPath, feature string) (string, error)
- func IsEMMC(testPath string) bool
- func IsNVME(testPath string) bool
- func MiniSoakRunner(ctx context.Context, s *testing.State, rw *FioResultWriter, ...)
- func OneHash() string
- func PartitionSize(ctx context.Context, partition string) (uint64, error)
- func RootPartitionForTest(ctx context.Context) (string, error)
- func RunFioStress(ctx context.Context, testConfig TestConfig) error
- func RunTrim(f *os.File, offset, size uint64) error
- func SetupBenchmarks(ctx context.Context, s *testing.State, rw *FioResultWriter, ...)
- func SetupChecks(ctx context.Context, s *testing.State)
- func SlcDevice(ctx context.Context) (string, error)
- func StressRunner(ctx context.Context, s *testing.State, rw *FioResultWriter, ...)
- func Suspend(ctx context.Context, skipResidencyCheck bool) error
- func Swapoff(ctx context.Context) error
- func WriteKeyVals(outDir string, keyVals map[string]float64) error
- func WriteRandomData(filename string, chunkCount uint64) error
- func WriteTestStatusFile(ctx context.Context, outDir string, passed bool, startTimestamp time.Time) error
- func ZeroHash() string
- type Blockdevice
- type DiskInfo
- type FioResultWriter
- type QualParam
- type TestConfig
- func (t TestConfig) WithDuration(duration time.Duration) TestConfig
- func (t TestConfig) WithJob(job string) TestConfig
- func (t TestConfig) WithJobFile(jobFile string) TestConfig
- func (t TestConfig) WithPath(path string) TestConfig
- func (t TestConfig) WithResultWriter(resultWriter *FioResultWriter) TestConfig
- func (t TestConfig) WithVerifyOnly(verifyOnly bool) TestConfig
Constants ¶
const ( // DefaultStressBlockTimeout is the duration of the stress sub-test. DefaultStressBlockTimeout = 240 * time.Minute // DefaultSlcStressBlockTimeout is the duration of the slc-stress sub-test. DefaultSlcStressBlockTimeout = 240 * time.Minute // DefaultRetentionBlockTimeout is the duration of the retention sub-test. DefaultRetentionBlockTimeout = 20 * time.Minute // DefaultSuspendBlockTimeout is the total duration of the suspend sub-test. DefaultSuspendBlockTimeout = 10 * time.Minute )
const (
// TrimChunkSize is the size (in bytes) of a data chunk to trim.
TrimChunkSize = 192 * 1024
)
Variables ¶
var ( // Configs lists all supported fio configurations. Configs = []string{ "surfing", "recovery", "seq_write", "seq_read", "4k_write", "4k_write_qd4", "4k_write_qd32", "4k_read", "4k_read_qd4", "4k_read_qd32", "16k_write", "16k_read", "64k_stress", "8k_async_randwrite", "8k_read", "1m_stress", "1m_write", "write_stress", } )
Functions ¶
func CalculateCurrentHashes ¶
CalculateCurrentHashes calculates hash values for all chunks of the given file.
func FunctionalRunner ¶
func FunctionalRunner(ctx context.Context, s *testing.State, rw *FioResultWriter, testParam QualParam)
FunctionalRunner exercises only the functional part of the block. It is intended to be used in the lab on bringup devices.
func GetNVMEIdNSFeature ¶
GetNVMEIdNSFeature returns the feature value for the NVMe disk using nvme id-ns.
func MiniSoakRunner ¶
func MiniSoakRunner(ctx context.Context, s *testing.State, rw *FioResultWriter, testParam QualParam)
MiniSoakRunner is a minimized version of the storage stress consisting from a single attempt of a soak subtest. This stress is used for storage qualification v2 validation.
func PartitionSize ¶
PartitionSize return size (in bytes) of given disk partition.
func RootPartitionForTest ¶
RootPartitionForTest returns root partition to use for the tests.
func RunFioStress ¶
func RunFioStress(ctx context.Context, testConfig TestConfig) error
RunFioStress runs an fio job single given path according to testConfig. This function returns an error rather than failing the test.
func SetupBenchmarks ¶
func SetupBenchmarks(ctx context.Context, s *testing.State, rw *FioResultWriter, testParam QualParam)
SetupBenchmarks captures and records bandwidth and latency disk benchmarks at the beginning and the end of the test suite.
func SetupChecks ¶
SetupChecks verifys the size of the storage device matches the user requested size.
func StressRunner ¶
StressRunner is the main entry point of the unversal stress block. It runs all other functional sub-tests in a sequence, retrying failed sub-tests.
func WriteKeyVals ¶
WriteKeyVals writes given key value data to an external file in output directory.
func WriteRandomData ¶
WriteRandomData dumps random data to a given file/disk.
Types ¶
type Blockdevice ¶
type Blockdevice struct { Name string `json:"name"` Type string `json:"type"` Hotplug bool `json:"hotplug"` Size int64 `json:"size"` State string `json:"state"` }
Blockdevice represents information about a single storage device as reported by lsblk.
type DiskInfo ¶
type DiskInfo struct {
Blockdevices []*Blockdevice `json:"blockdevices"`
}
DiskInfo is a serializable structure representing output of lsblk command.
func ReadDiskInfo ¶
ReadDiskInfo returns storage information as reported by lsblk tool. Only disk devices are returns.
func (DiskInfo) CheckMainDeviceSize ¶
CheckMainDeviceSize verifies that the size of the main storage disk is more than the given minimal size. Otherwise, an error is returned.
func (DiskInfo) DeviceCount ¶
DeviceCount returns number of found valid block devices on the system.
func (DiskInfo) MainDevice ¶
func (d DiskInfo) MainDevice() (*Blockdevice, error)
MainDevice returns the main storage device from a list of available devices. The method returns the device with the biggest size if multiple present.
func (DiskInfo) SaveDiskInfo ¶
SaveDiskInfo dumps disk info to an external file with a given file name. The information is saved in JSON format.
func (DiskInfo) SlcDevice ¶
func (d DiskInfo) SlcDevice() (*Blockdevice, error)
SlcDevice returns the slc storage device from a list of available devices. The method assumes at most two devices and returns the device with the smallest size.
type FioResultWriter ¶
type FioResultWriter struct {
// contains filtered or unexported fields
}
FioResultWriter is a serial processor of fio results.
func (*FioResultWriter) Report ¶
func (f *FioResultWriter) Report(group string, result *fioResult)
Report posts a single fio result to the writer.
func (*FioResultWriter) ReportDiskUsage ¶
func (f *FioResultWriter) ReportDiskUsage(diskName string, percentageUsed, totalBytesWritten int64)
ReportDiskUsage records the disk usage percents to report it at save time.
type QualParam ¶
type QualParam struct { IsSlcEnabled bool SlcDevice string TestDevice string RetentionBlockTimeout time.Duration SuspendBlockTimeout time.Duration StressBlockTimeout time.Duration SkipS0iXResidencyCheck bool }
QualParam is the configuration of dual-qual functionality.
type TestConfig ¶
type TestConfig struct { // Duration is a minimal duration that the stress should be running for. // If single run of the stress takes less than this time, it's going // to be repeated until the total running time is greater than this duration. Duration time.Duration // Job is the name of the fio profile to execute. Must be on of the Configs. Job string // JobFile is the absolute path and filename of the fio profile file corresponding to Job. JobFile string // Path to the fio target Path string // VerifyOnly if true, make benchmark data is collected to result-chart.json // without running the actual stress. VerifyOnly bool // ResultWriter references the result processing object. ResultWriter *FioResultWriter }
TestConfig provides extra test configuration arguments.
func (TestConfig) WithDuration ¶
func (t TestConfig) WithDuration(duration time.Duration) TestConfig
WithDuration sets Duration in TestConfig.
func (TestConfig) WithJob ¶
func (t TestConfig) WithJob(job string) TestConfig
WithJob sets Job in TestConfig.
func (TestConfig) WithJobFile ¶
func (t TestConfig) WithJobFile(jobFile string) TestConfig
WithJobFile sets JobFile in TestConfig.
func (TestConfig) WithPath ¶
func (t TestConfig) WithPath(path string) TestConfig
WithPath sets Path in TestConfig.
func (TestConfig) WithResultWriter ¶
func (t TestConfig) WithResultWriter(resultWriter *FioResultWriter) TestConfig
WithResultWriter sets ResultWriter in TestConfig.
func (TestConfig) WithVerifyOnly ¶
func (t TestConfig) WithVerifyOnly(verifyOnly bool) TestConfig
WithVerifyOnly sets VerifyOnly in TestConfig.