bboltgo.etcd.io/bbolt/tests/dmflakey Index | Files

package dmflakey

import "go.etcd.io/bbolt/tests/dmflakey"

Index

Types

type FSType

type FSType string

FSType represents the filesystem name.

const (
	FSTypeEXT4 FSType = "ext4"
	FSTypeXFS  FSType = "xfs"
)

Supported filesystems.

type FeatOpt

type FeatOpt func(*featCfg)

FeatOpt is used to configure failure feature.

func WithIntervalFeatOpt

func WithIntervalFeatOpt(interval time.Duration) FeatOpt

WithIntervalFeatOpt updates the up time for the feature.

func WithSyncFSFeatOpt

func WithSyncFSFeatOpt(syncFS bool) FeatOpt

WithSyncFSFeatOpt is to determine if the caller wants to synchronize filesystem before inject failure.

type Flakey

type Flakey interface {
	// DevicePath returns the flakey device path.
	DevicePath() string

	// Filesystem returns filesystem's type.
	Filesystem() FSType

	// AllowWrites allows write I/O.
	AllowWrites(opts ...FeatOpt) error

	// DropWrites drops all write I/O silently.
	DropWrites(opts ...FeatOpt) error

	// ErrorWrites drops all write I/O and returns error.
	ErrorWrites(opts ...FeatOpt) error

	// Teardown releases the flakey device.
	Teardown() error
}

Flakey is to inject failure into device.

func InitFlakey

func InitFlakey(flakeyDevice, dataStorePath string, fsType FSType, mkfsOpt string) (_ Flakey, retErr error)

InitFlakey creates an filesystem on a loopback device and returns Flakey on it.

The device-mapper device will be /dev/mapper/$flakeyDevice. And the filesystem image will be created at $dataStorePath/$flakeyDevice.img. By default, the device is available for 2 minutes and size is 10 GiB.

Source Files

dmflakey.go dmsetup.go loopback.go

Version
v1.4.0 (latest)
Published
Feb 5, 2025
Platform
linux/amd64
Imports
10 packages
Last checked
23 minutes ago

Tools for package owners.