mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
server/embed/config_test.go: Add unit test for socket options
This commit is contained in:
parent
73c530de83
commit
7957f4461d
@ -29,10 +29,11 @@ func AssertEqual(t *testing.T, e, a interface{}, msg ...string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
s := ""
|
s := ""
|
||||||
if len(msg) > 1 {
|
if len(msg) > 0 {
|
||||||
s = msg[0] + ": "
|
s = msg[0] + ": "
|
||||||
}
|
}
|
||||||
s = fmt.Sprintf("%sexpected %+v, got %+v", s, e, a)
|
|
||||||
|
s = fmt.Sprintf("%s:expected %+v, got %+v", s, e, a)
|
||||||
FatalStack(t, s)
|
FatalStack(t, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.etcd.io/etcd/client/pkg/v3/srv"
|
"go.etcd.io/etcd/client/pkg/v3/srv"
|
||||||
|
"go.etcd.io/etcd/client/pkg/v3/testutil"
|
||||||
"go.etcd.io/etcd/client/pkg/v3/transport"
|
"go.etcd.io/etcd/client/pkg/v3/transport"
|
||||||
"go.etcd.io/etcd/client/pkg/v3/types"
|
"go.etcd.io/etcd/client/pkg/v3/types"
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ func TestConfigFileOtherFields(t *testing.T) {
|
|||||||
Logger string `json:"logger"`
|
Logger string `json:"logger"`
|
||||||
LogOutputs []string `json:"log-outputs"`
|
LogOutputs []string `json:"log-outputs"`
|
||||||
Debug bool `json:"debug"`
|
Debug bool `json:"debug"`
|
||||||
|
SocketOpts transport.SocketOpts `json:"socket-options"`
|
||||||
}{
|
}{
|
||||||
ctls,
|
ctls,
|
||||||
ptls,
|
ptls,
|
||||||
@ -53,6 +55,9 @@ func TestConfigFileOtherFields(t *testing.T) {
|
|||||||
"zap",
|
"zap",
|
||||||
[]string{"/dev/null"},
|
[]string{"/dev/null"},
|
||||||
false,
|
false,
|
||||||
|
transport.SocketOpts{
|
||||||
|
ReusePort: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := yaml.Marshal(&yc)
|
b, err := yaml.Marshal(&yc)
|
||||||
@ -68,16 +73,18 @@ func TestConfigFileOtherFields(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !cfg.ForceNewCluster {
|
|
||||||
t.Errorf("ForceNewCluster = %v, want %v", cfg.ForceNewCluster, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !ctls.equals(&cfg.ClientTLSInfo) {
|
if !ctls.equals(&cfg.ClientTLSInfo) {
|
||||||
t.Errorf("ClientTLS = %v, want %v", cfg.ClientTLSInfo, ctls)
|
t.Errorf("ClientTLS = %v, want %v", cfg.ClientTLSInfo, ctls)
|
||||||
}
|
}
|
||||||
if !ptls.equals(&cfg.PeerTLSInfo) {
|
if !ptls.equals(&cfg.PeerTLSInfo) {
|
||||||
t.Errorf("PeerTLS = %v, want %v", cfg.PeerTLSInfo, ptls)
|
t.Errorf("PeerTLS = %v, want %v", cfg.PeerTLSInfo, ptls)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testutil.AssertEqual(t, true, cfg.ForceNewCluster, "ForceNewCluster does not match")
|
||||||
|
|
||||||
|
testutil.AssertEqual(t, true, cfg.SocketOpts.ReusePort, "ReusePort does not match")
|
||||||
|
|
||||||
|
testutil.AssertEqual(t, false, cfg.SocketOpts.ReuseAddress, "ReuseAddress does not match")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestUpdateDefaultClusterFromName ensures that etcd can start with 'etcd --name=abc'.
|
// TestUpdateDefaultClusterFromName ensures that etcd can start with 'etcd --name=abc'.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user