move aws backoff to its own file, and use it for redshift basic emitter

This commit is contained in:
dan 2015-05-06 09:18:15 -07:00
parent e42dd7f73d
commit e6a0af7ffd

View file

@ -6,6 +6,7 @@ import (
"testing" "testing"
"github.com/ezoic/go-kinesis" "github.com/ezoic/go-kinesis"
"github.com/lib/pq"
) )
func Test_isRecoverableError(t *testing.T) { func Test_isRecoverableError(t *testing.T) {
@ -21,6 +22,8 @@ func Test_isRecoverableError(t *testing.T) {
{err: &net.OpError{Err: fmt.Errorf("connection reset by peer")}, isRecoverable: true}, {err: &net.OpError{Err: fmt.Errorf("connection reset by peer")}, isRecoverable: true},
{err: &net.OpError{Err: fmt.Errorf("unexpected error")}, isRecoverable: false}, {err: &net.OpError{Err: fmt.Errorf("unexpected error")}, isRecoverable: false},
{err: fmt.Errorf("an arbitrary error"), isRecoverable: false}, {err: fmt.Errorf("an arbitrary error"), isRecoverable: false},
{err: pq.Error{Message: "The specified S3 prefix 'somefilethatismissing' does not exist"}, isRecoverable: true},
{err: pq.Error{Message: "Some other pq error"}, isRecoverable: false},
//"InternalFailure": true, //"InternalFailure": true,
//"Throttling": true, //"Throttling": true,
@ -31,8 +34,7 @@ func Test_isRecoverableError(t *testing.T) {
for idx, tc := range testCases { for idx, tc := range testCases {
p := Pipeline{} isRecoverable := isRecoverableError(tc.err)
isRecoverable := p.isRecoverableError(tc.err)
if isRecoverable != tc.isRecoverable { if isRecoverable != tc.isRecoverable {
t.Errorf("test case %d: isRecoverable expected %t, actual %t, for error %+v", idx, tc.isRecoverable, isRecoverable, tc.err) t.Errorf("test case %d: isRecoverable expected %t, actual %t, for error %+v", idx, tc.isRecoverable, isRecoverable, tc.err)
} }