Skip to content

Commit

Permalink
Minor refacotr on the e2e test framework
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Wang <[email protected]>
  • Loading branch information
ahrtr committed Feb 11, 2025
1 parent f197f44 commit 4bfc442
Showing 1 changed file with 33 additions and 20 deletions.
53 changes: 33 additions & 20 deletions tests/framework/e2e/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,26 +633,13 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in
args = append(args, "--discovery="+cfg.Discovery)
}

var execPath string
switch cfg.Version {
case CurrentVersion:
execPath = BinPath.Etcd
case MinorityLastVersion:
if i <= cfg.ClusterSize/2 {
execPath = BinPath.Etcd
} else {
execPath = BinPath.EtcdLastRelease
}
case QuorumLastVersion:
if i <= cfg.ClusterSize/2 {
execPath = BinPath.EtcdLastRelease
} else {
execPath = BinPath.Etcd
}
case LastVersion:
execPath = BinPath.EtcdLastRelease
default:
panic(fmt.Sprintf("Unknown cluster version %v", cfg.Version))
execPath := cfg.binaryPath(i)

if cfg.ServerConfig.SnapshotCatchUpEntries != etcdserver.DefaultSnapshotCatchUpEntries {
/*if !IsSnapshotCatchupEntriesFlagAvailable(execPath) {
cfg.ServerConfig.ExperimentalSnapshotCatchUpEntries = cfg.ServerConfig.SnapshotCatchUpEntries
cfg.ServerConfig.SnapshotCatchUpEntries = etcdserver.DefaultSnapshotCatchUpEntries
} */
}

defaultValues := values(*embed.NewConfig())
Expand Down Expand Up @@ -696,6 +683,32 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in
}
}

func (cfg *EtcdProcessClusterConfig) binaryPath(i int) string {
var execPath string
switch cfg.Version {
case CurrentVersion:
execPath = BinPath.Etcd
case MinorityLastVersion:
if i <= cfg.ClusterSize/2 {
execPath = BinPath.Etcd
} else {
execPath = BinPath.EtcdLastRelease
}
case QuorumLastVersion:
if i <= cfg.ClusterSize/2 {
execPath = BinPath.EtcdLastRelease
} else {
execPath = BinPath.Etcd
}
case LastVersion:
execPath = BinPath.EtcdLastRelease
default:
panic(fmt.Sprintf("Unknown cluster version %v", cfg.Version))
}

return execPath
}

func values(cfg embed.Config) map[string]string {
fs := flag.NewFlagSet("etcd", flag.ContinueOnError)
cfg.AddFlags(fs)
Expand Down

0 comments on commit 4bfc442

Please sign in to comment.