Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default embed config in e2e tests #16688

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions server/embed/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,21 @@ const (
ClusterStateFlagNew = "new"
ClusterStateFlagExisting = "existing"

DefaultName = "default"
DefaultMaxSnapshots = 5
DefaultMaxWALs = 5
DefaultMaxTxnOps = uint(128)
DefaultWarningApplyDuration = 100 * time.Millisecond
DefaultWarningUnaryRequestDuration = 300 * time.Millisecond
DefaultMaxRequestBytes = 1.5 * 1024 * 1024
DefaultMaxConcurrentStreams = math.MaxUint32
DefaultGRPCKeepAliveMinTime = 5 * time.Second
DefaultGRPCKeepAliveInterval = 2 * time.Hour
DefaultGRPCKeepAliveTimeout = 20 * time.Second
DefaultDowngradeCheckTime = 5 * time.Second
DefaultAutoCompactionMode = "periodic"
DefaultName = "default"
DefaultMaxSnapshots = 5
DefaultMaxWALs = 5
DefaultMaxTxnOps = uint(128)
DefaultWarningApplyDuration = 100 * time.Millisecond
DefaultWarningUnaryRequestDuration = 300 * time.Millisecond
DefaultMaxRequestBytes = 1.5 * 1024 * 1024
DefaultMaxConcurrentStreams = math.MaxUint32
DefaultGRPCKeepAliveMinTime = 5 * time.Second
DefaultGRPCKeepAliveInterval = 2 * time.Hour
DefaultGRPCKeepAliveTimeout = 20 * time.Second
DefaultDowngradeCheckTime = 5 * time.Second
DefaultAutoCompactionMode = "periodic"
DefaultAuthToken = "simple"
DefaultExperimentalCompactHashCheckTime = time.Minute

DefaultDiscoveryDialTimeout = 2 * time.Second
DefaultDiscoveryRequestTimeOut = 5 * time.Second
Expand Down Expand Up @@ -509,7 +511,7 @@ func NewConfig() *Config {
CORS: map[string]struct{}{"*": {}},
HostWhitelist: map[string]struct{}{"*": {}},

AuthToken: "simple",
AuthToken: DefaultAuthToken,
BcryptCost: uint(bcrypt.DefaultCost),
AuthTokenTTL: 300,

Expand All @@ -530,7 +532,7 @@ func NewConfig() *Config {
ExperimentalMaxLearners: membership.DefaultMaxLearners,

ExperimentalCompactHashCheckEnabled: false,
ExperimentalCompactHashCheckTime: time.Minute,
ExperimentalCompactHashCheckTime: DefaultExperimentalCompactHashCheckTime,

V2Deprecation: config.V2_DEPR_DEFAULT,

Expand Down
25 changes: 12 additions & 13 deletions tests/framework/e2e/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ import (
"go.uber.org/zap/zaptest"

"go.etcd.io/etcd/api/v3/etcdserverpb"
"go.etcd.io/etcd/client/pkg/v3/logutil"
clientv3 "go.etcd.io/etcd/client/v3"
"go.etcd.io/etcd/pkg/v3/proxy"
config2 "go.etcd.io/etcd/server/v3/config"
"go.etcd.io/etcd/server/v3/embed"
"go.etcd.io/etcd/server/v3/etcdserver"
"go.etcd.io/etcd/tests/v3/framework/config"
Expand Down Expand Up @@ -177,17 +179,14 @@ type EtcdProcessClusterConfig struct {
}

func DefaultConfig() *EtcdProcessClusterConfig {
return &EtcdProcessClusterConfig{
cfg := &EtcdProcessClusterConfig{
ClusterSize: 3,
CN: true,

ServerConfig: embed.Config{
InitialClusterToken: "new",
StrictReconfigCheck: true,
SnapshotCount: etcdserver.DefaultSnapshotCount,
SnapshotCatchUpEntries: etcdserver.DefaultSnapshotCatchUpEntries,
},
ServerConfig: *embed.NewConfig(),
}
cfg.ServerConfig.InitialClusterToken = "new"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, there are tests that depend on this value being exact "new". I might do a followup PR to remove this.

return cfg
}

func NewConfig(opts ...EPClusterOption) *EtcdProcessClusterConfig {
Expand Down Expand Up @@ -553,23 +552,23 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in

args = append(args, cfg.TlsArgs()...)

if cfg.ServerConfig.AuthToken != "" {
if cfg.ServerConfig.AuthToken != "" && cfg.ServerConfig.AuthToken != embed.DefaultAuthToken {
args = append(args, "--auth-token", cfg.ServerConfig.AuthToken)
}

if cfg.ServerConfig.V2Deprecation != "" {
if cfg.ServerConfig.V2Deprecation != "" && cfg.ServerConfig.V2Deprecation != config2.V2_DEPR_DEFAULT {
args = append(args, "--v2-deprecation", string(cfg.ServerConfig.V2Deprecation))
}

if cfg.Discovery != "" {
args = append(args, "--discovery", cfg.Discovery)
}

if cfg.ServerConfig.LogLevel != "" {
if cfg.ServerConfig.LogLevel != "" && cfg.ServerConfig.LogLevel != logutil.DefaultLogLevel {
args = append(args, "--log-level", cfg.ServerConfig.LogLevel)
}

if cfg.ServerConfig.MaxConcurrentStreams != 0 {
if cfg.ServerConfig.MaxConcurrentStreams != 0 && cfg.ServerConfig.MaxConcurrentStreams != embed.DefaultMaxConcurrentStreams {
args = append(args, "--max-concurrent-streams", fmt.Sprintf("%d", cfg.ServerConfig.MaxConcurrentStreams))
}

Expand All @@ -579,7 +578,7 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in
if cfg.ServerConfig.ExperimentalCompactHashCheckEnabled {
args = append(args, "--experimental-compact-hash-check-enabled")
}
if cfg.ServerConfig.ExperimentalCompactHashCheckTime != 0 {
if cfg.ServerConfig.ExperimentalCompactHashCheckTime != 0 && cfg.ServerConfig.ExperimentalCompactHashCheckTime != embed.DefaultExperimentalCompactHashCheckTime {
args = append(args, "--experimental-compact-hash-check-time", cfg.ServerConfig.ExperimentalCompactHashCheckTime.String())
}
if cfg.ServerConfig.ExperimentalCompactionBatchLimit != 0 {
Expand All @@ -597,7 +596,7 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in
if cfg.ServerConfig.ExperimentalWatchProgressNotifyInterval != 0 {
args = append(args, "--experimental-watch-progress-notify-interval", cfg.ServerConfig.ExperimentalWatchProgressNotifyInterval.String())
}
if cfg.ServerConfig.SnapshotCatchUpEntries != etcdserver.DefaultSnapshotCatchUpEntries {
if cfg.ServerConfig.SnapshotCatchUpEntries != 0 && cfg.ServerConfig.SnapshotCatchUpEntries != etcdserver.DefaultSnapshotCatchUpEntries {
if cfg.Version == CurrentVersion || (cfg.Version == MinorityLastVersion && i <= cfg.ClusterSize/2) || (cfg.Version == QuorumLastVersion && i > cfg.ClusterSize/2) {
args = append(args, "--experimental-snapshot-catchup-entries", fmt.Sprintf("%d", cfg.ServerConfig.SnapshotCatchUpEntries))
}
Expand Down
Loading