Revert "config: rename test struct field to args"

This reverts commit f2a291a4704c9954c441567860ca740ac0f58308.
This commit is contained in:
Frank Schröder 2017-10-23 09:58:19 +02:00
parent 0f0b510f37
commit b580f7a533
2 changed files with 210 additions and 210 deletions

View File

@ -27,7 +27,7 @@ import (
type configTest struct { type configTest struct {
desc string desc string
args []string flags []string
pre, post func() pre, post func()
json, jsontail []string json, jsontail []string
hcl, hcltail []string hcl, hcltail []string
@ -56,7 +56,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
{ {
desc: "-advertise", desc: "-advertise",
args: []string{ flags: []string{
`-advertise=1.2.3.4`, `-advertise=1.2.3.4`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -75,7 +75,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-advertise-wan", desc: "-advertise-wan",
args: []string{ flags: []string{
`-advertise-wan=1.2.3.4`, `-advertise-wan=1.2.3.4`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -91,7 +91,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-advertise and -advertise-wan", desc: "-advertise and -advertise-wan",
args: []string{ flags: []string{
`-advertise=1.2.3.4`, `-advertise=1.2.3.4`,
`-advertise-wan=5.6.7.8`, `-advertise-wan=5.6.7.8`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
@ -111,7 +111,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-bind", desc: "-bind",
args: []string{ flags: []string{
`-bind=1.2.3.4`, `-bind=1.2.3.4`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -134,7 +134,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-bootstrap", desc: "-bootstrap",
args: []string{ flags: []string{
`-bootstrap`, `-bootstrap`,
`-server`, `-server`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
@ -150,7 +150,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-bootstrap-expect", desc: "-bootstrap-expect",
args: []string{ flags: []string{
`-bootstrap-expect=3`, `-bootstrap-expect=3`,
`-server`, `-server`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
@ -166,7 +166,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-client", desc: "-client",
args: []string{ flags: []string{
`-client=1.2.3.4`, `-client=1.2.3.4`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -179,21 +179,21 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-data-dir empty", desc: "-data-dir empty",
args: []string{ flags: []string{
`-data-dir=`, `-data-dir=`,
}, },
err: "data_dir cannot be empty", err: "data_dir cannot be empty",
}, },
{ {
desc: "-data-dir non-directory", desc: "-data-dir non-directory",
args: []string{ flags: []string{
`-data-dir=runtime_test.go`, `-data-dir=runtime_test.go`,
}, },
err: `data_dir "runtime_test.go" is not a directory`, err: `data_dir "runtime_test.go" is not a directory`,
}, },
{ {
desc: "-datacenter", desc: "-datacenter",
args: []string{ flags: []string{
`-datacenter=a`, `-datacenter=a`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -204,7 +204,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-datacenter empty", desc: "-datacenter empty",
args: []string{ flags: []string{
`-datacenter=`, `-datacenter=`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -212,7 +212,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-dev", desc: "-dev",
args: []string{ flags: []string{
`-dev`, `-dev`,
}, },
patch: func(rt *RuntimeConfig) { patch: func(rt *RuntimeConfig) {
@ -252,7 +252,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-disable-host-node-id", desc: "-disable-host-node-id",
args: []string{ flags: []string{
`-disable-host-node-id`, `-disable-host-node-id`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -263,7 +263,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-disable-keyring-file", desc: "-disable-keyring-file",
args: []string{ flags: []string{
`-disable-keyring-file`, `-disable-keyring-file`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -274,7 +274,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-dns-port", desc: "-dns-port",
args: []string{ flags: []string{
`-dns-port=123`, `-dns-port=123`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -286,7 +286,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-domain", desc: "-domain",
args: []string{ flags: []string{
`-domain=a`, `-domain=a`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -297,7 +297,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-enable-script-checks", desc: "-enable-script-checks",
args: []string{ flags: []string{
`-enable-script-checks`, `-enable-script-checks`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -308,7 +308,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-encrypt", desc: "-encrypt",
args: []string{ flags: []string{
`-encrypt=i0P+gFTkLPg0h53eNYjydg==`, `-encrypt=i0P+gFTkLPg0h53eNYjydg==`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -319,7 +319,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-http-port", desc: "-http-port",
args: []string{ flags: []string{
`-http-port=123`, `-http-port=123`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -331,7 +331,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-join", desc: "-join",
args: []string{ flags: []string{
`-join=a`, `-join=a`,
`-join=b`, `-join=b`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
@ -343,7 +343,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-join-wan", desc: "-join-wan",
args: []string{ flags: []string{
`-join-wan=a`, `-join-wan=a`,
`-join-wan=b`, `-join-wan=b`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
@ -355,7 +355,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-log-level", desc: "-log-level",
args: []string{ flags: []string{
`-log-level=a`, `-log-level=a`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -366,7 +366,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-node", desc: "-node",
args: []string{ flags: []string{
`-node=a`, `-node=a`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -377,7 +377,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-node-id", desc: "-node-id",
args: []string{ flags: []string{
`-node-id=a`, `-node-id=a`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -388,7 +388,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-node-meta", desc: "-node-meta",
args: []string{ flags: []string{
`-node-meta=a:b`, `-node-meta=a:b`,
`-node-meta=c:d`, `-node-meta=c:d`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
@ -400,7 +400,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-non-voting-server", desc: "-non-voting-server",
args: []string{ flags: []string{
`-non-voting-server`, `-non-voting-server`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -411,7 +411,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-pid-file", desc: "-pid-file",
args: []string{ flags: []string{
`-pid-file=a`, `-pid-file=a`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -422,7 +422,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-protocol", desc: "-protocol",
args: []string{ flags: []string{
`-protocol=1`, `-protocol=1`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -433,7 +433,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-raft-protocol", desc: "-raft-protocol",
args: []string{ flags: []string{
`-raft-protocol=1`, `-raft-protocol=1`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -444,7 +444,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-recursor", desc: "-recursor",
args: []string{ flags: []string{
`-recursor=1.2.3.4`, `-recursor=1.2.3.4`,
`-recursor=5.6.7.8`, `-recursor=5.6.7.8`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
@ -456,7 +456,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-rejoin", desc: "-rejoin",
args: []string{ flags: []string{
`-rejoin`, `-rejoin`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -467,7 +467,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-retry-interval", desc: "-retry-interval",
args: []string{ flags: []string{
`-retry-interval=5s`, `-retry-interval=5s`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -478,7 +478,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-retry-interval-wan", desc: "-retry-interval-wan",
args: []string{ flags: []string{
`-retry-interval-wan=5s`, `-retry-interval-wan=5s`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -489,7 +489,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-retry-join", desc: "-retry-join",
args: []string{ flags: []string{
`-retry-join=a`, `-retry-join=a`,
`-retry-join=b`, `-retry-join=b`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
@ -501,7 +501,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-retry-join-wan", desc: "-retry-join-wan",
args: []string{ flags: []string{
`-retry-join-wan=a`, `-retry-join-wan=a`,
`-retry-join-wan=b`, `-retry-join-wan=b`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
@ -513,7 +513,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-retry-max", desc: "-retry-max",
args: []string{ flags: []string{
`-retry-max=1`, `-retry-max=1`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -524,7 +524,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-retry-max-wan", desc: "-retry-max-wan",
args: []string{ flags: []string{
`-retry-max-wan=1`, `-retry-max-wan=1`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -535,7 +535,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-serf-lan-bind", desc: "-serf-lan-bind",
args: []string{ flags: []string{
`-serf-lan-bind=1.2.3.4`, `-serf-lan-bind=1.2.3.4`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -546,7 +546,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-serf-wan-bind", desc: "-serf-wan-bind",
args: []string{ flags: []string{
`-serf-wan-bind=1.2.3.4`, `-serf-wan-bind=1.2.3.4`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -557,7 +557,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-server", desc: "-server",
args: []string{ flags: []string{
`-server`, `-server`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -570,7 +570,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-syslog", desc: "-syslog",
args: []string{ flags: []string{
`-syslog`, `-syslog`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -581,7 +581,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-ui", desc: "-ui",
args: []string{ flags: []string{
`-ui`, `-ui`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -592,7 +592,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "-ui-dir", desc: "-ui-dir",
args: []string{ flags: []string{
`-ui-dir=a`, `-ui-dir=a`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -608,7 +608,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
{ {
desc: "bind addr any v4", desc: "bind addr any v4",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "bind_addr":"0.0.0.0" }`}, json: []string{`{ "bind_addr":"0.0.0.0" }`},
hcl: []string{`bind_addr = "0.0.0.0"`}, hcl: []string{`bind_addr = "0.0.0.0"`},
patch: func(rt *RuntimeConfig) { patch: func(rt *RuntimeConfig) {
@ -630,7 +630,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "bind addr any v6", desc: "bind addr any v6",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "bind_addr":"::" }`}, json: []string{`{ "bind_addr":"::" }`},
hcl: []string{`bind_addr = "::"`}, hcl: []string{`bind_addr = "::"`},
patch: func(rt *RuntimeConfig) { patch: func(rt *RuntimeConfig) {
@ -655,7 +655,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "bind addr any and advertise set should not detect", desc: "bind addr any and advertise set should not detect",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "bind_addr":"0.0.0.0", "advertise_addr": "1.2.3.4" }`}, json: []string{`{ "bind_addr":"0.0.0.0", "advertise_addr": "1.2.3.4" }`},
hcl: []string{`bind_addr = "0.0.0.0" advertise_addr = "1.2.3.4"`}, hcl: []string{`bind_addr = "0.0.0.0" advertise_addr = "1.2.3.4"`},
patch: func(rt *RuntimeConfig) { patch: func(rt *RuntimeConfig) {
@ -680,7 +680,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "client addr and ports == 0", desc: "client addr and ports == 0",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ json: []string{`{
"client_addr":"0.0.0.0", "client_addr":"0.0.0.0",
"ports":{} "ports":{}
@ -698,7 +698,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "client addr and ports < 0", desc: "client addr and ports < 0",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ json: []string{`{
"client_addr":"0.0.0.0", "client_addr":"0.0.0.0",
"ports": { "dns":-1, "http":-2, "https":-3 } "ports": { "dns":-1, "http":-2, "https":-3 }
@ -718,7 +718,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "client addr and ports > 0", desc: "client addr and ports > 0",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ json: []string{`{
"client_addr":"0.0.0.0", "client_addr":"0.0.0.0",
"ports":{ "dns": 1, "http": 2, "https": 3 } "ports":{ "dns": 1, "http": 2, "https": 3 }
@ -741,7 +741,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
{ {
desc: "client addr, addresses and ports == 0", desc: "client addr, addresses and ports == 0",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ json: []string{`{
"client_addr":"0.0.0.0", "client_addr":"0.0.0.0",
"addresses": { "dns": "1.1.1.1", "http": "2.2.2.2", "https": "3.3.3.3" }, "addresses": { "dns": "1.1.1.1", "http": "2.2.2.2", "https": "3.3.3.3" },
@ -761,7 +761,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "client addr, addresses and ports < 0", desc: "client addr, addresses and ports < 0",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ json: []string{`{
"client_addr":"0.0.0.0", "client_addr":"0.0.0.0",
"addresses": { "dns": "1.1.1.1", "http": "2.2.2.2", "https": "3.3.3.3" }, "addresses": { "dns": "1.1.1.1", "http": "2.2.2.2", "https": "3.3.3.3" },
@ -783,7 +783,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "client addr, addresses and ports", desc: "client addr, addresses and ports",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ json: []string{`{
"client_addr": "0.0.0.0", "client_addr": "0.0.0.0",
"addresses": { "dns": "1.1.1.1", "http": "2.2.2.2", "https": "3.3.3.3" }, "addresses": { "dns": "1.1.1.1", "http": "2.2.2.2", "https": "3.3.3.3" },
@ -807,7 +807,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "client template and ports", desc: "client template and ports",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ json: []string{`{
"client_addr": "{{ printf \"1.2.3.4 2001:db8::1\" }}", "client_addr": "{{ printf \"1.2.3.4 2001:db8::1\" }}",
"ports":{ "dns":1, "http":2, "https":3 } "ports":{ "dns":1, "http":2, "https":3 }
@ -829,7 +829,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "client, address template and ports", desc: "client, address template and ports",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ json: []string{`{
"client_addr": "{{ printf \"1.2.3.4 2001:db8::1\" }}", "client_addr": "{{ printf \"1.2.3.4 2001:db8::1\" }}",
"addresses": { "addresses": {
@ -861,7 +861,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "advertise address lan template", desc: "advertise address lan template",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "advertise_addr": "{{ printf \"1.2.3.4\" }}" }`}, json: []string{`{ "advertise_addr": "{{ printf \"1.2.3.4\" }}" }`},
hcl: []string{`advertise_addr = "{{ printf \"1.2.3.4\" }}"`}, hcl: []string{`advertise_addr = "{{ printf \"1.2.3.4\" }}"`},
patch: func(rt *RuntimeConfig) { patch: func(rt *RuntimeConfig) {
@ -879,7 +879,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "advertise address wan template", desc: "advertise address wan template",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "advertise_addr_wan": "{{ printf \"1.2.3.4\" }}" }`}, json: []string{`{ "advertise_addr_wan": "{{ printf \"1.2.3.4\" }}" }`},
hcl: []string{`advertise_addr_wan = "{{ printf \"1.2.3.4\" }}"`}, hcl: []string{`advertise_addr_wan = "{{ printf \"1.2.3.4\" }}"`},
patch: func(rt *RuntimeConfig) { patch: func(rt *RuntimeConfig) {
@ -894,7 +894,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "advertise address lan with ports", desc: "advertise address lan with ports",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ json: []string{`{
"ports": { "ports": {
"server": 1000, "server": 1000,
@ -932,7 +932,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "advertise address wan with ports", desc: "advertise address wan with ports",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ json: []string{`{
"ports": { "ports": {
"server": 1000, "server": 1000,
@ -970,7 +970,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "serf bind address lan template", desc: "serf bind address lan template",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "serf_lan": "{{ printf \"1.2.3.4\" }}" }`}, json: []string{`{ "serf_lan": "{{ printf \"1.2.3.4\" }}" }`},
hcl: []string{`serf_lan = "{{ printf \"1.2.3.4\" }}"`}, hcl: []string{`serf_lan = "{{ printf \"1.2.3.4\" }}"`},
patch: func(rt *RuntimeConfig) { patch: func(rt *RuntimeConfig) {
@ -980,7 +980,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "serf bind address wan template", desc: "serf bind address wan template",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "serf_wan": "{{ printf \"1.2.3.4\" }}" }`}, json: []string{`{ "serf_wan": "{{ printf \"1.2.3.4\" }}" }`},
hcl: []string{`serf_wan = "{{ printf \"1.2.3.4\" }}"`}, hcl: []string{`serf_wan = "{{ printf \"1.2.3.4\" }}"`},
patch: func(rt *RuntimeConfig) { patch: func(rt *RuntimeConfig) {
@ -990,7 +990,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "dns recursor templates with deduplication", desc: "dns recursor templates with deduplication",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "recursors": [ "{{ printf \"5.6.7.8:9999\" }}", "{{ printf \"1.2.3.4\" }}", "{{ printf \"5.6.7.8:9999\" }}" ] }`}, json: []string{`{ "recursors": [ "{{ printf \"5.6.7.8:9999\" }}", "{{ printf \"1.2.3.4\" }}", "{{ printf \"5.6.7.8:9999\" }}" ] }`},
hcl: []string{`recursors = [ "{{ printf \"5.6.7.8:9999\" }}", "{{ printf \"1.2.3.4\" }}", "{{ printf \"5.6.7.8:9999\" }}" ] `}, hcl: []string{`recursors = [ "{{ printf \"5.6.7.8:9999\" }}", "{{ printf \"1.2.3.4\" }}", "{{ printf \"5.6.7.8:9999\" }}" ] `},
patch: func(rt *RuntimeConfig) { patch: func(rt *RuntimeConfig) {
@ -1005,7 +1005,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
{ {
desc: "precedence: merge order", desc: "precedence: merge order",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{ json: []string{
`{ `{
"bootstrap": true, "bootstrap": true,
@ -1077,7 +1077,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
start_join = ["a", "b"] start_join = ["a", "b"]
`, `,
}, },
args: []string{ flags: []string{
`-advertise=1.1.1.1`, `-advertise=1.1.1.1`,
`-advertise-wan=2.2.2.2`, `-advertise-wan=2.2.2.2`,
`-bootstrap=false`, `-bootstrap=false`,
@ -1115,7 +1115,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
// //
{ {
desc: "raft performance scaling", desc: "raft performance scaling",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "performance": { "raft_multiplier": 9} }`}, json: []string{`{ "performance": { "raft_multiplier": 9} }`},
hcl: []string{`performance = { raft_multiplier=9 }`}, hcl: []string{`performance = { raft_multiplier=9 }`},
patch: func(rt *RuntimeConfig) { patch: func(rt *RuntimeConfig) {
@ -1132,14 +1132,14 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
{ {
desc: "invalid input", desc: "invalid input",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`this is not JSON`}, json: []string{`this is not JSON`},
hcl: []string{`*** 0123 this is not HCL`}, hcl: []string{`*** 0123 this is not HCL`},
err: "Error parsing", err: "Error parsing",
}, },
{ {
desc: "datacenter is lower-cased", desc: "datacenter is lower-cased",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "datacenter": "A" }`}, json: []string{`{ "datacenter": "A" }`},
hcl: []string{`datacenter = "A"`}, hcl: []string{`datacenter = "A"`},
patch: func(rt *RuntimeConfig) { patch: func(rt *RuntimeConfig) {
@ -1149,7 +1149,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "acl_datacenter is lower-cased", desc: "acl_datacenter is lower-cased",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "acl_datacenter": "A" }`}, json: []string{`{ "acl_datacenter": "A" }`},
hcl: []string{`acl_datacenter = "A"`}, hcl: []string{`acl_datacenter = "A"`},
patch: func(rt *RuntimeConfig) { patch: func(rt *RuntimeConfig) {
@ -1159,7 +1159,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "acl_replication_token enables acl replication", desc: "acl_replication_token enables acl replication",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "acl_replication_token": "a" }`}, json: []string{`{ "acl_replication_token": "a" }`},
hcl: []string{`acl_replication_token = "a"`}, hcl: []string{`acl_replication_token = "a"`},
patch: func(rt *RuntimeConfig) { patch: func(rt *RuntimeConfig) {
@ -1170,7 +1170,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "advertise address detect fails v4", desc: "advertise address detect fails v4",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "bind_addr": "0.0.0.0"}`}, json: []string{`{ "bind_addr": "0.0.0.0"}`},
hcl: []string{`bind_addr = "0.0.0.0"`}, hcl: []string{`bind_addr = "0.0.0.0"`},
privatev4: func() ([]*net.IPAddr, error) { privatev4: func() ([]*net.IPAddr, error) {
@ -1180,7 +1180,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "advertise address detect none v4", desc: "advertise address detect none v4",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "bind_addr": "0.0.0.0"}`}, json: []string{`{ "bind_addr": "0.0.0.0"}`},
hcl: []string{`bind_addr = "0.0.0.0"`}, hcl: []string{`bind_addr = "0.0.0.0"`},
privatev4: func() ([]*net.IPAddr, error) { privatev4: func() ([]*net.IPAddr, error) {
@ -1190,7 +1190,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "advertise address detect multiple v4", desc: "advertise address detect multiple v4",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "bind_addr": "0.0.0.0"}`}, json: []string{`{ "bind_addr": "0.0.0.0"}`},
hcl: []string{`bind_addr = "0.0.0.0"`}, hcl: []string{`bind_addr = "0.0.0.0"`},
privatev4: func() ([]*net.IPAddr, error) { privatev4: func() ([]*net.IPAddr, error) {
@ -1200,7 +1200,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "advertise address detect fails v6", desc: "advertise address detect fails v6",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "bind_addr": "::"}`}, json: []string{`{ "bind_addr": "::"}`},
hcl: []string{`bind_addr = "::"`}, hcl: []string{`bind_addr = "::"`},
publicv6: func() ([]*net.IPAddr, error) { publicv6: func() ([]*net.IPAddr, error) {
@ -1210,7 +1210,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "advertise address detect none v6", desc: "advertise address detect none v6",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "bind_addr": "::"}`}, json: []string{`{ "bind_addr": "::"}`},
hcl: []string{`bind_addr = "::"`}, hcl: []string{`bind_addr = "::"`},
publicv6: func() ([]*net.IPAddr, error) { publicv6: func() ([]*net.IPAddr, error) {
@ -1220,7 +1220,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "advertise address detect multiple v6", desc: "advertise address detect multiple v6",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "bind_addr": "::"}`}, json: []string{`{ "bind_addr": "::"}`},
hcl: []string{`bind_addr = "::"`}, hcl: []string{`bind_addr = "::"`},
publicv6: func() ([]*net.IPAddr, error) { publicv6: func() ([]*net.IPAddr, error) {
@ -1230,21 +1230,21 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "ae_interval invalid == 0", desc: "ae_interval invalid == 0",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
jsontail: []string{`{ "ae_interval": "0s" }`}, jsontail: []string{`{ "ae_interval": "0s" }`},
hcltail: []string{`ae_interval = "0s"`}, hcltail: []string{`ae_interval = "0s"`},
err: `ae_interval cannot be 0s. Must be positive`, err: `ae_interval cannot be 0s. Must be positive`,
}, },
{ {
desc: "ae_interval invalid < 0", desc: "ae_interval invalid < 0",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
jsontail: []string{`{ "ae_interval": "-1s" }`}, jsontail: []string{`{ "ae_interval": "-1s" }`},
hcltail: []string{`ae_interval = "-1s"`}, hcltail: []string{`ae_interval = "-1s"`},
err: `ae_interval cannot be -1s. Must be positive`, err: `ae_interval cannot be -1s. Must be positive`,
}, },
{ {
desc: "acl_datacenter invalid", desc: "acl_datacenter invalid",
args: []string{ flags: []string{
`-datacenter=a`, `-datacenter=a`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -1254,7 +1254,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "autopilot.max_trailing_logs invalid", desc: "autopilot.max_trailing_logs invalid",
args: []string{ flags: []string{
`-datacenter=a`, `-datacenter=a`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -1264,28 +1264,28 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "bind_addr cannot be empty", desc: "bind_addr cannot be empty",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "bind_addr": "" }`}, json: []string{`{ "bind_addr": "" }`},
hcl: []string{`bind_addr = ""`}, hcl: []string{`bind_addr = ""`},
err: "bind_addr cannot be empty", err: "bind_addr cannot be empty",
}, },
{ {
desc: "bind_addr does not allow multiple addresses", desc: "bind_addr does not allow multiple addresses",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "bind_addr": "1.1.1.1 2.2.2.2" }`}, json: []string{`{ "bind_addr": "1.1.1.1 2.2.2.2" }`},
hcl: []string{`bind_addr = "1.1.1.1 2.2.2.2"`}, hcl: []string{`bind_addr = "1.1.1.1 2.2.2.2"`},
err: "bind_addr cannot contain multiple addresses", err: "bind_addr cannot contain multiple addresses",
}, },
{ {
desc: "bind_addr cannot be a unix socket", desc: "bind_addr cannot be a unix socket",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "bind_addr": "unix:///foo" }`}, json: []string{`{ "bind_addr": "unix:///foo" }`},
hcl: []string{`bind_addr = "unix:///foo"`}, hcl: []string{`bind_addr = "unix:///foo"`},
err: "bind_addr cannot be a unix socket", err: "bind_addr cannot be a unix socket",
}, },
{ {
desc: "bootstrap without server", desc: "bootstrap without server",
args: []string{ flags: []string{
`-datacenter=a`, `-datacenter=a`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -1295,7 +1295,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "bootstrap-expect without server", desc: "bootstrap-expect without server",
args: []string{ flags: []string{
`-datacenter=a`, `-datacenter=a`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -1305,7 +1305,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "bootstrap-expect invalid", desc: "bootstrap-expect invalid",
args: []string{ flags: []string{
`-datacenter=a`, `-datacenter=a`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -1315,7 +1315,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "bootstrap-expect and dev mode", desc: "bootstrap-expect and dev mode",
args: []string{ flags: []string{
`-dev`, `-dev`,
`-datacenter=a`, `-datacenter=a`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
@ -1326,7 +1326,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "bootstrap-expect and bootstrap", desc: "bootstrap-expect and bootstrap",
args: []string{ flags: []string{
`-datacenter=a`, `-datacenter=a`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -1336,7 +1336,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "bootstrap-expect=1 equals bootstrap", desc: "bootstrap-expect=1 equals bootstrap",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ "bootstrap_expect": 1, "server": true }`}, json: []string{`{ "bootstrap_expect": 1, "server": true }`},
@ -1353,7 +1353,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "bootstrap-expect=2 warning", desc: "bootstrap-expect=2 warning",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ "bootstrap_expect": 2, "server": true }`}, json: []string{`{ "bootstrap_expect": 2, "server": true }`},
@ -1372,7 +1372,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "bootstrap-expect > 2 but even warning", desc: "bootstrap-expect > 2 but even warning",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ "bootstrap_expect": 4, "server": true }`}, json: []string{`{ "bootstrap_expect": 4, "server": true }`},
@ -1391,7 +1391,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "client mode sets LeaveOnTerm and SkipLeaveOnInt correctly", desc: "client mode sets LeaveOnTerm and SkipLeaveOnInt correctly",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ "server": false }`}, json: []string{`{ "server": false }`},
@ -1405,7 +1405,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "client does not allow socket", desc: "client does not allow socket",
args: []string{ flags: []string{
`-datacenter=a`, `-datacenter=a`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -1415,14 +1415,14 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "datacenter invalid", desc: "datacenter invalid",
args: []string{`-data-dir=` + dataDir}, flags: []string{`-data-dir=` + dataDir},
json: []string{`{ "datacenter": "%" }`}, json: []string{`{ "datacenter": "%" }`},
hcl: []string{`datacenter = "%"`}, hcl: []string{`datacenter = "%"`},
err: `datacenter cannot be "%". Please use only [a-z0-9-_]`, err: `datacenter cannot be "%". Please use only [a-z0-9-_]`,
}, },
{ {
desc: "dns does not allow socket", desc: "dns does not allow socket",
args: []string{ flags: []string{
`-datacenter=a`, `-datacenter=a`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -1432,7 +1432,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "ui and ui_dir", desc: "ui and ui_dir",
args: []string{ flags: []string{
`-datacenter=a`, `-datacenter=a`,
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
@ -1447,7 +1447,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
// to avoid combinatory explosion for tests use 0.0.0.0, :: or [::] but not all of them // to avoid combinatory explosion for tests use 0.0.0.0, :: or [::] but not all of them
{ {
desc: "advertise_addr any", desc: "advertise_addr any",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ "advertise_addr": "0.0.0.0" }`}, json: []string{`{ "advertise_addr": "0.0.0.0" }`},
@ -1456,7 +1456,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "advertise_addr_wan any", desc: "advertise_addr_wan any",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ "advertise_addr_wan": "::" }`}, json: []string{`{ "advertise_addr_wan": "::" }`},
@ -1465,7 +1465,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "recursors any", desc: "recursors any",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ "recursors": ["::"] }`}, json: []string{`{ "recursors": ["::"] }`},
@ -1474,7 +1474,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "dns_config.udp_answer_limit invalid", desc: "dns_config.udp_answer_limit invalid",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ "dns_config": { "udp_answer_limit": -1 } }`}, json: []string{`{ "dns_config": { "udp_answer_limit": -1 } }`},
@ -1483,7 +1483,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "performance.raft_multiplier < 0", desc: "performance.raft_multiplier < 0",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ "performance": { "raft_multiplier": -1 } }`}, json: []string{`{ "performance": { "raft_multiplier": -1 } }`},
@ -1492,7 +1492,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "performance.raft_multiplier == 0", desc: "performance.raft_multiplier == 0",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ "performance": { "raft_multiplier": 0 } }`}, json: []string{`{ "performance": { "raft_multiplier": 0 } }`},
@ -1501,7 +1501,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "performance.raft_multiplier > 10", desc: "performance.raft_multiplier > 10",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ "performance": { "raft_multiplier": 20 } }`}, json: []string{`{ "performance": { "raft_multiplier": 20 } }`},
@ -1510,7 +1510,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "node_name invalid", desc: "node_name invalid",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
`-node=`, `-node=`,
}, },
@ -1519,7 +1519,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "node_meta key too long", desc: "node_meta key too long",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{ json: []string{
@ -1534,7 +1534,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "node_meta value too long", desc: "node_meta value too long",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{ json: []string{
@ -1549,7 +1549,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "node_meta too many keys", desc: "node_meta too many keys",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{ json: []string{
@ -1564,7 +1564,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "unique listeners dns vs http", desc: "unique listeners dns vs http",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ json: []string{`{
@ -1579,7 +1579,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "unique listeners dns vs https", desc: "unique listeners dns vs https",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ json: []string{`{
@ -1594,7 +1594,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "unique listeners http vs https", desc: "unique listeners http vs https",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ json: []string{`{
@ -1609,7 +1609,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "unique advertise addresses HTTP vs RPC", desc: "unique advertise addresses HTTP vs RPC",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ json: []string{`{
@ -1624,7 +1624,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "unique advertise addresses RPC vs Serf LAN", desc: "unique advertise addresses RPC vs Serf LAN",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ json: []string{`{
@ -1637,7 +1637,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "unique advertise addresses RPC vs Serf WAN", desc: "unique advertise addresses RPC vs Serf WAN",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ json: []string{`{
@ -1650,7 +1650,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "telemetry.prefix_filter cannot be empty", desc: "telemetry.prefix_filter cannot be empty",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ json: []string{`{
@ -1666,7 +1666,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "telemetry.prefix_filter must start with + or -", desc: "telemetry.prefix_filter must start with + or -",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ json: []string{`{
@ -1684,7 +1684,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "telemetry.enable_deprecated_names adds allow rule for whitelist", desc: "telemetry.enable_deprecated_names adds allow rule for whitelist",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ json: []string{`{
@ -1702,7 +1702,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "encrypt has invalid key", desc: "encrypt has invalid key",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ "encrypt": "this is not a valid key" }`}, json: []string{`{ "encrypt": "this is not a valid key" }`},
@ -1711,7 +1711,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "encrypt given but LAN keyring exists", desc: "encrypt given but LAN keyring exists",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ "encrypt": "i0P+gFTkLPg0h53eNYjydg==" }`}, json: []string{`{ "encrypt": "i0P+gFTkLPg0h53eNYjydg==" }`},
@ -1730,7 +1730,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "encrypt given but WAN keyring exists", desc: "encrypt given but WAN keyring exists",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ "encrypt": "i0P+gFTkLPg0h53eNYjydg==", "server": true }`}, json: []string{`{ "encrypt": "i0P+gFTkLPg0h53eNYjydg==", "server": true }`},
@ -1752,7 +1752,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "multiple check files", desc: "multiple check files",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{ json: []string{
@ -1773,7 +1773,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "multiple service files", desc: "multiple service files",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{ json: []string{
@ -1794,7 +1794,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
}, },
{ {
desc: "translated keys", desc: "translated keys",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{ json: []string{
@ -1886,7 +1886,7 @@ func testConfig(t *testing.T, tests []configTest, dataDir string) {
t.Run(strings.Join(desc, ":"), func(t *testing.T) { t.Run(strings.Join(desc, ":"), func(t *testing.T) {
// first parse the flags // first parse the flags
flags, err := ParseFlags(tt.args) flags, err := ParseFlags(tt.flags)
if err != nil { if err != nil {
t.Fatalf("ParseFlags failed: %s", err) t.Fatalf("ParseFlags failed: %s", err)
} }

View File

@ -16,7 +16,7 @@ func TestSegments(t *testing.T) {
tests := []configTest{ tests := []configTest{
{ {
desc: "segment name not in OSS", desc: "segment name not in OSS",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ "server": true, "segment": "a" }`}, json: []string{`{ "server": true, "segment": "a" }`},
@ -25,7 +25,7 @@ func TestSegments(t *testing.T) {
}, },
{ {
desc: "segment port must be set", desc: "segment port must be set",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ "segments":[{ "name":"x" }] }`}, json: []string{`{ "segments":[{ "name":"x" }] }`},
@ -34,7 +34,7 @@ func TestSegments(t *testing.T) {
}, },
{ {
desc: "segments not in OSS", desc: "segments not in OSS",
args: []string{ flags: []string{
`-data-dir=` + dataDir, `-data-dir=` + dataDir,
}, },
json: []string{`{ "segments":[{ "name":"x", "port": 123 }] }`}, json: []string{`{ "segments":[{ "name":"x", "port": 123 }] }`},