util

package
v0.0.0-...-9474aff Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: BSD-3-Clause Imports: 26 Imported by: 0

Documentation

Overview

Package util contains implementation of storage qualification stress types and DUT control utilities.

Index

Constants

View Source
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
)
View Source
const (

	// TrimChunkSize is the size (in bytes) of a data chunk to trim.
	TrimChunkSize = 192 * 1024
)

Variables

View Source
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

func CalculateCurrentHashes(filename string, chunkCount uint64) (hashes []string, err error)

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

func GetNVMEIdNSFeature(ctx context.Context, diskPath, feature string) (string, error)

GetNVMEIdNSFeature returns the feature value for the NVMe disk using nvme id-ns.

func IsEMMC

func IsEMMC(testPath string) bool

IsEMMC returns whether the device is an eMMC device.

func IsNVME

func IsNVME(testPath string) bool

IsNVME returns whether the device is an NVMe device.

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 OneHash

func OneHash() string

OneHash calculates sha256 has of the 1-value block.

func PartitionSize

func PartitionSize(ctx context.Context, partition string) (uint64, error)

PartitionSize return size (in bytes) of given disk partition.

func RootPartitionForTest

func RootPartitionForTest(ctx context.Context) (string, error)

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 RunTrim

func RunTrim(f *os.File, offset, size uint64) error

RunTrim invokes ioctl trim command.

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

func SetupChecks(ctx context.Context, s *testing.State)

SetupChecks verifys the size of the storage device matches the user requested size.

func SlcDevice

func SlcDevice(ctx context.Context) (string, error)

SlcDevice returns an Slc device path for dual-namespace AVL.

func StressRunner

func StressRunner(ctx context.Context, s *testing.State, rw *FioResultWriter, testParam QualParam)

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 Suspend

func Suspend(ctx context.Context, skipResidencyCheck bool) error

Suspend suspends the device for a pre-defined time and then resumes it.

func Swapoff

func Swapoff(ctx context.Context) error

Swapoff disables swap.

func WriteKeyVals

func WriteKeyVals(outDir string, keyVals map[string]float64) error

WriteKeyVals writes given key value data to an external file in output directory.

func WriteRandomData

func WriteRandomData(filename string, chunkCount uint64) error

WriteRandomData dumps random data to a given file/disk.

func WriteTestStatusFile

func WriteTestStatusFile(ctx context.Context, outDir string, passed bool, startTimestamp time.Time) error

WriteTestStatusFile writes test status JSON file to test's output folder. Status file contains start/end times and final test status (passed/failed).

func ZeroHash

func ZeroHash() string

ZeroHash calculates sha256 has of the 0-value block.

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

func ReadDiskInfo(ctx context.Context) (*DiskInfo, error)

ReadDiskInfo returns storage information as reported by lsblk tool. Only disk devices are returns.

func (DiskInfo) CheckMainDeviceSize

func (d DiskInfo) CheckMainDeviceSize(minSize int64) error

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

func (d DiskInfo) DeviceCount() int

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

func (d DiskInfo) SaveDiskInfo(fileName string) error

SaveDiskInfo dumps disk info to an external file with a given file name. The information is saved in JSON format.

func (DiskInfo) SizeInGB

func (d DiskInfo) SizeInGB() (int, error)

SizeInGB returns size of the main block device in whole GB's.

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.

func (*FioResultWriter) Save

func (f *FioResultWriter) Save(ctx context.Context, path string, writeKeyVal bool)

Save processes and saves reported results.

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.

Jump to

Keyboard shortcuts

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