Skip to content

Commit b4a0981

Browse files
committed
Fix passing compaction-batch-limit to etcd v3.4 and v3.5
Signed-off-by: Marek Siarkowicz <[email protected]>
1 parent 9da01a8 commit b4a0981

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

tests/e2e/corrupt_test.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -329,22 +329,19 @@ func testCompactHashCheckDetectCorruptionInterrupt(t *testing.T, useFeatureGate
329329
} else {
330330
opts = append(opts, e2e.WithCompactHashCheckEnabled(true))
331331
}
332-
var compactionBatchLimit e2e.EPClusterOption
332+
var flag string
333333
if useExperimentalFlag {
334-
compactionBatchLimit = e2e.WithExperimentalCompactionBatchLimit(1)
334+
flag = "--experimental-compaction-batch-limit=1"
335335
} else {
336-
compactionBatchLimit = e2e.WithCompactionBatchLimit(1)
336+
flag = "--compaction-batch-limit=1"
337337
}
338338

339339
cfg := e2e.NewConfig(opts...)
340340
epc, err := e2e.InitEtcdProcessCluster(t, cfg)
341341
require.NoError(t, err)
342342

343343
// Assign a node a very slow compaction speed, so that its compaction can be interrupted.
344-
err = epc.UpdateProcOptions(slowCompactionNodeIndex, t,
345-
compactionBatchLimit,
346-
e2e.WithCompactionSleepInterval(1*time.Hour),
347-
)
344+
err = epc.UpdateProcOptions(slowCompactionNodeIndex, t, flag, "--experimental-compaction-sleep-interval=1h")
348345
require.NoError(t, err)
349346

350347
epc, err = e2e.StartEtcdProcessCluster(ctx, t, epc, cfg)

tests/framework/e2e/cluster.go

+5-9
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,6 @@ func WithCompactionBatchLimit(limit int) EPClusterOption {
376376
return func(c *EtcdProcessClusterConfig) { c.ServerConfig.CompactionBatchLimit = limit }
377377
}
378378

379-
func WithExperimentalCompactionBatchLimit(limit int) EPClusterOption {
380-
return func(c *EtcdProcessClusterConfig) { c.ServerConfig.ExperimentalCompactionBatchLimit = limit }
381-
}
382-
383379
func WithCompactionSleepInterval(time time.Duration) EPClusterOption {
384380
return func(c *EtcdProcessClusterConfig) { c.ServerConfig.ExperimentalCompactionSleepInterval = time }
385381
}
@@ -640,6 +636,9 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in
640636
if flag == "experimental-snapshot-catchup-entries" && !CouldSetSnapshotCatchupEntries(execPath) {
641637
continue
642638
}
639+
if flag == "compaction-batch-limit" {
640+
flag = "experimental-compaction-batch-limit"
641+
}
643642
args = append(args, fmt.Sprintf("--%s=%s", flag, value))
644643
}
645644
envVars := map[string]string{}
@@ -881,16 +880,13 @@ func (epc *EtcdProcessCluster) StartNewProcFromConfig(ctx context.Context, tb te
881880

882881
// UpdateProcOptions updates the options for a specific process. If no opt is set, then the config is identical
883882
// to the cluster.
884-
func (epc *EtcdProcessCluster) UpdateProcOptions(i int, tb testing.TB, opts ...EPClusterOption) error {
883+
func (epc *EtcdProcessCluster) UpdateProcOptions(i int, tb testing.TB, newflags ...string) error {
885884
if epc.Procs[i].IsRunning() {
886885
return fmt.Errorf("process %d is still running, please close it before updating its options", i)
887886
}
888887
cfg := *epc.Cfg
889-
for _, opt := range opts {
890-
opt(&cfg)
891-
}
892888
serverCfg := cfg.EtcdServerProcessConfig(tb, i)
893-
889+
serverCfg.Args = append(serverCfg.Args, newflags...)
894890
var initialCluster []string
895891
for _, p := range epc.Procs {
896892
initialCluster = append(initialCluster, fmt.Sprintf("%s=%s", p.Config().Name, p.Config().PeerURL.String()))

0 commit comments

Comments
 (0)