mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdmain: test config file clustering flags
A test to ensure that when clustering flags are correctly and independently specified no errors are raised.
This commit is contained in:
parent
d0d4b1378b
commit
0472b2dc9f
@ -78,9 +78,7 @@ func TestConfigFileMemberFields(t *testing.T) {
|
||||
tmpfile := mustCreateCfgFile(t, b)
|
||||
defer os.Remove(tmpfile.Name())
|
||||
|
||||
args := []string{
|
||||
fmt.Sprintf("--config-file=%s", tmpfile.Name()),
|
||||
}
|
||||
args := []string{fmt.Sprintf("--config-file=%s", tmpfile.Name())}
|
||||
|
||||
cfg := newConfig()
|
||||
if err = cfg.parse(args); err != nil {
|
||||
@ -133,9 +131,7 @@ func TestConfigFileClusteringFields(t *testing.T) {
|
||||
tmpfile := mustCreateCfgFile(t, b)
|
||||
defer os.Remove(tmpfile.Name())
|
||||
|
||||
args := []string{
|
||||
fmt.Sprintf("--config-file=%s", tmpfile.Name()),
|
||||
}
|
||||
args := []string{fmt.Sprintf("--config-file=%s", tmpfile.Name())}
|
||||
cfg := newConfig()
|
||||
err = cfg.parse(args)
|
||||
if err != nil {
|
||||
@ -145,6 +141,60 @@ func TestConfigFileClusteringFields(t *testing.T) {
|
||||
validateClusteringFlags(t, cfg)
|
||||
}
|
||||
|
||||
func TestConfigFileClusteringFlags(t *testing.T) {
|
||||
tests := []struct {
|
||||
Name string `json:"name"`
|
||||
InitialCluster string `json:"initial-cluster"`
|
||||
DNSCluster string `json:"discovery-srv"`
|
||||
Durl string `json:"discovery"`
|
||||
}{
|
||||
{
|
||||
// Use default name and generate a default inital-cluster
|
||||
},
|
||||
{
|
||||
Name: "non-default",
|
||||
},
|
||||
{
|
||||
InitialCluster: "0=localhost:8000",
|
||||
},
|
||||
{
|
||||
Name: "non-default",
|
||||
InitialCluster: "0=localhost:8000",
|
||||
},
|
||||
{
|
||||
DNSCluster: "example.com",
|
||||
},
|
||||
{
|
||||
Name: "non-default",
|
||||
DNSCluster: "example.com",
|
||||
},
|
||||
{
|
||||
Durl: "http://example.com/abc",
|
||||
},
|
||||
{
|
||||
Name: "non-default",
|
||||
Durl: "http://example.com/abc",
|
||||
},
|
||||
}
|
||||
|
||||
for i, tt := range tests {
|
||||
b, err := yaml.Marshal(&tt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
tmpfile := mustCreateCfgFile(t, b)
|
||||
defer os.Remove(tmpfile.Name())
|
||||
|
||||
args := []string{fmt.Sprintf("--config-file=%s", tmpfile.Name())}
|
||||
|
||||
cfg := newConfig()
|
||||
if err := cfg.parse(args); err != nil {
|
||||
t.Errorf("%d: err = %v", i, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigParsingOtherFlags(t *testing.T) {
|
||||
args := []string{"-proxy=readonly"}
|
||||
|
||||
@ -172,9 +222,7 @@ func TestConfigFileOtherFields(t *testing.T) {
|
||||
tmpfile := mustCreateCfgFile(t, b)
|
||||
defer os.Remove(tmpfile.Name())
|
||||
|
||||
args := []string{
|
||||
fmt.Sprintf("--config-file=%s", tmpfile.Name()),
|
||||
}
|
||||
args := []string{fmt.Sprintf("--config-file=%s", tmpfile.Name())}
|
||||
|
||||
cfg := newConfig()
|
||||
err = cfg.parse(args)
|
||||
@ -248,9 +296,7 @@ func TestConfigFileConflictClusteringFlags(t *testing.T) {
|
||||
tmpfile := mustCreateCfgFile(t, b)
|
||||
defer os.Remove(tmpfile.Name())
|
||||
|
||||
args := []string{
|
||||
fmt.Sprintf("--config-file=%s", tmpfile.Name()),
|
||||
}
|
||||
args := []string{fmt.Sprintf("--config-file=%s", tmpfile.Name())}
|
||||
|
||||
cfg := newConfig()
|
||||
if err := cfg.parse(args); err != embed.ErrConflictBootstrapFlags {
|
||||
@ -428,9 +474,7 @@ func TestConfigFileElectionTimeout(t *testing.T) {
|
||||
tmpfile := mustCreateCfgFile(t, b)
|
||||
defer os.Remove(tmpfile.Name())
|
||||
|
||||
args := []string{
|
||||
fmt.Sprintf("--config-file=%s", tmpfile.Name()),
|
||||
}
|
||||
args := []string{fmt.Sprintf("--config-file=%s", tmpfile.Name())}
|
||||
|
||||
cfg := newConfig()
|
||||
if err := cfg.parse(args); err == nil || !strings.Contains(err.Error(), tt.errStr) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user