Documentation ¶
Overview ¶
Package blobtesting is used for testing BLOB storage implementations.
Package blobtesting implements storage with fault injection.
Index ¶
- Constants
- Variables
- func AssertConnectionInfoRoundTrips(ctx context.Context, t *testing.T, s blob.Storage)
- func AssertGetBlob(ctx context.Context, t *testing.T, s blob.Storage, blobID blob.ID, ...)
- func AssertGetBlobNotFound(ctx context.Context, t *testing.T, s blob.Storage, blobID blob.ID)
- func AssertGetMetadataNotFound(ctx context.Context, t *testing.T, s blob.Storage, blobID blob.ID)
- func AssertInvalidCredentials(ctx context.Context, t *testing.T, s blob.Storage, blobID blob.ID)
- func AssertInvalidOffsetLength(ctx context.Context, t *testing.T, s blob.Storage, blobID blob.ID, ...)
- func AssertListResults(ctx context.Context, t *testing.T, s blob.Storage, prefix blob.ID, ...)
- func AssertListResultsIDs(ctx context.Context, t *testing.T, s blob.Storage, prefix blob.ID, ...)
- func AssertTimestampsCloseEnough(t *testing.T, blobID blob.ID, got, want time.Time)
- func CleanupOldData(ctx context.Context, tb testing.TB, st blob.Storage, cleanupAge time.Duration)
- func NewEventuallyConsistentStorage(st blob.Storage, listSettleTime time.Duration, timeNow func() time.Time) blob.Storage
- func NewMapStorage(data DataMap, keyTime map[blob.ID]time.Time, timeNow func() time.Time) blob.Storage
- func NewVersionedMapStorage(timeNow func() time.Time) blob.Storage
- func VerifyConcurrentAccess(t *testing.T, st blob.Storage, options ConcurrentAccessOptions)
- func VerifyStorage(ctx context.Context, t *testing.T, r blob.Storage, opts blob.PutOptions)
- type ConcurrentAccessOptions
- type DataMap
- type FaultyStorage
- func (s *FaultyStorage) Close(ctx context.Context) error
- func (s *FaultyStorage) ConnectionInfo() blob.ConnectionInfo
- func (s *FaultyStorage) DeleteBlob(ctx context.Context, id blob.ID) error
- func (s *FaultyStorage) DisplayName() string
- func (s *FaultyStorage) FlushCaches(ctx context.Context) error
- func (s *FaultyStorage) GetBlob(ctx context.Context, id blob.ID, offset, length int64, ...) error
- func (s *FaultyStorage) GetMetadata(ctx context.Context, id blob.ID) (blob.Metadata, error)
- func (s *FaultyStorage) ListBlobs(ctx context.Context, prefix blob.ID, callback func(blob.Metadata) error) error
- func (s *FaultyStorage) PutBlob(ctx context.Context, id blob.ID, data blob.Bytes, opts blob.PutOptions) error
Constants ¶
const ( MethodGetBlob fault.Method = iota MethodGetMetadata MethodPutBlob MethodDeleteBlob MethodListBlobs MethodListBlobsItem MethodClose MethodFlushCaches )
Supported faulty methods.
const MinCleanupAge = time.Hour
MinCleanupAge is the default cleanup age.
Variables ¶
var TestValidationOptions = providervalidation.Options{ MaxClockDrift: 3 * time.Minute, ConcurrencyTestDuration: 15 * time.Second, NumPutBlobWorkers: 3, NumGetBlobWorkers: 3, NumGetMetadataWorkers: 3, NumListBlobsWorkers: 3, MaxBlobLength: 10e6, }
TestValidationOptions is the set of options used when running providing validation from tests. nolint:gomnd
Functions ¶
func AssertConnectionInfoRoundTrips ¶
AssertConnectionInfoRoundTrips verifies that the ConnectionInfo returned by a given storage can be used to create equivalent storage. nolint:thelper
func AssertGetBlob ¶
func AssertGetBlob(ctx context.Context, t *testing.T, s blob.Storage, blobID blob.ID, expected []byte)
AssertGetBlob asserts that the specified BLOB has correct content.
func AssertGetBlobNotFound ¶
AssertGetBlobNotFound asserts that GetBlob() for specified blobID returns ErrNotFound.
func AssertGetMetadataNotFound ¶ added in v0.8.0
AssertGetMetadataNotFound asserts that GetMetadata() for specified blobID returns ErrNotFound.
func AssertInvalidCredentials ¶ added in v0.10.4
AssertInvalidCredentials asserts that GetBlob() for specified blobID returns ErrInvalidCredentials.
func AssertInvalidOffsetLength ¶
func AssertInvalidOffsetLength(ctx context.Context, t *testing.T, s blob.Storage, blobID blob.ID, offset, length int64)
AssertInvalidOffsetLength verifies that the given combination of (offset,length) fails on GetBlob().
func AssertListResults ¶
func AssertListResults(ctx context.Context, t *testing.T, s blob.Storage, prefix blob.ID, want ...blob.ID)
AssertListResults asserts that the list results with given prefix return the specified list of names in order.
func AssertListResultsIDs ¶ added in v0.9.0
func AssertListResultsIDs(ctx context.Context, t *testing.T, s blob.Storage, prefix blob.ID, want ...blob.ID)
AssertListResultsIDs asserts that the list results with given prefix return the specified list of names.
func AssertTimestampsCloseEnough ¶ added in v0.9.8
AssertTimestampsCloseEnough asserts that two provided times are close enough - some providers don't store timestamps exactly but round them up/down by several seconds.
func CleanupOldData ¶ added in v0.9.0
CleanupOldData removes blobs older than provided time from storage using provided prefix.
func NewEventuallyConsistentStorage ¶ added in v0.6.0
func NewEventuallyConsistentStorage(st blob.Storage, listSettleTime time.Duration, timeNow func() time.Time) blob.Storage
NewEventuallyConsistentStorage returns an eventually-consistent storage wrapper on top of provided storage.
func NewMapStorage ¶
func NewMapStorage(data DataMap, keyTime map[blob.ID]time.Time, timeNow func() time.Time) blob.Storage
NewMapStorage returns an implementation of Storage backed by the contents of given map. Used primarily for testing.
func NewVersionedMapStorage ¶ added in v0.9.8
NewVersionedMapStorage returns an implementation of Storage backed by the contents of an internal in-memory map used primarily for testing.
func VerifyConcurrentAccess ¶ added in v0.5.2
func VerifyConcurrentAccess(t *testing.T, st blob.Storage, options ConcurrentAccessOptions)
VerifyConcurrentAccess tests data races on a repository to ensure only clean errors are returned. nolint:gocognit,gocyclo,funlen,cyclop
func VerifyStorage ¶
VerifyStorage verifies the behavior of the specified storage. nolint:gocyclo,thelper
Types ¶
type ConcurrentAccessOptions ¶ added in v0.5.2
type ConcurrentAccessOptions struct { NumBlobs int // number of shared blos in the pool Getters int Putters int Deleters int Listers int Iterations int RangeGetPercentage int // 0..100 - probability of issuing range get NonExistentListPrefixPercentage int // probability of issuing non-matching list prefix }
ConcurrentAccessOptions encapsulates parameters for VerifyConcurrentAccess.
type FaultyStorage ¶
FaultyStorage implements fault injection for FaultyStorage.
func NewFaultyStorage ¶ added in v0.9.8
func NewFaultyStorage(base blob.Storage) *FaultyStorage
NewFaultyStorage creates new Storage with fault injection.
func (*FaultyStorage) Close ¶
func (s *FaultyStorage) Close(ctx context.Context) error
Close implements blob.Storage.
func (*FaultyStorage) ConnectionInfo ¶
func (s *FaultyStorage) ConnectionInfo() blob.ConnectionInfo
ConnectionInfo implements blob.Storage.
func (*FaultyStorage) DeleteBlob ¶
DeleteBlob implements blob.Storage.
func (*FaultyStorage) DisplayName ¶ added in v0.6.0
func (s *FaultyStorage) DisplayName() string
DisplayName implements blob.Storage.
func (*FaultyStorage) FlushCaches ¶ added in v0.9.0
func (s *FaultyStorage) FlushCaches(ctx context.Context) error
FlushCaches implements blob.Storage.
func (*FaultyStorage) GetBlob ¶
func (s *FaultyStorage) GetBlob(ctx context.Context, id blob.ID, offset, length int64, output blob.OutputBuffer) error
GetBlob implements blob.Storage.
func (*FaultyStorage) GetMetadata ¶ added in v0.6.0
GetMetadata implements blob.Storage.