Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This should run all green #7964

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions pkg/block/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"context"
"encoding/json"
"fmt"
"io"
"math/rand"
"os"
"path"
Expand Down Expand Up @@ -63,6 +64,60 @@
return ret
}

type FailingBucketReader struct {
innerBucketReader objstore.BucketReader
}

func (b FailingBucketReader) Iter(ctx context.Context, dir string, f func(name string) error, options ...objstore.IterOption) error {
return b.innerBucketReader.Iter(ctx, dir, f, options...)
}

func (b FailingBucketReader) IterWithAttributes(ctx context.Context, dir string, f func(attrs objstore.IterObjectAttributes) error, options ...objstore.IterOption) error {
return b.innerBucketReader.IterWithAttributes(ctx, dir, f, options...)
}

// SupportedIterOptions returns a list of supported IterOptions by the underlying provider.
func (b FailingBucketReader) SupportedIterOptions() []objstore.IterOptionType {
return b.innerBucketReader.SupportedIterOptions()
}

// Get returns a reader for the given object name.
func (b FailingBucketReader) Get(ctx context.Context, name string) (io.ReadCloser, error) {
return b.innerBucketReader.Get(ctx, name)
}

// GetRange returns a new range reader for the given object name and range.
func (b FailingBucketReader) GetRange(ctx context.Context, name string, off, length int64) (io.ReadCloser, error) {
return b.innerBucketReader.GetRange(ctx, name, off, length)
}

// Exists checks if the given object exists in the bucket.
func (b FailingBucketReader) Exists(ctx context.Context, name string) (bool, error) {
return false, errors.New("simulated exists failure")
return b.innerBucketReader.Exists(ctx, name)

Check failure on line 97 in pkg/block/fetcher_test.go

View workflow job for this annotation

GitHub Actions / Linters (Static Analysis) for Go

unreachable: unreachable code (govet)
}

// IsObjNotFoundErr returns true if error means that object is not found. Relevant to Get operations.
func (b FailingBucketReader) IsObjNotFoundErr(err error) bool {
return b.innerBucketReader.IsObjNotFoundErr(err)
}

// IsAccessDeniedErr returns true if access to object is denied.
func (b FailingBucketReader) IsAccessDeniedErr(err error) bool {
return b.innerBucketReader.IsAccessDeniedErr(err)
}

// Attributes returns information about the specified object.
func (b FailingBucketReader) Attributes(ctx context.Context, name string) (objstore.ObjectAttributes, error) {
return b.innerBucketReader.Attributes(ctx, name)
}

func wrapBucketWithFailureLayer(bucketReader objstore.BucketReader) objstore.BucketReader {

Check failure on line 115 in pkg/block/fetcher_test.go

View workflow job for this annotation

GitHub Actions / Linters (Static Analysis) for Go

func `wrapBucketWithFailureLayer` is unused (unused)
failingBucket := FailingBucketReader{}
failingBucket.innerBucketReader = bucketReader
return failingBucket
}

func TestMetaFetcher_Fetch(t *testing.T) {
objtesting.ForeachStore(t, func(t *testing.T, bkt objstore.Bucket) {
ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
Expand Down
Loading