tests: Test different TLS configuration with TestKVPut

This commit is contained in:
Marek Siarkowicz
2022-02-18 13:06:48 +01:00
parent 58c3808919
commit 81ef11ffb8
3 changed files with 28 additions and 9 deletions

View File

@@ -28,10 +28,26 @@ func TestKVPut(t *testing.T) {
name string
config config.ClusterConfig
}{
{
name: "NoTLS",
config: config.ClusterConfig{ClusterSize: 1},
},
{
name: "PeerTLS",
config: config.ClusterConfig{ClusterSize: 1, PeerTLS: config.ManualTLS},
},
{
name: "PeerAutoTLS",
config: config.ClusterConfig{ClusterSize: 1, PeerTLS: config.AutoTLS},
},
{
name: "ClientTLS",
config: config.ClusterConfig{ClusterSize: 1, ClientTLS: config.ManualTLS},
},
{
name: "ClientAutoTLS",
config: config.ClusterConfig{ClusterSize: 1, ClientTLS: config.AutoTLS},
},
}
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {

View File

@@ -22,12 +22,6 @@ import (
"go.etcd.io/etcd/tests/v3/framework/e2e"
)
func TestCtlV3PutNoTLS(t *testing.T) { testCtl(t, putTest, withCfg(*e2e.NewConfigNoTLS())) }
func TestCtlV3PutClientTLS(t *testing.T) { testCtl(t, putTest, withCfg(*e2e.NewConfigClientTLS())) }
func TestCtlV3PutClientAutoTLS(t *testing.T) {
testCtl(t, putTest, withCfg(*e2e.NewConfigClientAutoTLS()))
}
func TestCtlV3PutPeerTLS(t *testing.T) { testCtl(t, putTest, withCfg(*e2e.NewConfigPeerTLS())) }
func TestCtlV3PutTimeout(t *testing.T) { testCtl(t, putTest, withDialTimeout(0)) }
func TestCtlV3PutClientTLSFlagByEnv(t *testing.T) {
testCtl(t, putTest, withCfg(*e2e.NewConfigClientTLS()), withFlagByEnv())

View File

@@ -1387,9 +1387,18 @@ func (c *Cluster) ClusterClient() (client *clientv3.Client, err error) {
endpoints = append(endpoints, m.GrpcURL)
}
cfg := clientv3.Config{
Endpoints: endpoints,
DialTimeout: 5 * time.Second,
DialOptions: []grpc.DialOption{grpc.WithBlock()},
Endpoints: endpoints,
DialTimeout: 5 * time.Second,
DialOptions: []grpc.DialOption{grpc.WithBlock()},
MaxCallSendMsgSize: c.Cfg.ClientMaxCallSendMsgSize,
MaxCallRecvMsgSize: c.Cfg.ClientMaxCallRecvMsgSize,
}
if c.Cfg.ClientTLS != nil {
tls, err := c.Cfg.ClientTLS.ClientConfig()
if err != nil {
return nil, err
}
cfg.TLS = tls
}
c.clusterClient, err = newClientV3(cfg)
if err != nil {