64baf36b60
This will emit warnings about the configs not doing anything but still allow them to be parsed. This also added the warnings for enterprise fields that we already had in OSS but didn’t change their enforcement behavior. For example, attempting to use a network segment will cause a hard error in OSS.
57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
// +build !consulent
|
|
|
|
package config
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/consul/sdk/testutil"
|
|
)
|
|
|
|
func TestSegments(t *testing.T) {
|
|
dataDir := testutil.TempDir(t, "consul")
|
|
defer os.RemoveAll(dataDir)
|
|
|
|
tests := []configTest{
|
|
{
|
|
desc: "segment name not in OSS",
|
|
args: []string{
|
|
`-data-dir=` + dataDir,
|
|
},
|
|
json: []string{`{ "server": true, "segment": "a" }`},
|
|
hcl: []string{` server = true segment = "a" `},
|
|
err: `Network segments are not supported in this version of Consul`,
|
|
warns: []string{
|
|
enterpriseConfigKeyError{key: "segment"}.Error(),
|
|
},
|
|
},
|
|
{
|
|
desc: "segment port must be set",
|
|
args: []string{
|
|
`-data-dir=` + dataDir,
|
|
},
|
|
json: []string{`{ "segments":[{ "name":"x" }] }`},
|
|
hcl: []string{`segments = [{ name = "x" }]`},
|
|
err: `Port for segment "x" cannot be <= 0`,
|
|
warns: []string{
|
|
enterpriseConfigKeyError{key: "segments"}.Error(),
|
|
},
|
|
},
|
|
{
|
|
desc: "segments not in OSS",
|
|
args: []string{
|
|
`-data-dir=` + dataDir,
|
|
},
|
|
json: []string{`{ "segments":[{ "name":"x", "port": 123 }] }`},
|
|
hcl: []string{`segments = [{ name = "x" port = 123 }]`},
|
|
err: `Network segments are not supported in this version of Consul`,
|
|
warns: []string{
|
|
enterpriseConfigKeyError{key: "segments"}.Error(),
|
|
},
|
|
},
|
|
}
|
|
|
|
testConfig(t, tests, dataDir)
|
|
}
|