Skip to content

Commit

Permalink
Ensure that WithParams keeps the transport (#15421)
Browse files Browse the repository at this point in the history
Signed-off-by: Dirkjan Bussink <[email protected]>
  • Loading branch information
dbussink authored Mar 7, 2024
1 parent 6c73053 commit 66f1990
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go/vt/mysqlctl/s3backupstorage/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ func (bs *S3BackupStorage) Close() error {
}

func (bs *S3BackupStorage) WithParams(params backupstorage.Params) backupstorage.BackupStorage {
return &S3BackupStorage{params: params}
return &S3BackupStorage{params: params, transport: bs.transport}
}

var _ backupstorage.BackupStorage = (*S3BackupStorage)(nil)
Expand Down
10 changes: 10 additions & 0 deletions go/vt/mysqlctl/s3backupstorage/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,13 @@ func TestNewS3Transport(t *testing.T) {
assert.NotNil(t, s3.transport.DialContext)
assert.NotNil(t, s3.transport.Proxy)
}

func TestWithParams(t *testing.T) {
bases3 := newS3BackupStorage()
s3 := bases3.WithParams(backupstorage.Params{}).(*S3BackupStorage)
// checking some of the values are present in the returned transport and match the http.DefaultTransport.
assert.Equal(t, http.DefaultTransport.(*http.Transport).IdleConnTimeout, s3.transport.IdleConnTimeout)
assert.Equal(t, http.DefaultTransport.(*http.Transport).MaxIdleConns, s3.transport.MaxIdleConns)
assert.NotNil(t, s3.transport.DialContext)
assert.NotNil(t, s3.transport.Proxy)
}

0 comments on commit 66f1990

Please sign in to comment.