From b4a09812957f3940a3296f40b18bfbf6e2d03e16 Mon Sep 17 00:00:00 2001 From: Marek Siarkowicz Date: Fri, 17 Jan 2025 14:14:22 +0100 Subject: [PATCH] Fix passing compaction-batch-limit to etcd v3.4 and v3.5 Signed-off-by: Marek Siarkowicz --- tests/e2e/corrupt_test.go | 11 ++++------- tests/framework/e2e/cluster.go | 14 +++++--------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/tests/e2e/corrupt_test.go b/tests/e2e/corrupt_test.go index 86535345e99..9ed3a47f486 100644 --- a/tests/e2e/corrupt_test.go +++ b/tests/e2e/corrupt_test.go @@ -329,11 +329,11 @@ func testCompactHashCheckDetectCorruptionInterrupt(t *testing.T, useFeatureGate } else { opts = append(opts, e2e.WithCompactHashCheckEnabled(true)) } - var compactionBatchLimit e2e.EPClusterOption + var flag string if useExperimentalFlag { - compactionBatchLimit = e2e.WithExperimentalCompactionBatchLimit(1) + flag = "--experimental-compaction-batch-limit=1" } else { - compactionBatchLimit = e2e.WithCompactionBatchLimit(1) + flag = "--compaction-batch-limit=1" } cfg := e2e.NewConfig(opts...) @@ -341,10 +341,7 @@ func testCompactHashCheckDetectCorruptionInterrupt(t *testing.T, useFeatureGate require.NoError(t, err) // Assign a node a very slow compaction speed, so that its compaction can be interrupted. - err = epc.UpdateProcOptions(slowCompactionNodeIndex, t, - compactionBatchLimit, - e2e.WithCompactionSleepInterval(1*time.Hour), - ) + err = epc.UpdateProcOptions(slowCompactionNodeIndex, t, flag, "--experimental-compaction-sleep-interval=1h") require.NoError(t, err) epc, err = e2e.StartEtcdProcessCluster(ctx, t, epc, cfg) diff --git a/tests/framework/e2e/cluster.go b/tests/framework/e2e/cluster.go index 3da0ff9a8f2..00661f422e4 100644 --- a/tests/framework/e2e/cluster.go +++ b/tests/framework/e2e/cluster.go @@ -376,10 +376,6 @@ func WithCompactionBatchLimit(limit int) EPClusterOption { return func(c *EtcdProcessClusterConfig) { c.ServerConfig.CompactionBatchLimit = limit } } -func WithExperimentalCompactionBatchLimit(limit int) EPClusterOption { - return func(c *EtcdProcessClusterConfig) { c.ServerConfig.ExperimentalCompactionBatchLimit = limit } -} - func WithCompactionSleepInterval(time time.Duration) EPClusterOption { return func(c *EtcdProcessClusterConfig) { c.ServerConfig.ExperimentalCompactionSleepInterval = time } } @@ -640,6 +636,9 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in if flag == "experimental-snapshot-catchup-entries" && !CouldSetSnapshotCatchupEntries(execPath) { continue } + if flag == "compaction-batch-limit" { + flag = "experimental-compaction-batch-limit" + } args = append(args, fmt.Sprintf("--%s=%s", flag, value)) } envVars := map[string]string{} @@ -881,16 +880,13 @@ func (epc *EtcdProcessCluster) StartNewProcFromConfig(ctx context.Context, tb te // UpdateProcOptions updates the options for a specific process. If no opt is set, then the config is identical // to the cluster. -func (epc *EtcdProcessCluster) UpdateProcOptions(i int, tb testing.TB, opts ...EPClusterOption) error { +func (epc *EtcdProcessCluster) UpdateProcOptions(i int, tb testing.TB, newflags ...string) error { if epc.Procs[i].IsRunning() { return fmt.Errorf("process %d is still running, please close it before updating its options", i) } cfg := *epc.Cfg - for _, opt := range opts { - opt(&cfg) - } serverCfg := cfg.EtcdServerProcessConfig(tb, i) - + serverCfg.Args = append(serverCfg.Args, newflags...) var initialCluster []string for _, p := range epc.Procs { initialCluster = append(initialCluster, fmt.Sprintf("%s=%s", p.Config().Name, p.Config().PeerURL.String()))