diff --git a/tests/e2e/warning_logging_test.go b/tests/e2e/promote_experimental_flag_test.go similarity index 73% rename from tests/e2e/warning_logging_test.go rename to tests/e2e/promote_experimental_flag_test.go index 139a6a4afa5d..e794cbc6e311 100644 --- a/tests/e2e/warning_logging_test.go +++ b/tests/e2e/promote_experimental_flag_test.go @@ -19,9 +19,9 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/stretchr/testify/assert" "go.etcd.io/etcd/tests/v3/framework/config" "go.etcd.io/etcd/tests/v3/framework/e2e" ) @@ -29,11 +29,10 @@ import ( func TestWarningApplyDuration(t *testing.T) { e2e.BeforeTest(t) - epc, err := e2e.NewEtcdProcessCluster(context.TODO(), t, &e2e.EtcdProcessClusterConfig{ - ClusterSize: 1, - //Set very small duration to trigger warning - WarningUnaryRequestDuration: time.Microsecond, - }) + epc, err := e2e.NewEtcdProcessCluster(context.TODO(), t, + e2e.WithClusterSize(1), + e2e.WithWarningUnaryRequestDuration(time.Microsecond), + ) if err != nil { t.Fatalf("could not start etcd process cluster (%v)", err) } @@ -43,7 +42,7 @@ func TestWarningApplyDuration(t *testing.T) { } }) - cc, err := e2e.NewEtcdctl(epc.Cfg, epc.EndpointsV3()) + cc, err := e2e.NewEtcdctl(epc.Cfg.Client, epc.EndpointsV3()) require.NoError(t, err) err = cc.Put(context.TODO(), "foo", "bar", config.PutOptions{}) assert.NoError(t, err, "error on put") @@ -57,11 +56,10 @@ func TestWarningApplyDuration(t *testing.T) { func TestExperimentalWarningApplyDuration(t *testing.T) { e2e.BeforeTest(t) - epc, err := e2e.NewEtcdProcessCluster(context.TODO(), t, &e2e.EtcdProcessClusterConfig{ - ClusterSize: 1, - //Set very small duration to trigger warning - ExperimentalWarningUnaryRequestDuration: time.Microsecond, - }) + epc, err := e2e.NewEtcdProcessCluster(context.TODO(), t, + e2e.WithClusterSize(1), + e2e.WithExperimentalWarningUnaryRequestDuration(time.Microsecond), + ) if err != nil { t.Fatalf("could not start etcd process cluster (%v)", err) } @@ -71,7 +69,7 @@ func TestExperimentalWarningApplyDuration(t *testing.T) { } }) - cc, err := e2e.NewEtcdctl(epc.Cfg, epc.EndpointsV3()) + cc, err := e2e.NewEtcdctl(epc.Cfg.Client, epc.EndpointsV3()) require.NoError(t, err) err = cc.Put(context.TODO(), "foo", "bar", config.PutOptions{}) assert.NoError(t, err, "error on put") @@ -83,11 +81,11 @@ func TestExperimentalWarningApplyDuration(t *testing.T) { func TestBothWarningApplyDurationFlagsFail(t *testing.T) { e2e.BeforeTest(t) - _, err := e2e.NewEtcdProcessCluster(context.TODO(), t, &e2e.EtcdProcessClusterConfig{ - ClusterSize: 1, - WarningUnaryRequestDuration: time.Second, - ExperimentalWarningUnaryRequestDuration: time.Second, - }) + _, err := e2e.NewEtcdProcessCluster(context.TODO(), t, + e2e.WithClusterSize(1), + e2e.WithWarningUnaryRequestDuration(time.Second), + e2e.WithExperimentalWarningUnaryRequestDuration(time.Second), + ) if err == nil { t.Fatal("Expected process to fail") } diff --git a/tests/framework/e2e/cluster.go b/tests/framework/e2e/cluster.go index 2650e156cbe1..ee46dd6b565b 100644 --- a/tests/framework/e2e/cluster.go +++ b/tests/framework/e2e/cluster.go @@ -313,6 +313,16 @@ func WithGoFailEnabled(enabled bool) EPClusterOption { return func(c *EtcdProcessClusterConfig) { c.GoFailEnabled = enabled } } +func WithWarningUnaryRequestDuration(time time.Duration) EPClusterOption { + return func(c *EtcdProcessClusterConfig) { c.WarningUnaryRequestDuration = time } +} + +// WithExperimentalWarningUnaryRequestDuration sets a value for `-experimental-warning-unary-request-duration`. +// TODO(ahrtr): remove this function when the corresponding experimental flag is decommissioned. +func WithExperimentalWarningUnaryRequestDuration(time time.Duration) EPClusterOption { + return func(c *EtcdProcessClusterConfig) { c.ExperimentalWarningUnaryRequestDuration = time } +} + func WithCompactionBatchLimit(limit int) EPClusterOption { return func(c *EtcdProcessClusterConfig) { c.CompactionBatchLimit = limit } }