Browse Source
Client disconnects create context cancelled errors, 500x errors and Filer lookup failures (#8845)
Client disconnects create context cancelled errors, 500x errors and Filer lookup failures (#8845)
* Update stream.go Client disconnects create context cancelled errors and Filer lookup failures * s3api: handle canceled stream requests cleanly * s3api: address canceled streaming review feedback --------- Co-authored-by: Chris Lu <chris.lu@gmail.com>pull/5637/merge
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 225 additions and 6 deletions
-
20weed/filer/stream.go
-
106weed/filer/stream_failover_test.go
-
44weed/s3api/s3api_object_handlers.go
-
61weed/s3api/s3api_stream_error_test.go
@ -0,0 +1,61 @@ |
|||
package s3api |
|||
|
|||
import ( |
|||
"context" |
|||
"testing" |
|||
|
|||
"google.golang.org/grpc/codes" |
|||
"google.golang.org/grpc/status" |
|||
) |
|||
|
|||
func TestShouldWriteStreamingErrorResponse(t *testing.T) { |
|||
tests := []struct { |
|||
name string |
|||
err error |
|||
expected bool |
|||
}{ |
|||
{ |
|||
name: "nil error", |
|||
err: nil, |
|||
expected: false, |
|||
}, |
|||
{ |
|||
name: "context canceled", |
|||
err: context.Canceled, |
|||
expected: false, |
|||
}, |
|||
{ |
|||
name: "wrapped context canceled", |
|||
err: &StreamError{Err: context.Canceled}, |
|||
expected: false, |
|||
}, |
|||
{ |
|||
name: "grpc canceled", |
|||
err: status.Error(codes.Canceled, "client connection is closing"), |
|||
expected: false, |
|||
}, |
|||
{ |
|||
name: "wrapped grpc canceled", |
|||
err: &StreamError{Err: status.Error(codes.Canceled, "client connection is closing")}, |
|||
expected: false, |
|||
}, |
|||
{ |
|||
name: "deadline exceeded", |
|||
err: context.DeadlineExceeded, |
|||
expected: true, |
|||
}, |
|||
{ |
|||
name: "wrapped deadline exceeded", |
|||
err: &StreamError{Err: context.DeadlineExceeded}, |
|||
expected: true, |
|||
}, |
|||
} |
|||
|
|||
for _, tt := range tests { |
|||
t.Run(tt.name, func(t *testing.T) { |
|||
if got := shouldWriteStreamingErrorResponse(tt.err); got != tt.expected { |
|||
t.Fatalf("shouldWriteStreamingErrorResponse(%v) = %v, want %v", tt.err, got, tt.expected) |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue