mirror of https://github.com/status-im/consul.git
add test cases for h2ping_use_tls default behavior
This commit is contained in:
parent
e52f5071d0
commit
3fe637156c
|
@ -2375,6 +2375,42 @@ func TestLoad_IntegrationWithFlags(t *testing.T) {
|
|||
rt.DataDir = dataDir
|
||||
},
|
||||
})
|
||||
run(t, testCase{
|
||||
desc: "h2ping check without h2ping_use_tls set",
|
||||
args: []string{
|
||||
`-data-dir=` + dataDir,
|
||||
},
|
||||
json: []string{
|
||||
`{ "check": { "name": "a", "h2ping": "localhost:55555", "interval": "5s" } }`,
|
||||
},
|
||||
hcl: []string{
|
||||
`check = { name = "a" h2ping = "localhost:55555" interval = "5s" }`,
|
||||
},
|
||||
expected: func(rt *RuntimeConfig) {
|
||||
rt.Checks = []*structs.CheckDefinition{
|
||||
{Name: "a", H2PING: "localhost:55555", H2PingUseTLS: true, OutputMaxSize: checks.DefaultBufSize, Interval: 5 * time.Second},
|
||||
}
|
||||
rt.DataDir = dataDir
|
||||
},
|
||||
})
|
||||
run(t, testCase{
|
||||
desc: "h2ping check with h2ping_use_tls set to false",
|
||||
args: []string{
|
||||
`-data-dir=` + dataDir,
|
||||
},
|
||||
json: []string{
|
||||
`{ "check": { "name": "a", "h2ping": "localhost:55555", "h2ping_use_tls": false, "interval": "5s" } }`,
|
||||
},
|
||||
hcl: []string{
|
||||
`check = { name = "a" h2ping = "localhost:55555" h2ping_use_tls = false interval = "5s" }`,
|
||||
},
|
||||
expected: func(rt *RuntimeConfig) {
|
||||
rt.Checks = []*structs.CheckDefinition{
|
||||
{Name: "a", H2PING: "localhost:55555", H2PingUseTLS: false, OutputMaxSize: checks.DefaultBufSize, Interval: 5 * time.Second},
|
||||
}
|
||||
rt.DataDir = dataDir
|
||||
},
|
||||
})
|
||||
run(t, testCase{
|
||||
desc: "alias check with no node",
|
||||
args: []string{
|
||||
|
|
|
@ -702,7 +702,7 @@ func h2pingUseTLSEqFn(out interface{}, want interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
var h2pingUseTLSFields = []string{`"H2PingUseTLS": %s`, `"h2ping_use_tls": %s`}
|
||||
var h2pingUseTLSFields = []string{`"H2PING": "testing"`, `"H2PingUseTLS": %s`, `"h2ping_use_tls": %s`}
|
||||
var translateH2PingUseTLS = []translateKeyTestCase{
|
||||
{
|
||||
desc: "H2PingUseTLS: both set",
|
||||
|
@ -715,21 +715,21 @@ var translateH2PingUseTLS = []translateKeyTestCase{
|
|||
desc: "H2PingUseTLS:: first set",
|
||||
in: []interface{}{`false`},
|
||||
want: false,
|
||||
jsonFmtStr: "{" + h2pingUseTLSFields[0] + "}",
|
||||
jsonFmtStr: "{" + strings.Join(h2pingUseTLSFields[0:2], ",") + "}",
|
||||
equalityFn: h2pingUseTLSEqFn,
|
||||
},
|
||||
{
|
||||
desc: "H2PingUseTLS: second set",
|
||||
in: []interface{}{`false`},
|
||||
want: false,
|
||||
jsonFmtStr: "{" + h2pingUseTLSFields[1] + "}",
|
||||
jsonFmtStr: "{" + h2pingUseTLSFields[0] + "," + h2pingUseTLSFields[2] + "}",
|
||||
equalityFn: h2pingUseTLSEqFn,
|
||||
},
|
||||
{
|
||||
desc: "H2PingUseTLS: neither set",
|
||||
in: []interface{}{},
|
||||
want: true, // zero value
|
||||
jsonFmtStr: "{" + `"h2ping":"testing"` + "}",
|
||||
jsonFmtStr: "{" + h2pingUseTLSFields[0] + "}",
|
||||
equalityFn: h2pingUseTLSEqFn,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue