diff --git a/bench/fails/fails.go b/bench/fails/fails.go index b35e0fbcd..76ec23f68 100644 --- a/bench/fails/fails.go +++ b/bench/fails/fails.go @@ -14,8 +14,6 @@ const ( ErrApplication failure.StringCode = "error application" // ErrTimeout はタイムアウトエラー。基本は大目に見る。 ErrTimeout failure.StringCode = "error timeout" - // ErrTemporary は一時的なエラー。基本は大目に見る。 - ErrTemporary failure.StringCode = "error temporary" ) var ( @@ -82,9 +80,6 @@ func (e *Errors) Add(err error) { case ErrTimeout: msg += "(タイムアウトしました)" e.trivial++ - case ErrTemporary: - msg += "(一時的なエラー)" - e.trivial++ case ErrApplication: e.application++ default: diff --git a/bench/server/shipment.go b/bench/server/shipment.go index b94389ecd..c8d9f0ed4 100644 --- a/bench/server/shipment.go +++ b/bench/server/shipment.go @@ -158,8 +158,6 @@ func (c *shipmentStore) Get(key string) (shipment, bool) { } func init() { - rand.Seed(time.Now().UnixNano()) - shipmentHash = sha1.New() shipmentHash.Write(SecretSeed) } diff --git a/bench/session/session.go b/bench/session/session.go index 453298d8c..d85e0503b 100644 --- a/bench/session/session.go +++ b/bench/session/session.go @@ -3,7 +3,6 @@ package session import ( "fmt" "io" - "io/ioutil" "net" "net/http" "net/url" @@ -150,7 +149,7 @@ func checkStatusCode(res *http.Response, expectedStatusCode int) error { prefixMsg := fmt.Sprintf("%s %s", res.Request.Method, res.Request.URL.Path) if res.StatusCode != expectedStatusCode { - b, err := ioutil.ReadAll(res.Body) + b, err := io.ReadAll(res.Body) if err != nil { return failure.Wrap(err, failure.Message(prefixMsg+": bodyの読み込みに失敗しました")) } @@ -166,7 +165,7 @@ func checkStatusCodeWithMsg(res *http.Response, expectedStatusCode int, msg stri prefixMsg := fmt.Sprintf("%s %s", res.Request.Method, res.Request.URL.Path) if res.StatusCode != expectedStatusCode { - b, err := ioutil.ReadAll(res.Body) + b, err := io.ReadAll(res.Body) if err != nil { return failure.Wrap(err, failure.Message(prefixMsg+": bodyの読み込みに失敗しました "+msg)) } @@ -184,8 +183,6 @@ func (s *Session) Do(req *http.Request) (*http.Response, error) { if nerr, ok := err.(net.Error); ok { if nerr.Timeout() { return nil, failure.Translate(err, fails.ErrTimeout) - } else if nerr.Temporary() { - return nil, failure.Translate(err, fails.ErrTemporary) } } diff --git a/bench/session/webapp.go b/bench/session/webapp.go index 647713c59..54e9fc25a 100644 --- a/bench/session/webapp.go +++ b/bench/session/webapp.go @@ -7,7 +7,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "mime/multipart" "net/http" "net/url" @@ -509,7 +508,7 @@ func (s *Session) ShipDone(ctx context.Context, itemID int64) error { return err } - _, err = ioutil.ReadAll(res.Body) + _, err = io.ReadAll(res.Body) if err != nil { return failure.Wrap(err, failure.Messagef("POST /ship_done: bodyの読み込みに失敗しました (item_id: %d)", itemID)) } @@ -540,7 +539,7 @@ func (s *Session) Complete(ctx context.Context, itemID int64) error { return err } - _, err = ioutil.ReadAll(res.Body) + _, err = io.ReadAll(res.Body) if err != nil { return failure.Wrap(err, failure.Messagef("POST /complete: bodyの読み込みに失敗しました (item_id: %d)", itemID)) } diff --git a/cmd/bench-worker/main.go b/cmd/bench-worker/main.go index 691e8cfc8..d3babe130 100644 --- a/cmd/bench-worker/main.go +++ b/cmd/bench-worker/main.go @@ -231,8 +231,9 @@ func runBenchmarker(benchmarkerPath string, job *Job) (*BenchmarkResult, error) fmt.Sprintf("-shipment-url=https://%s", fmt.Sprintf("shipment%s.isucon9q.catatsuy.org", suffix)), fmt.Sprintf("-target-url=https://%s", target.GlobalIP), fmt.Sprintf("-allowed-ips=%s", strings.Join(allowedIPs, ",")), - fmt.Sprintf("-data-dir=/home/isucon/isucari/initial-data"), - fmt.Sprintf("-static-dir=/home/isucon/isucari/webapp/public/static")) + "-data-dir=/home/isucon/isucari/initial-data", + "-static-dir=/home/isucon/isucari/webapp/public/static", + ) var ( stdout bytes.Buffer diff --git a/cmd/bench/main.go b/cmd/bench/main.go index 1b2164382..756520edf 100644 --- a/cmd/bench/main.go +++ b/cmd/bench/main.go @@ -5,7 +5,6 @@ import ( "encoding/json" "flag" "log" - "math/rand" "net" "os" "sort" @@ -39,8 +38,6 @@ type Config struct { } func init() { - rand.Seed(time.Now().UnixNano()) - log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile) } diff --git a/webapp/go/api.go b/webapp/go/api.go index f26387fc3..d31a3e28f 100644 --- a/webapp/go/api.go +++ b/webapp/go/api.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" ) @@ -68,7 +68,7 @@ func APIPaymentToken(paymentURL string, param *APIPaymentServiceTokenReq) (*APIP defer res.Body.Close() if res.StatusCode != http.StatusOK { - b, err := ioutil.ReadAll(res.Body) + b, err := io.ReadAll(res.Body) if err != nil { return nil, fmt.Errorf("failed to read res.Body and the status code of the response from shipment service was not 200: %v", err) } @@ -103,7 +103,7 @@ func APIShipmentCreate(shipmentURL string, param *APIShipmentCreateReq) (*APIShi defer res.Body.Close() if res.StatusCode != http.StatusOK { - b, err := ioutil.ReadAll(res.Body) + b, err := io.ReadAll(res.Body) if err != nil { return nil, fmt.Errorf("failed to read res.Body and the status code of the response from shipment service was not 200: %v", err) } @@ -138,14 +138,14 @@ func APIShipmentRequest(shipmentURL string, param *APIShipmentRequestReq) ([]byt defer res.Body.Close() if res.StatusCode != http.StatusOK { - b, err := ioutil.ReadAll(res.Body) + b, err := io.ReadAll(res.Body) if err != nil { return nil, fmt.Errorf("failed to read res.Body and the status code of the response from shipment service was not 200: %v", err) } return nil, fmt.Errorf("status code: %d; body: %s", res.StatusCode, b) } - return ioutil.ReadAll(res.Body) + return io.ReadAll(res.Body) } func APIShipmentStatus(shipmentURL string, param *APIShipmentStatusReq) (*APIShipmentStatusRes, error) { @@ -167,7 +167,7 @@ func APIShipmentStatus(shipmentURL string, param *APIShipmentStatusReq) (*APIShi defer res.Body.Close() if res.StatusCode != http.StatusOK { - b, err := ioutil.ReadAll(res.Body) + b, err := io.ReadAll(res.Body) if err != nil { return nil, fmt.Errorf("failed to read res.Body and the status code of the response from shipment service was not 200: %v", err) }