mirror of
https://github.com/kemko/nomad.git
synced 2026-01-05 18:05:42 +03:00
agent/testdata add a configuration directory for testing
This commit is contained in:
@@ -572,6 +572,38 @@ var sample0 = &Config{
|
||||
|
||||
func TestConfig_ParseSample0(t *testing.T) {
|
||||
c, err := ParseConfigFile("./testdata/sample0.json")
|
||||
require.Nil(t, err)
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, sample0, c)
|
||||
}
|
||||
|
||||
func TestConfig_ParseDir(t *testing.T) {
|
||||
c, err := LoadConfig("./testdata/sample1")
|
||||
require.NoError(t, err)
|
||||
|
||||
// Defaults
|
||||
sample1 := ParseConfigDefault().Merge(sample0)
|
||||
|
||||
// Merge makes empty maps & slices rather than nil, so set those for the expected
|
||||
// value
|
||||
require.Nil(t, sample1.Client.Options)
|
||||
sample1.Client.Options = map[string]string{}
|
||||
require.Nil(t, sample1.Client.Meta)
|
||||
sample1.Client.Meta = map[string]string{}
|
||||
require.Nil(t, sample1.Client.ChrootEnv)
|
||||
sample1.Client.ChrootEnv = map[string]string{}
|
||||
require.Nil(t, sample1.Server.StartJoin)
|
||||
sample1.Server.StartJoin = []string{}
|
||||
|
||||
// This value added to the config file
|
||||
sample1.Consul.EnableSSL = helper.BoolToPtr(true)
|
||||
|
||||
// LoadDir listed the config files
|
||||
require.Nil(t, sample1.Files)
|
||||
sample1.Files = []string{
|
||||
"testdata/sample1/sample0.json",
|
||||
"testdata/sample1/sample1.json",
|
||||
"testdata/sample1/sample2.hcl",
|
||||
}
|
||||
|
||||
require.EqualValues(t, sample1, c)
|
||||
}
|
||||
|
||||
38
command/agent/testdata/sample1/sample0.json
vendored
Normal file
38
command/agent/testdata/sample1/sample0.json
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"acl": {
|
||||
"enabled": true
|
||||
},
|
||||
"bind_addr": "0.0.0.0",
|
||||
"consul": {
|
||||
"ssl": true,
|
||||
"server_auto_join": false,
|
||||
"client_auto_join": false,
|
||||
"token": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
|
||||
},
|
||||
"data_dir": "/opt/data/nomad/data",
|
||||
"datacenter": "dc1",
|
||||
"enable_syslog": true,
|
||||
"leave_on_interrupt": true,
|
||||
"leave_on_terminate": true,
|
||||
"log_level": "INFO",
|
||||
"region": "global",
|
||||
"server": {
|
||||
"bootstrap_expect": 3,
|
||||
"enabled": true,
|
||||
"encrypt": "sHck3WL6cxuhuY7Mso9BHA==",
|
||||
"retry_join": [
|
||||
"10.0.0.101",
|
||||
"10.0.0.102",
|
||||
"10.0.0.103"
|
||||
]
|
||||
},
|
||||
"syslog_facility": "LOCAL0",
|
||||
"tls": {
|
||||
"ca_file": "/opt/data/nomad/certs/nomad-ca.pem",
|
||||
"cert_file": "/opt/data/nomad/certs/server.pem",
|
||||
"http": true,
|
||||
},
|
||||
"vault": {
|
||||
"address": "http://host.example.com:8200",
|
||||
}
|
||||
}
|
||||
38
command/agent/testdata/sample1/sample1.json
vendored
Normal file
38
command/agent/testdata/sample1/sample1.json
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"acl": {
|
||||
"enabled": true
|
||||
},
|
||||
"advertise": {
|
||||
"http": "host.example.com",
|
||||
"rpc": "host.example.com",
|
||||
"serf": "host.example.com"
|
||||
},
|
||||
"bind_addr": "0.0.0.0",
|
||||
"data_dir": "/opt/data/nomad/data",
|
||||
"datacenter": "dc1",
|
||||
"enable_syslog": true,
|
||||
"leave_on_interrupt": true,
|
||||
"leave_on_terminate": true,
|
||||
"log_level": "INFO",
|
||||
"region": "global",
|
||||
"server": {
|
||||
"bootstrap_expect": 3,
|
||||
"enabled": true,
|
||||
},
|
||||
"syslog_facility": "LOCAL0",
|
||||
"telemetry": {
|
||||
"collection_interval": "60s",
|
||||
"disable_hostname": true,
|
||||
"prometheus_metrics": true,
|
||||
"publish_allocation_metrics": true,
|
||||
"publish_node_metrics": true
|
||||
},
|
||||
"tls": {
|
||||
"key_file": "/opt/data/nomad/certs/server-key.pem",
|
||||
"rpc": true,
|
||||
"verify_server_hostname": true
|
||||
},
|
||||
"vault": {
|
||||
"create_from_role": "nomad-cluster",
|
||||
}
|
||||
}
|
||||
19
command/agent/testdata/sample1/sample2.hcl
vendored
Normal file
19
command/agent/testdata/sample1/sample2.hcl
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"advertise" = {
|
||||
"http" = "host.example.com"
|
||||
"rpc" = "host.example.com"
|
||||
"serf" = "host.example.com"
|
||||
}
|
||||
|
||||
"autopilot" = {
|
||||
"cleanup_dead_servers" = true
|
||||
}
|
||||
|
||||
"consul" = {
|
||||
"client_auto_join" = false
|
||||
"server_auto_join" = false
|
||||
"token" = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
|
||||
}
|
||||
|
||||
vault = {
|
||||
enabled = true
|
||||
}
|
||||
Reference in New Issue
Block a user