-
Notifications
You must be signed in to change notification settings - Fork 104
/
config_profile_test.go
55 lines (48 loc) · 1.91 KB
/
config_profile_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package gocb
import "time"
var defaultConfig = ClusterOptions{
TimeoutsConfig: TimeoutsConfig{
KVTimeout: 2500 * time.Millisecond,
ConnectTimeout: 10 * time.Second,
KVDurableTimeout: 10 * time.Second,
KVScanTimeout: 10 * time.Second,
ViewTimeout: 75 * time.Second,
AnalyticsTimeout: 75 * time.Second,
SearchTimeout: 75 * time.Second,
ManagementTimeout: 75 * time.Second,
QueryTimeout: 75 * time.Second,
},
Transcoder: NewJSONTranscoder(),
Tracer: NewThresholdLoggingTracer(nil),
Meter: newAggregatingMeter(nil),
RetryStrategy: NewBestEffortRetryStrategy(nil),
}
func (suite *UnitTestSuite) TestDevelopmentConfigProfile() {
auth := PasswordAuthenticator{
Username: globalConfig.User,
Password: globalConfig.Password,
}
options := defaultConfig
options.Authenticator = auth
err := options.ApplyProfile(ClusterConfigProfileWanDevelopment)
suite.Require().Nil(err)
suite.Assert().Equal(20*time.Second, options.TimeoutsConfig.KVTimeout)
suite.Assert().Equal(20*time.Second, options.TimeoutsConfig.ConnectTimeout)
suite.Assert().Equal(20*time.Second, options.TimeoutsConfig.KVDurableTimeout)
suite.Assert().Equal(20*time.Second, options.TimeoutsConfig.KVScanTimeout)
suite.Assert().Equal(120*time.Second, options.TimeoutsConfig.ViewTimeout)
suite.Assert().Equal(120*time.Second, options.TimeoutsConfig.AnalyticsTimeout)
suite.Assert().Equal(120*time.Second, options.TimeoutsConfig.SearchTimeout)
suite.Assert().Equal(120*time.Second, options.TimeoutsConfig.ManagementTimeout)
suite.Assert().Equal(120*time.Second, options.TimeoutsConfig.QueryTimeout)
}
func (suite *UnitTestSuite) TestUnknownConfigProfile() {
auth := PasswordAuthenticator{
Username: globalConfig.User,
Password: globalConfig.Password,
}
options := defaultConfig
options.Authenticator = auth
err := options.ApplyProfile("unknown")
suite.Require().ErrorIs(err, ErrInvalidArgument)
}