-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Track BackupEngine and BackupStorageHandle errors together. #6350
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6196538
Use the same error recorder in backupengine as backuphandle
ajm188 cd34835
Update the rest of the backupstorage implementations
ajm188 d7e084e
Change type of s3 client from the `s3.S3` struct to `s3iface.S3API`
ajm188 0b7d4a0
Add a test for AddFile error tracking
ajm188 3e31049
Update these callsites
ajm188 4afdaee
Reword comment to make sense without the diff
ajm188 3c3822c
Use `require`/`assert` in tests
ajm188 7d572fc
Use NotNil rather than NotEqual(x, nil)
ajm188 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package s3backupstorage | ||
|
||
import ( | ||
"errors" | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/request" | ||
"github.com/aws/aws-sdk-go/service/s3" | ||
"github.com/aws/aws-sdk-go/service/s3/s3iface" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
type s3ErrorClient struct{ s3iface.S3API } | ||
|
||
func (s3errclient *s3ErrorClient) PutObjectRequest(in *s3.PutObjectInput) (*request.Request, *s3.PutObjectOutput) { | ||
req := request.Request{ | ||
HTTPRequest: &http.Request{}, // without this we segfault \_(ツ)_/¯ (see https://github.com/aws/aws-sdk-go/blob/v1.28.8/aws/request/request_context.go#L13) | ||
Error: errors.New("some error"), // this forces req.Send() (which is called by the uploader) to always return non-nil error | ||
} | ||
|
||
return &req, &s3.PutObjectOutput{} | ||
} | ||
|
||
func TestAddFileError(t *testing.T) { | ||
bh := &S3BackupHandle{client: &s3ErrorClient{}, readOnly: false} | ||
|
||
wc, err := bh.AddFile(aws.BackgroundContext(), "somefile", 100000) | ||
require.NoErrorf(t, err, "AddFile() expected no error, got %s", err) | ||
assert.NotEqual(t, nil, wc, "AddFile() expected non-nil WriteCloser") | ||
|
||
n, err := wc.Write([]byte("here are some bytes")) | ||
require.NoErrorf(t, err, "TestAddFile() could not write to uploader, got %d bytes written, err %s", n, err) | ||
|
||
err = wc.Close() | ||
require.NoErrorf(t, err, "TestAddFile() could not close writer, got %s", err) | ||
|
||
bh.waitGroup.Wait() // wait for the goroutine to finish, at which point it should have recorded an error | ||
|
||
require.Equal(t, bh.HasErrors(), true, "AddFile() expected bh to record async error but did not") | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also an assert.NotNil, but I'll accept this.