-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
COS: Add http_config for cos object store client (#4482)
* Fix cos client MaxIdleConnsPerHost too low, too many TIME_WAIT (#4479) The http.Transport is not auto-tuning and one size does not seem to fit all cases. Add `HTTPConfig` Allow to tune most of the http.Transport parameters and `MaxIdleConnsPerHost` tune to 100. Signed-off-by: hanjm <hanjinming@outlook.com> * Add docs about cos object store config `http_config` Signed-off-by: hanjm <hanjinming@outlook.com> * Add changelog Signed-off-by: hanjm <hanjinming@outlook.com> * Add copyright Signed-off-by: hanjm <hanjinming@outlook.com>
- Loading branch information
Showing
5 changed files
with
134 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright (c) The Thanos Authors. | ||
// Licensed under the Apache License 2.0. | ||
|
||
package cos | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/prometheus/common/model" | ||
"github.com/thanos-io/thanos/pkg/testutil" | ||
) | ||
|
||
func Test_parseConfig(t *testing.T) { | ||
type args struct { | ||
conf []byte | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want Config | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "empty", | ||
args: args{ | ||
conf: []byte(""), | ||
}, | ||
want: DefaultConfig, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "max_idle_conns", | ||
args: args{ | ||
conf: []byte(` | ||
http_config: | ||
max_idle_conns: 200 | ||
`), | ||
}, | ||
want: Config{ | ||
HTTPConfig: HTTPConfig{ | ||
IdleConnTimeout: model.Duration(90 * time.Second), | ||
ResponseHeaderTimeout: model.Duration(2 * time.Minute), | ||
TLSHandshakeTimeout: model.Duration(10 * time.Second), | ||
ExpectContinueTimeout: model.Duration(1 * time.Second), | ||
MaxIdleConns: 200, | ||
MaxIdleConnsPerHost: 100, | ||
MaxConnsPerHost: 0, | ||
}, | ||
}, | ||
wantErr: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := parseConfig(tt.args.conf) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("parseConfig() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
testutil.Equals(t, tt.want, got) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters