You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: s3_test.go
    path of file: ./repos/tidb/br/pkg/storage
    
    the code of the file until where you have to start completion: // Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0.

package storage_test

import (
	"bufio"
	"bytes"
	"context"
	"fmt"
	"io"
	"math/rand"
	"net/http"
	"net/http/httptest"
	"os"
	"strings"
	"sync"
	"testing"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/awserr"
	"github.com/aws/aws-sdk-go/aws/request"
	"github.com/aws/aws-sdk-go/service/s3"
	"github.com/pingcap/errors"
	"github.com/pingcap/failpoint"
	backuppb "github.com/pingcap/kvproto/pkg/brpb"
	"github.com/pingcap/tidb/br/pkg/mock"
	. "github.com/pingcap/tidb/br/pkg/storage"
	"github.com/stretchr/testify/require"
	"go.uber.org/mock/gomock"
)

const bucketRegionHeader = "X-Amz-Bucket-Region"

type s3Suite struct {
	controller *gomock.Controller
	s3         *mock.MockS3API
	storage    *S3Storage
}

func createS3Suite(t *testing.T) *s3Suite {
	s := new(s3Suite)
	s.controller = gomock.NewController(t)
	s.s3 = mock.NewMockS3API(s.controller)
	s.storage = NewS3StorageForTest(
		s.s3,
		&backuppb.S3{
			Region:       "us-wes
    
func TestRetryError(t *testing.T) {
	var count int32 = 0
	var errString string = "read tcp *.*.*.*:*->*.*.*.*:*: read: connection reset by peer"
	var lock sync.Mutex
	server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		if r.Method == "PUT" {
			var curCnt int32
			t.Log(r.URL)
			lock.Lock()
			count += 1
			curCnt = count
			lock.Unlock()
			if curCnt < 2 {
				// write an cannot-retry error, but we modify the error to specific error, so client would retry.
				w.WriteHeader(403)
				return
			}
		}

		w.WriteHeader(200)
	}))

	defer server.Close()
	t.Log(server.URL)

	require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/br/pkg/storage/replace-error-to-connection-reset-by-peer", "return(true)"))
	defer func() {
		failpoint.Disable("github.com/pingcap/tidb/br/pkg/storage/replace-error-to-connection-reset-by-peer")
	}()

	ctx := context.Background()
	s, err := NewS3Storage(ctx, &backuppb.S3{
		Endpoint:        server.URL,
		Bucket:          "test",
		Prefix:          "retry",
		AccessKey:       "none",
		SecretAccessKey: "none",
		Provider:        "skip check region",
		ForcePathStyle:  true,
	}, &ExternalStorageOptions{})
	require.NoError(t, err)
	err = s.WriteFile(ctx, "reset", []byte(errString))
	require.NoError(t, err)
	require.Equal(t, count, int32(2))
}