diff --git a/tests/framework/e2e/cluster.go b/tests/framework/e2e/cluster.go index 00bba5f95a8..b273041a999 100644 --- a/tests/framework/e2e/cluster.go +++ b/tests/framework/e2e/cluster.go @@ -396,6 +396,22 @@ func WithPeerProxy(enabled bool) EPClusterOption { return func(c *EtcdProcessClusterConfig) { c.PeerProxy = enabled } } +func WithClientHTTPSeparate(enabled bool) EPClusterOption { + return func(c *EtcdProcessClusterConfig) { c.ClientHTTPSeparate = enabled } +} + +func WithForceNewCluster(enabled bool) EPClusterOption { + return func(c *EtcdProcessClusterConfig) { c.ServerConfig.ForceNewCluster = enabled } +} + +func WithMetricsURLScheme(scheme string) EPClusterOption { + return func(c *EtcdProcessClusterConfig) { c.MetricsURLScheme = scheme } +} + +func WithCipherSuites(suites []string) EPClusterOption { + return func(c *EtcdProcessClusterConfig) { c.ServerConfig.CipherSuites = suites } +} + // NewEtcdProcessCluster launches a new cluster from etcd processes, returning // a new EtcdProcessCluster once all nodes are ready to accept client requests. func NewEtcdProcessCluster(ctx context.Context, t testing.TB, opts ...EPClusterOption) (*EtcdProcessCluster, error) { @@ -581,7 +597,7 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in } if cfg.ServerConfig.ForceNewCluster { - args = append(args, "--force-new-cluster") + args = append(args, "--force-new-cluster=true") } if cfg.ServerConfig.QuotaBackendBytes > 0 { args = append(args, @@ -592,7 +608,7 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in args = append(args, "--strict-reconfig-check=false") } if cfg.EnableV2 { - args = append(args, "--enable-v2") + args = append(args, "--enable-v2=true") } var murl string if cfg.MetricsURLScheme != "" { diff --git a/tests/framework/e2e/cluster_test.go b/tests/framework/e2e/cluster_test.go index 7222460ef0d..fc9787addaa 100644 --- a/tests/framework/e2e/cluster_test.go +++ b/tests/framework/e2e/cluster_test.go @@ -28,20 +28,25 @@ func TestEtcdServerProcessConfig(t *testing.T) { tcs := []struct { name string config *EtcdProcessClusterConfig + expectArgsEquals []string expectArgsNotContain []string expectArgsContain []string mockBinaryVersion *semver.Version }{ { name: "Default", - config: NewConfig(), - expectArgsContain: []string{ + config: NewConfig(WithDataDirPath("/tmp/a")), + expectArgsEquals: []string{ + "--name=TestEtcdServerProcessConfigDefault-test-0", "--listen-client-urls=http://localhost:0", "--advertise-client-urls=http://localhost:0", "--listen-peer-urls=http://localhost:1", "--initial-advertise-peer-urls=http://localhost:1", "--initial-cluster-token=new", + "--data-dir", + "/tmp/a/member-0", "--snapshot-count=10000", + "--initial-cluster-token=new", }, }, { @@ -95,6 +100,121 @@ func TestEtcdServerProcessConfig(t *testing.T) { }, mockBinaryVersion: &v3_5_12, }, + { + name: "ClientHTTPSeparate", + config: NewConfig(WithClientHTTPSeparate(true)), + expectArgsContain: []string{ + "--listen-client-http-urls=http://localhost:4", + }, + }, + { + name: "ForceNewCluster", + config: NewConfig(WithForceNewCluster(true)), + expectArgsContain: []string{ + "--force-new-cluster=true", + }, + }, + { + name: "EnableV2", + config: NewConfig(WithEnableV2(true)), + expectArgsContain: []string{ + "--enable-v2=true", + }, + }, + { + name: "MetricsURL", + config: NewConfig(WithMetricsURLScheme("http")), + expectArgsContain: []string{ + "--listen-metrics-urls=http://localhost:2", + }, + }, + { + name: "Discovery", + config: NewConfig(WithDiscovery("123")), + expectArgsContain: []string{ + "--discovery=123", + }, + }, + { + name: "ClientTLS", + config: NewConfig(WithClientConnType(ClientTLS)), + expectArgsContain: []string{ + "--cert-file", + "--key-file", + "--trusted-ca-file", + }, + expectArgsNotContain: []string{ + "--auto-tls", + "--client-cert-auth", + }, + }, + { + name: "ClientTLSCA", + config: NewConfig(WithClientConnType(ClientTLS), WithClientCertAuthority(true)), + expectArgsContain: []string{ + "--cert-file", + "--key-file", + "--trusted-ca-file", + "--client-cert-auth", + }, + expectArgsNotContain: []string{ + "--auto-tls", + }, + }, + { + name: "ClientAutoTLS", + config: NewConfig(WithClientConnType(ClientTLS), WithClientAutoTLS(true)), + expectArgsContain: []string{ + "--auto-tls", + }, + expectArgsNotContain: []string{ + "--cert-file", + "--key-file", + "--trusted-ca-file", + "--client-cert-auth", + }, + }, + { + name: "PeerTLS", + config: NewConfig(WithIsPeerTLS(true)), + expectArgsContain: []string{ + "--peer-cert-file", + "--peer-key-file", + "--peer-trusted-ca-file", + }, + expectArgsNotContain: []string{ + "--peer-auto-tls", + "--peer-client-cert-auth", + }, + }, + { + name: "PeerAutoTLS", + config: NewConfig(WithIsPeerTLS(true), WithIsPeerAutoTLS(true)), + expectArgsContain: []string{ + "--peer-auto-tls", + }, + expectArgsNotContain: []string{ + "--peer-cert-file", + "--peer-key-file", + "--peer-trusted-ca-file", + "--peer-client-cert-auth", + }, + }, + { + name: "RevokeCerts", + config: NewConfig(WithClientRevokeCerts(true)), + expectArgsContain: []string{ + "--client-crl-file", + "--client-cert-auth", + }, + }, + { + name: "CipherSuites", + config: NewConfig(WithCipherSuites([]string{"a", "b"})), + expectArgsContain: []string{ + "--cipher-suites", + }, + }, } for _, tc := range tcs { t.Run(tc.name, func(t *testing.T) { @@ -110,6 +230,9 @@ func TestEtcdServerProcessConfig(t *testing.T) { } setGetVersionFromBinary(t, mockGetVersionFromBinary) args := tc.config.EtcdServerProcessConfig(t, 0).Args + if len(tc.expectArgsEquals) != 0 { + assert.Equal(t, args, tc.expectArgsEquals) + } if len(tc.expectArgsContain) != 0 { assert.Subset(t, args, tc.expectArgsContain) }