2017-09-25 18:40:42 +00:00
package config
import (
"bytes"
"crypto/tls"
"encoding/base64"
2017-09-27 18:47:40 +00:00
"encoding/json"
2017-09-25 18:40:42 +00:00
"errors"
"flag"
"fmt"
"io/ioutil"
"net"
"os"
"path/filepath"
"reflect"
"strconv"
"strings"
"testing"
"time"
2019-06-26 15:43:25 +00:00
"github.com/hashicorp/consul/agent/checks"
2017-09-25 18:40:42 +00:00
"github.com/hashicorp/consul/agent/structs"
2018-06-14 12:52:48 +00:00
"github.com/hashicorp/consul/lib"
2019-03-27 12:54:56 +00:00
"github.com/hashicorp/consul/sdk/testutil"
2017-09-25 18:40:42 +00:00
"github.com/hashicorp/consul/types"
"github.com/pascaldekloe/goe/verify"
2018-06-14 12:52:48 +00:00
"github.com/stretchr/testify/require"
2017-09-25 18:40:42 +00:00
)
type configTest struct {
desc string
2017-10-20 09:46:16 +00:00
args [ ] string
2017-09-25 18:40:42 +00:00
pre , post func ( )
json , jsontail [ ] string
hcl , hcltail [ ] string
2018-05-05 18:10:24 +00:00
skipformat bool
2017-09-25 18:40:42 +00:00
privatev4 func ( ) ( [ ] * net . IPAddr , error )
publicv6 func ( ) ( [ ] * net . IPAddr , error )
patch func ( rt * RuntimeConfig )
err string
warns [ ] string
hostname func ( ) ( string , error )
}
// TestConfigFlagsAndEdgecases tests the command line flags and
// edgecases for the config parsing. It provides a test structure which
// checks for warnings on deprecated fields and flags. These tests
// should check one option at a time if possible and should use generic
// values, e.g. 'a' or 1 instead of 'servicex' or 3306.
func TestConfigFlagsAndEdgecases ( t * testing . T ) {
dataDir := testutil . TempDir ( t , "consul" )
defer os . RemoveAll ( dataDir )
tests := [ ] configTest {
// ------------------------------------------------------------
// cmd line flags
//
{
desc : "-advertise" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -advertise=1.2.3.4 ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . AdvertiseAddrLAN = ipAddr ( "1.2.3.4" )
rt . AdvertiseAddrWAN = ipAddr ( "1.2.3.4" )
rt . RPCAdvertiseAddr = tcpAddr ( "1.2.3.4:8300" )
rt . SerfAdvertiseAddrLAN = tcpAddr ( "1.2.3.4:8301" )
rt . SerfAdvertiseAddrWAN = tcpAddr ( "1.2.3.4:8302" )
rt . TaggedAddresses = map [ string ] string {
2020-01-17 14:54:17 +00:00
"lan" : "1.2.3.4" ,
"lan_ipv4" : "1.2.3.4" ,
"wan" : "1.2.3.4" ,
"wan_ipv4" : "1.2.3.4" ,
2017-09-25 18:40:42 +00:00
}
rt . DataDir = dataDir
} ,
} ,
{
desc : "-advertise-wan" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -advertise-wan=1.2.3.4 ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . AdvertiseAddrWAN = ipAddr ( "1.2.3.4" )
rt . SerfAdvertiseAddrWAN = tcpAddr ( "1.2.3.4:8302" )
rt . TaggedAddresses = map [ string ] string {
2020-01-17 14:54:17 +00:00
"lan" : "10.0.0.1" ,
"lan_ipv4" : "10.0.0.1" ,
"wan" : "1.2.3.4" ,
"wan_ipv4" : "1.2.3.4" ,
2017-09-25 18:40:42 +00:00
}
rt . DataDir = dataDir
} ,
} ,
{
desc : "-advertise and -advertise-wan" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -advertise=1.2.3.4 ` ,
` -advertise-wan=5.6.7.8 ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . AdvertiseAddrLAN = ipAddr ( "1.2.3.4" )
rt . AdvertiseAddrWAN = ipAddr ( "5.6.7.8" )
rt . RPCAdvertiseAddr = tcpAddr ( "1.2.3.4:8300" )
rt . SerfAdvertiseAddrLAN = tcpAddr ( "1.2.3.4:8301" )
rt . SerfAdvertiseAddrWAN = tcpAddr ( "5.6.7.8:8302" )
rt . TaggedAddresses = map [ string ] string {
2020-01-17 14:54:17 +00:00
"lan" : "1.2.3.4" ,
"lan_ipv4" : "1.2.3.4" ,
"wan" : "5.6.7.8" ,
"wan_ipv4" : "5.6.7.8" ,
2017-09-25 18:40:42 +00:00
}
rt . DataDir = dataDir
} ,
} ,
{
desc : "-bind" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -bind=1.2.3.4 ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . BindAddr = ipAddr ( "1.2.3.4" )
rt . AdvertiseAddrLAN = ipAddr ( "1.2.3.4" )
rt . AdvertiseAddrWAN = ipAddr ( "1.2.3.4" )
rt . RPCAdvertiseAddr = tcpAddr ( "1.2.3.4:8300" )
rt . RPCBindAddr = tcpAddr ( "1.2.3.4:8300" )
rt . SerfAdvertiseAddrLAN = tcpAddr ( "1.2.3.4:8301" )
rt . SerfAdvertiseAddrWAN = tcpAddr ( "1.2.3.4:8302" )
rt . SerfBindAddrLAN = tcpAddr ( "1.2.3.4:8301" )
rt . SerfBindAddrWAN = tcpAddr ( "1.2.3.4:8302" )
rt . TaggedAddresses = map [ string ] string {
2020-01-17 14:54:17 +00:00
"lan" : "1.2.3.4" ,
"lan_ipv4" : "1.2.3.4" ,
"wan" : "1.2.3.4" ,
"wan_ipv4" : "1.2.3.4" ,
2017-09-25 18:40:42 +00:00
}
rt . DataDir = dataDir
} ,
} ,
{
desc : "-bootstrap" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -bootstrap ` ,
` -server ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . Bootstrap = true
rt . ServerMode = true
rt . LeaveOnTerm = false
rt . SkipLeaveOnInt = true
rt . DataDir = dataDir
} ,
warns : [ ] string { "bootstrap = true: do not enable unless necessary" } ,
} ,
{
desc : "-bootstrap-expect" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -bootstrap-expect=3 ` ,
` -server ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . BootstrapExpect = 3
rt . ServerMode = true
rt . LeaveOnTerm = false
rt . SkipLeaveOnInt = true
rt . DataDir = dataDir
} ,
warns : [ ] string { "bootstrap_expect > 0: expecting 3 servers" } ,
} ,
{
desc : "-client" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -client=1.2.3.4 ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . ClientAddrs = [ ] * net . IPAddr { ipAddr ( "1.2.3.4" ) }
rt . DNSAddrs = [ ] net . Addr { tcpAddr ( "1.2.3.4:8600" ) , udpAddr ( "1.2.3.4:8600" ) }
rt . HTTPAddrs = [ ] net . Addr { tcpAddr ( "1.2.3.4:8500" ) }
rt . DataDir = dataDir
} ,
} ,
2017-10-31 22:30:01 +00:00
{
desc : "-config-dir" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
` -config-dir ` , filepath . Join ( dataDir , "conf.d" ) ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . Datacenter = "a"
2020-01-23 15:59:31 +00:00
rt . ACLDatacenter = "a"
rt . PrimaryDatacenter = "a"
2017-10-31 22:30:01 +00:00
rt . DataDir = dataDir
} ,
pre : func ( ) {
writeFile ( filepath . Join ( dataDir , "conf.d/conf.json" ) , [ ] byte ( ` { "datacenter":"a"} ` ) )
} ,
} ,
{
desc : "-config-file json" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
` -config-file ` , filepath . Join ( dataDir , "conf.json" ) ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . Datacenter = "a"
2020-01-23 15:59:31 +00:00
rt . ACLDatacenter = "a"
rt . PrimaryDatacenter = "a"
2017-10-31 22:30:01 +00:00
rt . DataDir = dataDir
} ,
pre : func ( ) {
writeFile ( filepath . Join ( dataDir , "conf.json" ) , [ ] byte ( ` { "datacenter":"a"} ` ) )
} ,
} ,
{
desc : "-config-file hcl and json" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
` -config-file ` , filepath . Join ( dataDir , "conf.hcl" ) ,
` -config-file ` , filepath . Join ( dataDir , "conf.json" ) ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . Datacenter = "b"
2020-01-23 15:59:31 +00:00
rt . ACLDatacenter = "b"
rt . PrimaryDatacenter = "b"
2017-10-31 22:30:01 +00:00
rt . DataDir = dataDir
} ,
pre : func ( ) {
writeFile ( filepath . Join ( dataDir , "conf.hcl" ) , [ ] byte ( ` datacenter = "a" ` ) )
writeFile ( filepath . Join ( dataDir , "conf.json" ) , [ ] byte ( ` { "datacenter":"b"} ` ) )
} ,
} ,
2017-09-25 18:40:42 +00:00
{
desc : "-data-dir empty" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` ,
} ,
err : "data_dir cannot be empty" ,
} ,
{
desc : "-data-dir non-directory" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir=runtime_test.go ` ,
} ,
err : ` data_dir "runtime_test.go" is not a directory ` ,
} ,
{
desc : "-datacenter" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -datacenter=a ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . Datacenter = "a"
2020-01-23 15:59:31 +00:00
rt . ACLDatacenter = "a"
rt . PrimaryDatacenter = "a"
2017-09-25 18:40:42 +00:00
rt . DataDir = dataDir
} ,
} ,
{
desc : "-datacenter empty" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -datacenter= ` ,
` -data-dir= ` + dataDir ,
} ,
err : "datacenter cannot be empty" ,
} ,
{
desc : "-dev" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -dev ` ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . AdvertiseAddrLAN = ipAddr ( "127.0.0.1" )
rt . AdvertiseAddrWAN = ipAddr ( "127.0.0.1" )
rt . BindAddr = ipAddr ( "127.0.0.1" )
2018-05-04 20:33:05 +00:00
rt . ConnectEnabled = true
2017-09-25 18:40:42 +00:00
rt . DevMode = true
rt . DisableAnonymousSignature = true
rt . DisableKeyringFile = true
rt . EnableDebug = true
rt . EnableUI = true
rt . LeaveOnTerm = false
rt . LogLevel = "DEBUG"
rt . RPCAdvertiseAddr = tcpAddr ( "127.0.0.1:8300" )
rt . RPCBindAddr = tcpAddr ( "127.0.0.1:8300" )
rt . SerfAdvertiseAddrLAN = tcpAddr ( "127.0.0.1:8301" )
rt . SerfAdvertiseAddrWAN = tcpAddr ( "127.0.0.1:8302" )
rt . SerfBindAddrLAN = tcpAddr ( "127.0.0.1:8301" )
rt . SerfBindAddrWAN = tcpAddr ( "127.0.0.1:8302" )
rt . ServerMode = true
rt . SkipLeaveOnInt = true
2020-01-17 14:54:17 +00:00
rt . TaggedAddresses = map [ string ] string {
"lan" : "127.0.0.1" ,
"lan_ipv4" : "127.0.0.1" ,
"wan" : "127.0.0.1" ,
"wan_ipv4" : "127.0.0.1" ,
}
2017-09-25 18:40:42 +00:00
rt . ConsulCoordinateUpdatePeriod = 100 * time . Millisecond
rt . ConsulRaftElectionTimeout = 52 * time . Millisecond
rt . ConsulRaftHeartbeatTimeout = 35 * time . Millisecond
rt . ConsulRaftLeaderLeaseTimeout = 20 * time . Millisecond
2018-07-26 15:39:49 +00:00
rt . GossipLANGossipInterval = 100 * time . Millisecond
rt . GossipLANProbeInterval = 100 * time . Millisecond
rt . GossipLANProbeTimeout = 100 * time . Millisecond
rt . GossipLANSuspicionMult = 3
rt . GossipWANGossipInterval = 100 * time . Millisecond
rt . GossipWANProbeInterval = 100 * time . Millisecond
rt . GossipWANProbeTimeout = 100 * time . Millisecond
rt . GossipWANSuspicionMult = 3
2017-09-25 18:40:42 +00:00
rt . ConsulServerHealthInterval = 10 * time . Millisecond
2018-10-03 13:05:28 +00:00
rt . GRPCPort = 8502
rt . GRPCAddrs = [ ] net . Addr { tcpAddr ( "127.0.0.1:8502" ) }
2017-09-25 18:40:42 +00:00
} ,
} ,
{
desc : "-disable-host-node-id" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -disable-host-node-id ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . DisableHostNodeID = true
rt . DataDir = dataDir
} ,
} ,
{
desc : "-disable-keyring-file" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -disable-keyring-file ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . DisableKeyringFile = true
rt . DataDir = dataDir
} ,
} ,
{
desc : "-dns-port" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -dns-port=123 ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . DNSPort = 123
rt . DNSAddrs = [ ] net . Addr { tcpAddr ( "127.0.0.1:123" ) , udpAddr ( "127.0.0.1:123" ) }
rt . DataDir = dataDir
} ,
} ,
{
desc : "-domain" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -domain=a ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . DNSDomain = "a"
rt . DataDir = dataDir
} ,
} ,
2019-06-27 10:00:37 +00:00
{
desc : "-alt-domain" ,
args : [ ] string {
` -alt-domain=alt ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . DNSAltDomain = "alt"
rt . DataDir = dataDir
} ,
} ,
{
desc : "-alt-domain can't be prefixed by DC" ,
args : [ ] string {
` -datacenter=a ` ,
` -alt-domain=a.alt ` ,
` -data-dir= ` + dataDir ,
} ,
err : "alt_domain cannot start with {service,connect,node,query,addr,a}" ,
} ,
{
desc : "-alt-domain can't be prefixed by service" ,
args : [ ] string {
` -alt-domain=service.alt ` ,
` -data-dir= ` + dataDir ,
} ,
err : "alt_domain cannot start with {service,connect,node,query,addr,dc1}" ,
} ,
{
desc : "-alt-domain can be prefixed by non-keywords" ,
args : [ ] string {
` -alt-domain=mydomain.alt ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . DNSAltDomain = "mydomain.alt"
rt . DataDir = dataDir
} ,
} ,
{
desc : "-alt-domain can't be prefixed by DC" ,
args : [ ] string {
` -alt-domain=dc1.alt ` ,
` -data-dir= ` + dataDir ,
} ,
err : "alt_domain cannot start with {service,connect,node,query,addr,dc1}" ,
} ,
2017-09-25 18:40:42 +00:00
{
desc : "-enable-script-checks" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -enable-script-checks ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
2018-10-11 12:22:11 +00:00
rt . EnableLocalScriptChecks = true
rt . EnableRemoteScriptChecks = true
2017-09-25 18:40:42 +00:00
rt . DataDir = dataDir
} ,
} ,
{
desc : "-encrypt" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2019-07-30 15:45:41 +00:00
` -encrypt=pUqJrVyVRj5jsiYEkM/tFQYfWyJIv4s3XkvDwy7Cu5s= ` ,
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
2019-07-30 15:45:41 +00:00
rt . EncryptKey = "pUqJrVyVRj5jsiYEkM/tFQYfWyJIv4s3XkvDwy7Cu5s="
2017-09-25 18:40:42 +00:00
rt . DataDir = dataDir
} ,
} ,
2017-11-11 02:06:07 +00:00
{
desc : "-config-format disabled, skip unknown files" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
` -config-dir ` , filepath . Join ( dataDir , "conf" ) ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . Datacenter = "a"
2020-01-23 15:59:31 +00:00
rt . ACLDatacenter = "a"
rt . PrimaryDatacenter = "a"
2017-11-11 02:06:07 +00:00
rt . DataDir = dataDir
} ,
pre : func ( ) {
writeFile ( filepath . Join ( dataDir , "conf" , "valid.json" ) , [ ] byte ( ` { "datacenter":"a"} ` ) )
writeFile ( filepath . Join ( dataDir , "conf" , "invalid.skip" ) , [ ] byte ( ` NOPE ` ) )
} ,
} ,
2017-10-31 22:30:01 +00:00
{
desc : "-config-format=json" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
` -config-format=json ` ,
` -config-file ` , filepath . Join ( dataDir , "conf" ) ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . Datacenter = "a"
2020-01-23 15:59:31 +00:00
rt . ACLDatacenter = "a"
rt . PrimaryDatacenter = "a"
2017-10-31 22:30:01 +00:00
rt . DataDir = dataDir
} ,
pre : func ( ) {
writeFile ( filepath . Join ( dataDir , "conf" ) , [ ] byte ( ` { "datacenter":"a"} ` ) )
} ,
} ,
{
desc : "-config-format=hcl" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
` -config-format=hcl ` ,
` -config-file ` , filepath . Join ( dataDir , "conf" ) ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . Datacenter = "a"
2020-01-23 15:59:31 +00:00
rt . ACLDatacenter = "a"
rt . PrimaryDatacenter = "a"
2017-10-31 22:30:01 +00:00
rt . DataDir = dataDir
} ,
pre : func ( ) {
writeFile ( filepath . Join ( dataDir , "conf" ) , [ ] byte ( ` datacenter = "a" ` ) )
} ,
} ,
{
desc : "-config-format invalid" ,
args : [ ] string {
` -config-format=foobar ` ,
} ,
err : "-config-format must be either 'hcl' or 'json'" ,
} ,
2017-09-25 18:40:42 +00:00
{
desc : "-http-port" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -http-port=123 ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . HTTPPort = 123
rt . HTTPAddrs = [ ] net . Addr { tcpAddr ( "127.0.0.1:123" ) }
rt . DataDir = dataDir
} ,
} ,
{
desc : "-join" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -join=a ` ,
` -join=b ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . StartJoinAddrsLAN = [ ] string { "a" , "b" }
rt . DataDir = dataDir
} ,
} ,
{
desc : "-join-wan" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -join-wan=a ` ,
` -join-wan=b ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . StartJoinAddrsWAN = [ ] string { "a" , "b" }
rt . DataDir = dataDir
} ,
} ,
{
desc : "-log-level" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -log-level=a ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . LogLevel = "a"
rt . DataDir = dataDir
} ,
} ,
2020-01-28 23:50:41 +00:00
{
desc : "-log-json" ,
args : [ ] string {
` -log-json ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . LogJSON = true
rt . DataDir = dataDir
} ,
} ,
2019-07-19 21:36:34 +00:00
{
desc : "-log-rotate-max-files" ,
args : [ ] string {
` -log-rotate-max-files=2 ` ,
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "log_rotate_max_files": 2 } ` } ,
hcl : [ ] string { ` log_rotate_max_files = 2 ` } ,
patch : func ( rt * RuntimeConfig ) {
rt . LogRotateMaxFiles = 2
rt . DataDir = dataDir
} ,
} ,
2017-09-25 18:40:42 +00:00
{
desc : "-node" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -node=a ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . NodeName = "a"
rt . DataDir = dataDir
} ,
} ,
{
desc : "-node-id" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -node-id=a ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . NodeID = "a"
rt . DataDir = dataDir
} ,
} ,
{
desc : "-node-meta" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -node-meta=a:b ` ,
` -node-meta=c:d ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . NodeMeta = map [ string ] string { "a" : "b" , "c" : "d" }
rt . DataDir = dataDir
} ,
} ,
{
desc : "-non-voting-server" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -non-voting-server ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . NonVotingServer = true
rt . DataDir = dataDir
} ,
} ,
{
desc : "-pid-file" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -pid-file=a ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . PidFile = "a"
rt . DataDir = dataDir
} ,
} ,
{
desc : "-protocol" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -protocol=1 ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . RPCProtocol = 1
rt . DataDir = dataDir
} ,
} ,
{
desc : "-raft-protocol" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -raft-protocol=1 ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . RaftProtocol = 1
rt . DataDir = dataDir
} ,
} ,
{
desc : "-recursor" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-10-20 13:36:52 +00:00
` -recursor=1.2.3.4 ` ,
` -recursor=5.6.7.8 ` ,
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
2017-10-20 13:36:52 +00:00
rt . DNSRecursors = [ ] string { "1.2.3.4" , "5.6.7.8" }
2017-09-25 18:40:42 +00:00
rt . DataDir = dataDir
} ,
} ,
{
desc : "-rejoin" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -rejoin ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . RejoinAfterLeave = true
rt . DataDir = dataDir
} ,
} ,
{
desc : "-retry-interval" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -retry-interval=5s ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . RetryJoinIntervalLAN = 5 * time . Second
rt . DataDir = dataDir
} ,
} ,
{
desc : "-retry-interval-wan" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -retry-interval-wan=5s ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . RetryJoinIntervalWAN = 5 * time . Second
rt . DataDir = dataDir
} ,
} ,
{
desc : "-retry-join" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -retry-join=a ` ,
` -retry-join=b ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . RetryJoinLAN = [ ] string { "a" , "b" }
rt . DataDir = dataDir
} ,
} ,
{
desc : "-retry-join-wan" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -retry-join-wan=a ` ,
` -retry-join-wan=b ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . RetryJoinWAN = [ ] string { "a" , "b" }
rt . DataDir = dataDir
} ,
} ,
{
desc : "-retry-max" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -retry-max=1 ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . RetryJoinMaxAttemptsLAN = 1
rt . DataDir = dataDir
} ,
} ,
{
desc : "-retry-max-wan" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -retry-max-wan=1 ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . RetryJoinMaxAttemptsWAN = 1
rt . DataDir = dataDir
} ,
} ,
{
desc : "-serf-lan-bind" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -serf-lan-bind=1.2.3.4 ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . SerfBindAddrLAN = tcpAddr ( "1.2.3.4:8301" )
rt . DataDir = dataDir
} ,
} ,
2018-07-06 18:05:06 +00:00
{
desc : "-serf-lan-port" ,
args : [ ] string {
` -serf-lan-port=123 ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . SerfPortLAN = 123
rt . SerfAdvertiseAddrLAN = tcpAddr ( "10.0.0.1:123" )
rt . SerfBindAddrLAN = tcpAddr ( "0.0.0.0:123" )
rt . DataDir = dataDir
} ,
} ,
2017-09-25 18:40:42 +00:00
{
desc : "-serf-wan-bind" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -serf-wan-bind=1.2.3.4 ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . SerfBindAddrWAN = tcpAddr ( "1.2.3.4:8302" )
rt . DataDir = dataDir
} ,
} ,
2018-07-06 18:05:06 +00:00
{
desc : "-serf-wan-port" ,
args : [ ] string {
` -serf-wan-port=123 ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . SerfPortWAN = 123
rt . SerfAdvertiseAddrWAN = tcpAddr ( "10.0.0.1:123" )
rt . SerfBindAddrWAN = tcpAddr ( "0.0.0.0:123" )
rt . DataDir = dataDir
} ,
} ,
2017-09-25 18:40:42 +00:00
{
desc : "-server" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -server ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . ServerMode = true
rt . LeaveOnTerm = false
rt . SkipLeaveOnInt = true
rt . DataDir = dataDir
} ,
} ,
2018-07-06 18:05:06 +00:00
{
desc : "-server-port" ,
args : [ ] string {
` -server-port=123 ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . ServerPort = 123
rt . RPCAdvertiseAddr = tcpAddr ( "10.0.0.1:123" )
rt . RPCBindAddr = tcpAddr ( "0.0.0.0:123" )
rt . DataDir = dataDir
} ,
} ,
2017-09-25 18:40:42 +00:00
{
desc : "-syslog" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -syslog ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . EnableSyslog = true
rt . DataDir = dataDir
} ,
} ,
{
desc : "-ui" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -ui ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . EnableUI = true
rt . DataDir = dataDir
} ,
} ,
{
desc : "-ui-dir" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -ui-dir=a ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . UIDir = "a"
rt . DataDir = dataDir
} ,
} ,
ui: modify content path (#5950)
* Add ui-content-path flag
* tests complete, regex validator on string, index.html updated
* cleaning up debugging stuff
* ui: Enable ember environment configuration to be set via the go binary at runtime (#5934)
* ui: Only inject {{.ContentPath}} if we are makeing a prod build...
...otherwise we just use the current rootURL
This gets injected into a <base /> node which solves the assets path
problem but not the ember problem
* ui: Pull out the <base href=""> value and inject it into ember env
See previous commit:
The <base href=""> value is 'sometimes' injected from go at index
serve time. We pass this value down to ember by overwriting the ember
config that is injected via a <meta> tag. This has to be done before
ember bootup.
Sometimes (during testing and development, basically not production)
this is injected with the already existing value, in which case this
essentially changes nothing.
The code here is slightly abstracted away from our specific usage to
make it easier for anyone else to use, and also make sure we can cope
with using this same method to pass variables down from the CLI through
to ember in the future.
* ui: We can't use <base /> move everything to javascript (#5941)
Unfortuantely we can't seem to be able to use <base> and rootURL
together as URL paths will get doubled up (`ui/ui/`).
This moves all the things that we need to interpolate with .ContentPath
to the `startup` javascript so we can conditionally print out
`{{.ContentPath}}` in lots of places (now we can't use base)
* fixed when we serve index.html
* ui: For writing a ContentPath, we also need to cope with testing... (#5945)
...and potentially more environments
Testing has more additional things in a separate index.html in `tests/`
This make the entire thing a little saner and uses just javascriopt
template literals instead of a pseudo handbrake synatx for our
templating of these files.
Intead of just templating the entire file this way, we still only
template `{{content-for 'head'}}` and `{{content-for 'body'}}`
in this way to ensure we support other plugins/addons
* build: Loosen up the regex for retrieving the CONSUL_VERSION (#5946)
* build: Loosen up the regex for retrieving the CONSUL_VERSION
1. Previously the `sed` replacement was searching for the CONSUL_VERSION
comment at the start of a line, it no longer does this to allow for
indentation.
2. Both `grep` and `sed` where looking for the omment at the end of the
line. We've removed this restriction here. We don't need to remove it
right now, but if we ever put the comment followed by something here the
searching would break.
3. Added `xargs` for trimming the resulting version string. We aren't
using this already in the rest of the scripts, but we are pretty sure
this is available on most systems.
* ui: Fix erroneous variable, and also force an ember cache clean on build
1. We referenced a variable incorrectly here, this fixes that.
2. We also made sure that every `make` target clears ember's `tmp` cache
to ensure that its not using any caches that have since been edited
everytime we call a `make` target.
* added docs, fixed encoding
* fixed go fmt
* Update agent/config/config.go
Co-Authored-By: R.B. Boyer <public@richardboyer.net>
* Completed Suggestions
* run gofmt on http.go
* fix testsanitize
* fix fullconfig/hcl by setting correct 'want'
* ran gofmt on agent/config/runtime_test.go
* Update website/source/docs/agent/options.html.md
Co-Authored-By: Hans Hasselberg <me@hans.io>
* Update website/source/docs/agent/options.html.md
Co-Authored-By: kaitlincarter-hc <43049322+kaitlincarter-hc@users.noreply.github.com>
* remove contentpath from redirectFS struct
2019-06-26 16:43:30 +00:00
{
desc : "-ui-content-path" ,
args : [ ] string {
` -ui-content-path=/a/b ` ,
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . UIContentPath = "/a/b/"
rt . DataDir = dataDir
} ,
} ,
2017-09-25 18:40:42 +00:00
// ------------------------------------------------------------
// ports and addresses
//
{
2017-10-20 09:46:16 +00:00
desc : "bind addr any v4" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "bind_addr":"0.0.0.0" } ` } ,
hcl : [ ] string { ` bind_addr = "0.0.0.0" ` } ,
2017-09-25 18:40:42 +00:00
patch : func ( rt * RuntimeConfig ) {
rt . AdvertiseAddrLAN = ipAddr ( "10.0.0.1" )
rt . AdvertiseAddrWAN = ipAddr ( "10.0.0.1" )
rt . BindAddr = ipAddr ( "0.0.0.0" )
rt . RPCAdvertiseAddr = tcpAddr ( "10.0.0.1:8300" )
rt . RPCBindAddr = tcpAddr ( "0.0.0.0:8300" )
rt . SerfAdvertiseAddrLAN = tcpAddr ( "10.0.0.1:8301" )
rt . SerfAdvertiseAddrWAN = tcpAddr ( "10.0.0.1:8302" )
rt . SerfBindAddrLAN = tcpAddr ( "0.0.0.0:8301" )
rt . SerfBindAddrWAN = tcpAddr ( "0.0.0.0:8302" )
rt . TaggedAddresses = map [ string ] string {
2020-01-17 14:54:17 +00:00
"lan" : "10.0.0.1" ,
"lan_ipv4" : "10.0.0.1" ,
"wan" : "10.0.0.1" ,
"wan_ipv4" : "10.0.0.1" ,
2017-09-25 18:40:42 +00:00
}
rt . DataDir = dataDir
} ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "bind addr any v6" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "bind_addr":"::" } ` } ,
hcl : [ ] string { ` bind_addr = "::" ` } ,
2017-09-25 18:40:42 +00:00
patch : func ( rt * RuntimeConfig ) {
rt . AdvertiseAddrLAN = ipAddr ( "dead:beef::1" )
rt . AdvertiseAddrWAN = ipAddr ( "dead:beef::1" )
rt . BindAddr = ipAddr ( "::" )
rt . RPCAdvertiseAddr = tcpAddr ( "[dead:beef::1]:8300" )
rt . RPCBindAddr = tcpAddr ( "[::]:8300" )
rt . SerfAdvertiseAddrLAN = tcpAddr ( "[dead:beef::1]:8301" )
rt . SerfAdvertiseAddrWAN = tcpAddr ( "[dead:beef::1]:8302" )
rt . SerfBindAddrLAN = tcpAddr ( "[::]:8301" )
rt . SerfBindAddrWAN = tcpAddr ( "[::]:8302" )
rt . TaggedAddresses = map [ string ] string {
2020-01-17 14:54:17 +00:00
"lan" : "dead:beef::1" ,
"lan_ipv6" : "dead:beef::1" ,
"wan" : "dead:beef::1" ,
"wan_ipv6" : "dead:beef::1" ,
2017-09-25 18:40:42 +00:00
}
rt . DataDir = dataDir
} ,
publicv6 : func ( ) ( [ ] * net . IPAddr , error ) {
return [ ] * net . IPAddr { ipAddr ( "dead:beef::1" ) } , nil
} ,
} ,
2017-09-27 19:59:47 +00:00
{
2017-10-20 09:46:16 +00:00
desc : "bind addr any and advertise set should not detect" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
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" ` } ,
2017-09-27 19:59:47 +00:00
patch : func ( rt * RuntimeConfig ) {
rt . AdvertiseAddrLAN = ipAddr ( "1.2.3.4" )
rt . AdvertiseAddrWAN = ipAddr ( "1.2.3.4" )
rt . BindAddr = ipAddr ( "0.0.0.0" )
rt . RPCAdvertiseAddr = tcpAddr ( "1.2.3.4:8300" )
rt . RPCBindAddr = tcpAddr ( "0.0.0.0:8300" )
rt . SerfAdvertiseAddrLAN = tcpAddr ( "1.2.3.4:8301" )
rt . SerfAdvertiseAddrWAN = tcpAddr ( "1.2.3.4:8302" )
rt . SerfBindAddrLAN = tcpAddr ( "0.0.0.0:8301" )
rt . SerfBindAddrWAN = tcpAddr ( "0.0.0.0:8302" )
rt . TaggedAddresses = map [ string ] string {
2020-01-17 14:54:17 +00:00
"lan" : "1.2.3.4" ,
"lan_ipv4" : "1.2.3.4" ,
"wan" : "1.2.3.4" ,
"wan_ipv4" : "1.2.3.4" ,
2017-09-27 19:59:47 +00:00
}
rt . DataDir = dataDir
} ,
privatev4 : func ( ) ( [ ] * net . IPAddr , error ) {
return nil , fmt . Errorf ( "should not detect advertise_addr" )
} ,
} ,
2017-09-25 18:40:42 +00:00
{
2017-10-20 09:46:16 +00:00
desc : "client addr and ports == 0" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
2017-09-25 18:40:42 +00:00
json : [ ] string { ` {
"client_addr" : "0.0.0.0" ,
"ports" : { }
} ` } ,
hcl : [ ] string { `
client_addr = "0.0.0.0"
ports { }
` } ,
patch : func ( rt * RuntimeConfig ) {
rt . ClientAddrs = [ ] * net . IPAddr { ipAddr ( "0.0.0.0" ) }
rt . DNSAddrs = [ ] net . Addr { tcpAddr ( "0.0.0.0:8600" ) , udpAddr ( "0.0.0.0:8600" ) }
rt . HTTPAddrs = [ ] net . Addr { tcpAddr ( "0.0.0.0:8500" ) }
rt . DataDir = dataDir
} ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "client addr and ports < 0" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
2017-09-25 18:40:42 +00:00
json : [ ] string { ` {
"client_addr" : "0.0.0.0" ,
2018-10-03 13:05:28 +00:00
"ports" : { "dns" : - 1 , "http" : - 2 , "https" : - 3 , "grpc" : - 4 }
2017-09-25 18:40:42 +00:00
} ` } ,
hcl : [ ] string { `
client_addr = "0.0.0.0"
2018-10-03 13:05:28 +00:00
ports { dns = - 1 http = - 2 https = - 3 grpc = - 4 }
2017-09-25 18:40:42 +00:00
` } ,
patch : func ( rt * RuntimeConfig ) {
rt . ClientAddrs = [ ] * net . IPAddr { ipAddr ( "0.0.0.0" ) }
rt . DNSPort = - 1
rt . DNSAddrs = nil
rt . HTTPPort = - 1
rt . HTTPAddrs = nil
2018-10-03 13:05:28 +00:00
// HTTPS and gRPC default to disabled so shouldn't be different from
// default rt.
2017-09-25 18:40:42 +00:00
rt . DataDir = dataDir
} ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "client addr and ports > 0" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
2017-09-25 18:40:42 +00:00
json : [ ] string { ` {
"client_addr" : "0.0.0.0" ,
2018-10-03 13:05:28 +00:00
"ports" : { "dns" : 1 , "http" : 2 , "https" : 3 , "grpc" : 4 }
2017-09-25 18:40:42 +00:00
} ` } ,
hcl : [ ] string { `
client_addr = "0.0.0.0"
2018-10-03 13:05:28 +00:00
ports { dns = 1 http = 2 https = 3 grpc = 4 }
2017-09-25 18:40:42 +00:00
` } ,
patch : func ( rt * RuntimeConfig ) {
rt . ClientAddrs = [ ] * net . IPAddr { ipAddr ( "0.0.0.0" ) }
rt . DNSPort = 1
rt . DNSAddrs = [ ] net . Addr { tcpAddr ( "0.0.0.0:1" ) , udpAddr ( "0.0.0.0:1" ) }
rt . HTTPPort = 2
rt . HTTPAddrs = [ ] net . Addr { tcpAddr ( "0.0.0.0:2" ) }
rt . HTTPSPort = 3
rt . HTTPSAddrs = [ ] net . Addr { tcpAddr ( "0.0.0.0:3" ) }
2018-10-03 13:05:28 +00:00
rt . GRPCPort = 4
rt . GRPCAddrs = [ ] net . Addr { tcpAddr ( "0.0.0.0:4" ) }
2017-09-25 18:40:42 +00:00
rt . DataDir = dataDir
} ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "client addr, addresses and ports == 0" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
2017-09-25 18:40:42 +00:00
json : [ ] string { ` {
"client_addr" : "0.0.0.0" ,
2018-10-03 13:05:28 +00:00
"addresses" : { "dns" : "1.1.1.1" , "http" : "2.2.2.2" , "https" : "3.3.3.3" , "grpc" : "4.4.4.4" } ,
2017-09-25 18:40:42 +00:00
"ports" : { }
} ` } ,
hcl : [ ] string { `
client_addr = "0.0.0.0"
2018-10-03 13:05:28 +00:00
addresses = { dns = "1.1.1.1" http = "2.2.2.2" https = "3.3.3.3" grpc = "4.4.4.4" }
2017-09-25 18:40:42 +00:00
ports { }
` } ,
patch : func ( rt * RuntimeConfig ) {
rt . ClientAddrs = [ ] * net . IPAddr { ipAddr ( "0.0.0.0" ) }
rt . DNSAddrs = [ ] net . Addr { tcpAddr ( "1.1.1.1:8600" ) , udpAddr ( "1.1.1.1:8600" ) }
rt . HTTPAddrs = [ ] net . Addr { tcpAddr ( "2.2.2.2:8500" ) }
2018-10-03 13:05:28 +00:00
// HTTPS and gRPC default to disabled so shouldn't be different from
// default rt.
2017-09-25 18:40:42 +00:00
rt . DataDir = dataDir
} ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "client addr, addresses and ports < 0" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
2017-09-25 18:40:42 +00:00
json : [ ] string { ` {
"client_addr" : "0.0.0.0" ,
2018-10-03 13:05:28 +00:00
"addresses" : { "dns" : "1.1.1.1" , "http" : "2.2.2.2" , "https" : "3.3.3.3" , "grpc" : "4.4.4.4" } ,
"ports" : { "dns" : - 1 , "http" : - 2 , "https" : - 3 , "grpc" : - 4 }
2017-09-25 18:40:42 +00:00
} ` } ,
hcl : [ ] string { `
client_addr = "0.0.0.0"
2018-10-03 13:05:28 +00:00
addresses = { dns = "1.1.1.1" http = "2.2.2.2" https = "3.3.3.3" grpc = "4.4.4.4" }
ports { dns = - 1 http = - 2 https = - 3 grpc = - 4 }
2017-09-25 18:40:42 +00:00
` } ,
patch : func ( rt * RuntimeConfig ) {
rt . ClientAddrs = [ ] * net . IPAddr { ipAddr ( "0.0.0.0" ) }
rt . DNSPort = - 1
rt . DNSAddrs = nil
rt . HTTPPort = - 1
rt . HTTPAddrs = nil
2018-10-03 13:05:28 +00:00
// HTTPS and gRPC default to disabled so shouldn't be different from
// default rt.
2017-09-25 18:40:42 +00:00
rt . DataDir = dataDir
} ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "client addr, addresses and ports" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
2017-09-25 18:40:42 +00:00
json : [ ] string { ` {
"client_addr" : "0.0.0.0" ,
2018-10-03 13:05:28 +00:00
"addresses" : { "dns" : "1.1.1.1" , "http" : "2.2.2.2" , "https" : "3.3.3.3" , "grpc" : "4.4.4.4" } ,
"ports" : { "dns" : 1 , "http" : 2 , "https" : 3 , "grpc" : 4 }
2017-09-25 18:40:42 +00:00
} ` } ,
hcl : [ ] string { `
client_addr = "0.0.0.0"
2018-10-03 13:05:28 +00:00
addresses = { dns = "1.1.1.1" http = "2.2.2.2" https = "3.3.3.3" grpc = "4.4.4.4" }
ports { dns = 1 http = 2 https = 3 grpc = 4 }
2017-09-25 18:40:42 +00:00
` } ,
patch : func ( rt * RuntimeConfig ) {
rt . ClientAddrs = [ ] * net . IPAddr { ipAddr ( "0.0.0.0" ) }
rt . DNSPort = 1
rt . DNSAddrs = [ ] net . Addr { tcpAddr ( "1.1.1.1:1" ) , udpAddr ( "1.1.1.1:1" ) }
rt . HTTPPort = 2
rt . HTTPAddrs = [ ] net . Addr { tcpAddr ( "2.2.2.2:2" ) }
rt . HTTPSPort = 3
rt . HTTPSAddrs = [ ] net . Addr { tcpAddr ( "3.3.3.3:3" ) }
2018-10-03 13:05:28 +00:00
rt . GRPCPort = 4
rt . GRPCAddrs = [ ] net . Addr { tcpAddr ( "4.4.4.4:4" ) }
2017-09-25 18:40:42 +00:00
rt . DataDir = dataDir
} ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "client template and ports" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
2017-09-25 18:40:42 +00:00
json : [ ] string { ` {
"client_addr" : "{{ printf \"1.2.3.4 2001:db8::1\" }}" ,
2018-10-03 13:05:28 +00:00
"ports" : { "dns" : 1 , "http" : 2 , "https" : 3 , "grpc" : 4 }
2017-09-25 18:40:42 +00:00
} ` } ,
hcl : [ ] string { `
client_addr = "{{ printf \"1.2.3.4 2001:db8::1\" }}"
2018-10-03 13:05:28 +00:00
ports { dns = 1 http = 2 https = 3 grpc = 4 }
2017-09-25 18:40:42 +00:00
` } ,
patch : func ( rt * RuntimeConfig ) {
rt . ClientAddrs = [ ] * net . IPAddr { ipAddr ( "1.2.3.4" ) , ipAddr ( "2001:db8::1" ) }
rt . DNSPort = 1
rt . DNSAddrs = [ ] net . Addr { tcpAddr ( "1.2.3.4:1" ) , tcpAddr ( "[2001:db8::1]:1" ) , udpAddr ( "1.2.3.4:1" ) , udpAddr ( "[2001:db8::1]:1" ) }
rt . HTTPPort = 2
rt . HTTPAddrs = [ ] net . Addr { tcpAddr ( "1.2.3.4:2" ) , tcpAddr ( "[2001:db8::1]:2" ) }
rt . HTTPSPort = 3
rt . HTTPSAddrs = [ ] net . Addr { tcpAddr ( "1.2.3.4:3" ) , tcpAddr ( "[2001:db8::1]:3" ) }
2018-10-03 13:05:28 +00:00
rt . GRPCPort = 4
rt . GRPCAddrs = [ ] net . Addr { tcpAddr ( "1.2.3.4:4" ) , tcpAddr ( "[2001:db8::1]:4" ) }
2017-09-25 18:40:42 +00:00
rt . DataDir = dataDir
} ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "client, address template and ports" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
2017-09-25 18:40:42 +00:00
json : [ ] string { ` {
"client_addr" : "{{ printf \"1.2.3.4 2001:db8::1\" }}" ,
"addresses" : {
"dns" : "{{ printf \"1.1.1.1 2001:db8::10 \" }}" ,
"http" : "{{ printf \"2.2.2.2 unix://http 2001:db8::20 \" }}" ,
2018-10-03 13:05:28 +00:00
"https" : "{{ printf \"3.3.3.3 unix://https 2001:db8::30 \" }}" ,
"grpc" : "{{ printf \"4.4.4.4 unix://grpc 2001:db8::40 \" }}"
2017-09-25 18:40:42 +00:00
} ,
2018-10-03 13:05:28 +00:00
"ports" : { "dns" : 1 , "http" : 2 , "https" : 3 , "grpc" : 4 }
2017-09-25 18:40:42 +00:00
} ` } ,
hcl : [ ] string { `
client_addr = "{{ printf \"1.2.3.4 2001:db8::1\" }}"
addresses = {
dns = "{{ printf \"1.1.1.1 2001:db8::10 \" }}"
http = "{{ printf \"2.2.2.2 unix://http 2001:db8::20 \" }}"
https = "{{ printf \"3.3.3.3 unix://https 2001:db8::30 \" }}"
2018-10-03 13:05:28 +00:00
grpc = "{{ printf \"4.4.4.4 unix://grpc 2001:db8::40 \" }}"
2017-09-25 18:40:42 +00:00
}
2018-10-03 13:05:28 +00:00
ports { dns = 1 http = 2 https = 3 grpc = 4 }
2017-09-25 18:40:42 +00:00
` } ,
patch : func ( rt * RuntimeConfig ) {
rt . ClientAddrs = [ ] * net . IPAddr { ipAddr ( "1.2.3.4" ) , ipAddr ( "2001:db8::1" ) }
rt . DNSPort = 1
rt . DNSAddrs = [ ] net . Addr { tcpAddr ( "1.1.1.1:1" ) , tcpAddr ( "[2001:db8::10]:1" ) , udpAddr ( "1.1.1.1:1" ) , udpAddr ( "[2001:db8::10]:1" ) }
rt . HTTPPort = 2
rt . HTTPAddrs = [ ] net . Addr { tcpAddr ( "2.2.2.2:2" ) , unixAddr ( "unix://http" ) , tcpAddr ( "[2001:db8::20]:2" ) }
rt . HTTPSPort = 3
rt . HTTPSAddrs = [ ] net . Addr { tcpAddr ( "3.3.3.3:3" ) , unixAddr ( "unix://https" ) , tcpAddr ( "[2001:db8::30]:3" ) }
2018-10-03 13:05:28 +00:00
rt . GRPCPort = 4
rt . GRPCAddrs = [ ] net . Addr { tcpAddr ( "4.4.4.4:4" ) , unixAddr ( "unix://grpc" ) , tcpAddr ( "[2001:db8::40]:4" ) }
2017-09-25 18:40:42 +00:00
rt . DataDir = dataDir
} ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "advertise address lan template" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "advertise_addr": " {{ printf \ "1.2.3.4\" }}" } ` } ,
hcl : [ ] string { ` advertise_addr = " {{ printf \ "1.2.3.4\" }}" ` } ,
2017-09-25 18:40:42 +00:00
patch : func ( rt * RuntimeConfig ) {
rt . AdvertiseAddrLAN = ipAddr ( "1.2.3.4" )
rt . AdvertiseAddrWAN = ipAddr ( "1.2.3.4" )
rt . RPCAdvertiseAddr = tcpAddr ( "1.2.3.4:8300" )
rt . SerfAdvertiseAddrLAN = tcpAddr ( "1.2.3.4:8301" )
rt . SerfAdvertiseAddrWAN = tcpAddr ( "1.2.3.4:8302" )
rt . TaggedAddresses = map [ string ] string {
2020-01-17 14:54:17 +00:00
"lan" : "1.2.3.4" ,
"lan_ipv4" : "1.2.3.4" ,
"wan" : "1.2.3.4" ,
"wan_ipv4" : "1.2.3.4" ,
2017-09-25 18:40:42 +00:00
}
rt . DataDir = dataDir
} ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "advertise address wan template" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "advertise_addr_wan": " {{ printf \ "1.2.3.4\" }}" } ` } ,
hcl : [ ] string { ` advertise_addr_wan = " {{ printf \ "1.2.3.4\" }}" ` } ,
2017-09-25 18:40:42 +00:00
patch : func ( rt * RuntimeConfig ) {
rt . AdvertiseAddrWAN = ipAddr ( "1.2.3.4" )
rt . SerfAdvertiseAddrWAN = tcpAddr ( "1.2.3.4:8302" )
rt . TaggedAddresses = map [ string ] string {
2020-01-17 14:54:17 +00:00
"lan" : "10.0.0.1" ,
"lan_ipv4" : "10.0.0.1" ,
"wan" : "1.2.3.4" ,
"wan_ipv4" : "1.2.3.4" ,
2017-09-25 18:40:42 +00:00
}
rt . DataDir = dataDir
} ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "advertise address lan with ports" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
2017-09-29 09:35:51 +00:00
json : [ ] string { ` {
"ports" : {
"server" : 1000 ,
"serf_lan" : 2000 ,
"serf_wan" : 3000
} ,
"advertise_addr" : "1.2.3.4"
} ` } ,
hcl : [ ] string { `
ports {
server = 1000
serf_lan = 2000
serf_wan = 3000
}
advertise_addr = "1.2.3.4"
` } ,
2017-09-25 18:40:42 +00:00
patch : func ( rt * RuntimeConfig ) {
2017-09-29 09:35:51 +00:00
rt . AdvertiseAddrLAN = ipAddr ( "1.2.3.4" )
rt . AdvertiseAddrWAN = ipAddr ( "1.2.3.4" )
rt . RPCAdvertiseAddr = tcpAddr ( "1.2.3.4:1000" )
rt . RPCBindAddr = tcpAddr ( "0.0.0.0:1000" )
rt . SerfAdvertiseAddrLAN = tcpAddr ( "1.2.3.4:2000" )
rt . SerfAdvertiseAddrWAN = tcpAddr ( "1.2.3.4:3000" )
rt . SerfBindAddrLAN = tcpAddr ( "0.0.0.0:2000" )
rt . SerfBindAddrWAN = tcpAddr ( "0.0.0.0:3000" )
rt . SerfPortLAN = 2000
rt . SerfPortWAN = 3000
rt . ServerPort = 1000
rt . TaggedAddresses = map [ string ] string {
2020-01-17 14:54:17 +00:00
"lan" : "1.2.3.4" ,
"lan_ipv4" : "1.2.3.4" ,
"wan" : "1.2.3.4" ,
"wan_ipv4" : "1.2.3.4" ,
2017-09-29 09:35:51 +00:00
}
2017-09-25 18:40:42 +00:00
rt . DataDir = dataDir
} ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "advertise address wan with ports" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
2017-09-29 09:35:51 +00:00
json : [ ] string { ` {
"ports" : {
"server" : 1000 ,
"serf_lan" : 2000 ,
"serf_wan" : 3000
} ,
"advertise_addr_wan" : "1.2.3.4"
} ` } ,
hcl : [ ] string { `
ports {
server = 1000
serf_lan = 2000
serf_wan = 3000
}
advertise_addr_wan = "1.2.3.4"
` } ,
2017-09-25 18:40:42 +00:00
patch : func ( rt * RuntimeConfig ) {
2017-09-29 09:35:51 +00:00
rt . AdvertiseAddrLAN = ipAddr ( "10.0.0.1" )
rt . AdvertiseAddrWAN = ipAddr ( "1.2.3.4" )
rt . RPCAdvertiseAddr = tcpAddr ( "10.0.0.1:1000" )
rt . RPCBindAddr = tcpAddr ( "0.0.0.0:1000" )
rt . SerfAdvertiseAddrLAN = tcpAddr ( "10.0.0.1:2000" )
rt . SerfAdvertiseAddrWAN = tcpAddr ( "1.2.3.4:3000" )
rt . SerfBindAddrLAN = tcpAddr ( "0.0.0.0:2000" )
rt . SerfBindAddrWAN = tcpAddr ( "0.0.0.0:3000" )
rt . SerfPortLAN = 2000
rt . SerfPortWAN = 3000
rt . ServerPort = 1000
rt . TaggedAddresses = map [ string ] string {
2020-01-17 14:54:17 +00:00
"lan" : "10.0.0.1" ,
"lan_ipv4" : "10.0.0.1" ,
"wan" : "1.2.3.4" ,
"wan_ipv4" : "1.2.3.4" ,
2017-09-29 09:35:51 +00:00
}
2017-09-25 18:40:42 +00:00
rt . DataDir = dataDir
} ,
} ,
2018-01-19 21:48:31 +00:00
{
2018-03-26 19:21:06 +00:00
desc : "allow disabling serf wan port" ,
2018-01-19 21:48:31 +00:00
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` {
"ports" : {
"serf_wan" : - 1
} ,
"advertise_addr_wan" : "1.2.3.4"
} ` } ,
hcl : [ ] string { `
ports {
serf_wan = - 1
}
advertise_addr_wan = "1.2.3.4"
` } ,
2018-03-27 14:44:41 +00:00
patch : func ( rt * RuntimeConfig ) {
rt . AdvertiseAddrWAN = ipAddr ( "1.2.3.4" )
rt . SerfAdvertiseAddrWAN = nil
rt . SerfBindAddrWAN = nil
rt . TaggedAddresses = map [ string ] string {
2020-01-17 14:54:17 +00:00
"lan" : "10.0.0.1" ,
"lan_ipv4" : "10.0.0.1" ,
"wan" : "1.2.3.4" ,
"wan_ipv4" : "1.2.3.4" ,
2018-03-27 14:44:41 +00:00
}
rt . DataDir = dataDir
rt . SerfPortWAN = - 1
} ,
2018-01-19 21:48:31 +00:00
} ,
2017-09-25 18:40:42 +00:00
{
2017-10-20 09:46:16 +00:00
desc : "serf bind address lan template" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "serf_lan": " {{ printf \ "1.2.3.4\" }}" } ` } ,
hcl : [ ] string { ` serf_lan = " {{ printf \ "1.2.3.4\" }}" ` } ,
2017-09-25 18:40:42 +00:00
patch : func ( rt * RuntimeConfig ) {
rt . SerfBindAddrLAN = tcpAddr ( "1.2.3.4:8301" )
rt . DataDir = dataDir
} ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "serf bind address wan template" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "serf_wan": " {{ printf \ "1.2.3.4\" }}" } ` } ,
hcl : [ ] string { ` serf_wan = " {{ printf \ "1.2.3.4\" }}" ` } ,
2017-09-25 18:40:42 +00:00
patch : func ( rt * RuntimeConfig ) {
rt . SerfBindAddrWAN = tcpAddr ( "1.2.3.4:8302" )
rt . DataDir = dataDir
} ,
} ,
2017-10-20 13:36:52 +00:00
{
2017-10-20 09:46:16 +00:00
desc : "dns recursor templates with deduplication" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
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\" }}" ] ` } ,
2017-10-20 13:36:52 +00:00
patch : func ( rt * RuntimeConfig ) {
rt . DNSRecursors = [ ] string { "5.6.7.8:9999" , "1.2.3.4" }
rt . DataDir = dataDir
} ,
} ,
2018-05-10 13:30:24 +00:00
{
desc : "start_join address template" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "start_join": [" {{ printf \ "1.2.3.4 4.3.2.1\" }}" ] } ` } ,
hcl : [ ] string { ` start_join = [" {{ printf \ "1.2.3.4 4.3.2.1\" }}" ] ` } ,
patch : func ( rt * RuntimeConfig ) {
rt . StartJoinAddrsLAN = [ ] string { "1.2.3.4" , "4.3.2.1" }
rt . DataDir = dataDir
} ,
} ,
{
desc : "start_join_wan address template" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "start_join_wan": [" {{ printf \ "1.2.3.4 4.3.2.1\" }}" ] } ` } ,
hcl : [ ] string { ` start_join_wan = [" {{ printf \ "1.2.3.4 4.3.2.1\" }}" ] ` } ,
patch : func ( rt * RuntimeConfig ) {
rt . StartJoinAddrsWAN = [ ] string { "1.2.3.4" , "4.3.2.1" }
rt . DataDir = dataDir
} ,
} ,
{
desc : "retry_join address template" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "retry_join": [" {{ printf \ "1.2.3.4 4.3.2.1\" }}" ] } ` } ,
hcl : [ ] string { ` retry_join = [" {{ printf \ "1.2.3.4 4.3.2.1\" }}" ] ` } ,
patch : func ( rt * RuntimeConfig ) {
rt . RetryJoinLAN = [ ] string { "1.2.3.4" , "4.3.2.1" }
rt . DataDir = dataDir
} ,
} ,
{
desc : "retry_join_wan address template" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "retry_join_wan": [" {{ printf \ "1.2.3.4 4.3.2.1\" }}" ] } ` } ,
hcl : [ ] string { ` retry_join_wan = [" {{ printf \ "1.2.3.4 4.3.2.1\" }}" ] ` } ,
patch : func ( rt * RuntimeConfig ) {
rt . RetryJoinWAN = [ ] string { "1.2.3.4" , "4.3.2.1" }
rt . DataDir = dataDir
} ,
} ,
2019-09-26 02:55:52 +00:00
{
desc : "min/max ports for dynamic exposed listeners" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` {
"ports" : {
"expose_min_port" : 1234 ,
"expose_max_port" : 5678
}
} ` } ,
hcl : [ ] string { `
ports {
expose_min_port = 1234
expose_max_port = 5678
}
` } ,
patch : func ( rt * RuntimeConfig ) {
rt . ExposeMinPort = 1234
rt . ExposeMaxPort = 5678
rt . DataDir = dataDir
} ,
} ,
{
desc : "defaults for dynamic exposed listeners" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
patch : func ( rt * RuntimeConfig ) {
rt . ExposeMinPort = 21500
rt . ExposeMaxPort = 21755
rt . DataDir = dataDir
} ,
} ,
2017-09-25 18:40:42 +00:00
// ------------------------------------------------------------
// precedence rules
//
{
2017-10-20 09:46:16 +00:00
desc : "precedence: merge order" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
2017-09-25 18:40:42 +00:00
json : [ ] string {
` {
"bootstrap" : true ,
"bootstrap_expect" : 1 ,
"datacenter" : "a" ,
"start_join" : [ "a" , "b" ] ,
"node_meta" : { "a" : "b" }
} ` ,
` {
"bootstrap" : false ,
"bootstrap_expect" : 0 ,
"datacenter" : "b" ,
"start_join" : [ "c" , "d" ] ,
2017-12-14 00:06:01 +00:00
"node_meta" : { "a" : "c" }
2017-09-25 18:40:42 +00:00
} ` ,
} ,
hcl : [ ] string {
`
bootstrap = true
bootstrap_expect = 1
datacenter = "a"
start_join = [ "a" , "b" ]
node_meta = { "a" = "b" }
` ,
`
bootstrap = false
bootstrap_expect = 0
datacenter = "b"
start_join = [ "c" , "d" ]
2017-12-14 00:06:01 +00:00
node_meta = { "a" = "c" }
2017-09-25 18:40:42 +00:00
` ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . Bootstrap = false
rt . BootstrapExpect = 0
rt . Datacenter = "b"
2020-01-23 15:59:31 +00:00
rt . ACLDatacenter = "b"
rt . PrimaryDatacenter = "b"
2017-09-25 18:40:42 +00:00
rt . StartJoinAddrsLAN = [ ] string { "a" , "b" , "c" , "d" }
2017-12-14 00:06:01 +00:00
rt . NodeMeta = map [ string ] string { "a" : "c" }
2017-09-25 18:40:42 +00:00
rt . DataDir = dataDir
} ,
} ,
{
desc : "precedence: flag before file" ,
json : [ ] string {
` {
"advertise_addr" : "1.2.3.4" ,
"advertise_addr_wan" : "5.6.7.8" ,
"bootstrap" : true ,
"bootstrap_expect" : 3 ,
"datacenter" : "a" ,
"node_meta" : { "a" : "b" } ,
2017-10-20 13:36:52 +00:00
"recursors" : [ "1.2.3.5" , "5.6.7.9" ] ,
2017-09-25 18:40:42 +00:00
"serf_lan" : "a" ,
"serf_wan" : "a" ,
"start_join" : [ "a" , "b" ]
} ` ,
} ,
hcl : [ ] string {
`
advertise_addr = "1.2.3.4"
advertise_addr_wan = "5.6.7.8"
bootstrap = true
bootstrap_expect = 3
datacenter = "a"
node_meta = { "a" = "b" }
2017-10-20 13:36:52 +00:00
recursors = [ "1.2.3.5" , "5.6.7.9" ]
2017-09-25 18:40:42 +00:00
serf_lan = "a"
serf_wan = "a"
start_join = [ "a" , "b" ]
` ,
} ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -advertise=1.1.1.1 ` ,
` -advertise-wan=2.2.2.2 ` ,
` -bootstrap=false ` ,
` -bootstrap-expect=0 ` ,
` -datacenter=b ` ,
` -data-dir= ` + dataDir ,
` -join ` , ` c ` , ` -join=d ` ,
2017-12-14 00:06:01 +00:00
` -node-meta=a:c ` ,
2017-10-20 13:36:52 +00:00
` -recursor ` , ` 1.2.3.6 ` , ` -recursor=5.6.7.10 ` ,
2017-09-25 18:40:42 +00:00
` -serf-lan-bind=3.3.3.3 ` ,
` -serf-wan-bind=4.4.4.4 ` ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . AdvertiseAddrLAN = ipAddr ( "1.1.1.1" )
rt . AdvertiseAddrWAN = ipAddr ( "2.2.2.2" )
rt . RPCAdvertiseAddr = tcpAddr ( "1.1.1.1:8300" )
rt . SerfAdvertiseAddrLAN = tcpAddr ( "1.1.1.1:8301" )
rt . SerfAdvertiseAddrWAN = tcpAddr ( "2.2.2.2:8302" )
rt . Datacenter = "b"
2020-01-23 15:59:31 +00:00
rt . ACLDatacenter = "b"
rt . PrimaryDatacenter = "b"
2017-10-20 13:36:52 +00:00
rt . DNSRecursors = [ ] string { "1.2.3.6" , "5.6.7.10" , "1.2.3.5" , "5.6.7.9" }
2017-12-14 00:06:01 +00:00
rt . NodeMeta = map [ string ] string { "a" : "c" }
2017-09-25 18:40:42 +00:00
rt . SerfBindAddrLAN = tcpAddr ( "3.3.3.3:8301" )
rt . SerfBindAddrWAN = tcpAddr ( "4.4.4.4:8302" )
rt . StartJoinAddrsLAN = [ ] string { "c" , "d" , "a" , "b" }
rt . TaggedAddresses = map [ string ] string {
2020-01-17 14:54:17 +00:00
"lan" : "1.1.1.1" ,
"lan_ipv4" : "1.1.1.1" ,
"wan" : "2.2.2.2" ,
"wan_ipv4" : "2.2.2.2" ,
2017-09-25 18:40:42 +00:00
}
rt . DataDir = dataDir
} ,
} ,
// ------------------------------------------------------------
// transformations
//
2017-11-10 21:50:45 +00:00
2017-09-25 18:40:42 +00:00
{
2017-10-20 09:46:16 +00:00
desc : "raft performance scaling" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "performance": { "raft_multiplier": 9} } ` } ,
hcl : [ ] string { ` performance = { raft_multiplier=9 } ` } ,
2017-09-25 18:40:42 +00:00
patch : func ( rt * RuntimeConfig ) {
rt . ConsulRaftElectionTimeout = 9 * 1000 * time . Millisecond
rt . ConsulRaftHeartbeatTimeout = 9 * 1000 * time . Millisecond
rt . ConsulRaftLeaderLeaseTimeout = 9 * 500 * time . Millisecond
rt . DataDir = dataDir
} ,
} ,
// ------------------------------------------------------------
// validations
//
{
2017-10-20 09:46:16 +00:00
desc : "invalid input" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` this is not JSON ` } ,
hcl : [ ] string { ` *** 0123 this is not HCL ` } ,
err : "Error parsing" ,
2017-09-25 18:40:42 +00:00
} ,
{
2017-10-20 09:46:16 +00:00
desc : "datacenter is lower-cased" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "datacenter": "A" } ` } ,
hcl : [ ] string { ` datacenter = "A" ` } ,
2017-09-25 18:40:42 +00:00
patch : func ( rt * RuntimeConfig ) {
rt . Datacenter = "a"
2020-01-23 15:59:31 +00:00
rt . ACLDatacenter = "a"
rt . PrimaryDatacenter = "a"
2017-09-25 18:40:42 +00:00
rt . DataDir = dataDir
} ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "acl_datacenter is lower-cased" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "acl_datacenter": "A" } ` } ,
hcl : [ ] string { ` acl_datacenter = "A" ` } ,
2017-09-25 18:40:42 +00:00
patch : func ( rt * RuntimeConfig ) {
2018-10-19 16:04:07 +00:00
rt . ACLsEnabled = true
2017-09-25 18:40:42 +00:00
rt . ACLDatacenter = "a"
rt . DataDir = dataDir
2018-10-15 16:17:48 +00:00
rt . PrimaryDatacenter = "a"
2017-09-25 18:40:42 +00:00
} ,
2018-10-15 16:17:48 +00:00
warns : [ ] string { ` The 'acl_datacenter' field is deprecated. Use the 'primary_datacenter' field instead. ` } ,
2017-09-25 18:40:42 +00:00
} ,
{
2017-10-20 09:46:16 +00:00
desc : "acl_replication_token enables acl replication" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "acl_replication_token": "a" } ` } ,
hcl : [ ] string { ` acl_replication_token = "a" ` } ,
2017-09-25 18:40:42 +00:00
patch : func ( rt * RuntimeConfig ) {
rt . ACLReplicationToken = "a"
2018-10-19 16:04:07 +00:00
rt . ACLTokenReplication = true
2017-09-25 18:40:42 +00:00
rt . DataDir = dataDir
} ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "advertise address detect fails v4" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "bind_addr": "0.0.0.0"} ` } ,
hcl : [ ] string { ` bind_addr = "0.0.0.0" ` } ,
2017-09-25 18:40:42 +00:00
privatev4 : func ( ) ( [ ] * net . IPAddr , error ) {
return nil , errors . New ( "some error" )
} ,
err : "Error detecting private IPv4 address: some error" ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "advertise address detect none v4" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "bind_addr": "0.0.0.0"} ` } ,
hcl : [ ] string { ` bind_addr = "0.0.0.0" ` } ,
2017-09-25 18:40:42 +00:00
privatev4 : func ( ) ( [ ] * net . IPAddr , error ) {
return nil , nil
} ,
err : "No private IPv4 address found" ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "advertise address detect multiple v4" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "bind_addr": "0.0.0.0"} ` } ,
hcl : [ ] string { ` bind_addr = "0.0.0.0" ` } ,
2017-09-25 18:40:42 +00:00
privatev4 : func ( ) ( [ ] * net . IPAddr , error ) {
return [ ] * net . IPAddr { ipAddr ( "1.1.1.1" ) , ipAddr ( "2.2.2.2" ) } , nil
} ,
err : "Multiple private IPv4 addresses found. Please configure one" ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "advertise address detect fails v6" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "bind_addr": "::"} ` } ,
hcl : [ ] string { ` bind_addr = "::" ` } ,
2017-09-25 18:40:42 +00:00
publicv6 : func ( ) ( [ ] * net . IPAddr , error ) {
return nil , errors . New ( "some error" )
} ,
err : "Error detecting public IPv6 address: some error" ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "advertise address detect none v6" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "bind_addr": "::"} ` } ,
hcl : [ ] string { ` bind_addr = "::" ` } ,
2017-09-25 18:40:42 +00:00
publicv6 : func ( ) ( [ ] * net . IPAddr , error ) {
return nil , nil
} ,
err : "No public IPv6 address found" ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "advertise address detect multiple v6" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "bind_addr": "::"} ` } ,
hcl : [ ] string { ` bind_addr = "::" ` } ,
2017-09-25 18:40:42 +00:00
publicv6 : func ( ) ( [ ] * net . IPAddr , error ) {
return [ ] * net . IPAddr { ipAddr ( "dead:beef::1" ) , ipAddr ( "dead:beef::2" ) } , nil
} ,
err : "Multiple public IPv6 addresses found. Please configure one" ,
} ,
{
desc : "ae_interval invalid == 0" ,
2017-10-20 09:46:16 +00:00
args : [ ] string { ` -data-dir= ` + dataDir } ,
2017-09-25 18:40:42 +00:00
jsontail : [ ] string { ` { "ae_interval": "0s" } ` } ,
hcltail : [ ] string { ` ae_interval = "0s" ` } ,
err : ` ae_interval cannot be 0s. Must be positive ` ,
} ,
{
desc : "ae_interval invalid < 0" ,
2017-10-20 09:46:16 +00:00
args : [ ] string { ` -data-dir= ` + dataDir } ,
2017-09-25 18:40:42 +00:00
jsontail : [ ] string { ` { "ae_interval": "-1s" } ` } ,
hcltail : [ ] string { ` ae_interval = "-1s" ` } ,
err : ` ae_interval cannot be -1s. Must be positive ` ,
} ,
{
desc : "acl_datacenter invalid" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -datacenter=a ` ,
` -data-dir= ` + dataDir ,
} ,
2018-10-15 16:17:48 +00:00
json : [ ] string { ` { "acl_datacenter": "%" } ` } ,
hcl : [ ] string { ` acl_datacenter = "%" ` } ,
err : ` acl_datacenter cannot be "%". Please use only [a-z0-9-_] ` ,
warns : [ ] string { ` The 'acl_datacenter' field is deprecated. Use the 'primary_datacenter' field instead. ` } ,
2017-09-25 18:40:42 +00:00
} ,
{
desc : "autopilot.max_trailing_logs invalid" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -datacenter=a ` ,
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "autopilot": { "max_trailing_logs": -1 } } ` } ,
hcl : [ ] string { ` autopilot = { max_trailing_logs = -1 } ` } ,
err : "autopilot.max_trailing_logs cannot be -1. Must be greater than or equal to zero" ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "bind_addr cannot be empty" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "bind_addr": "" } ` } ,
hcl : [ ] string { ` bind_addr = "" ` } ,
err : "bind_addr cannot be empty" ,
2017-09-25 18:40:42 +00:00
} ,
{
2017-10-20 09:46:16 +00:00
desc : "bind_addr does not allow multiple addresses" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] 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" ,
2017-09-25 18:40:42 +00:00
} ,
{
2017-10-20 09:46:16 +00:00
desc : "bind_addr cannot be a unix socket" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "bind_addr": "unix:///foo" } ` } ,
hcl : [ ] string { ` bind_addr = "unix:///foo" ` } ,
err : "bind_addr cannot be a unix socket" ,
2017-09-25 18:40:42 +00:00
} ,
{
desc : "bootstrap without server" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -datacenter=a ` ,
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "bootstrap": true } ` } ,
hcl : [ ] string { ` bootstrap = true ` } ,
err : "'bootstrap = true' requires 'server = true'" ,
} ,
{
desc : "bootstrap-expect without server" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -datacenter=a ` ,
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "bootstrap_expect": 3 } ` } ,
hcl : [ ] string { ` bootstrap_expect = 3 ` } ,
err : "'bootstrap_expect > 0' requires 'server = true'" ,
} ,
{
desc : "bootstrap-expect invalid" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -datacenter=a ` ,
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "bootstrap_expect": -1 } ` } ,
hcl : [ ] string { ` bootstrap_expect = -1 ` } ,
err : "bootstrap_expect cannot be -1. Must be greater than or equal to zero" ,
} ,
{
desc : "bootstrap-expect and dev mode" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -dev ` ,
` -datacenter=a ` ,
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "bootstrap_expect": 3, "server": true } ` } ,
hcl : [ ] string { ` bootstrap_expect = 3 server = true ` } ,
err : "'bootstrap_expect > 0' not allowed in dev mode" ,
} ,
{
2017-10-05 14:27:39 +00:00
desc : "bootstrap-expect and bootstrap" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -datacenter=a ` ,
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "bootstrap": true, "bootstrap_expect": 3, "server": true } ` } ,
hcl : [ ] string { ` bootstrap = true bootstrap_expect = 3 server = true ` } ,
err : "'bootstrap_expect > 0' and 'bootstrap = true' are mutually exclusive" ,
} ,
{
2017-10-05 14:27:39 +00:00
desc : "bootstrap-expect=1 equals bootstrap" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "bootstrap_expect": 1, "server": true } ` } ,
hcl : [ ] string { ` bootstrap_expect = 1 server = true ` } ,
patch : func ( rt * RuntimeConfig ) {
rt . Bootstrap = true
rt . BootstrapExpect = 0
rt . LeaveOnTerm = false
rt . ServerMode = true
rt . SkipLeaveOnInt = true
rt . DataDir = dataDir
} ,
warns : [ ] string { "BootstrapExpect is set to 1; this is the same as Bootstrap mode." , "bootstrap = true: do not enable unless necessary" } ,
} ,
{
desc : "bootstrap-expect=2 warning" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "bootstrap_expect": 2, "server": true } ` } ,
hcl : [ ] string { ` bootstrap_expect = 2 server = true ` } ,
patch : func ( rt * RuntimeConfig ) {
rt . BootstrapExpect = 2
rt . LeaveOnTerm = false
rt . ServerMode = true
rt . SkipLeaveOnInt = true
rt . DataDir = dataDir
} ,
warns : [ ] string {
` bootstrap_expect = 2: A cluster with 2 servers will provide no failure tolerance. See https://www.consul.io/docs/internals/consensus.html#deployment-table ` ,
` bootstrap_expect > 0: expecting 2 servers ` ,
} ,
} ,
{
desc : "bootstrap-expect > 2 but even warning" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "bootstrap_expect": 4, "server": true } ` } ,
hcl : [ ] string { ` bootstrap_expect = 4 server = true ` } ,
patch : func ( rt * RuntimeConfig ) {
rt . BootstrapExpect = 4
rt . LeaveOnTerm = false
rt . ServerMode = true
rt . SkipLeaveOnInt = true
rt . DataDir = dataDir
} ,
warns : [ ] string {
` bootstrap_expect is even number: A cluster with an even number of servers does not achieve optimum fault tolerance. See https://www.consul.io/docs/internals/consensus.html#deployment-table ` ,
` bootstrap_expect > 0: expecting 4 servers ` ,
} ,
} ,
{
desc : "client mode sets LeaveOnTerm and SkipLeaveOnInt correctly" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "server": false } ` } ,
hcl : [ ] string { ` server = false ` } ,
patch : func ( rt * RuntimeConfig ) {
rt . LeaveOnTerm = true
rt . ServerMode = false
rt . SkipLeaveOnInt = false
rt . DataDir = dataDir
} ,
} ,
{
desc : "client does not allow socket" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -datacenter=a ` ,
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "client_addr": "unix:///foo" } ` } ,
hcl : [ ] string { ` client_addr = "unix:///foo" ` } ,
err : "client_addr cannot be a unix socket" ,
} ,
{
2017-10-20 09:46:16 +00:00
desc : "datacenter invalid" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` { "datacenter": "%" } ` } ,
hcl : [ ] string { ` datacenter = "%" ` } ,
err : ` datacenter cannot be "%". Please use only [a-z0-9-_] ` ,
2017-09-25 18:40:42 +00:00
} ,
{
desc : "dns does not allow socket" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -datacenter=a ` ,
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "addresses": { "dns": "unix:///foo" } } ` } ,
hcl : [ ] string { ` addresses = { dns = "unix:///foo" } ` } ,
err : "DNS address cannot be a unix socket" ,
} ,
{
2017-09-26 06:58:54 +00:00
desc : "ui and ui_dir" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -datacenter=a ` ,
` -data-dir= ` + dataDir ,
} ,
2017-09-26 06:58:54 +00:00
json : [ ] string { ` { "ui": true, "ui_dir": "a" } ` } ,
hcl : [ ] string { ` ui = true ui_dir = "a" ` } ,
2017-09-25 18:40:42 +00:00
err : "Both the ui and ui-dir flags were specified, please provide only one.\n" +
"If trying to use your own web UI resources, use the ui-dir flag.\n" +
"If using Consul version 0.7.0 or later, the web UI is included in the binary so use ui to enable it" ,
} ,
// test ANY address failures
// to avoid combinatory explosion for tests use 0.0.0.0, :: or [::] but not all of them
{
desc : "advertise_addr any" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "advertise_addr": "0.0.0.0" } ` } ,
hcl : [ ] string { ` advertise_addr = "0.0.0.0" ` } ,
err : "Advertise address cannot be 0.0.0.0, :: or [::]" ,
} ,
{
desc : "advertise_addr_wan any" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "advertise_addr_wan": "::" } ` } ,
hcl : [ ] string { ` advertise_addr_wan = "::" ` } ,
err : "Advertise WAN address cannot be 0.0.0.0, :: or [::]" ,
} ,
2017-10-20 18:00:45 +00:00
{
desc : "recursors any" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-10-20 18:00:45 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "recursors": ["::"] } ` } ,
hcl : [ ] string { ` recursors = ["::"] ` } ,
err : "DNS recursor address cannot be 0.0.0.0, :: or [::]" ,
} ,
2017-09-25 18:40:42 +00:00
{
desc : "dns_config.udp_answer_limit invalid" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "dns_config": { "udp_answer_limit": -1 } } ` } ,
hcl : [ ] string { ` dns_config = { udp_answer_limit = -1 } ` } ,
err : "dns_config.udp_answer_limit cannot be -1. Must be greater than or equal to zero" ,
} ,
2018-03-06 01:07:42 +00:00
{
desc : "dns_config.a_record_limit invalid" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "dns_config": { "a_record_limit": -1 } } ` } ,
hcl : [ ] string { ` dns_config = { a_record_limit = -1 } ` } ,
err : "dns_config.a_record_limit cannot be -1. Must be greater than or equal to zero" ,
} ,
2017-09-25 18:40:42 +00:00
{
desc : "performance.raft_multiplier < 0" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "performance": { "raft_multiplier": -1 } } ` } ,
hcl : [ ] string { ` performance = { raft_multiplier = -1 } ` } ,
err : ` performance.raft_multiplier cannot be -1. Must be between 1 and 10 ` ,
} ,
{
desc : "performance.raft_multiplier == 0" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "performance": { "raft_multiplier": 0 } } ` } ,
hcl : [ ] string { ` performance = { raft_multiplier = 0 } ` } ,
err : ` performance.raft_multiplier cannot be 0. Must be between 1 and 10 ` ,
} ,
{
desc : "performance.raft_multiplier > 10" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "performance": { "raft_multiplier": 20 } } ` } ,
hcl : [ ] string { ` performance = { raft_multiplier = 20 } ` } ,
err : ` performance.raft_multiplier cannot be 20. Must be between 1 and 10 ` ,
} ,
{
desc : "node_name invalid" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
` -node= ` ,
} ,
hostname : func ( ) ( string , error ) { return "" , nil } ,
err : "node_name cannot be empty" ,
} ,
{
desc : "node_meta key too long" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string {
` { "dns_config": { "udp_answer_limit": 1 } } ` ,
` { "node_meta": { " ` + randomString ( 130 ) + ` ": "a" } } ` ,
} ,
hcl : [ ] string {
` dns_config = { udp_answer_limit = 1 } ` ,
` node_meta = { " ` + randomString ( 130 ) + ` " = "a" } ` ,
} ,
err : "Key is too long (limit: 128 characters)" ,
} ,
{
desc : "node_meta value too long" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string {
` { "dns_config": { "udp_answer_limit": 1 } } ` ,
` { "node_meta": { "a": " ` + randomString ( 520 ) + ` " } } ` ,
} ,
hcl : [ ] string {
` dns_config = { udp_answer_limit = 1 } ` ,
` node_meta = { "a" = " ` + randomString ( 520 ) + ` " } ` ,
} ,
err : "Value is too long (limit: 512 characters)" ,
} ,
{
desc : "node_meta too many keys" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string {
` { "dns_config": { "udp_answer_limit": 1 } } ` ,
` { "node_meta": { ` + metaPairs ( 70 , "json" ) + ` } } ` ,
} ,
hcl : [ ] string {
` dns_config = { udp_answer_limit = 1 } ` ,
` node_meta = { ` + metaPairs ( 70 , "hcl" ) + ` } ` ,
} ,
err : "Node metadata cannot contain more than 64 key/value pairs" ,
} ,
{
desc : "unique listeners dns vs http" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"client_addr" : "1.2.3.4" ,
"ports" : { "dns" : 1000 , "http" : 1000 }
} ` } ,
hcl : [ ] string { `
client_addr = "1.2.3.4"
ports = { dns = 1000 http = 1000 }
` } ,
err : "HTTP address 1.2.3.4:1000 already configured for DNS" ,
} ,
{
desc : "unique listeners dns vs https" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"client_addr" : "1.2.3.4" ,
"ports" : { "dns" : 1000 , "https" : 1000 }
} ` } ,
hcl : [ ] string { `
client_addr = "1.2.3.4"
ports = { dns = 1000 https = 1000 }
` } ,
err : "HTTPS address 1.2.3.4:1000 already configured for DNS" ,
} ,
{
desc : "unique listeners http vs https" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"client_addr" : "1.2.3.4" ,
"ports" : { "http" : 1000 , "https" : 1000 }
} ` } ,
hcl : [ ] string { `
client_addr = "1.2.3.4"
ports = { http = 1000 https = 1000 }
` } ,
err : "HTTPS address 1.2.3.4:1000 already configured for HTTP" ,
} ,
{
desc : "unique advertise addresses HTTP vs RPC" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"addresses" : { "http" : "10.0.0.1" } ,
"ports" : { "http" : 1000 , "server" : 1000 }
} ` } ,
hcl : [ ] string { `
addresses = { http = "10.0.0.1" }
ports = { http = 1000 server = 1000 }
` } ,
err : "RPC Advertise address 10.0.0.1:1000 already configured for HTTP" ,
} ,
{
desc : "unique advertise addresses RPC vs Serf LAN" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"ports" : { "server" : 1000 , "serf_lan" : 1000 }
} ` } ,
hcl : [ ] string { `
ports = { server = 1000 serf_lan = 1000 }
` } ,
err : "Serf Advertise LAN address 10.0.0.1:1000 already configured for RPC Advertise" ,
} ,
{
desc : "unique advertise addresses RPC vs Serf WAN" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"ports" : { "server" : 1000 , "serf_wan" : 1000 }
} ` } ,
hcl : [ ] string { `
ports = { server = 1000 serf_wan = 1000 }
` } ,
err : "Serf Advertise WAN address 10.0.0.1:1000 already configured for RPC Advertise" ,
} ,
2018-09-27 13:33:12 +00:00
{
desc : "sidecar_service can't have ID" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"service" : {
"name" : "web" ,
"port" : 1234 ,
"connect" : {
"sidecar_service" : {
"ID" : "random-sidecar-id"
}
}
}
} ` } ,
hcl : [ ] string { `
service {
name = "web"
port = 1234
connect {
sidecar_service {
ID = "random-sidecar-id"
}
}
}
` } ,
2018-10-09 16:57:26 +00:00
err : "sidecar_service can't specify an ID" ,
2018-09-27 13:33:12 +00:00
} ,
{
desc : "sidecar_service can't have nested sidecar" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"service" : {
"name" : "web" ,
"port" : 1234 ,
"connect" : {
"sidecar_service" : {
"connect" : {
"sidecar_service" : { }
}
}
}
}
} ` } ,
hcl : [ ] string { `
service {
name = "web"
port = 1234
connect {
sidecar_service {
connect {
sidecar_service {
}
}
}
}
}
` } ,
err : "sidecar_service can't have a nested sidecar_service" ,
} ,
2017-09-25 18:40:42 +00:00
{
desc : "telemetry.prefix_filter cannot be empty" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"telemetry" : { "prefix_filter" : [ "" ] }
} ` } ,
hcl : [ ] string { `
telemetry = { prefix_filter = [ "" ] }
` } ,
patch : func ( rt * RuntimeConfig ) {
rt . DataDir = dataDir
} ,
warns : [ ] string { "Cannot have empty filter rule in prefix_filter" } ,
} ,
{
desc : "telemetry.prefix_filter must start with + or -" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"telemetry" : { "prefix_filter" : [ "+foo" , "-bar" , "nix" ] }
} ` } ,
hcl : [ ] string { `
telemetry = { prefix_filter = [ "+foo" , "-bar" , "nix" ] }
` } ,
patch : func ( rt * RuntimeConfig ) {
rt . DataDir = dataDir
2018-06-14 12:52:48 +00:00
rt . Telemetry . AllowedPrefixes = [ ] string { "foo" }
rt . Telemetry . BlockedPrefixes = [ ] string { "bar" }
2017-09-25 18:40:42 +00:00
} ,
warns : [ ] string { ` Filter rule must begin with either '+' or '-': "nix" ` } ,
} ,
{
desc : "encrypt has invalid key" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` { "encrypt": "this is not a valid key" } ` } ,
hcl : [ ] string { ` encrypt = "this is not a valid key" ` } ,
err : "encrypt has invalid key: illegal base64 data at input byte 4" ,
} ,
{
desc : "encrypt given but LAN keyring exists" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
2019-07-30 15:45:41 +00:00
json : [ ] string { ` { "encrypt": "pUqJrVyVRj5jsiYEkM/tFQYfWyJIv4s3XkvDwy7Cu5s=" } ` } ,
hcl : [ ] string { ` encrypt = "pUqJrVyVRj5jsiYEkM/tFQYfWyJIv4s3XkvDwy7Cu5s=" ` } ,
2017-09-25 18:40:42 +00:00
patch : func ( rt * RuntimeConfig ) {
2019-07-30 15:45:41 +00:00
rt . EncryptKey = "pUqJrVyVRj5jsiYEkM/tFQYfWyJIv4s3XkvDwy7Cu5s="
2017-09-25 18:40:42 +00:00
rt . DataDir = dataDir
} ,
pre : func ( ) {
2019-07-30 15:45:41 +00:00
writeFile ( filepath . Join ( dataDir , SerfLANKeyring ) , [ ] byte ( "pUqJrVyVRj5jsiYEkM/tFQYfWyJIv4s3XkvDwy7Cu5s=" ) )
2017-09-25 18:40:42 +00:00
} ,
warns : [ ] string { ` WARNING: LAN keyring exists but -encrypt given, using keyring ` } ,
} ,
{
desc : "encrypt given but WAN keyring exists" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-25 18:40:42 +00:00
` -data-dir= ` + dataDir ,
} ,
2019-07-30 15:45:41 +00:00
json : [ ] string { ` { "encrypt": "pUqJrVyVRj5jsiYEkM/tFQYfWyJIv4s3XkvDwy7Cu5s=", "server": true } ` } ,
hcl : [ ] string { ` encrypt = "pUqJrVyVRj5jsiYEkM/tFQYfWyJIv4s3XkvDwy7Cu5s=" server = true ` } ,
2017-09-25 18:40:42 +00:00
patch : func ( rt * RuntimeConfig ) {
2019-07-30 15:45:41 +00:00
rt . EncryptKey = "pUqJrVyVRj5jsiYEkM/tFQYfWyJIv4s3XkvDwy7Cu5s="
2017-09-25 18:40:42 +00:00
rt . ServerMode = true
rt . LeaveOnTerm = false
rt . SkipLeaveOnInt = true
rt . DataDir = dataDir
} ,
pre : func ( ) {
2019-07-30 15:45:41 +00:00
writeFile ( filepath . Join ( dataDir , SerfWANKeyring ) , [ ] byte ( "pUqJrVyVRj5jsiYEkM/tFQYfWyJIv4s3XkvDwy7Cu5s=" ) )
2017-09-25 18:40:42 +00:00
} ,
warns : [ ] string { ` WARNING: WAN keyring exists but -encrypt given, using keyring ` } ,
} ,
2017-09-26 08:14:14 +00:00
{
desc : "multiple check files" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-26 08:14:14 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string {
2018-05-08 22:31:53 +00:00
` { "check": { "name": "a", "args": ["/bin/true"] } } ` ,
` { "check": { "name": "b", "args": ["/bin/false"] } } ` ,
2017-09-26 08:14:14 +00:00
} ,
hcl : [ ] string {
2018-05-08 22:31:53 +00:00
` check = { name = "a" args = ["/bin/true"] } ` ,
` check = { name = "b" args = ["/bin/false"] } ` ,
2017-09-26 08:14:14 +00:00
} ,
patch : func ( rt * RuntimeConfig ) {
rt . Checks = [ ] * structs . CheckDefinition {
2019-12-10 02:26:41 +00:00
& structs . CheckDefinition { Name : "a" , ScriptArgs : [ ] string { "/bin/true" } , OutputMaxSize : checks . DefaultBufSize , EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) } ,
& structs . CheckDefinition { Name : "b" , ScriptArgs : [ ] string { "/bin/false" } , OutputMaxSize : checks . DefaultBufSize , EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) } ,
2017-09-26 08:14:14 +00:00
}
rt . DataDir = dataDir
} ,
} ,
2017-12-27 04:35:22 +00:00
{
desc : "grpc check" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string {
2018-02-03 01:29:34 +00:00
` { "check": { "name": "a", "grpc": "localhost:12345/foo", "grpc_use_tls": true } } ` ,
2017-12-27 04:35:22 +00:00
} ,
hcl : [ ] string {
2018-02-03 01:29:34 +00:00
` check = { name = "a" grpc = "localhost:12345/foo", grpc_use_tls = true } ` ,
2017-12-27 04:35:22 +00:00
} ,
patch : func ( rt * RuntimeConfig ) {
rt . Checks = [ ] * structs . CheckDefinition {
2019-12-10 02:26:41 +00:00
& structs . CheckDefinition { Name : "a" , GRPC : "localhost:12345/foo" , GRPCUseTLS : true , OutputMaxSize : checks . DefaultBufSize , EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) } ,
2017-12-27 04:35:22 +00:00
}
rt . DataDir = dataDir
} ,
} ,
2018-06-30 06:09:58 +00:00
{
desc : "alias check with no node" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string {
` { "check": { "name": "a", "alias_service": "foo" } } ` ,
} ,
hcl : [ ] string {
` check = { name = "a", alias_service = "foo" } ` ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . Checks = [ ] * structs . CheckDefinition {
2019-12-10 02:26:41 +00:00
& structs . CheckDefinition { Name : "a" , AliasService : "foo" , OutputMaxSize : checks . DefaultBufSize , EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) } ,
2018-06-30 06:09:58 +00:00
}
rt . DataDir = dataDir
} ,
} ,
2017-09-26 08:14:14 +00:00
{
desc : "multiple service files" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-09-26 08:14:14 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string {
` { "service": { "name": "a", "port": 80 } } ` ,
2018-09-07 14:30:47 +00:00
` { "service": { "name": "b", "port": 90, "meta": { "my": "value"}, "weights": { "passing": 13} } } ` ,
2017-09-26 08:14:14 +00:00
} ,
hcl : [ ] string {
` service = { name = "a" port = 80 } ` ,
2018-09-07 14:30:47 +00:00
` service = { name = "b" port = 90 meta= { my="value"}, weights= { passing=13}} ` ,
2017-09-26 08:14:14 +00:00
} ,
patch : func ( rt * RuntimeConfig ) {
rt . Services = [ ] * structs . ServiceDefinition {
2019-12-10 02:26:41 +00:00
& structs . ServiceDefinition {
Name : "a" ,
Port : 80 ,
Weights : & structs . Weights {
Passing : 1 ,
Warning : 1 ,
} ,
EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) ,
} ,
& structs . ServiceDefinition {
Name : "b" ,
Port : 90 ,
Meta : map [ string ] string { "my" : "value" } ,
Weights : & structs . Weights {
Passing : 13 ,
Warning : 1 ,
} ,
EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) ,
} ,
2017-09-26 08:14:14 +00:00
}
rt . DataDir = dataDir
} ,
} ,
2018-04-18 20:57:33 +00:00
{
2018-04-18 21:07:25 +00:00
desc : "service with wrong meta: too long key" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string {
` { "service": { "name": "a", "port": 80, "meta": { " ` + randomString ( 520 ) + ` ": "metaValue" } } } ` ,
} ,
hcl : [ ] string {
` service = { name = "a" port = 80, meta= { ` + randomString ( 520 ) + ` ="metaValue"} } ` ,
} ,
err : ` Key is too long ` ,
} ,
{
desc : "service with wrong meta: too long value" ,
2018-04-18 20:57:33 +00:00
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string {
` { "service": { "name": "a", "port": 80, "meta": { "a": " ` + randomString ( 520 ) + ` " } } } ` ,
} ,
hcl : [ ] string {
` service = { name = "a" port = 80, meta= { a=" ` + randomString ( 520 ) + ` "} } ` ,
} ,
err : ` Value is too long ` ,
} ,
{
desc : "service with wrong meta: too many meta" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string {
` { "service": { "name": "a", "port": 80, "meta": { ` + metaPairs ( 70 , "json" ) + ` } } } ` ,
} ,
hcl : [ ] string {
` service = { name = "a" port = 80 meta= { ` + metaPairs ( 70 , "hcl" ) + ` } } ` ,
} ,
err : ` invalid meta for service a: Node metadata cannot contain more than 64 key ` ,
} ,
2017-10-10 23:40:59 +00:00
{
desc : "translated keys" ,
2017-10-20 09:46:16 +00:00
args : [ ] string {
2017-10-10 23:40:59 +00:00
` -data-dir= ` + dataDir ,
} ,
json : [ ] string {
` {
"service" : {
"name" : "a" ,
"port" : 80 ,
2019-06-17 14:51:50 +00:00
"tagged_addresses" : {
"wan" : {
"address" : "198.18.3.4" ,
"port" : 443
}
} ,
2018-05-07 23:19:13 +00:00
"enable_tag_override" : true ,
2017-10-10 23:40:59 +00:00
"check" : {
2018-05-07 22:51:05 +00:00
"id" : "x" ,
2017-10-10 23:40:59 +00:00
"name" : "y" ,
"DockerContainerID" : "z" ,
"DeregisterCriticalServiceAfter" : "10s" ,
"ScriptArgs" : [ "a" , "b" ]
}
}
} ` ,
} ,
hcl : [ ] string {
` service = {
name = "a"
port = 80
2018-05-07 23:19:13 +00:00
enable_tag_override = true
2019-06-17 14:51:50 +00:00
tagged_addresses = {
wan = {
address = "198.18.3.4"
port = 443
}
}
2017-10-10 23:40:59 +00:00
check = {
2018-05-07 22:51:05 +00:00
id = "x"
2017-10-10 23:40:59 +00:00
name = "y"
DockerContainerID = "z"
DeregisterCriticalServiceAfter = "10s"
ScriptArgs = [ "a" , "b" ]
}
} ` ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . Services = [ ] * structs . ServiceDefinition {
& structs . ServiceDefinition {
2019-06-17 14:51:50 +00:00
Name : "a" ,
Port : 80 ,
TaggedAddresses : map [ string ] structs . ServiceAddress {
"wan" : structs . ServiceAddress {
Address : "198.18.3.4" ,
Port : 443 ,
} ,
} ,
2017-10-10 23:40:59 +00:00
EnableTagOverride : true ,
Checks : [ ] * structs . CheckType {
& structs . CheckType {
CheckID : types . CheckID ( "x" ) ,
Name : "y" ,
DockerContainerID : "z" ,
DeregisterCriticalServiceAfter : 10 * time . Second ,
ScriptArgs : [ ] string { "a" , "b" } ,
2019-06-26 15:43:25 +00:00
OutputMaxSize : checks . DefaultBufSize ,
2017-10-10 23:40:59 +00:00
} ,
} ,
2018-09-07 14:30:47 +00:00
Weights : & structs . Weights {
Passing : 1 ,
Warning : 1 ,
} ,
2019-12-10 02:26:41 +00:00
EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) ,
2017-10-10 23:40:59 +00:00
} ,
}
rt . DataDir = dataDir
} ,
} ,
2017-11-10 21:50:45 +00:00
{
desc : "ignore snapshot_agent sub-object" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string {
` { "snapshot_agent": { "dont": "care" } } ` ,
} ,
hcl : [ ] string {
` snapshot_agent = { dont = "care" } ` ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . DataDir = dataDir
} ,
} ,
2018-06-12 12:25:08 +00:00
2018-09-27 13:33:12 +00:00
{
// This tests that we correct added the nested paths to arrays of objects
2019-06-28 16:35:35 +00:00
// to the exceptions in PatchSliceOfMaps in config.go (for single service)
2018-09-27 13:33:12 +00:00
desc : "service.connectsidecar_service with checks and upstreams" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"service" : {
"name" : "web" ,
"port" : 1234 ,
"connect" : {
"sidecar_service" : {
"port" : 2345 ,
"checks" : [
{
"TCP" : "127.0.0.1:2345" ,
"Interval" : "10s"
}
] ,
"proxy" : {
2019-09-26 02:55:52 +00:00
"expose" : {
"checks" : true ,
"paths" : [
{
"path" : "/health" ,
"local_path_port" : 8080 ,
"listener_port" : 21500 ,
"protocol" : "http"
}
]
} ,
2018-09-27 13:33:12 +00:00
"upstreams" : [
{
"destination_name" : "db" ,
"local_bind_port" : 7000
}
]
}
}
}
}
} ` } ,
hcl : [ ] string { `
service {
name = "web"
port = 1234
connect {
sidecar_service {
port = 2345
checks = [
{
tcp = "127.0.0.1:2345"
interval = "10s"
}
]
proxy {
2019-09-26 02:55:52 +00:00
expose {
checks = true
paths = [
{
path = "/health"
local_path_port = 8080
listener_port = 21500
protocol = "http"
}
]
} ,
2018-09-27 13:33:12 +00:00
upstreams = [
{
destination_name = "db"
local_bind_port = 7000
} ,
]
}
}
}
}
` } ,
patch : func ( rt * RuntimeConfig ) {
rt . DataDir = dataDir
rt . Services = [ ] * structs . ServiceDefinition {
{
Name : "web" ,
Port : 1234 ,
Connect : & structs . ServiceConnect {
SidecarService : & structs . ServiceDefinition {
Port : 2345 ,
Checks : structs . CheckTypes {
{
2019-06-26 15:43:25 +00:00
TCP : "127.0.0.1:2345" ,
Interval : 10 * time . Second ,
OutputMaxSize : checks . DefaultBufSize ,
2018-09-27 13:33:12 +00:00
} ,
} ,
Proxy : & structs . ConnectProxyConfig {
2019-09-26 02:55:52 +00:00
Expose : structs . ExposeConfig {
Checks : true ,
Paths : [ ] structs . ExposePath {
{
Path : "/health" ,
LocalPathPort : 8080 ,
ListenerPort : 21500 ,
Protocol : "http" ,
} ,
} ,
} ,
2018-09-27 13:33:12 +00:00
Upstreams : structs . Upstreams {
structs . Upstream {
DestinationType : "service" ,
DestinationName : "db" ,
LocalBindPort : 7000 ,
} ,
} ,
} ,
2018-10-04 13:08:12 +00:00
Weights : & structs . Weights {
Passing : 1 ,
Warning : 1 ,
} ,
2019-12-10 02:26:41 +00:00
EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) ,
2018-09-27 13:33:12 +00:00
} ,
} ,
2018-10-04 13:08:12 +00:00
Weights : & structs . Weights {
Passing : 1 ,
Warning : 1 ,
} ,
2019-12-10 02:26:41 +00:00
EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) ,
2018-09-27 13:33:12 +00:00
} ,
}
} ,
} ,
{
// This tests that we correct added the nested paths to arrays of objects
2019-06-28 16:35:35 +00:00
// to the exceptions in PatchSliceOfMaps in config.go (for service*s*)
2018-09-27 13:33:12 +00:00
desc : "services.connect.sidecar_service with checks and upstreams" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"services" : [ {
"name" : "web" ,
"port" : 1234 ,
"connect" : {
"sidecar_service" : {
"port" : 2345 ,
"checks" : [
{
"TCP" : "127.0.0.1:2345" ,
"Interval" : "10s"
}
] ,
"proxy" : {
2019-09-26 02:55:52 +00:00
"expose" : {
"checks" : true ,
"paths" : [
{
"path" : "/health" ,
"local_path_port" : 8080 ,
"listener_port" : 21500 ,
"protocol" : "http"
}
]
} ,
2018-09-27 13:33:12 +00:00
"upstreams" : [
{
"destination_name" : "db" ,
"local_bind_port" : 7000
}
]
}
}
}
} ]
} ` } ,
hcl : [ ] string { `
services = [ {
name = "web"
port = 1234
connect {
sidecar_service {
port = 2345
checks = [
{
tcp = "127.0.0.1:2345"
interval = "10s"
}
]
proxy {
2019-09-26 02:55:52 +00:00
expose {
checks = true
paths = [
{
path = "/health"
local_path_port = 8080
listener_port = 21500
protocol = "http"
}
]
} ,
2018-09-27 13:33:12 +00:00
upstreams = [
{
destination_name = "db"
local_bind_port = 7000
} ,
]
}
}
}
} ]
` } ,
patch : func ( rt * RuntimeConfig ) {
rt . DataDir = dataDir
rt . Services = [ ] * structs . ServiceDefinition {
{
Name : "web" ,
Port : 1234 ,
Connect : & structs . ServiceConnect {
SidecarService : & structs . ServiceDefinition {
Port : 2345 ,
Checks : structs . CheckTypes {
{
2019-06-26 15:43:25 +00:00
TCP : "127.0.0.1:2345" ,
Interval : 10 * time . Second ,
OutputMaxSize : checks . DefaultBufSize ,
2018-09-27 13:33:12 +00:00
} ,
} ,
Proxy : & structs . ConnectProxyConfig {
2019-09-26 02:55:52 +00:00
Expose : structs . ExposeConfig {
Checks : true ,
Paths : [ ] structs . ExposePath {
{
Path : "/health" ,
LocalPathPort : 8080 ,
ListenerPort : 21500 ,
Protocol : "http" ,
} ,
} ,
} ,
2018-09-27 13:33:12 +00:00
Upstreams : structs . Upstreams {
structs . Upstream {
DestinationType : "service" ,
DestinationName : "db" ,
LocalBindPort : 7000 ,
} ,
} ,
} ,
2018-10-04 13:08:12 +00:00
Weights : & structs . Weights {
Passing : 1 ,
Warning : 1 ,
} ,
2019-12-10 02:26:41 +00:00
EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) ,
2018-09-27 13:33:12 +00:00
} ,
} ,
2018-10-04 13:08:12 +00:00
Weights : & structs . Weights {
Passing : 1 ,
Warning : 1 ,
} ,
2019-12-10 02:26:41 +00:00
EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) ,
2018-09-27 13:33:12 +00:00
} ,
}
} ,
} ,
2018-12-06 21:51:49 +00:00
{
// This tests checks that VerifyServerHostname implies VerifyOutgoing
desc : "verify_server_hostname implies verify_outgoing" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"verify_server_hostname" : true
} ` } ,
hcl : [ ] string { `
verify_server_hostname = true
` } ,
patch : func ( rt * RuntimeConfig ) {
rt . DataDir = dataDir
rt . VerifyServerHostname = true
rt . VerifyOutgoing = true
} ,
} ,
2019-08-27 12:36:36 +00:00
{
desc : "auto_encrypt.allow works implies connect" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"verify_incoming" : true ,
"auto_encrypt" : { "allow_tls" : true }
} ` } ,
hcl : [ ] string { `
verify_incoming = true
auto_encrypt { allow_tls = true }
` } ,
patch : func ( rt * RuntimeConfig ) {
rt . DataDir = dataDir
rt . VerifyIncoming = true
rt . AutoEncryptAllowTLS = true
rt . ConnectEnabled = true
} ,
} ,
{
desc : "auto_encrypt.allow works with verify_incoming" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"verify_incoming" : true ,
"auto_encrypt" : { "allow_tls" : true }
} ` } ,
hcl : [ ] string { `
verify_incoming = true
auto_encrypt { allow_tls = true }
` } ,
patch : func ( rt * RuntimeConfig ) {
rt . DataDir = dataDir
rt . VerifyIncoming = true
rt . AutoEncryptAllowTLS = true
rt . ConnectEnabled = true
} ,
} ,
{
desc : "auto_encrypt.allow works with verify_incoming_rpc" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"verify_incoming_rpc" : true ,
"auto_encrypt" : { "allow_tls" : true }
} ` } ,
hcl : [ ] string { `
verify_incoming_rpc = true
auto_encrypt { allow_tls = true }
` } ,
patch : func ( rt * RuntimeConfig ) {
rt . DataDir = dataDir
rt . VerifyIncomingRPC = true
rt . AutoEncryptAllowTLS = true
rt . ConnectEnabled = true
} ,
} ,
{
2019-12-06 20:36:13 +00:00
desc : "auto_encrypt.allow warns without verify_incoming or verify_incoming_rpc" ,
2019-08-27 12:36:36 +00:00
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"auto_encrypt" : { "allow_tls" : true }
} ` } ,
hcl : [ ] string { `
auto_encrypt { allow_tls = true }
` } ,
2019-12-06 20:36:13 +00:00
warns : [ ] string { "if auto_encrypt.allow_tls is turned on, either verify_incoming or verify_incoming_rpc should be enabled. It is necessary to turn it off during a migration to TLS, but it should definitely be turned on afterwards." } ,
patch : func ( rt * RuntimeConfig ) {
rt . DataDir = dataDir
rt . AutoEncryptAllowTLS = true
rt . ConnectEnabled = true
} ,
2019-08-27 12:36:36 +00:00
} ,
2019-01-08 16:09:22 +00:00
{
desc : "test connect vault provider configuration" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"connect" : {
"enabled" : true ,
"ca_provider" : "vault" ,
"ca_config" : {
"ca_file" : "/capath/ca.pem" ,
"ca_path" : "/capath/" ,
"cert_file" : "/certpath/cert.pem" ,
"key_file" : "/certpath/key.pem" ,
"tls_server_name" : "server.name" ,
"tls_skip_verify" : true ,
"token" : "abc" ,
"root_pki_path" : "consul-vault" ,
"intermediate_pki_path" : "connect-intermediate"
}
}
} ` } ,
hcl : [ ] string { `
connect {
enabled = true
ca_provider = "vault"
ca_config {
ca_file = "/capath/ca.pem"
ca_path = "/capath/"
cert_file = "/certpath/cert.pem"
key_file = "/certpath/key.pem"
tls_server_name = "server.name"
tls_skip_verify = true
token = "abc"
root_pki_path = "consul-vault"
intermediate_pki_path = "connect-intermediate"
}
}
` } ,
patch : func ( rt * RuntimeConfig ) {
rt . DataDir = dataDir
rt . ConnectEnabled = true
rt . ConnectCAProvider = "vault"
rt . ConnectCAConfig = map [ string ] interface { } {
"CAFile" : "/capath/ca.pem" ,
"CAPath" : "/capath/" ,
"CertFile" : "/certpath/cert.pem" ,
"KeyFile" : "/certpath/key.pem" ,
"TLSServerName" : "server.name" ,
"TLSSkipVerify" : true ,
"Token" : "abc" ,
"RootPKIPath" : "consul-vault" ,
"IntermediatePKIPath" : "connect-intermediate" ,
}
} ,
} ,
2019-11-21 17:40:29 +00:00
{
desc : "Connect AWS CA provider configuration" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"connect" : {
"enabled" : true ,
"ca_provider" : "aws-pca" ,
"ca_config" : {
"existing_arn" : "foo" ,
"delete_on_exit" : true
}
}
} ` } ,
hcl : [ ] string { `
connect {
enabled = true
ca_provider = "aws-pca"
ca_config {
existing_arn = "foo"
delete_on_exit = true
}
}
` } ,
patch : func ( rt * RuntimeConfig ) {
rt . DataDir = dataDir
rt . ConnectEnabled = true
rt . ConnectCAProvider = "aws-pca"
rt . ConnectCAConfig = map [ string ] interface { } {
"ExistingARN" : "foo" ,
"DeleteOnExit" : true ,
}
} ,
} ,
{
desc : "Connect AWS CA provider TTL validation" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"connect" : {
"enabled" : true ,
"ca_provider" : "aws-pca" ,
"ca_config" : {
"leaf_cert_ttl" : "1h"
}
}
} ` } ,
hcl : [ ] string { `
connect {
enabled = true
ca_provider = "aws-pca"
ca_config {
leaf_cert_ttl = "1h"
}
}
` } ,
err : "AWS PCA doesn't support certificates that are valid for less than 24 hours" ,
} ,
{
desc : "Connect AWS CA provider EC key length validation" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
json : [ ] string { ` {
"connect" : {
"enabled" : true ,
"ca_provider" : "aws-pca" ,
"ca_config" : {
"private_key_bits" : 521
}
}
} ` } ,
hcl : [ ] string { `
connect {
enabled = true
ca_provider = "aws-pca"
ca_config {
private_key_bits = 521
}
}
` } ,
err : "AWS PCA only supports P256 EC curve" ,
} ,
2019-04-30 14:13:59 +00:00
// ------------------------------------------------------------
// ConfigEntry Handling
//
{
desc : "ConfigEntry bootstrap doesn't parse" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` {
"config_entries" : {
"bootstrap" : [
{
"foo" : "bar"
}
]
}
} ` } ,
hcl : [ ] string { `
config_entries {
bootstrap {
foo = "bar"
}
} ` } ,
2019-07-12 17:20:30 +00:00
err : "config_entries.bootstrap[0]: Payload does not contain a kind/Kind" ,
2019-04-30 14:13:59 +00:00
} ,
{
desc : "ConfigEntry bootstrap unknown kind" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` {
"config_entries" : {
"bootstrap" : [
{
"kind" : "foo" ,
"name" : "bar" ,
"baz" : 1
}
]
}
} ` } ,
hcl : [ ] string { `
config_entries {
bootstrap {
kind = "foo"
name = "bar"
baz = 1
}
} ` } ,
err : "config_entries.bootstrap[0]: invalid config entry kind: foo" ,
} ,
{
desc : "ConfigEntry bootstrap invalid" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` {
"config_entries" : {
"bootstrap" : [
{
"kind" : "proxy-defaults" ,
"name" : "invalid-name" ,
"config" : {
"foo" : "bar"
}
}
]
}
} ` } ,
hcl : [ ] string { `
config_entries {
bootstrap {
kind = "proxy-defaults"
name = "invalid-name"
config {
foo = "bar"
}
}
} ` } ,
err : "config_entries.bootstrap[0]: invalid name (\"invalid-name\"), only \"global\" is supported" ,
} ,
2019-07-12 17:20:30 +00:00
{
desc : "ConfigEntry bootstrap proxy-defaults (snake-case)" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` {
"config_entries" : {
"bootstrap" : [
{
"kind" : "proxy-defaults" ,
"name" : "global" ,
"config" : {
"bar" : "abc" ,
"moreconfig" : {
"moar" : "config"
}
} ,
"mesh_gateway" : {
"mode" : "remote"
}
}
]
}
} ` } ,
hcl : [ ] string { `
config_entries {
bootstrap {
kind = "proxy-defaults"
name = "global"
config {
"bar" = "abc"
"moreconfig" {
"moar" = "config"
}
}
mesh_gateway {
mode = "remote"
}
}
} ` } ,
patch : func ( rt * RuntimeConfig ) {
rt . DataDir = dataDir
rt . ConfigEntryBootstrap = [ ] structs . ConfigEntry {
& structs . ProxyConfigEntry {
Kind : structs . ProxyDefaults ,
Name : structs . ProxyConfigGlobal ,
Config : map [ string ] interface { } {
"bar" : "abc" ,
"moreconfig" : map [ string ] interface { } {
"moar" : "config" ,
} ,
} ,
MeshGateway : structs . MeshGatewayConfig {
Mode : structs . MeshGatewayModeRemote ,
} ,
} ,
}
} ,
} ,
{
desc : "ConfigEntry bootstrap proxy-defaults (camel-case)" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` {
"config_entries" : {
"bootstrap" : [
{
"Kind" : "proxy-defaults" ,
"Name" : "global" ,
"Config" : {
"bar" : "abc" ,
"moreconfig" : {
"moar" : "config"
}
} ,
"MeshGateway" : {
"Mode" : "remote"
}
}
]
}
} ` } ,
hcl : [ ] string { `
config_entries {
bootstrap {
Kind = "proxy-defaults"
Name = "global"
Config {
"bar" = "abc"
"moreconfig" {
"moar" = "config"
}
}
MeshGateway {
Mode = "remote"
}
}
} ` } ,
patch : func ( rt * RuntimeConfig ) {
rt . DataDir = dataDir
rt . ConfigEntryBootstrap = [ ] structs . ConfigEntry {
& structs . ProxyConfigEntry {
Kind : structs . ProxyDefaults ,
Name : structs . ProxyConfigGlobal ,
Config : map [ string ] interface { } {
"bar" : "abc" ,
"moreconfig" : map [ string ] interface { } {
"moar" : "config" ,
} ,
} ,
MeshGateway : structs . MeshGatewayConfig {
Mode : structs . MeshGatewayModeRemote ,
} ,
} ,
}
} ,
} ,
{
desc : "ConfigEntry bootstrap service-defaults (snake-case)" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` {
"config_entries" : {
"bootstrap" : [
{
"kind" : "service-defaults" ,
"name" : "web" ,
"protocol" : "http" ,
2019-08-19 17:19:44 +00:00
"external_sni" : "abc-123" ,
2019-07-12 17:20:30 +00:00
"mesh_gateway" : {
"mode" : "remote"
}
}
]
}
} ` } ,
hcl : [ ] string { `
config_entries {
bootstrap {
kind = "service-defaults"
name = "web"
protocol = "http"
2019-08-19 17:19:44 +00:00
external_sni = "abc-123"
2019-07-12 17:20:30 +00:00
mesh_gateway {
mode = "remote"
}
}
} ` } ,
patch : func ( rt * RuntimeConfig ) {
rt . DataDir = dataDir
rt . ConfigEntryBootstrap = [ ] structs . ConfigEntry {
& structs . ServiceConfigEntry {
2019-08-19 17:19:44 +00:00
Kind : structs . ServiceDefaults ,
Name : "web" ,
Protocol : "http" ,
ExternalSNI : "abc-123" ,
2019-07-12 17:20:30 +00:00
MeshGateway : structs . MeshGatewayConfig {
Mode : structs . MeshGatewayModeRemote ,
} ,
} ,
}
} ,
} ,
{
desc : "ConfigEntry bootstrap service-defaults (camel-case)" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` {
"config_entries" : {
"bootstrap" : [
{
"Kind" : "service-defaults" ,
"Name" : "web" ,
"Protocol" : "http" ,
2019-08-19 17:19:44 +00:00
"ExternalSNI" : "abc-123" ,
2019-07-12 17:20:30 +00:00
"MeshGateway" : {
"Mode" : "remote"
}
}
]
}
} ` } ,
hcl : [ ] string { `
config_entries {
bootstrap {
Kind = "service-defaults"
Name = "web"
Protocol = "http"
2019-08-19 17:19:44 +00:00
ExternalSNI = "abc-123"
2019-07-12 17:20:30 +00:00
MeshGateway {
Mode = "remote"
}
}
} ` } ,
patch : func ( rt * RuntimeConfig ) {
rt . DataDir = dataDir
rt . ConfigEntryBootstrap = [ ] structs . ConfigEntry {
& structs . ServiceConfigEntry {
2019-08-19 17:19:44 +00:00
Kind : structs . ServiceDefaults ,
Name : "web" ,
Protocol : "http" ,
ExternalSNI : "abc-123" ,
2019-07-12 17:20:30 +00:00
MeshGateway : structs . MeshGatewayConfig {
Mode : structs . MeshGatewayModeRemote ,
} ,
} ,
}
} ,
} ,
{
desc : "ConfigEntry bootstrap service-router (snake-case)" ,
args : [ ] string { ` -data-dir= ` + dataDir } ,
json : [ ] string { ` {
"config_entries" : {
"bootstrap" : [
{
"kind" : "service-router" ,
"name" : "main" ,
"routes" : [
{
"match" : {
"http" : {
"path_exact" : "/foo" ,
"header" : [
{
"name" : "debug1" ,
"present" : true
} ,
{
"name" : "debug2" ,
2019-07-24 01:50:23 +00:00
"present" : true ,
2019-07-12 17:20:30 +00:00
"invert" : true
} ,
{
"name" : "debug3" ,
"exact" : "1"
} ,
{
"name" : "debug4" ,
"prefix" : "aaa"
} ,
{
"name" : "debug5" ,
"suffix" : "bbb"
} ,
{
"name" : "debug6" ,
"regex" : "a.*z"
}
]
}
} ,
"destination" : {
"service" : "carrot" ,
"service_subset" : "kale" ,
"namespace" : "leek" ,
"prefix_rewrite" : "/alternate" ,
"request_timeout" : "99s" ,
"num_retries" : 12345 ,
"retry_on_connect_failure" : true ,
"retry_on_status_codes" : [ 401 , 209 ]
}
} ,
{
"match" : {
"http" : {
"path_prefix" : "/foo" ,
2019-07-24 01:56:39 +00:00
"methods" : [ "GET" , "DELETE" ] ,
2019-07-12 17:20:30 +00:00
"query_param" : [
{
2019-07-24 01:55:26 +00:00
"name" : "hack1" ,
"present" : true
2019-07-12 17:20:30 +00:00
} ,
{
"name" : "hack2" ,
2019-07-24 01:55:26 +00:00
"exact" : "1"
2019-07-12 17:20:30 +00:00
} ,
{
"name" : "hack3" ,
2019-07-24 01:55:26 +00:00
"regex" : "a.*z"
2019-07-12 17:20:30 +00:00
}
]
}
}
} ,
{
"match" : {
"http" : {
"path_regex" : "/foo"
}
}
}
]
}
]
}
} ` } ,
hcl : [ ] string { `
config_entries {
bootstrap {
kind = "service-router"
name = "main"
routes = [
{
match {
http {
path_exact = "/foo"
header = [
{
name = "debug1"
present = true
} ,
{
name = "debug2"
2019-07-24 01:50:23 +00:00
present = true
2019-07-12 17:20:30 +00:00
invert = true
} ,
{
name = "debug3"
exact = "1"
} ,
{
name = "debug4"
prefix = "aaa"
} ,
{
name = "debug5"
suffix = "bbb"
} ,
{
name = "debug6"
regex = "a.*z"
} ,
]
}
}
destination {
service = "carrot"
service_subset = "kale"
namespace = "leek"
prefix_rewrite = "/alternate"
request_timeout = "99s"
num_retries = 12345
retry_on_connect_failure = true
retry_on_status_codes = [ 401 , 209 ]
}
} ,
{
match {
http {
path_prefix = "/foo"
2019-07-24 01:56:39 +00:00
methods = [ "GET" , "DELETE" ]
2019-07-12 17:20:30 +00:00
query_param = [
{
name = "hack1"
2019-07-24 01:55:26 +00:00
present = true
2019-07-12 17:20:30 +00:00
} ,
{
name = "hack2"
2019-07-24 01:55:26 +00:00
exact = "1"
2019-07-12 17:20:30 +00:00
} ,
{
name = "hack3"
2019-07-24 01:55:26 +00:00
regex = "a.*z"
2019-07-12 17:20:30 +00:00
} ,
]
}
}
} ,
{
match {
http {
path_regex = "/foo"
}
}
} ,
]
}
} ` } ,
patch : func ( rt * RuntimeConfig ) {
rt . DataDir = dataDir
rt . ConfigEntryBootstrap = [ ] structs . ConfigEntry {
& structs . ServiceRouterConfigEntry {
Kind : structs . ServiceRouter ,
Name : "main" ,
Routes : [ ] structs . ServiceRoute {
{
Match : & structs . ServiceRouteMatch {
HTTP : & structs . ServiceRouteHTTPMatch {
PathExact : "/foo" ,
Header : [ ] structs . ServiceRouteHTTPMatchHeader {
{
Name : "debug1" ,
Present : true ,
} ,
{
Name : "debug2" ,
2019-07-24 01:50:23 +00:00
Present : true ,
2019-07-12 17:20:30 +00:00
Invert : true ,
} ,
{
Name : "debug3" ,
Exact : "1" ,
} ,
{
Name : "debug4" ,
Prefix : "aaa" ,
} ,
{
Name : "debug5" ,
Suffix : "bbb" ,
} ,
{
Name : "debug6" ,
Regex : "a.*z" ,
} ,
} ,
} ,
} ,
Destination : & structs . ServiceRouteDestination {
Service : "carrot" ,
ServiceSubset : "kale" ,
Namespace : "leek" ,
PrefixRewrite : "/alternate" ,
RequestTimeout : 99 * time . Second ,
NumRetries : 12345 ,
RetryOnConnectFailure : true ,
RetryOnStatusCodes : [ ] uint32 { 401 , 209 } ,
} ,
} ,
{
Match : & structs . ServiceRouteMatch {
HTTP : & structs . ServiceRouteHTTPMatch {
PathPrefix : "/foo" ,
2019-07-24 01:56:39 +00:00
Methods : [ ] string { "GET" , "DELETE" } ,
2019-07-12 17:20:30 +00:00
QueryParam : [ ] structs . ServiceRouteHTTPMatchQueryParam {
{
2019-07-24 01:55:26 +00:00
Name : "hack1" ,
Present : true ,
2019-07-12 17:20:30 +00:00
} ,
{
Name : "hack2" ,
2019-07-24 01:55:26 +00:00
Exact : "1" ,
2019-07-12 17:20:30 +00:00
} ,
{
Name : "hack3" ,
2019-07-24 01:55:26 +00:00
Regex : "a.*z" ,
2019-07-12 17:20:30 +00:00
} ,
} ,
} ,
} ,
} ,
{
Match : & structs . ServiceRouteMatch {
HTTP : & structs . ServiceRouteHTTPMatch {
PathRegex : "/foo" ,
} ,
} ,
} ,
} ,
} ,
}
} ,
} ,
2020-01-31 16:19:37 +00:00
///////////////////////////////////
// Defaults sanity checks
{
desc : "default limits" ,
args : [ ] string {
` -data-dir= ` + dataDir ,
} ,
patch : func ( rt * RuntimeConfig ) {
rt . DataDir = dataDir
// Note that in the happy case this test will pass even if you comment
// out all the stuff below since rt is also initialized from the
// defaults. But it's still valuable as it will fail as soon as the
// defaults are changed from these values forcing that change to be
// intentional.
rt . RPCHandshakeTimeout = 5 * time . Second
rt . HTTPSHandshakeTimeout = 5 * time . Second
rt . HTTPMaxConnsPerClient = 100
rt . RPCMaxConnsPerClient = 100
} ,
} ,
2017-09-25 18:40:42 +00:00
}
testConfig ( t , tests , dataDir )
}
func testConfig ( t * testing . T , tests [ ] configTest , dataDir string ) {
2019-07-12 17:20:30 +00:00
t . Helper ( )
2017-09-25 18:40:42 +00:00
for _ , tt := range tests {
for pass , format := range [ ] string { "json" , "hcl" } {
2017-10-31 22:30:01 +00:00
// clean data dir before every test
cleanDir ( dataDir )
2017-09-25 18:40:42 +00:00
// when we test only flags then there are no JSON or HCL
// sources and we need to make only one pass over the
// tests.
flagsOnly := len ( tt . json ) == 0 && len ( tt . hcl ) == 0
if flagsOnly && pass > 0 {
continue
}
// json and hcl sources need to be in sync
// to make sure we're generating the same config
2018-05-05 18:10:24 +00:00
if len ( tt . json ) != len ( tt . hcl ) && ! tt . skipformat {
2017-09-25 18:40:42 +00:00
t . Fatal ( tt . desc , ": JSON and HCL test case out of sync" )
}
// select the source
srcs , tails := tt . json , tt . jsontail
if format == "hcl" {
srcs , tails = tt . hcl , tt . hcltail
}
2018-05-05 18:10:24 +00:00
// If we're skipping a format and the current format is empty,
// then skip it!
if tt . skipformat && len ( srcs ) == 0 {
continue
}
2017-09-25 18:40:42 +00:00
// build the description
var desc [ ] string
if ! flagsOnly {
desc = append ( desc , format )
}
if tt . desc != "" {
desc = append ( desc , tt . desc )
}
t . Run ( strings . Join ( desc , ":" ) , func ( t * testing . T ) {
// first parse the flags
2017-10-20 10:02:05 +00:00
flags := Flags { }
fs := flag . NewFlagSet ( "" , flag . ContinueOnError )
AddFlags ( fs , & flags )
err := fs . Parse ( tt . args )
2017-09-25 18:40:42 +00:00
if err != nil {
t . Fatalf ( "ParseFlags failed: %s" , err )
}
2017-10-20 10:02:05 +00:00
flags . Args = fs . Args ( )
2017-09-25 18:40:42 +00:00
2017-10-31 22:30:01 +00:00
if tt . pre != nil {
tt . pre ( )
}
defer func ( ) {
if tt . post != nil {
tt . post ( )
}
} ( )
2017-09-25 18:40:42 +00:00
// Then create a builder with the flags.
b , err := NewBuilder ( flags )
if err != nil {
t . Fatal ( "NewBuilder" , err )
}
// mock the hostname function unless a mock is provided
b . Hostname = tt . hostname
if b . Hostname == nil {
b . Hostname = func ( ) ( string , error ) { return "nodex" , nil }
}
// mock the ip address detection
privatev4 := tt . privatev4
if privatev4 == nil {
privatev4 = func ( ) ( [ ] * net . IPAddr , error ) {
return [ ] * net . IPAddr { ipAddr ( "10.0.0.1" ) } , nil
}
}
2017-09-27 19:59:47 +00:00
publicv6 := tt . publicv6
if publicv6 == nil {
publicv6 = func ( ) ( [ ] * net . IPAddr , error ) {
return [ ] * net . IPAddr { ipAddr ( "dead:beef::1" ) } , nil
}
}
2017-09-25 18:40:42 +00:00
b . GetPrivateIPv4 = privatev4
2017-09-27 19:59:47 +00:00
b . GetPublicIPv6 = publicv6
2017-09-25 18:40:42 +00:00
// read the source fragements
for i , data := range srcs {
b . Sources = append ( b . Sources , Source {
2017-10-31 22:30:01 +00:00
Name : fmt . Sprintf ( "src-%d.%s" , i , format ) ,
2017-09-25 18:40:42 +00:00
Format : format ,
Data : data ,
} )
}
for i , data := range tails {
b . Tail = append ( b . Tail , Source {
2017-10-31 22:30:01 +00:00
Name : fmt . Sprintf ( "tail-%d.%s" , i , format ) ,
2017-09-25 18:40:42 +00:00
Format : format ,
Data : data ,
} )
}
// build/merge the config fragments
rt , err := b . BuildAndValidate ( )
if err == nil && tt . err != "" {
t . Fatalf ( "got no error want %q" , tt . err )
}
if err != nil && tt . err == "" {
t . Fatalf ( "got error %s want nil" , err )
}
if err == nil && tt . err != "" {
t . Fatalf ( "got nil want error to contain %q" , tt . err )
}
if err != nil && tt . err != "" && ! strings . Contains ( err . Error ( ) , tt . err ) {
t . Fatalf ( "error %q does not contain %q" , err . Error ( ) , tt . err )
}
// check the warnings
if ! verify . Values ( t , "warnings" , b . Warnings , tt . warns ) {
t . FailNow ( )
}
// stop if we expected an error
if tt . err != "" {
return
}
// build a default configuration, then patch the fields we expect to change
// and compare it with the generated configuration. Since the expected
// runtime config has been validated we do not need to validate it again.
x , err := NewBuilder ( Flags { } )
if err != nil {
t . Fatal ( err )
}
x . Hostname = b . Hostname
2017-09-27 19:59:47 +00:00
x . GetPrivateIPv4 = func ( ) ( [ ] * net . IPAddr , error ) { return [ ] * net . IPAddr { ipAddr ( "10.0.0.1" ) } , nil }
x . GetPublicIPv6 = func ( ) ( [ ] * net . IPAddr , error ) { return [ ] * net . IPAddr { ipAddr ( "dead:beef::1" ) } , nil }
2017-09-25 18:40:42 +00:00
patchedRT , err := x . Build ( )
if err != nil {
t . Fatalf ( "build default failed: %s" , err )
}
if tt . patch != nil {
tt . patch ( & patchedRT )
}
// if err := x.Validate(wantRT); err != nil {
// t.Fatalf("validate default failed: %s", err)
// }
if got , want := rt , patchedRT ; ! verify . Values ( t , "" , got , want ) {
t . FailNow ( )
}
} )
}
}
}
// TestFullConfig tests the conversion from a fully populated JSON or
// HCL config file to a RuntimeConfig structure. All fields must be set
// to a unique non-zero value.
//
// To aid populating the fields the following bash functions can be used
// to generate random strings and ints:
//
// random-int() { echo $RANDOM }
// random-string() { base64 /dev/urandom | tr -d '/+' | fold -w ${1:-32} | head -n 1 }
//
// To generate a random string of length 8 run the following command in
// a terminal:
//
// random-string 8
//
func TestFullConfig ( t * testing . T ) {
dataDir := testutil . TempDir ( t , "consul" )
defer os . RemoveAll ( dataDir )
2019-01-10 14:27:26 +00:00
cidr := func ( s string ) * net . IPNet {
_ , n , _ := net . ParseCIDR ( s )
return n
}
2017-09-25 18:40:42 +00:00
flagSrc := [ ] string { ` -dev ` }
src := map [ string ] string {
"json" : ` {
"acl_agent_master_token" : "furuQD0b" ,
"acl_agent_token" : "cOshLOQ2" ,
"acl_datacenter" : "m3urck3z" ,
"acl_default_policy" : "ArK3WIfE" ,
"acl_down_policy" : "vZXMfMP0" ,
"acl_enforce_version_8" : true ,
2018-10-19 16:04:07 +00:00
"acl_enable_key_list_policy" : true ,
2017-09-25 18:40:42 +00:00
"acl_master_token" : "C1Q1oIwh" ,
"acl_replication_token" : "LMmgy5dO" ,
"acl_token" : "O1El0wan" ,
"acl_ttl" : "18060s" ,
2018-10-19 16:04:07 +00:00
"acl" : {
"enabled" : true ,
"down_policy" : "03eb2aee" ,
"default_policy" : "72c2e7a0" ,
2019-12-10 02:26:41 +00:00
"enable_key_list_policy" : true ,
2019-02-27 19:28:31 +00:00
"enable_token_persistence" : true ,
2018-10-19 16:04:07 +00:00
"policy_ttl" : "1123s" ,
2019-04-15 20:43:19 +00:00
"role_ttl" : "9876s" ,
2018-10-19 16:04:07 +00:00
"token_ttl" : "3321s" ,
"enable_token_replication" : true ,
"tokens" : {
"master" : "8a19ac27" ,
"agent_master" : "64fd0e08" ,
"replication" : "5795983a" ,
"agent" : "bed2377c" ,
"default" : "418fdff1"
}
} ,
2017-09-25 18:40:42 +00:00
"addresses" : {
"dns" : "93.95.95.81" ,
"http" : "83.39.91.39" ,
2018-10-03 13:05:28 +00:00
"https" : "95.17.17.19" ,
"grpc" : "32.31.61.91"
2017-09-25 18:40:42 +00:00
} ,
"advertise_addr" : "17.99.29.16" ,
"advertise_addr_wan" : "78.63.37.19" ,
"autopilot" : {
"cleanup_dead_servers" : true ,
"disable_upgrade_migration" : true ,
"last_contact_threshold" : "12705s" ,
"max_trailing_logs" : 17849 ,
2019-10-29 14:04:41 +00:00
"min_quorum" : 3 ,
2017-09-25 18:40:42 +00:00
"redundancy_zone_tag" : "3IsufDJf" ,
"server_stabilization_time" : "23057s" ,
"upgrade_version_tag" : "W9pDwFAL"
} ,
"bind_addr" : "16.99.34.17" ,
"bootstrap" : true ,
"bootstrap_expect" : 53 ,
"ca_file" : "erA7T0PM" ,
"ca_path" : "mQEN1Mfp" ,
"cert_file" : "7s4QAzDk" ,
"check" : {
"id" : "fZaCAXww" ,
"name" : "OOM2eo0f" ,
"notes" : "zXzXI9Gt" ,
"service_id" : "L8G0QNmR" ,
"token" : "oo4BCTgJ" ,
"status" : "qLykAl5u" ,
2017-10-04 23:48:00 +00:00
"args" : [ "f3BemRjy" , "e5zgpef7" ] ,
2017-09-25 18:40:42 +00:00
"http" : "29B93haH" ,
"header" : {
"hBq0zn1q" : [ "2a9o9ZKP" , "vKwA5lR6" ] ,
"f3r6xFtM" : [ "RyuIdDWv" , "QbxEcIUM" ]
} ,
"method" : "Dou0nGT5" ,
2019-06-26 15:43:25 +00:00
"output_max_size" : ` + strconv.Itoa(checks.DefaultBufSize) + ` ,
2017-09-25 18:40:42 +00:00
"tcp" : "JY6fTTcw" ,
"interval" : "18714s" ,
"docker_container_id" : "qF66POS9" ,
"shell" : "sOnDy228" ,
"tls_skip_verify" : true ,
"timeout" : "5954s" ,
"ttl" : "30044s" ,
"deregister_critical_service_after" : "13209s"
} ,
"checks" : [
{
"id" : "uAjE6m9Z" ,
"name" : "QsZRGpYr" ,
"notes" : "VJ7Sk4BY" ,
"service_id" : "lSulPcyz" ,
"token" : "toO59sh8" ,
"status" : "9RlWsXMV" ,
2017-10-04 23:48:00 +00:00
"args" : [ "4BAJttck" , "4D2NPtTQ" ] ,
2017-09-25 18:40:42 +00:00
"http" : "dohLcyQ2" ,
"header" : {
"ZBfTin3L" : [ "1sDbEqYG" , "lJGASsWK" ] ,
"Ui0nU99X" : [ "LMccm3Qe" , "k5H5RggQ" ]
} ,
"method" : "aldrIQ4l" ,
"tcp" : "RJQND605" ,
"interval" : "22164s" ,
2019-06-26 15:43:25 +00:00
"output_max_size" : ` + strconv.Itoa(checks.DefaultBufSize) + ` ,
2017-09-25 18:40:42 +00:00
"docker_container_id" : "ipgdFtjd" ,
"shell" : "qAeOYy0M" ,
"tls_skip_verify" : true ,
"timeout" : "1813s" ,
"ttl" : "21743s" ,
"deregister_critical_service_after" : "14232s"
} ,
{
"id" : "Cqq95BhP" ,
"name" : "3qXpkS0i" ,
"notes" : "sb5qLTex" ,
"service_id" : "CmUUcRna" ,
"token" : "a3nQzHuy" ,
"status" : "irj26nf3" ,
2017-10-04 23:48:00 +00:00
"args" : [ "9s526ogY" , "gSlOHj1w" ] ,
2017-09-25 18:40:42 +00:00
"http" : "yzhgsQ7Y" ,
"header" : {
"zcqwA8dO" : [ "qb1zx0DL" , "sXCxPFsD" ] ,
"qxvdnSE9" : [ "6wBPUYdF" , "YYh8wtSZ" ]
} ,
"method" : "gLrztrNw" ,
"tcp" : "4jG5casb" ,
"interval" : "28767s" ,
2019-06-26 15:43:25 +00:00
"output_max_size" : ` + strconv.Itoa(checks.DefaultBufSize) + ` ,
2017-09-25 18:40:42 +00:00
"docker_container_id" : "THW6u7rL" ,
"shell" : "C1Zt3Zwh" ,
"tls_skip_verify" : true ,
"timeout" : "18506s" ,
"ttl" : "31006s" ,
"deregister_critical_service_after" : "2366s"
}
] ,
"check_update_interval" : "16507s" ,
"client_addr" : "93.83.18.19" ,
2019-04-26 18:25:03 +00:00
"config_entries" : {
2019-04-30 14:13:59 +00:00
"bootstrap" : [
{
"kind" : "proxy-defaults" ,
"name" : "global" ,
"config" : {
2019-04-26 18:25:03 +00:00
"foo" : "bar" ,
"bar" : 1.0
}
}
2019-04-30 14:13:59 +00:00
]
2019-06-27 20:22:07 +00:00
} ,
"auto_encrypt" : {
"tls" : true ,
2020-01-17 22:25:26 +00:00
"dns_san" : [ "a.com" , "b.com" ] ,
"ip_san" : [ "192.168.4.139" , "192.168.4.140" ] ,
2019-06-27 20:22:07 +00:00
"allow_tls" : true
2019-04-26 18:25:03 +00:00
} ,
2018-04-16 15:00:20 +00:00
"connect" : {
2018-06-16 00:59:08 +00:00
"ca_provider" : "consul" ,
2018-04-25 18:34:08 +00:00
"ca_config" : {
2019-01-22 17:19:36 +00:00
"rotation_period" : "90h" ,
2020-01-17 22:27:13 +00:00
"intermediate_cert_ttl" : "8760h" ,
2019-01-22 17:19:36 +00:00
"leaf_cert_ttl" : "1h" ,
"csr_max_per_second" : 100 ,
"csr_max_concurrent" : 2
2018-04-25 18:34:08 +00:00
} ,
2019-08-09 19:19:30 +00:00
"enabled" : true
2018-04-16 15:00:20 +00:00
} ,
2018-07-26 15:39:49 +00:00
"gossip_lan" : {
"gossip_nodes" : 6 ,
"gossip_interval" : "25252s" ,
"retransmit_mult" : 1234 ,
"suspicion_mult" : 1235 ,
"probe_interval" : "101ms" ,
"probe_timeout" : "102ms"
} ,
"gossip_wan" : {
"gossip_nodes" : 2 ,
"gossip_interval" : "6966s" ,
"retransmit_mult" : 16384 ,
"suspicion_mult" : 16385 ,
"probe_interval" : "103ms" ,
"probe_timeout" : "104ms"
} ,
2017-09-25 18:40:42 +00:00
"data_dir" : "` + dataDir + `" ,
"datacenter" : "rzo029wg" ,
2020-01-17 13:20:57 +00:00
"default_query_time" : "16743s" ,
2017-09-25 18:40:42 +00:00
"disable_anonymous_signature" : true ,
"disable_coordinates" : true ,
"disable_host_node_id" : true ,
2018-07-26 12:53:39 +00:00
"disable_http_unprintable_char_filter" : true ,
2017-09-25 18:40:42 +00:00
"disable_keyring_file" : true ,
"disable_remote_exec" : true ,
"disable_update_check" : true ,
2017-10-11 00:04:52 +00:00
"discard_check_output" : true ,
2018-03-30 15:14:44 +00:00
"discovery_max_stale" : "5s" ,
2017-09-25 18:40:42 +00:00
"domain" : "7W1xXSqd" ,
2019-06-27 10:00:37 +00:00
"alt_domain" : "1789hsd" ,
2017-09-25 18:40:42 +00:00
"dns_config" : {
"allow_stale" : true ,
2018-03-06 01:07:42 +00:00
"a_record_limit" : 29907 ,
2017-09-25 18:40:42 +00:00
"disable_compression" : true ,
"enable_truncate" : true ,
"max_stale" : "29685s" ,
"node_ttl" : "7084s" ,
"only_passing" : true ,
"recursor_timeout" : "4427s" ,
"service_ttl" : {
"*" : "32030s"
} ,
2019-02-25 19:06:01 +00:00
"udp_answer_limit" : 29909 ,
"use_cache" : true ,
2019-12-18 15:16:35 +00:00
"cache_max_age" : "5m" ` + entFullDNSJSONConfig + `
2017-09-25 18:40:42 +00:00
} ,
"enable_acl_replication" : true ,
2017-11-08 02:22:09 +00:00
"enable_agent_tls_for_checks" : true ,
2019-04-24 13:11:08 +00:00
"enable_central_service_config" : true ,
2017-09-25 18:40:42 +00:00
"enable_debug" : true ,
"enable_script_checks" : true ,
2018-10-11 12:22:11 +00:00
"enable_local_script_checks" : true ,
2017-09-25 18:40:42 +00:00
"enable_syslog" : true ,
"encrypt" : "A4wELWqH" ,
"encrypt_verify_incoming" : true ,
"encrypt_verify_outgoing" : true ,
"http_config" : {
"block_endpoints" : [ "RBvAFcGD" , "fWOWFznh" ] ,
2019-01-10 14:27:26 +00:00
"allow_write_http_from" : [ "127.0.0.1/8" , "22.33.44.55/32" , "0.0.0.0/0" ] ,
2017-09-25 18:40:42 +00:00
"response_headers" : {
"M6TKa9NP" : "xjuxjOzQ" ,
"JRCrHZed" : "rl0mTx81"
}
} ,
"key_file" : "IEkkwgIA" ,
"leave_on_terminate" : true ,
"limits" : {
2020-01-31 16:19:37 +00:00
"http_max_conns_per_client" : 9283 ,
"https_handshake_timeout" : "2391ms" ,
"rpc_handshake_timeout" : "1932ms" ,
2017-09-25 18:40:42 +00:00
"rpc_rate" : 12029.43 ,
2019-07-24 21:06:39 +00:00
"rpc_max_burst" : 44848 ,
2020-01-31 16:19:37 +00:00
"rpc_max_conns_per_client" : 2954 ,
2019-07-24 21:06:39 +00:00
"kv_max_value_size" : 1234567800000000
2017-09-25 18:40:42 +00:00
} ,
"log_level" : "k1zo9Spt" ,
2020-01-28 23:50:41 +00:00
"log_json" : true ,
2020-01-17 13:20:57 +00:00
"max_query_time" : "18237s" ,
2017-09-25 18:40:42 +00:00
"node_id" : "AsUIlw99" ,
"node_meta" : {
"5mgGQMBk" : "mJLtVMSG" ,
"A7ynFMJB" : "0Nx6RGab"
} ,
"node_name" : "otlLxGaI" ,
"non_voting_server" : true ,
"performance" : {
2017-10-10 22:19:50 +00:00
"leave_drain_time" : "8265s" ,
"raft_multiplier" : 5 ,
"rpc_hold_timeout" : "15707s"
2017-09-25 18:40:42 +00:00
} ,
"pid_file" : "43xN80Km" ,
"ports" : {
"dns" : 7001 ,
"http" : 7999 ,
"https" : 15127 ,
2018-06-06 20:35:44 +00:00
"server" : 3757 ,
2018-10-03 13:05:28 +00:00
"grpc" : 4881 ,
2018-09-27 13:33:12 +00:00
"sidecar_min_port" : 8888 ,
2019-09-26 02:55:52 +00:00
"sidecar_max_port" : 9999 ,
"expose_min_port" : 1111 ,
"expose_max_port" : 2222
2017-09-25 18:40:42 +00:00
} ,
"protocol" : 30793 ,
2018-10-15 16:17:48 +00:00
"primary_datacenter" : "ejtmd43d" ,
2017-09-25 18:40:42 +00:00
"raft_protocol" : 19016 ,
2018-05-10 15:27:18 +00:00
"raft_snapshot_threshold" : 16384 ,
2018-05-10 22:06:47 +00:00
"raft_snapshot_interval" : "30s" ,
2019-07-23 14:19:57 +00:00
"raft_trailing_logs" : 83749 ,
2017-09-25 18:40:42 +00:00
"reconnect_timeout" : "23739s" ,
"reconnect_timeout_wan" : "26694s" ,
2017-10-20 13:36:52 +00:00
"recursors" : [ "63.38.39.58" , "92.49.18.18" ] ,
2017-09-25 18:40:42 +00:00
"rejoin_after_leave" : true ,
"retry_interval" : "8067s" ,
"retry_interval_wan" : "28866s" ,
"retry_join" : [ "pbsSFY7U" , "l0qLtWij" ] ,
"retry_join_wan" : [ "PFsR02Ye" , "rJdQIhER" ] ,
"retry_max" : 913 ,
"retry_max_wan" : 23160 ,
"segment" : "BC2NhTDi" ,
"segments" : [
{
"name" : "PExYMe2E" ,
"bind" : "36.73.36.19" ,
"port" : 38295 ,
"rpc_listener" : true ,
"advertise" : "63.39.19.18"
} ,
{
"name" : "UzCvJgup" ,
"bind" : "37.58.38.19" ,
"port" : 39292 ,
"rpc_listener" : true ,
"advertise" : "83.58.26.27"
}
] ,
"serf_lan" : "99.43.63.15" ,
"serf_wan" : "67.88.33.19" ,
"server" : true ,
"server_name" : "Oerr9n1G" ,
"service" : {
"id" : "dLOXpSCI" ,
"name" : "o1ynPkp0" ,
2018-04-24 14:39:43 +00:00
"meta" : {
"mymeta" : "data"
} ,
2019-06-17 14:51:50 +00:00
"tagged_addresses" : {
"lan" : {
"address" : "2d79888a" ,
"port" : 2143
} ,
"wan" : {
"address" : "d4db85e2" ,
"port" : 6109
}
} ,
2017-09-25 18:40:42 +00:00
"tags" : [ "nkwshvM5" , "NTDWn3ek" ] ,
"address" : "cOlSOhbp" ,
"token" : "msy7iWER" ,
"port" : 24237 ,
2018-09-07 14:30:47 +00:00
"weights" : {
"passing" : 100 ,
"warning" : 1
} ,
2017-09-25 18:40:42 +00:00
"enable_tag_override" : true ,
"check" : {
2018-05-07 22:51:05 +00:00
"id" : "RMi85Dv8" ,
2017-09-25 18:40:42 +00:00
"name" : "iehanzuq" ,
"status" : "rCvn53TH" ,
"notes" : "fti5lfF3" ,
2017-10-04 23:48:00 +00:00
"args" : [ "16WRUmwS" , "QWk7j7ae" ] ,
2017-09-25 18:40:42 +00:00
"http" : "dl3Fgme3" ,
"header" : {
"rjm4DEd3" : [ "2m3m2Fls" ] ,
"l4HwQ112" : [ "fk56MNlo" , "dhLK56aZ" ]
} ,
"method" : "9afLm3Mj" ,
"tcp" : "fjiLFqVd" ,
"interval" : "23926s" ,
2019-06-26 15:43:25 +00:00
"output_max_size" : ` + strconv.Itoa(checks.DefaultBufSize) + ` ,
2017-09-25 18:40:42 +00:00
"docker_container_id" : "dO5TtRHk" ,
"shell" : "e6q2ttES" ,
"tls_skip_verify" : true ,
"timeout" : "38483s" ,
"ttl" : "10943s" ,
"deregister_critical_service_after" : "68787s"
} ,
"checks" : [
{
"id" : "Zv99e9Ka" ,
"name" : "sgV4F7Pk" ,
"notes" : "yP5nKbW0" ,
"status" : "7oLMEyfu" ,
2017-10-04 23:48:00 +00:00
"args" : [ "5wEZtZpv" , "0Ihyk8cS" ] ,
2017-09-25 18:40:42 +00:00
"http" : "KyDjGY9H" ,
"header" : {
"gv5qefTz" : [ "5Olo2pMG" , "PvvKWQU5" ] ,
"SHOVq1Vv" : [ "jntFhyym" , "GYJh32pp" ]
} ,
"method" : "T66MFBfR" ,
"tcp" : "bNnNfx2A" ,
"interval" : "22224s" ,
2019-06-26 15:43:25 +00:00
"output_max_size" : ` + strconv.Itoa(checks.DefaultBufSize) + ` ,
2017-09-25 18:40:42 +00:00
"docker_container_id" : "ipgdFtjd" ,
"shell" : "omVZq7Sz" ,
"tls_skip_verify" : true ,
"timeout" : "18913s" ,
"ttl" : "44743s" ,
"deregister_critical_service_after" : "8482s"
} ,
{
"id" : "G79O6Mpr" ,
"name" : "IEqrzrsd" ,
"notes" : "SVqApqeM" ,
"status" : "XXkVoZXt" ,
2017-10-04 23:48:00 +00:00
"args" : [ "wD05Bvao" , "rLYB7kQC" ] ,
2017-09-25 18:40:42 +00:00
"http" : "kyICZsn8" ,
"header" : {
"4ebP5vL4" : [ "G20SrL5Q" , "DwPKlMbo" ] ,
"p2UI34Qz" : [ "UsG1D0Qh" , "NHhRiB6s" ]
} ,
"method" : "ciYHWors" ,
"tcp" : "FfvCwlqH" ,
"interval" : "12356s" ,
2019-06-26 15:43:25 +00:00
"output_max_size" : ` + strconv.Itoa(checks.DefaultBufSize) + ` ,
2017-09-25 18:40:42 +00:00
"docker_container_id" : "HBndBU6R" ,
"shell" : "hVI33JjA" ,
"tls_skip_verify" : true ,
"timeout" : "38282s" ,
"ttl" : "1181s" ,
"deregister_critical_service_after" : "4992s"
}
2018-07-25 18:55:41 +00:00
] ,
"connect" : {
"native" : true
}
2017-09-25 18:40:42 +00:00
} ,
"services" : [
{
"id" : "wI1dzxS4" ,
"name" : "7IszXMQ1" ,
"tags" : [ "0Zwg8l6v" , "zebELdN5" ] ,
"address" : "9RhqPSPB" ,
"token" : "myjKJkWH" ,
"port" : 72219 ,
"enable_tag_override" : true ,
"check" : {
2018-05-07 22:51:05 +00:00
"id" : "qmfeO5if" ,
2017-09-25 18:40:42 +00:00
"name" : "atDGP7n5" ,
"status" : "pDQKEhWL" ,
"notes" : "Yt8EDLev" ,
2017-10-04 23:48:00 +00:00
"args" : [ "81EDZLPa" , "bPY5X8xd" ] ,
2017-09-25 18:40:42 +00:00
"http" : "qzHYvmJO" ,
"header" : {
"UkpmZ3a3" : [ "2dfzXuxZ" ] ,
"cVFpko4u" : [ "gGqdEB6k" , "9LsRo22u" ]
} ,
"method" : "X5DrovFc" ,
"tcp" : "ICbxkpSF" ,
"interval" : "24392s" ,
2019-06-26 15:43:25 +00:00
"output_max_size" : ` + strconv.Itoa(checks.DefaultBufSize) + ` ,
2017-09-25 18:40:42 +00:00
"docker_container_id" : "ZKXr68Yb" ,
"shell" : "CEfzx0Fo" ,
"tls_skip_verify" : true ,
"timeout" : "38333s" ,
"ttl" : "57201s" ,
"deregister_critical_service_after" : "44214s"
2018-09-27 13:33:12 +00:00
} ,
"connect" : {
"sidecar_service" : { }
2017-09-25 18:40:42 +00:00
}
} ,
{
"id" : "MRHVMZuD" ,
"name" : "6L6BVfgH" ,
"tags" : [ "7Ale4y6o" , "PMBW08hy" ] ,
"address" : "R6H6g8h0" ,
"token" : "ZgY8gjMI" ,
"port" : 38292 ,
2018-09-07 14:30:47 +00:00
"weights" : {
"passing" : 1979 ,
"warning" : 6
} ,
2017-09-25 18:40:42 +00:00
"enable_tag_override" : true ,
"checks" : [
{
"id" : "GTti9hCo" ,
"name" : "9OOS93ne" ,
"notes" : "CQy86DH0" ,
"status" : "P0SWDvrk" ,
2017-10-04 23:48:00 +00:00
"args" : [ "EXvkYIuG" , "BATOyt6h" ] ,
2017-09-25 18:40:42 +00:00
"http" : "u97ByEiW" ,
"header" : {
"MUlReo8L" : [ "AUZG7wHG" , "gsN0Dc2N" ] ,
"1UJXjVrT" : [ "OJgxzTfk" , "xZZrFsq7" ]
} ,
"method" : "5wkAxCUE" ,
"tcp" : "MN3oA9D2" ,
"interval" : "32718s" ,
2019-06-26 15:43:25 +00:00
"output_max_size" : ` + strconv.Itoa(checks.DefaultBufSize) + ` ,
2017-09-25 18:40:42 +00:00
"docker_container_id" : "cU15LMet" ,
"shell" : "nEz9qz2l" ,
"tls_skip_verify" : true ,
"timeout" : "34738s" ,
"ttl" : "22773s" ,
"deregister_critical_service_after" : "84282s"
} ,
{
"id" : "UHsDeLxG" ,
"name" : "PQSaPWlT" ,
"notes" : "jKChDOdl" ,
"status" : "5qFz6OZn" ,
2017-10-04 23:48:00 +00:00
"args" : [ "NMtYWlT9" , "vj74JXsm" ] ,
2017-09-25 18:40:42 +00:00
"http" : "1LBDJhw4" ,
"header" : {
"cXPmnv1M" : [ "imDqfaBx" , "NFxZ1bQe" ] ,
"vr7wY7CS" : [ "EtCoNPPL" , "9vAarJ5s" ]
} ,
"method" : "wzByP903" ,
"tcp" : "2exjZIGE" ,
"interval" : "5656s" ,
2019-06-26 15:43:25 +00:00
"output_max_size" : ` + strconv.Itoa(checks.DefaultBufSize) + ` ,
2017-09-25 18:40:42 +00:00
"docker_container_id" : "5tDBWpfA" ,
"shell" : "rlTpLM8s" ,
"tls_skip_verify" : true ,
"timeout" : "4868s" ,
"ttl" : "11222s" ,
"deregister_critical_service_after" : "68482s"
}
2018-04-16 15:00:20 +00:00
] ,
2019-08-09 19:19:30 +00:00
"connect" : { }
2018-07-25 18:55:41 +00:00
} ,
{
"id" : "Kh81CPF6" ,
2018-09-12 16:07:47 +00:00
"kind" : "connect-proxy" ,
2018-07-25 18:55:41 +00:00
"name" : "Kh81CPF6-proxy" ,
"port" : 31471 ,
2018-09-12 16:07:47 +00:00
"proxy" : {
"config" : {
"cedGGtZf" : "pWrUNiWw"
} ,
"destination_service_id" : "6L6BVfgH-id" ,
"destination_service_name" : "6L6BVfgH" ,
"local_service_address" : "127.0.0.2" ,
"local_service_port" : 23759 ,
2019-09-26 02:55:52 +00:00
"expose" : {
"checks" : true ,
"paths" : [
{
"path" : "/health" ,
"local_path_port" : 8080 ,
"listener_port" : 21500 ,
"protocol" : "http"
}
]
} ,
2018-09-12 16:07:47 +00:00
"upstreams" : [
{
"destination_name" : "KPtAj2cb" ,
"local_bind_port" : 4051 ,
"config" : {
"kzRnZOyd" : "nUNKoL8H"
}
} ,
{
"destination_name" : "KSd8HsRl" ,
"destination_namespace" : "9nakw0td" ,
"destination_type" : "prepared_query" ,
"local_bind_address" : "127.24.88.0" ,
"local_bind_port" : 11884
}
]
}
2019-06-18 00:52:01 +00:00
} ,
{
"id" : "kvVqbwSE" ,
"kind" : "mesh-gateway" ,
"name" : "gw-primary-dc" ,
"port" : 27147 ,
"proxy" : {
"config" : {
"1CuJHVfw" : "Kzqsa7yc"
}
}
2017-09-25 18:40:42 +00:00
}
] ,
"session_ttl_min" : "26627s" ,
"skip_leave_on_interrupt" : true ,
"start_join" : [ "LR3hGDoG" , "MwVpZ4Up" ] ,
"start_join_wan" : [ "EbFSc3nA" , "kwXTh623" ] ,
"syslog_facility" : "hHv79Uia" ,
"tagged_addresses" : {
"7MYgHrYH" : "dALJAhLD" ,
"h6DdBy6K" : "ebrr9zZ8"
} ,
"telemetry" : {
"circonus_api_app" : "p4QOTe9j" ,
"circonus_api_token" : "E3j35V23" ,
"circonus_api_url" : "mEMjHpGg" ,
"circonus_broker_id" : "BHlxUhed" ,
"circonus_broker_select_tag" : "13xy1gHm" ,
"circonus_check_display_name" : "DRSlQR6n" ,
"circonus_check_force_metric_activation" : "Ua5FGVYf" ,
"circonus_check_id" : "kGorutad" ,
"circonus_check_instance_id" : "rwoOL6R4" ,
"circonus_check_search_tag" : "ovT4hT4f" ,
"circonus_check_tags" : "prvO4uBl" ,
"circonus_submission_interval" : "DolzaflP" ,
"circonus_submission_url" : "gTcbS93G" ,
"disable_hostname" : true ,
"dogstatsd_addr" : "0wSndumK" ,
"dogstatsd_tags" : [ "3N81zSUB" , "Xtj8AnXZ" ] ,
"filter_default" : true ,
"prefix_filter" : [ "+oJotS8XJ" , "-cazlEhGn" ] ,
2017-09-27 00:49:55 +00:00
"metrics_prefix" : "ftO6DySn" ,
2018-04-06 12:21:05 +00:00
"prometheus_retention_time" : "15s" ,
2017-09-25 18:40:42 +00:00
"statsd_address" : "drce87cy" ,
2017-09-27 00:49:55 +00:00
"statsite_address" : "HpFwKB8R"
2017-09-25 18:40:42 +00:00
} ,
2018-03-13 16:50:41 +00:00
"tls_cipher_suites" : "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" ,
2017-09-25 18:40:42 +00:00
"tls_min_version" : "pAOWafkR" ,
"tls_prefer_server_cipher_suites" : true ,
"translate_wan_addrs" : true ,
2017-09-26 06:58:54 +00:00
"ui" : true ,
2017-09-25 18:40:42 +00:00
"ui_dir" : "11IFzAUn" ,
2019-10-09 14:14:48 +00:00
"ui_content_path" : "consul" ,
2017-09-25 18:40:42 +00:00
"unix_sockets" : {
"group" : "8pFodrV8" ,
"mode" : "E8sAwOv4" ,
"user" : "E0nB1DwA"
} ,
"verify_incoming" : true ,
"verify_incoming_https" : true ,
"verify_incoming_rpc" : true ,
"verify_outgoing" : true ,
"verify_server_hostname" : true ,
"watches" : [
{
"type" : "key" ,
"datacenter" : "GyE6jpeW" ,
"key" : "j9lF1Tve" ,
"handler" : "90N7S4LN"
2017-10-04 23:48:00 +00:00
} , {
"type" : "keyprefix" ,
"datacenter" : "fYrl3F5d" ,
"key" : "sl3Dffu7" ,
"args" : [ "dltjDJ2a" , "flEa7C2d" ]
2017-09-25 18:40:42 +00:00
}
]
} ` ,
"hcl" : `
acl_agent_master_token = "furuQD0b"
acl_agent_token = "cOshLOQ2"
acl_datacenter = "m3urck3z"
acl_default_policy = "ArK3WIfE"
acl_down_policy = "vZXMfMP0"
acl_enforce_version_8 = true
2019-02-27 19:28:31 +00:00
acl_enable_key_list_policy = true
2017-09-25 18:40:42 +00:00
acl_master_token = "C1Q1oIwh"
acl_replication_token = "LMmgy5dO"
acl_token = "O1El0wan"
acl_ttl = "18060s"
2018-10-19 16:04:07 +00:00
acl = {
enabled = true
down_policy = "03eb2aee"
default_policy = "72c2e7a0"
2019-12-10 02:26:41 +00:00
enable_key_list_policy = true
2019-02-27 19:28:31 +00:00
enable_token_persistence = true
2018-10-19 16:04:07 +00:00
policy_ttl = "1123s"
2019-04-15 20:43:19 +00:00
role_ttl = "9876s"
2018-10-19 16:04:07 +00:00
token_ttl = "3321s"
enable_token_replication = true
tokens = {
master = "8a19ac27" ,
agent_master = "64fd0e08" ,
replication = "5795983a" ,
agent = "bed2377c" ,
default = "418fdff1"
}
}
2017-09-25 18:40:42 +00:00
addresses = {
dns = "93.95.95.81"
http = "83.39.91.39"
https = "95.17.17.19"
2018-10-03 13:05:28 +00:00
grpc = "32.31.61.91"
2017-09-25 18:40:42 +00:00
}
advertise_addr = "17.99.29.16"
advertise_addr_wan = "78.63.37.19"
autopilot = {
cleanup_dead_servers = true
disable_upgrade_migration = true
last_contact_threshold = "12705s"
max_trailing_logs = 17849
2019-10-29 14:04:41 +00:00
min_quorum = 3
2017-09-25 18:40:42 +00:00
redundancy_zone_tag = "3IsufDJf"
server_stabilization_time = "23057s"
upgrade_version_tag = "W9pDwFAL"
}
bind_addr = "16.99.34.17"
bootstrap = true
bootstrap_expect = 53
ca_file = "erA7T0PM"
ca_path = "mQEN1Mfp"
cert_file = "7s4QAzDk"
check = {
id = "fZaCAXww"
name = "OOM2eo0f"
notes = "zXzXI9Gt"
service_id = "L8G0QNmR"
token = "oo4BCTgJ"
status = "qLykAl5u"
2017-10-04 23:48:00 +00:00
args = [ "f3BemRjy" , "e5zgpef7" ]
2017-09-25 18:40:42 +00:00
http = "29B93haH"
header = {
hBq0zn1q = [ "2a9o9ZKP" , "vKwA5lR6" ]
f3r6xFtM = [ "RyuIdDWv" , "QbxEcIUM" ]
}
method = "Dou0nGT5"
tcp = "JY6fTTcw"
interval = "18714s"
2019-06-26 15:43:25 +00:00
output_max_size = ` + strconv.Itoa(checks.DefaultBufSize) + `
2017-09-25 18:40:42 +00:00
docker_container_id = "qF66POS9"
shell = "sOnDy228"
tls_skip_verify = true
timeout = "5954s"
ttl = "30044s"
deregister_critical_service_after = "13209s"
} ,
checks = [
{
id = "uAjE6m9Z"
name = "QsZRGpYr"
notes = "VJ7Sk4BY"
service_id = "lSulPcyz"
token = "toO59sh8"
status = "9RlWsXMV"
2017-10-04 23:48:00 +00:00
args = [ "4BAJttck" , "4D2NPtTQ" ]
2017-09-25 18:40:42 +00:00
http = "dohLcyQ2"
header = {
"ZBfTin3L" = [ "1sDbEqYG" , "lJGASsWK" ]
"Ui0nU99X" = [ "LMccm3Qe" , "k5H5RggQ" ]
}
method = "aldrIQ4l"
tcp = "RJQND605"
interval = "22164s"
2019-06-26 15:43:25 +00:00
output_max_size = ` + strconv.Itoa(checks.DefaultBufSize) + `
2017-09-25 18:40:42 +00:00
docker_container_id = "ipgdFtjd"
shell = "qAeOYy0M"
tls_skip_verify = true
timeout = "1813s"
ttl = "21743s"
deregister_critical_service_after = "14232s"
} ,
{
id = "Cqq95BhP"
name = "3qXpkS0i"
notes = "sb5qLTex"
service_id = "CmUUcRna"
token = "a3nQzHuy"
status = "irj26nf3"
2017-10-04 23:48:00 +00:00
args = [ "9s526ogY" , "gSlOHj1w" ]
2017-09-25 18:40:42 +00:00
http = "yzhgsQ7Y"
header = {
"zcqwA8dO" = [ "qb1zx0DL" , "sXCxPFsD" ]
"qxvdnSE9" = [ "6wBPUYdF" , "YYh8wtSZ" ]
}
method = "gLrztrNw"
tcp = "4jG5casb"
interval = "28767s"
2019-06-26 15:43:25 +00:00
output_max_size = ` + strconv.Itoa(checks.DefaultBufSize) + `
2017-09-25 18:40:42 +00:00
docker_container_id = "THW6u7rL"
shell = "C1Zt3Zwh"
tls_skip_verify = true
timeout = "18506s"
ttl = "31006s"
deregister_critical_service_after = "2366s"
}
]
check_update_interval = "16507s"
client_addr = "93.83.18.19"
2019-04-26 18:25:03 +00:00
config_entries {
2019-04-30 14:13:59 +00:00
# This is using the repeated block - to - array HCL magic
bootstrap {
kind = "proxy-defaults"
name = "global"
config {
foo = "bar"
bar = 1.0
}
2019-04-26 18:25:03 +00:00
}
}
2019-06-27 20:22:07 +00:00
auto_encrypt = {
tls = true
2020-01-17 22:25:26 +00:00
dns_san = [ "a.com" , "b.com" ]
ip_san = [ "192.168.4.139" , "192.168.4.140" ]
2019-06-27 20:22:07 +00:00
allow_tls = true
}
2018-04-16 15:00:20 +00:00
connect {
2018-06-16 00:59:08 +00:00
ca_provider = "consul"
2018-04-25 18:34:08 +00:00
ca_config {
2018-07-16 09:46:10 +00:00
rotation_period = "90h"
2020-01-17 22:27:13 +00:00
intermediate_cert_ttl = "8760h"
2018-07-16 09:46:10 +00:00
leaf_cert_ttl = "1h"
2019-01-22 17:19:36 +00:00
# hack float since json parses numbers as float and we have to
# assert against the same thing
csr_max_per_second = 100.0
csr_max_concurrent = 2.0
2018-04-25 18:34:08 +00:00
}
2018-04-16 15:00:20 +00:00
enabled = true
}
2018-07-26 15:39:49 +00:00
gossip_lan {
gossip_nodes = 6
gossip_interval = "25252s"
retransmit_mult = 1234
suspicion_mult = 1235
probe_interval = "101ms"
probe_timeout = "102ms"
}
gossip_wan {
gossip_nodes = 2
gossip_interval = "6966s"
retransmit_mult = 16384
suspicion_mult = 16385
probe_interval = "103ms"
probe_timeout = "104ms"
}
2017-09-25 18:40:42 +00:00
data_dir = "` + dataDir + `"
datacenter = "rzo029wg"
2020-01-17 13:20:57 +00:00
default_query_time = "16743s"
2017-09-25 18:40:42 +00:00
disable_anonymous_signature = true
disable_coordinates = true
disable_host_node_id = true
2018-07-26 12:53:39 +00:00
disable_http_unprintable_char_filter = true
2017-09-25 18:40:42 +00:00
disable_keyring_file = true
disable_remote_exec = true
disable_update_check = true
2017-10-11 00:04:52 +00:00
discard_check_output = true
2018-03-30 15:14:44 +00:00
discovery_max_stale = "5s"
2017-09-25 18:40:42 +00:00
domain = "7W1xXSqd"
2019-06-27 10:00:37 +00:00
alt_domain = "1789hsd"
2017-09-25 18:40:42 +00:00
dns_config {
allow_stale = true
2018-03-06 01:07:42 +00:00
a_record_limit = 29907
2017-09-25 18:40:42 +00:00
disable_compression = true
enable_truncate = true
max_stale = "29685s"
node_ttl = "7084s"
only_passing = true
recursor_timeout = "4427s"
service_ttl = {
"*" = "32030s"
}
udp_answer_limit = 29909
2019-02-25 19:06:01 +00:00
use_cache = true
cache_max_age = "5m"
2019-12-18 15:16:35 +00:00
` + entFullDNSHCLConfig + `
2017-09-25 18:40:42 +00:00
}
enable_acl_replication = true
2017-11-08 02:22:09 +00:00
enable_agent_tls_for_checks = true
2019-04-24 13:11:08 +00:00
enable_central_service_config = true
2017-09-25 18:40:42 +00:00
enable_debug = true
enable_script_checks = true
2018-10-11 12:22:11 +00:00
enable_local_script_checks = true
2017-09-25 18:40:42 +00:00
enable_syslog = true
encrypt = "A4wELWqH"
encrypt_verify_incoming = true
encrypt_verify_outgoing = true
http_config {
block_endpoints = [ "RBvAFcGD" , "fWOWFznh" ]
2019-01-10 14:27:26 +00:00
allow_write_http_from = [ "127.0.0.1/8" , "22.33.44.55/32" , "0.0.0.0/0" ]
2017-09-25 18:40:42 +00:00
response_headers = {
"M6TKa9NP" = "xjuxjOzQ"
"JRCrHZed" = "rl0mTx81"
}
}
key_file = "IEkkwgIA"
leave_on_terminate = true
limits {
2020-01-31 16:19:37 +00:00
http_max_conns_per_client = 9283
https_handshake_timeout = "2391ms"
rpc_handshake_timeout = "1932ms"
2017-09-25 18:40:42 +00:00
rpc_rate = 12029.43
rpc_max_burst = 44848
2020-01-31 16:19:37 +00:00
rpc_max_conns_per_client = 2954
2019-07-24 21:06:39 +00:00
kv_max_value_size = 1234567800000000
2017-09-25 18:40:42 +00:00
}
log_level = "k1zo9Spt"
2020-01-28 23:50:41 +00:00
log_json = true
2020-01-17 13:20:57 +00:00
max_query_time = "18237s"
2017-09-25 18:40:42 +00:00
node_id = "AsUIlw99"
node_meta {
"5mgGQMBk" = "mJLtVMSG"
"A7ynFMJB" = "0Nx6RGab"
}
node_name = "otlLxGaI"
non_voting_server = true
performance {
2017-10-10 22:19:50 +00:00
leave_drain_time = "8265s"
2017-09-25 18:40:42 +00:00
raft_multiplier = 5
2017-10-10 22:19:50 +00:00
rpc_hold_timeout = "15707s"
2017-09-25 18:40:42 +00:00
}
pid_file = "43xN80Km"
ports {
2019-09-26 02:55:52 +00:00
dns = 7001
http = 7999
2017-09-25 18:40:42 +00:00
https = 15127
server = 3757
2018-10-03 13:05:28 +00:00
grpc = 4881
2018-06-06 20:35:44 +00:00
proxy_min_port = 2000
proxy_max_port = 3000
2018-09-27 13:33:12 +00:00
sidecar_min_port = 8888
sidecar_max_port = 9999
2019-09-26 02:55:52 +00:00
expose_min_port = 1111
expose_max_port = 2222
2017-09-25 18:40:42 +00:00
}
protocol = 30793
2018-10-15 16:17:48 +00:00
primary_datacenter = "ejtmd43d"
2017-09-25 18:40:42 +00:00
raft_protocol = 19016
2018-05-10 15:27:18 +00:00
raft_snapshot_threshold = 16384
2018-05-10 22:06:47 +00:00
raft_snapshot_interval = "30s"
2019-07-23 14:19:57 +00:00
raft_trailing_logs = 83749
2017-09-25 18:40:42 +00:00
reconnect_timeout = "23739s"
reconnect_timeout_wan = "26694s"
2017-10-20 13:36:52 +00:00
recursors = [ "63.38.39.58" , "92.49.18.18" ]
2017-09-25 18:40:42 +00:00
rejoin_after_leave = true
retry_interval = "8067s"
retry_interval_wan = "28866s"
retry_join = [ "pbsSFY7U" , "l0qLtWij" ]
retry_join_wan = [ "PFsR02Ye" , "rJdQIhER" ]
retry_max = 913
retry_max_wan = 23160
segment = "BC2NhTDi"
segments = [
{
name = "PExYMe2E"
bind = "36.73.36.19"
port = 38295
rpc_listener = true
advertise = "63.39.19.18"
} ,
{
name = "UzCvJgup"
bind = "37.58.38.19"
port = 39292
rpc_listener = true
advertise = "83.58.26.27"
}
]
serf_lan = "99.43.63.15"
serf_wan = "67.88.33.19"
server = true
server_name = "Oerr9n1G"
service = {
id = "dLOXpSCI"
name = "o1ynPkp0"
2018-04-24 14:39:43 +00:00
meta = {
mymeta = "data"
}
2019-06-17 14:51:50 +00:00
tagged_addresses = {
lan = {
address = "2d79888a"
port = 2143
}
wan = {
address = "d4db85e2"
port = 6109
}
}
2017-09-25 18:40:42 +00:00
tags = [ "nkwshvM5" , "NTDWn3ek" ]
address = "cOlSOhbp"
token = "msy7iWER"
port = 24237
2018-09-07 14:30:47 +00:00
weights = {
passing = 100 ,
warning = 1
}
2017-09-25 18:40:42 +00:00
enable_tag_override = true
check = {
2018-05-07 22:51:05 +00:00
id = "RMi85Dv8"
2017-09-25 18:40:42 +00:00
name = "iehanzuq"
status = "rCvn53TH"
notes = "fti5lfF3"
2017-10-04 23:48:00 +00:00
args = [ "16WRUmwS" , "QWk7j7ae" ]
2017-09-25 18:40:42 +00:00
http = "dl3Fgme3"
header = {
rjm4DEd3 = [ "2m3m2Fls" ]
l4HwQ112 = [ "fk56MNlo" , "dhLK56aZ" ]
}
method = "9afLm3Mj"
tcp = "fjiLFqVd"
interval = "23926s"
docker_container_id = "dO5TtRHk"
shell = "e6q2ttES"
tls_skip_verify = true
timeout = "38483s"
ttl = "10943s"
deregister_critical_service_after = "68787s"
}
checks = [
{
id = "Zv99e9Ka"
name = "sgV4F7Pk"
notes = "yP5nKbW0"
status = "7oLMEyfu"
2017-10-04 23:48:00 +00:00
args = [ "5wEZtZpv" , "0Ihyk8cS" ]
2017-09-25 18:40:42 +00:00
http = "KyDjGY9H"
header = {
"gv5qefTz" = [ "5Olo2pMG" , "PvvKWQU5" ]
"SHOVq1Vv" = [ "jntFhyym" , "GYJh32pp" ]
}
method = "T66MFBfR"
tcp = "bNnNfx2A"
interval = "22224s"
2019-06-26 15:43:25 +00:00
output_max_size = ` + strconv.Itoa(checks.DefaultBufSize) + `
2017-09-25 18:40:42 +00:00
docker_container_id = "ipgdFtjd"
shell = "omVZq7Sz"
tls_skip_verify = true
timeout = "18913s"
ttl = "44743s"
deregister_critical_service_after = "8482s"
} ,
{
id = "G79O6Mpr"
name = "IEqrzrsd"
notes = "SVqApqeM"
status = "XXkVoZXt"
2017-10-04 23:48:00 +00:00
args = [ "wD05Bvao" , "rLYB7kQC" ]
2017-09-25 18:40:42 +00:00
http = "kyICZsn8"
header = {
"4ebP5vL4" = [ "G20SrL5Q" , "DwPKlMbo" ]
"p2UI34Qz" = [ "UsG1D0Qh" , "NHhRiB6s" ]
}
method = "ciYHWors"
tcp = "FfvCwlqH"
interval = "12356s"
2019-06-26 15:43:25 +00:00
output_max_size = ` + strconv.Itoa(checks.DefaultBufSize) + `
2017-09-25 18:40:42 +00:00
docker_container_id = "HBndBU6R"
shell = "hVI33JjA"
tls_skip_verify = true
timeout = "38282s"
ttl = "1181s"
deregister_critical_service_after = "4992s"
}
]
2018-07-25 18:55:41 +00:00
connect {
native = true
}
2017-09-25 18:40:42 +00:00
}
services = [
{
id = "wI1dzxS4"
name = "7IszXMQ1"
tags = [ "0Zwg8l6v" , "zebELdN5" ]
address = "9RhqPSPB"
token = "myjKJkWH"
port = 72219
enable_tag_override = true
check = {
2018-05-07 22:51:05 +00:00
id = "qmfeO5if"
2017-09-25 18:40:42 +00:00
name = "atDGP7n5"
status = "pDQKEhWL"
notes = "Yt8EDLev"
2017-10-04 23:48:00 +00:00
args = [ "81EDZLPa" , "bPY5X8xd" ]
2017-09-25 18:40:42 +00:00
http = "qzHYvmJO"
header = {
UkpmZ3a3 = [ "2dfzXuxZ" ]
cVFpko4u = [ "gGqdEB6k" , "9LsRo22u" ]
}
method = "X5DrovFc"
tcp = "ICbxkpSF"
interval = "24392s"
2019-06-26 15:43:25 +00:00
output_max_size = ` + strconv.Itoa(checks.DefaultBufSize) + `
2017-09-25 18:40:42 +00:00
docker_container_id = "ZKXr68Yb"
shell = "CEfzx0Fo"
tls_skip_verify = true
timeout = "38333s"
ttl = "57201s"
deregister_critical_service_after = "44214s"
}
2018-09-27 13:33:12 +00:00
connect {
sidecar_service { }
}
2017-09-25 18:40:42 +00:00
} ,
{
id = "MRHVMZuD"
name = "6L6BVfgH"
tags = [ "7Ale4y6o" , "PMBW08hy" ]
address = "R6H6g8h0"
token = "ZgY8gjMI"
port = 38292
2018-09-07 14:30:47 +00:00
weights = {
passing = 1979 ,
warning = 6
}
2017-09-25 18:40:42 +00:00
enable_tag_override = true
checks = [
{
id = "GTti9hCo"
name = "9OOS93ne"
notes = "CQy86DH0"
status = "P0SWDvrk"
2017-10-04 23:48:00 +00:00
args = [ "EXvkYIuG" , "BATOyt6h" ]
2017-09-25 18:40:42 +00:00
http = "u97ByEiW"
header = {
"MUlReo8L" = [ "AUZG7wHG" , "gsN0Dc2N" ]
"1UJXjVrT" = [ "OJgxzTfk" , "xZZrFsq7" ]
}
method = "5wkAxCUE"
tcp = "MN3oA9D2"
interval = "32718s"
2019-06-26 15:43:25 +00:00
output_max_size = ` + strconv.Itoa(checks.DefaultBufSize) + `
2017-09-25 18:40:42 +00:00
docker_container_id = "cU15LMet"
shell = "nEz9qz2l"
tls_skip_verify = true
timeout = "34738s"
ttl = "22773s"
deregister_critical_service_after = "84282s"
} ,
{
id = "UHsDeLxG"
name = "PQSaPWlT"
notes = "jKChDOdl"
status = "5qFz6OZn"
2017-10-04 23:48:00 +00:00
args = [ "NMtYWlT9" , "vj74JXsm" ]
2017-09-25 18:40:42 +00:00
http = "1LBDJhw4"
header = {
"cXPmnv1M" = [ "imDqfaBx" , "NFxZ1bQe" ] ,
"vr7wY7CS" = [ "EtCoNPPL" , "9vAarJ5s" ]
}
method = "wzByP903"
tcp = "2exjZIGE"
interval = "5656s"
2019-06-26 15:43:25 +00:00
output_max_size = ` + strconv.Itoa(checks.DefaultBufSize) + `
2017-09-25 18:40:42 +00:00
docker_container_id = "5tDBWpfA"
shell = "rlTpLM8s"
tls_skip_verify = true
timeout = "4868s"
ttl = "11222s"
deregister_critical_service_after = "68482s"
}
]
2019-08-09 19:19:30 +00:00
connect { }
2018-07-25 18:55:41 +00:00
} ,
{
id = "Kh81CPF6"
name = "Kh81CPF6-proxy"
port = 31471
kind = "connect-proxy"
2018-09-12 16:07:47 +00:00
proxy {
destination_service_name = "6L6BVfgH"
destination_service_id = "6L6BVfgH-id"
local_service_address = "127.0.0.2"
local_service_port = 23759
config {
cedGGtZf = "pWrUNiWw"
}
upstreams = [
{
destination_name = "KPtAj2cb"
local_bind_port = 4051
config {
kzRnZOyd = "nUNKoL8H"
}
} ,
{
destination_type = "prepared_query"
destination_namespace = "9nakw0td"
destination_name = "KSd8HsRl"
local_bind_port = 11884
local_bind_address = "127.24.88.0"
} ,
]
2019-09-26 02:55:52 +00:00
expose {
checks = true
paths = [
{
path = "/health"
local_path_port = 8080
listener_port = 21500
protocol = "http"
}
]
}
2018-09-12 16:07:47 +00:00
}
2019-06-18 00:52:01 +00:00
} ,
{
id = "kvVqbwSE"
kind = "mesh-gateway"
name = "gw-primary-dc"
port = 27147
proxy {
config {
"1CuJHVfw" = "Kzqsa7yc"
}
}
2017-09-25 18:40:42 +00:00
}
]
session_ttl_min = "26627s"
skip_leave_on_interrupt = true
start_join = [ "LR3hGDoG" , "MwVpZ4Up" ]
start_join_wan = [ "EbFSc3nA" , "kwXTh623" ]
syslog_facility = "hHv79Uia"
tagged_addresses = {
"7MYgHrYH" = "dALJAhLD"
"h6DdBy6K" = "ebrr9zZ8"
}
telemetry {
circonus_api_app = "p4QOTe9j"
circonus_api_token = "E3j35V23"
circonus_api_url = "mEMjHpGg"
circonus_broker_id = "BHlxUhed"
circonus_broker_select_tag = "13xy1gHm"
circonus_check_display_name = "DRSlQR6n"
circonus_check_force_metric_activation = "Ua5FGVYf"
circonus_check_id = "kGorutad"
circonus_check_instance_id = "rwoOL6R4"
circonus_check_search_tag = "ovT4hT4f"
circonus_check_tags = "prvO4uBl"
circonus_submission_interval = "DolzaflP"
circonus_submission_url = "gTcbS93G"
disable_hostname = true
dogstatsd_addr = "0wSndumK"
dogstatsd_tags = [ "3N81zSUB" , "Xtj8AnXZ" ]
filter_default = true
prefix_filter = [ "+oJotS8XJ" , "-cazlEhGn" ]
2017-09-27 00:49:55 +00:00
metrics_prefix = "ftO6DySn"
2018-04-06 12:21:05 +00:00
prometheus_retention_time = "15s"
2017-09-25 18:40:42 +00:00
statsd_address = "drce87cy"
statsite_address = "HpFwKB8R"
}
2018-03-15 17:30:38 +00:00
tls_cipher_suites = "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"
2017-09-25 18:40:42 +00:00
tls_min_version = "pAOWafkR"
tls_prefer_server_cipher_suites = true
translate_wan_addrs = true
2017-09-26 06:58:54 +00:00
ui = true
2017-09-25 18:40:42 +00:00
ui_dir = "11IFzAUn"
2019-10-09 14:14:48 +00:00
ui_content_path = "consul"
2017-09-25 18:40:42 +00:00
unix_sockets = {
group = "8pFodrV8"
mode = "E8sAwOv4"
user = "E0nB1DwA"
}
verify_incoming = true
verify_incoming_https = true
verify_incoming_rpc = true
verify_outgoing = true
verify_server_hostname = true
watches = [ {
type = "key"
datacenter = "GyE6jpeW"
key = "j9lF1Tve"
handler = "90N7S4LN"
2017-10-04 23:48:00 +00:00
} , {
type = "keyprefix"
datacenter = "fYrl3F5d"
key = "sl3Dffu7"
args = [ "dltjDJ2a" , "flEa7C2d" ]
2017-09-25 18:40:42 +00:00
} ]
` }
tail := map [ string ] [ ] Source {
"json" : [ ] Source {
{
Name : "tail.non-user.json" ,
Format : "json" ,
Data : `
{
"acl_disabled_ttl" : "957s" ,
2018-10-19 16:04:07 +00:00
"acl" : {
"disabled_ttl" : "957s"
} ,
2017-09-25 18:40:42 +00:00
"ae_interval" : "10003s" ,
"check_deregister_interval_min" : "27870s" ,
"check_reap_interval" : "10662s" ,
2018-03-30 15:14:44 +00:00
"discovery_max_stale" : "5s" ,
2017-09-25 18:40:42 +00:00
"segment_limit" : 24705 ,
"segment_name_limit" : 27046 ,
"sync_coordinate_interval_min" : "27983s" ,
"sync_coordinate_rate_target" : 137.81
} ` ,
} ,
{
Name : "tail.consul.json" ,
Format : "json" ,
Data : `
{
"consul" : {
"coordinate" : {
"update_batch_size" : 9244 ,
"update_max_batches" : 15164 ,
"update_period" : "25093s"
} ,
"raft" : {
"election_timeout" : "31947s" ,
"heartbeat_timeout" : "25699s" ,
"leader_lease_timeout" : "15351s"
} ,
"server" : {
"health_interval" : "17455s"
}
}
} ` ,
} ,
} ,
"hcl" : [ ] Source {
{
Name : "tail.non-user.hcl" ,
Format : "hcl" ,
Data : `
acl_disabled_ttl = "957s"
2018-10-19 16:04:07 +00:00
acl = {
disabled_ttl = "957s"
}
2017-09-25 18:40:42 +00:00
ae_interval = "10003s"
check_deregister_interval_min = "27870s"
check_reap_interval = "10662s"
2018-03-30 15:14:44 +00:00
discovery_max_stale = "5s"
2017-09-25 18:40:42 +00:00
segment_limit = 24705
segment_name_limit = 27046
sync_coordinate_interval_min = "27983s"
sync_coordinate_rate_target = 137.81
` ,
} ,
{
Name : "tail.consul.hcl" ,
Format : "hcl" ,
Data : `
consul = {
coordinate = {
update_batch_size = 9244
update_max_batches = 15164
update_period = "25093s"
}
raft = {
election_timeout = "31947s"
heartbeat_timeout = "25699s"
leader_lease_timeout = "15351s"
}
server = {
health_interval = "17455s"
}
}
` ,
} ,
} ,
}
want := RuntimeConfig {
// non-user configurable values
ACLDisabledTTL : 957 * time . Second ,
AEInterval : 10003 * time . Second ,
CheckDeregisterIntervalMin : 27870 * time . Second ,
CheckReapInterval : 10662 * time . Second ,
SegmentLimit : 24705 ,
SegmentNameLimit : 27046 ,
SyncCoordinateIntervalMin : 27983 * time . Second ,
SyncCoordinateRateTarget : 137.81 ,
Revision : "JNtPSav3" ,
Version : "R909Hblt" ,
VersionPrerelease : "ZT1JOQLn" ,
// consul configuration
ConsulCoordinateUpdateBatchSize : 9244 ,
ConsulCoordinateUpdateMaxBatches : 15164 ,
ConsulCoordinateUpdatePeriod : 25093 * time . Second ,
ConsulRaftElectionTimeout : 5 * 31947 * time . Second ,
ConsulRaftHeartbeatTimeout : 5 * 25699 * time . Second ,
ConsulRaftLeaderLeaseTimeout : 5 * 15351 * time . Second ,
2018-07-26 15:39:49 +00:00
GossipLANGossipInterval : 25252 * time . Second ,
GossipLANGossipNodes : 6 ,
GossipLANProbeInterval : 101 * time . Millisecond ,
GossipLANProbeTimeout : 102 * time . Millisecond ,
GossipLANSuspicionMult : 1235 ,
GossipLANRetransmitMult : 1234 ,
GossipWANGossipInterval : 6966 * time . Second ,
GossipWANGossipNodes : 2 ,
GossipWANProbeInterval : 103 * time . Millisecond ,
GossipWANProbeTimeout : 104 * time . Millisecond ,
GossipWANSuspicionMult : 16385 ,
GossipWANRetransmitMult : 16384 ,
2017-09-25 18:40:42 +00:00
ConsulServerHealthInterval : 17455 * time . Second ,
// user configurable values
2018-10-19 16:04:07 +00:00
ACLAgentMasterToken : "64fd0e08" ,
ACLAgentToken : "bed2377c" ,
ACLsEnabled : true ,
ACLDatacenter : "ejtmd43d" ,
ACLDefaultPolicy : "72c2e7a0" ,
ACLDownPolicy : "03eb2aee" ,
2017-09-25 18:40:42 +00:00
ACLEnforceVersion8 : true ,
2019-12-10 02:26:41 +00:00
ACLEnableKeyListPolicy : true ,
2019-02-27 19:28:31 +00:00
ACLEnableTokenPersistence : true ,
2018-10-19 16:04:07 +00:00
ACLMasterToken : "8a19ac27" ,
ACLReplicationToken : "5795983a" ,
ACLTokenTTL : 3321 * time . Second ,
ACLPolicyTTL : 1123 * time . Second ,
2019-04-15 20:43:19 +00:00
ACLRoleTTL : 9876 * time . Second ,
2018-10-19 16:04:07 +00:00
ACLToken : "418fdff1" ,
ACLTokenReplication : true ,
2017-09-25 18:40:42 +00:00
AdvertiseAddrLAN : ipAddr ( "17.99.29.16" ) ,
AdvertiseAddrWAN : ipAddr ( "78.63.37.19" ) ,
AutopilotCleanupDeadServers : true ,
AutopilotDisableUpgradeMigration : true ,
AutopilotLastContactThreshold : 12705 * time . Second ,
AutopilotMaxTrailingLogs : 17849 ,
2019-10-29 14:04:41 +00:00
AutopilotMinQuorum : 3 ,
2017-09-25 18:40:42 +00:00
AutopilotRedundancyZoneTag : "3IsufDJf" ,
AutopilotServerStabilizationTime : 23057 * time . Second ,
AutopilotUpgradeVersionTag : "W9pDwFAL" ,
BindAddr : ipAddr ( "16.99.34.17" ) ,
Bootstrap : true ,
BootstrapExpect : 53 ,
CAFile : "erA7T0PM" ,
CAPath : "mQEN1Mfp" ,
CertFile : "7s4QAzDk" ,
2019-06-26 15:43:25 +00:00
CheckOutputMaxSize : checks . DefaultBufSize ,
2017-09-25 18:40:42 +00:00
Checks : [ ] * structs . CheckDefinition {
& structs . CheckDefinition {
2017-10-04 23:48:00 +00:00
ID : "uAjE6m9Z" ,
Name : "QsZRGpYr" ,
Notes : "VJ7Sk4BY" ,
ServiceID : "lSulPcyz" ,
Token : "toO59sh8" ,
Status : "9RlWsXMV" ,
ScriptArgs : [ ] string { "4BAJttck" , "4D2NPtTQ" } ,
HTTP : "dohLcyQ2" ,
2017-09-25 18:40:42 +00:00
Header : map [ string ] [ ] string {
"ZBfTin3L" : [ ] string { "1sDbEqYG" , "lJGASsWK" } ,
"Ui0nU99X" : [ ] string { "LMccm3Qe" , "k5H5RggQ" } ,
} ,
2018-09-12 16:07:47 +00:00
Method : "aldrIQ4l" ,
TCP : "RJQND605" ,
Interval : 22164 * time . Second ,
2019-06-26 15:43:25 +00:00
OutputMaxSize : checks . DefaultBufSize ,
2018-09-12 16:07:47 +00:00
DockerContainerID : "ipgdFtjd" ,
Shell : "qAeOYy0M" ,
TLSSkipVerify : true ,
Timeout : 1813 * time . Second ,
TTL : 21743 * time . Second ,
2017-09-25 18:40:42 +00:00
DeregisterCriticalServiceAfter : 14232 * time . Second ,
2019-12-10 02:26:41 +00:00
EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) ,
2017-09-25 18:40:42 +00:00
} ,
& structs . CheckDefinition {
2017-10-04 23:48:00 +00:00
ID : "Cqq95BhP" ,
Name : "3qXpkS0i" ,
Notes : "sb5qLTex" ,
ServiceID : "CmUUcRna" ,
Token : "a3nQzHuy" ,
Status : "irj26nf3" ,
ScriptArgs : [ ] string { "9s526ogY" , "gSlOHj1w" } ,
HTTP : "yzhgsQ7Y" ,
2017-09-25 18:40:42 +00:00
Header : map [ string ] [ ] string {
"zcqwA8dO" : [ ] string { "qb1zx0DL" , "sXCxPFsD" } ,
"qxvdnSE9" : [ ] string { "6wBPUYdF" , "YYh8wtSZ" } ,
} ,
2018-09-12 16:07:47 +00:00
Method : "gLrztrNw" ,
2019-06-26 15:43:25 +00:00
OutputMaxSize : checks . DefaultBufSize ,
2018-09-12 16:07:47 +00:00
TCP : "4jG5casb" ,
Interval : 28767 * time . Second ,
DockerContainerID : "THW6u7rL" ,
Shell : "C1Zt3Zwh" ,
TLSSkipVerify : true ,
Timeout : 18506 * time . Second ,
TTL : 31006 * time . Second ,
2017-09-25 18:40:42 +00:00
DeregisterCriticalServiceAfter : 2366 * time . Second ,
2019-12-10 02:26:41 +00:00
EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) ,
2017-09-25 18:40:42 +00:00
} ,
2017-09-26 08:14:14 +00:00
& structs . CheckDefinition {
2017-10-04 23:48:00 +00:00
ID : "fZaCAXww" ,
Name : "OOM2eo0f" ,
Notes : "zXzXI9Gt" ,
ServiceID : "L8G0QNmR" ,
Token : "oo4BCTgJ" ,
Status : "qLykAl5u" ,
ScriptArgs : [ ] string { "f3BemRjy" , "e5zgpef7" } ,
HTTP : "29B93haH" ,
2017-09-26 08:14:14 +00:00
Header : map [ string ] [ ] string {
"hBq0zn1q" : { "2a9o9ZKP" , "vKwA5lR6" } ,
"f3r6xFtM" : { "RyuIdDWv" , "QbxEcIUM" } ,
} ,
2018-09-12 16:07:47 +00:00
Method : "Dou0nGT5" ,
2019-06-26 15:43:25 +00:00
OutputMaxSize : checks . DefaultBufSize ,
2018-09-12 16:07:47 +00:00
TCP : "JY6fTTcw" ,
Interval : 18714 * time . Second ,
DockerContainerID : "qF66POS9" ,
Shell : "sOnDy228" ,
TLSSkipVerify : true ,
Timeout : 5954 * time . Second ,
TTL : 30044 * time . Second ,
2017-09-26 08:14:14 +00:00
DeregisterCriticalServiceAfter : 13209 * time . Second ,
2019-12-10 02:26:41 +00:00
EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) ,
2017-09-26 08:14:14 +00:00
} ,
2017-09-25 18:40:42 +00:00
} ,
2019-04-26 18:25:03 +00:00
CheckUpdateInterval : 16507 * time . Second ,
ClientAddrs : [ ] * net . IPAddr { ipAddr ( "93.83.18.19" ) } ,
ConfigEntryBootstrap : [ ] structs . ConfigEntry {
& structs . ProxyConfigEntry {
Kind : structs . ProxyDefaults ,
Name : structs . ProxyConfigGlobal ,
Config : map [ string ] interface { } {
"foo" : "bar" ,
// has to be a float due to being a map[string]interface
"bar" : float64 ( 1 ) ,
} ,
} ,
} ,
2019-08-09 19:19:30 +00:00
AutoEncryptTLS : true ,
2020-01-17 22:25:26 +00:00
AutoEncryptDNSSAN : [ ] string { "a.com" , "b.com" } ,
AutoEncryptIPSAN : [ ] net . IP { net . ParseIP ( "192.168.4.139" ) , net . ParseIP ( "192.168.4.140" ) } ,
2019-08-09 19:19:30 +00:00
AutoEncryptAllowTLS : true ,
ConnectEnabled : true ,
ConnectSidecarMinPort : 8888 ,
ConnectSidecarMaxPort : 9999 ,
2019-09-26 02:55:52 +00:00
ExposeMinPort : 1111 ,
ExposeMaxPort : 2222 ,
2019-08-09 19:19:30 +00:00
ConnectCAProvider : "consul" ,
2018-04-25 18:34:08 +00:00
ConnectCAConfig : map [ string ] interface { } {
2020-01-17 22:27:13 +00:00
"RotationPeriod" : "90h" ,
"IntermediateCertTTL" : "8760h" ,
"LeafCertTTL" : "1h" ,
"CSRMaxPerSecond" : float64 ( 100 ) ,
"CSRMaxConcurrent" : float64 ( 2 ) ,
2018-04-25 18:34:08 +00:00
} ,
2018-07-26 12:53:39 +00:00
DNSAddrs : [ ] net . Addr { tcpAddr ( "93.95.95.81:7001" ) , udpAddr ( "93.95.95.81:7001" ) } ,
DNSARecordLimit : 29907 ,
DNSAllowStale : true ,
DNSDisableCompression : true ,
DNSDomain : "7W1xXSqd" ,
2019-06-27 10:00:37 +00:00
DNSAltDomain : "1789hsd" ,
2018-07-26 12:53:39 +00:00
DNSEnableTruncate : true ,
DNSMaxStale : 29685 * time . Second ,
DNSNodeTTL : 7084 * time . Second ,
DNSOnlyPassing : true ,
DNSPort : 7001 ,
DNSRecursorTimeout : 4427 * time . Second ,
DNSRecursors : [ ] string { "63.38.39.58" , "92.49.18.18" } ,
Added SOA configuration for DNS settings. (#4714)
This will allow to fine TUNE SOA settings sent by Consul in DNS responses,
for instance to be able to control negative ttl.
Will fix: https://github.com/hashicorp/consul/issues/4713
# Example
Override all settings:
* min_ttl: 0 => 60s
* retry: 600 (10m) => 300s (5 minutes),
* expire: 86400 (24h) => 43200 (12h)
* refresh: 3600 (1h) => 1800 (30 minutes)
```
consul agent -dev -hcl 'dns_config={soa={min_ttl=60,retry=300,expire=43200,refresh=1800}}'
```
Result:
```
dig +multiline @localhost -p 8600 service.consul
; <<>> DiG 9.12.1 <<>> +multiline @localhost -p 8600 service.consul
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 36557
;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;service.consul. IN A
;; AUTHORITY SECTION:
consul. 0 IN SOA ns.consul. hostmaster.consul. (
1537959133 ; serial
1800 ; refresh (30 minutes)
300 ; retry (5 minutes)
43200 ; expire (12 hours)
60 ; minimum (1 minute)
)
;; Query time: 4 msec
;; SERVER: 127.0.0.1#8600(127.0.0.1)
;; WHEN: Wed Sep 26 12:52:13 CEST 2018
;; MSG SIZE rcvd: 93
```
2018-10-10 19:50:56 +00:00
DNSSOA : RuntimeSOAConfig { Refresh : 3600 , Retry : 600 , Expire : 86400 , Minttl : 0 } ,
2018-07-26 12:53:39 +00:00
DNSServiceTTL : map [ string ] time . Duration { "*" : 32030 * time . Second } ,
DNSUDPAnswerLimit : 29909 ,
DNSNodeMetaTXT : true ,
2019-02-25 19:06:01 +00:00
DNSUseCache : true ,
DNSCacheMaxAge : 5 * time . Minute ,
2018-07-26 12:53:39 +00:00
DataDir : dataDir ,
Datacenter : "rzo029wg" ,
2020-01-17 13:20:57 +00:00
DefaultQueryTime : 16743 * time . Second ,
2018-07-26 12:53:39 +00:00
DevMode : true ,
DisableAnonymousSignature : true ,
DisableCoordinates : true ,
DisableHostNodeID : true ,
DisableHTTPUnprintableCharFilter : true ,
DisableKeyringFile : true ,
DisableRemoteExec : true ,
DisableUpdateCheck : true ,
DiscardCheckOutput : true ,
DiscoveryMaxStale : 5 * time . Second ,
EnableAgentTLSForChecks : true ,
2019-04-24 13:11:08 +00:00
EnableCentralServiceConfig : true ,
2018-07-26 12:53:39 +00:00
EnableDebug : true ,
2018-10-11 12:22:11 +00:00
EnableRemoteScriptChecks : true ,
EnableLocalScriptChecks : true ,
2018-07-26 12:53:39 +00:00
EnableSyslog : true ,
EnableUI : true ,
EncryptKey : "A4wELWqH" ,
EncryptVerifyIncoming : true ,
EncryptVerifyOutgoing : true ,
2018-10-03 13:05:28 +00:00
GRPCPort : 4881 ,
GRPCAddrs : [ ] net . Addr { tcpAddr ( "32.31.61.91:4881" ) } ,
2018-07-26 12:53:39 +00:00
HTTPAddrs : [ ] net . Addr { tcpAddr ( "83.39.91.39:7999" ) } ,
HTTPBlockEndpoints : [ ] string { "RBvAFcGD" , "fWOWFznh" } ,
2019-01-10 14:27:26 +00:00
AllowWriteHTTPFrom : [ ] * net . IPNet { cidr ( "127.0.0.0/8" ) , cidr ( "22.33.44.55/32" ) , cidr ( "0.0.0.0/0" ) } ,
2018-07-26 12:53:39 +00:00
HTTPPort : 7999 ,
HTTPResponseHeaders : map [ string ] string { "M6TKa9NP" : "xjuxjOzQ" , "JRCrHZed" : "rl0mTx81" } ,
HTTPSAddrs : [ ] net . Addr { tcpAddr ( "95.17.17.19:15127" ) } ,
2020-01-31 16:19:37 +00:00
HTTPMaxConnsPerClient : 9283 ,
HTTPSHandshakeTimeout : 2391 * time . Millisecond ,
2018-07-26 12:53:39 +00:00
HTTPSPort : 15127 ,
KeyFile : "IEkkwgIA" ,
2019-07-24 21:06:39 +00:00
KVMaxValueSize : 1234567800000000 ,
2018-07-26 12:53:39 +00:00
LeaveDrainTime : 8265 * time . Second ,
LeaveOnTerm : true ,
LogLevel : "k1zo9Spt" ,
2020-01-28 23:50:41 +00:00
LogJSON : true ,
2020-01-17 13:20:57 +00:00
MaxQueryTime : 18237 * time . Second ,
2018-07-26 12:53:39 +00:00
NodeID : types . NodeID ( "AsUIlw99" ) ,
NodeMeta : map [ string ] string { "5mgGQMBk" : "mJLtVMSG" , "A7ynFMJB" : "0Nx6RGab" } ,
NodeName : "otlLxGaI" ,
NonVotingServer : true ,
PidFile : "43xN80Km" ,
2018-10-15 16:17:48 +00:00
PrimaryDatacenter : "ejtmd43d" ,
2018-07-26 12:53:39 +00:00
RPCAdvertiseAddr : tcpAddr ( "17.99.29.16:3757" ) ,
RPCBindAddr : tcpAddr ( "16.99.34.17:3757" ) ,
2020-01-31 16:19:37 +00:00
RPCHandshakeTimeout : 1932 * time . Millisecond ,
2018-07-26 12:53:39 +00:00
RPCHoldTimeout : 15707 * time . Second ,
RPCProtocol : 30793 ,
RPCRateLimit : 12029.43 ,
RPCMaxBurst : 44848 ,
2020-01-31 16:19:37 +00:00
RPCMaxConnsPerClient : 2954 ,
2018-07-26 12:53:39 +00:00
RaftProtocol : 19016 ,
RaftSnapshotThreshold : 16384 ,
RaftSnapshotInterval : 30 * time . Second ,
2019-07-23 14:19:57 +00:00
RaftTrailingLogs : 83749 ,
2018-07-26 12:53:39 +00:00
ReconnectTimeoutLAN : 23739 * time . Second ,
ReconnectTimeoutWAN : 26694 * time . Second ,
RejoinAfterLeave : true ,
RetryJoinIntervalLAN : 8067 * time . Second ,
RetryJoinIntervalWAN : 28866 * time . Second ,
RetryJoinLAN : [ ] string { "pbsSFY7U" , "l0qLtWij" } ,
RetryJoinMaxAttemptsLAN : 913 ,
RetryJoinMaxAttemptsWAN : 23160 ,
RetryJoinWAN : [ ] string { "PFsR02Ye" , "rJdQIhER" } ,
SegmentName : "BC2NhTDi" ,
2017-09-25 18:40:42 +00:00
Segments : [ ] structs . NetworkSegment {
{
Name : "PExYMe2E" ,
Bind : tcpAddr ( "36.73.36.19:38295" ) ,
Advertise : tcpAddr ( "63.39.19.18:38295" ) ,
RPCListener : true ,
} ,
{
Name : "UzCvJgup" ,
Bind : tcpAddr ( "37.58.38.19:39292" ) ,
Advertise : tcpAddr ( "83.58.26.27:39292" ) ,
RPCListener : true ,
} ,
} ,
SerfPortLAN : 8301 ,
SerfPortWAN : 8302 ,
ServerMode : true ,
ServerName : "Oerr9n1G" ,
ServerPort : 3757 ,
Services : [ ] * structs . ServiceDefinition {
{
2018-09-07 14:30:47 +00:00
ID : "wI1dzxS4" ,
Name : "7IszXMQ1" ,
Tags : [ ] string { "0Zwg8l6v" , "zebELdN5" } ,
Address : "9RhqPSPB" ,
Token : "myjKJkWH" ,
Port : 72219 ,
Weights : & structs . Weights {
Passing : 1 ,
Warning : 1 ,
} ,
2017-09-25 18:40:42 +00:00
EnableTagOverride : true ,
Checks : [ ] * structs . CheckType {
& structs . CheckType {
2017-10-04 23:48:00 +00:00
CheckID : "qmfeO5if" ,
Name : "atDGP7n5" ,
Status : "pDQKEhWL" ,
Notes : "Yt8EDLev" ,
ScriptArgs : [ ] string { "81EDZLPa" , "bPY5X8xd" } ,
HTTP : "qzHYvmJO" ,
2017-09-25 18:40:42 +00:00
Header : map [ string ] [ ] string {
"UkpmZ3a3" : { "2dfzXuxZ" } ,
"cVFpko4u" : { "gGqdEB6k" , "9LsRo22u" } ,
} ,
2018-09-12 16:07:47 +00:00
Method : "X5DrovFc" ,
2019-06-26 15:43:25 +00:00
OutputMaxSize : checks . DefaultBufSize ,
2018-09-12 16:07:47 +00:00
TCP : "ICbxkpSF" ,
Interval : 24392 * time . Second ,
DockerContainerID : "ZKXr68Yb" ,
Shell : "CEfzx0Fo" ,
TLSSkipVerify : true ,
Timeout : 38333 * time . Second ,
TTL : 57201 * time . Second ,
2017-09-25 18:40:42 +00:00
DeregisterCriticalServiceAfter : 44214 * time . Second ,
} ,
} ,
2018-09-27 13:33:12 +00:00
// Note that although this SidecarService is only syntax sugar for
// registering another service, that has to happen in the agent code so
// it can make intelligent decisions about automatic port assignments
// etc. So we expect config just to pass it through verbatim.
Connect : & structs . ServiceConnect {
2018-10-04 13:08:12 +00:00
SidecarService : & structs . ServiceDefinition {
Weights : & structs . Weights {
Passing : 1 ,
Warning : 1 ,
} ,
2019-12-10 02:26:41 +00:00
EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) ,
2018-10-04 13:08:12 +00:00
} ,
2018-09-27 13:33:12 +00:00
} ,
2019-12-10 02:26:41 +00:00
EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) ,
2017-09-25 18:40:42 +00:00
} ,
{
2018-09-07 14:30:47 +00:00
ID : "MRHVMZuD" ,
Name : "6L6BVfgH" ,
Tags : [ ] string { "7Ale4y6o" , "PMBW08hy" } ,
Address : "R6H6g8h0" ,
Token : "ZgY8gjMI" ,
Port : 38292 ,
Weights : & structs . Weights {
Passing : 1979 ,
Warning : 6 ,
} ,
2017-09-25 18:40:42 +00:00
EnableTagOverride : true ,
Checks : structs . CheckTypes {
& structs . CheckType {
2017-10-04 23:48:00 +00:00
CheckID : "GTti9hCo" ,
Name : "9OOS93ne" ,
Notes : "CQy86DH0" ,
Status : "P0SWDvrk" ,
ScriptArgs : [ ] string { "EXvkYIuG" , "BATOyt6h" } ,
HTTP : "u97ByEiW" ,
2017-09-25 18:40:42 +00:00
Header : map [ string ] [ ] string {
"MUlReo8L" : { "AUZG7wHG" , "gsN0Dc2N" } ,
"1UJXjVrT" : { "OJgxzTfk" , "xZZrFsq7" } ,
} ,
2018-09-12 16:07:47 +00:00
Method : "5wkAxCUE" ,
2019-06-26 15:43:25 +00:00
OutputMaxSize : checks . DefaultBufSize ,
2018-09-12 16:07:47 +00:00
TCP : "MN3oA9D2" ,
Interval : 32718 * time . Second ,
DockerContainerID : "cU15LMet" ,
Shell : "nEz9qz2l" ,
TLSSkipVerify : true ,
Timeout : 34738 * time . Second ,
TTL : 22773 * time . Second ,
2017-09-25 18:40:42 +00:00
DeregisterCriticalServiceAfter : 84282 * time . Second ,
} ,
& structs . CheckType {
2017-10-04 23:48:00 +00:00
CheckID : "UHsDeLxG" ,
Name : "PQSaPWlT" ,
Notes : "jKChDOdl" ,
Status : "5qFz6OZn" ,
ScriptArgs : [ ] string { "NMtYWlT9" , "vj74JXsm" } ,
HTTP : "1LBDJhw4" ,
2017-09-25 18:40:42 +00:00
Header : map [ string ] [ ] string {
"cXPmnv1M" : { "imDqfaBx" , "NFxZ1bQe" } ,
"vr7wY7CS" : { "EtCoNPPL" , "9vAarJ5s" } ,
} ,
2018-09-12 16:07:47 +00:00
Method : "wzByP903" ,
2019-06-26 15:43:25 +00:00
OutputMaxSize : checks . DefaultBufSize ,
2018-09-12 16:07:47 +00:00
TCP : "2exjZIGE" ,
Interval : 5656 * time . Second ,
DockerContainerID : "5tDBWpfA" ,
Shell : "rlTpLM8s" ,
TLSSkipVerify : true ,
Timeout : 4868 * time . Second ,
TTL : 11222 * time . Second ,
2017-09-25 18:40:42 +00:00
DeregisterCriticalServiceAfter : 68482 * time . Second ,
} ,
} ,
2019-12-10 02:26:41 +00:00
Connect : & structs . ServiceConnect { } ,
EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) ,
2017-09-25 18:40:42 +00:00
} ,
2018-07-25 18:55:41 +00:00
{
2018-09-12 16:07:47 +00:00
ID : "Kh81CPF6" ,
Name : "Kh81CPF6-proxy" ,
Port : 31471 ,
Kind : "connect-proxy" ,
Proxy : & structs . ConnectProxyConfig {
DestinationServiceName : "6L6BVfgH" ,
DestinationServiceID : "6L6BVfgH-id" ,
LocalServiceAddress : "127.0.0.2" ,
LocalServicePort : 23759 ,
Config : map [ string ] interface { } {
"cedGGtZf" : "pWrUNiWw" ,
} ,
Upstreams : structs . Upstreams {
{
DestinationType : "service" , // Default should be explicitly filled
DestinationName : "KPtAj2cb" ,
LocalBindPort : 4051 ,
Config : map [ string ] interface { } {
"kzRnZOyd" : "nUNKoL8H" ,
} ,
} ,
{
DestinationType : "prepared_query" ,
DestinationNamespace : "9nakw0td" ,
DestinationName : "KSd8HsRl" ,
LocalBindPort : 11884 ,
LocalBindAddress : "127.24.88.0" ,
} ,
} ,
2019-09-26 02:55:52 +00:00
Expose : structs . ExposeConfig {
Checks : true ,
Paths : [ ] structs . ExposePath {
{
Path : "/health" ,
LocalPathPort : 8080 ,
ListenerPort : 21500 ,
Protocol : "http" ,
} ,
} ,
} ,
2018-09-12 16:07:47 +00:00
} ,
2018-09-07 14:30:47 +00:00
Weights : & structs . Weights {
Passing : 1 ,
Warning : 1 ,
} ,
2019-12-10 02:26:41 +00:00
EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) ,
2018-07-25 18:55:41 +00:00
} ,
2019-06-18 00:52:01 +00:00
{
ID : "kvVqbwSE" ,
Kind : "mesh-gateway" ,
Name : "gw-primary-dc" ,
Port : 27147 ,
Proxy : & structs . ConnectProxyConfig {
Config : map [ string ] interface { } {
"1CuJHVfw" : "Kzqsa7yc" ,
} ,
} ,
Weights : & structs . Weights {
Passing : 1 ,
Warning : 1 ,
} ,
2019-12-10 02:26:41 +00:00
EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) ,
2019-06-18 00:52:01 +00:00
} ,
2017-09-25 18:40:42 +00:00
{
2019-06-17 14:51:50 +00:00
ID : "dLOXpSCI" ,
Name : "o1ynPkp0" ,
TaggedAddresses : map [ string ] structs . ServiceAddress {
"lan" : structs . ServiceAddress {
Address : "2d79888a" ,
Port : 2143 ,
} ,
"wan" : structs . ServiceAddress {
Address : "d4db85e2" ,
Port : 6109 ,
} ,
} ,
2018-09-07 14:30:47 +00:00
Tags : [ ] string { "nkwshvM5" , "NTDWn3ek" } ,
Address : "cOlSOhbp" ,
Token : "msy7iWER" ,
Meta : map [ string ] string { "mymeta" : "data" } ,
Port : 24237 ,
Weights : & structs . Weights {
Passing : 100 ,
Warning : 1 ,
} ,
2017-09-25 18:40:42 +00:00
EnableTagOverride : true ,
2018-07-25 18:55:41 +00:00
Connect : & structs . ServiceConnect {
Native : true ,
} ,
2017-09-25 18:40:42 +00:00
Checks : structs . CheckTypes {
& structs . CheckType {
2017-10-04 23:48:00 +00:00
CheckID : "Zv99e9Ka" ,
Name : "sgV4F7Pk" ,
Notes : "yP5nKbW0" ,
Status : "7oLMEyfu" ,
ScriptArgs : [ ] string { "5wEZtZpv" , "0Ihyk8cS" } ,
HTTP : "KyDjGY9H" ,
2017-09-25 18:40:42 +00:00
Header : map [ string ] [ ] string {
"gv5qefTz" : { "5Olo2pMG" , "PvvKWQU5" } ,
"SHOVq1Vv" : { "jntFhyym" , "GYJh32pp" } ,
} ,
2018-09-12 16:07:47 +00:00
Method : "T66MFBfR" ,
2019-06-26 15:43:25 +00:00
OutputMaxSize : checks . DefaultBufSize ,
2018-09-12 16:07:47 +00:00
TCP : "bNnNfx2A" ,
Interval : 22224 * time . Second ,
DockerContainerID : "ipgdFtjd" ,
Shell : "omVZq7Sz" ,
TLSSkipVerify : true ,
Timeout : 18913 * time . Second ,
TTL : 44743 * time . Second ,
2017-09-25 18:40:42 +00:00
DeregisterCriticalServiceAfter : 8482 * time . Second ,
} ,
& structs . CheckType {
2017-10-04 23:48:00 +00:00
CheckID : "G79O6Mpr" ,
Name : "IEqrzrsd" ,
Notes : "SVqApqeM" ,
Status : "XXkVoZXt" ,
ScriptArgs : [ ] string { "wD05Bvao" , "rLYB7kQC" } ,
HTTP : "kyICZsn8" ,
2017-09-25 18:40:42 +00:00
Header : map [ string ] [ ] string {
"4ebP5vL4" : { "G20SrL5Q" , "DwPKlMbo" } ,
"p2UI34Qz" : { "UsG1D0Qh" , "NHhRiB6s" } ,
} ,
2018-09-12 16:07:47 +00:00
Method : "ciYHWors" ,
2019-06-26 15:43:25 +00:00
OutputMaxSize : checks . DefaultBufSize ,
2018-09-12 16:07:47 +00:00
TCP : "FfvCwlqH" ,
Interval : 12356 * time . Second ,
DockerContainerID : "HBndBU6R" ,
Shell : "hVI33JjA" ,
TLSSkipVerify : true ,
Timeout : 38282 * time . Second ,
TTL : 1181 * time . Second ,
2017-09-25 18:40:42 +00:00
DeregisterCriticalServiceAfter : 4992 * time . Second ,
} ,
& structs . CheckType {
2017-10-04 23:48:00 +00:00
CheckID : "RMi85Dv8" ,
Name : "iehanzuq" ,
Status : "rCvn53TH" ,
Notes : "fti5lfF3" ,
ScriptArgs : [ ] string { "16WRUmwS" , "QWk7j7ae" } ,
HTTP : "dl3Fgme3" ,
2017-09-25 18:40:42 +00:00
Header : map [ string ] [ ] string {
"rjm4DEd3" : { "2m3m2Fls" } ,
"l4HwQ112" : { "fk56MNlo" , "dhLK56aZ" } ,
} ,
2018-09-12 16:07:47 +00:00
Method : "9afLm3Mj" ,
2019-06-26 15:43:25 +00:00
OutputMaxSize : checks . DefaultBufSize ,
2018-09-12 16:07:47 +00:00
TCP : "fjiLFqVd" ,
Interval : 23926 * time . Second ,
DockerContainerID : "dO5TtRHk" ,
Shell : "e6q2ttES" ,
TLSSkipVerify : true ,
Timeout : 38483 * time . Second ,
TTL : 10943 * time . Second ,
2017-09-25 18:40:42 +00:00
DeregisterCriticalServiceAfter : 68787 * time . Second ,
} ,
} ,
2019-12-10 02:26:41 +00:00
EnterpriseMeta : * structs . DefaultEnterpriseMeta ( ) ,
2017-09-25 18:40:42 +00:00
} ,
} ,
2018-06-14 12:52:48 +00:00
SerfAdvertiseAddrLAN : tcpAddr ( "17.99.29.16:8301" ) ,
SerfAdvertiseAddrWAN : tcpAddr ( "78.63.37.19:8302" ) ,
SerfBindAddrLAN : tcpAddr ( "99.43.63.15:8301" ) ,
SerfBindAddrWAN : tcpAddr ( "67.88.33.19:8302" ) ,
SessionTTLMin : 26627 * time . Second ,
SkipLeaveOnInt : true ,
StartJoinAddrsLAN : [ ] string { "LR3hGDoG" , "MwVpZ4Up" } ,
StartJoinAddrsWAN : [ ] string { "EbFSc3nA" , "kwXTh623" } ,
SyslogFacility : "hHv79Uia" ,
Telemetry : lib . TelemetryConfig {
CirconusAPIApp : "p4QOTe9j" ,
CirconusAPIToken : "E3j35V23" ,
CirconusAPIURL : "mEMjHpGg" ,
CirconusBrokerID : "BHlxUhed" ,
CirconusBrokerSelectTag : "13xy1gHm" ,
CirconusCheckDisplayName : "DRSlQR6n" ,
CirconusCheckForceMetricActivation : "Ua5FGVYf" ,
CirconusCheckID : "kGorutad" ,
CirconusCheckInstanceID : "rwoOL6R4" ,
CirconusCheckSearchTag : "ovT4hT4f" ,
CirconusCheckTags : "prvO4uBl" ,
CirconusSubmissionInterval : "DolzaflP" ,
CirconusSubmissionURL : "gTcbS93G" ,
DisableHostname : true ,
DogstatsdAddr : "0wSndumK" ,
DogstatsdTags : [ ] string { "3N81zSUB" , "Xtj8AnXZ" } ,
FilterDefault : true ,
AllowedPrefixes : [ ] string { "oJotS8XJ" } ,
BlockedPrefixes : [ ] string { "cazlEhGn" } ,
MetricsPrefix : "ftO6DySn" ,
PrometheusRetentionTime : 15 * time . Second ,
StatsdAddr : "drce87cy" ,
StatsiteAddr : "HpFwKB8R" ,
} ,
TLSCipherSuites : [ ] uint16 { tls . TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305 , tls . TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 } ,
TLSMinVersion : "pAOWafkR" ,
TLSPreferServerCipherSuites : true ,
2017-09-25 18:40:42 +00:00
TaggedAddresses : map [ string ] string {
"7MYgHrYH" : "dALJAhLD" ,
"h6DdBy6K" : "ebrr9zZ8" ,
"lan" : "17.99.29.16" ,
2020-01-17 14:54:17 +00:00
"lan_ipv4" : "17.99.29.16" ,
2017-09-25 18:40:42 +00:00
"wan" : "78.63.37.19" ,
2020-01-17 14:54:17 +00:00
"wan_ipv4" : "78.63.37.19" ,
2017-09-25 18:40:42 +00:00
} ,
TranslateWANAddrs : true ,
2019-10-09 14:14:48 +00:00
UIContentPath : "/consul/" ,
2017-09-25 18:40:42 +00:00
UIDir : "11IFzAUn" ,
UnixSocketUser : "E0nB1DwA" ,
UnixSocketGroup : "8pFodrV8" ,
UnixSocketMode : "E8sAwOv4" ,
VerifyIncoming : true ,
VerifyIncomingHTTPS : true ,
VerifyIncomingRPC : true ,
VerifyOutgoing : true ,
VerifyServerHostname : true ,
Watches : [ ] map [ string ] interface { } {
map [ string ] interface { } {
"type" : "key" ,
"datacenter" : "GyE6jpeW" ,
"key" : "j9lF1Tve" ,
"handler" : "90N7S4LN" ,
} ,
2017-10-04 23:48:00 +00:00
map [ string ] interface { } {
"type" : "keyprefix" ,
"datacenter" : "fYrl3F5d" ,
"key" : "sl3Dffu7" ,
"args" : [ ] interface { } { "dltjDJ2a" , "flEa7C2d" } ,
} ,
2017-09-25 18:40:42 +00:00
} ,
2019-12-18 15:16:35 +00:00
EnterpriseRuntimeConfig : entFullRuntimeConfig ,
2017-09-25 18:40:42 +00:00
}
warns := [ ] string {
2018-10-15 16:17:48 +00:00
` The 'acl_datacenter' field is deprecated. Use the 'primary_datacenter' field instead. ` ,
2017-09-25 18:40:42 +00:00
` bootstrap_expect > 0: expecting 53 servers ` ,
}
// ensure that all fields are set to unique non-zero values
// todo(fs): This currently fails since ServiceDefinition.Check is not used
// todo(fs): not sure on how to work around this. Possible options are:
// todo(fs): * move first check into the Check field
// todo(fs): * ignore the Check field
// todo(fs): both feel like a hack
if err := nonZero ( "RuntimeConfig" , nil , want ) ; err != nil {
t . Log ( err )
}
for format , data := range src {
t . Run ( format , func ( t * testing . T ) {
// parse the flags since this is the only way we can set the
// DevMode flag
var flags Flags
fs := flag . NewFlagSet ( "" , flag . ContinueOnError )
AddFlags ( fs , & flags )
if err := fs . Parse ( flagSrc ) ; err != nil {
t . Fatalf ( "ParseFlags: %s" , err )
}
// ensure that all fields are set to unique non-zero values
// if err := nonZero("Config", nil, c); err != nil {
// t.Fatal(err)
// }
b , err := NewBuilder ( flags )
if err != nil {
t . Fatalf ( "NewBuilder: %s" , err )
}
2017-10-31 22:30:01 +00:00
b . Sources = append ( b . Sources , Source { Name : "full." + format , Data : data } )
2017-09-25 18:40:42 +00:00
b . Tail = append ( b . Tail , tail [ format ] ... )
b . Tail = append ( b . Tail , VersionSource ( "JNtPSav3" , "R909Hblt" , "ZT1JOQLn" ) )
// construct the runtime config
rt , err := b . Build ( )
if err != nil {
t . Fatalf ( "Build: %s" , err )
}
// verify that all fields are set
if ! verify . Values ( t , "runtime_config" , rt , want ) {
t . FailNow ( )
}
// at this point we have confirmed that the parsing worked
// for all fields but the validation will fail since certain
// combinations are not allowed. Since it is not possible to have
// all fields with non-zero values and to have a valid configuration
// we are patching a handful of safe fields to make validation pass.
rt . Bootstrap = false
rt . DevMode = false
rt . EnableUI = false
rt . SegmentName = ""
rt . Segments = nil
// validate the runtime config
if err := b . Validate ( rt ) ; err != nil {
t . Fatalf ( "Validate: %s" , err )
}
// check the warnings
if got , want := b . Warnings , warns ; ! verify . Values ( t , "warnings" , got , want ) {
t . FailNow ( )
}
} )
}
}
// nonZero verifies recursively that all fields are set to unique,
// non-zero and non-nil values.
//
// struct: check all fields recursively
// slice: check len > 0 and all values recursively
// ptr: check not nil
// bool: check not zero (cannot check uniqueness)
// string, int, uint: check not zero and unique
// other: error
func nonZero ( name string , uniq map [ interface { } ] string , v interface { } ) error {
if v == nil {
return fmt . Errorf ( "%q is nil" , name )
}
if uniq == nil {
uniq = map [ interface { } ] string { }
}
isUnique := func ( v interface { } ) error {
if other := uniq [ v ] ; other != "" {
2018-03-19 16:56:00 +00:00
return fmt . Errorf ( "%q and %q both use value %q" , name , other , v )
2017-09-25 18:40:42 +00:00
}
uniq [ v ] = name
return nil
}
val , typ := reflect . ValueOf ( v ) , reflect . TypeOf ( v )
// fmt.Printf("%s: %T\n", name, v)
switch typ . Kind ( ) {
case reflect . Struct :
for i := 0 ; i < typ . NumField ( ) ; i ++ {
f := typ . Field ( i )
fieldname := fmt . Sprintf ( "%s.%s" , name , f . Name )
err := nonZero ( fieldname , uniq , val . Field ( i ) . Interface ( ) )
if err != nil {
return err
}
}
case reflect . Slice :
if val . Len ( ) == 0 {
return fmt . Errorf ( "%q is empty slice" , name )
}
for i := 0 ; i < val . Len ( ) ; i ++ {
elemname := fmt . Sprintf ( "%s[%d]" , name , i )
err := nonZero ( elemname , uniq , val . Index ( i ) . Interface ( ) )
if err != nil {
return err
}
}
case reflect . Map :
if val . Len ( ) == 0 {
return fmt . Errorf ( "%q is empty map" , name )
}
for _ , key := range val . MapKeys ( ) {
keyname := fmt . Sprintf ( "%s[%s]" , name , key . String ( ) )
if err := nonZero ( keyname , uniq , key . Interface ( ) ) ; err != nil {
if strings . Contains ( err . Error ( ) , "is zero value" ) {
return fmt . Errorf ( "%q has zero value map key" , name )
}
return err
}
if err := nonZero ( keyname , uniq , val . MapIndex ( key ) . Interface ( ) ) ; err != nil {
return err
}
}
case reflect . Bool :
if val . Bool ( ) != true {
return fmt . Errorf ( "%q is zero value" , name )
}
// do not test bool for uniqueness since there are only two values
case reflect . String :
if val . Len ( ) == 0 {
return fmt . Errorf ( "%q is zero value" , name )
}
return isUnique ( v )
case reflect . Int , reflect . Int8 , reflect . Int16 , reflect . Int32 , reflect . Int64 :
if val . Int ( ) == 0 {
return fmt . Errorf ( "%q is zero value" , name )
}
return isUnique ( v )
case reflect . Uint , reflect . Uint8 , reflect . Uint16 , reflect . Uint32 , reflect . Uint64 :
if val . Uint ( ) == 0 {
return fmt . Errorf ( "%q is zero value" , name )
}
return isUnique ( v )
case reflect . Float32 , reflect . Float64 :
if val . Float ( ) == 0 {
return fmt . Errorf ( "%q is zero value" , name )
}
return isUnique ( v )
case reflect . Ptr :
if val . IsNil ( ) {
return fmt . Errorf ( "%q is nil" , name )
}
return nonZero ( "*" + name , uniq , val . Elem ( ) . Interface ( ) )
default :
return fmt . Errorf ( "%T is not supported" , v )
}
return nil
}
func TestNonZero ( t * testing . T ) {
var empty string
tests := [ ] struct {
desc string
v interface { }
err error
} {
{ "nil" , nil , errors . New ( ` "x" is nil ` ) } ,
{ "zero bool" , false , errors . New ( ` "x" is zero value ` ) } ,
{ "zero string" , "" , errors . New ( ` "x" is zero value ` ) } ,
{ "zero int" , int ( 0 ) , errors . New ( ` "x" is zero value ` ) } ,
{ "zero int8" , int8 ( 0 ) , errors . New ( ` "x" is zero value ` ) } ,
{ "zero int16" , int16 ( 0 ) , errors . New ( ` "x" is zero value ` ) } ,
{ "zero int32" , int32 ( 0 ) , errors . New ( ` "x" is zero value ` ) } ,
{ "zero int64" , int64 ( 0 ) , errors . New ( ` "x" is zero value ` ) } ,
{ "zero uint" , uint ( 0 ) , errors . New ( ` "x" is zero value ` ) } ,
{ "zero uint8" , uint8 ( 0 ) , errors . New ( ` "x" is zero value ` ) } ,
{ "zero uint16" , uint16 ( 0 ) , errors . New ( ` "x" is zero value ` ) } ,
{ "zero uint32" , uint32 ( 0 ) , errors . New ( ` "x" is zero value ` ) } ,
{ "zero uint64" , uint64 ( 0 ) , errors . New ( ` "x" is zero value ` ) } ,
{ "zero float32" , float32 ( 0 ) , errors . New ( ` "x" is zero value ` ) } ,
{ "zero float64" , float64 ( 0 ) , errors . New ( ` "x" is zero value ` ) } ,
{ "ptr to zero value" , & empty , errors . New ( ` "*x" is zero value ` ) } ,
{ "empty slice" , [ ] string { } , errors . New ( ` "x" is empty slice ` ) } ,
{ "slice with zero value" , [ ] string { "" } , errors . New ( ` "x[0]" is zero value ` ) } ,
{ "empty map" , map [ string ] string { } , errors . New ( ` "x" is empty map ` ) } ,
{ "map with zero value key" , map [ string ] string { "" : "y" } , errors . New ( ` "x" has zero value map key ` ) } ,
{ "map with zero value elem" , map [ string ] string { "y" : "" } , errors . New ( ` "x[y]" is zero value ` ) } ,
{ "struct with nil field" , struct { Y * int } { } , errors . New ( ` "x.Y" is nil ` ) } ,
{ "struct with zero value field" , struct { Y string } { } , errors . New ( ` "x.Y" is zero value ` ) } ,
{ "struct with empty array" , struct { Y [ ] string } { } , errors . New ( ` "x.Y" is empty slice ` ) } ,
}
for _ , tt := range tests {
t . Run ( tt . desc , func ( t * testing . T ) {
if got , want := nonZero ( "x" , nil , tt . v ) , tt . err ; ! reflect . DeepEqual ( got , want ) {
t . Fatalf ( "got error %v want %v" , got , want )
}
} )
}
}
func TestConfigDecodeBytes ( t * testing . T ) {
t . Parallel ( )
// Test with some input
src := [ ] byte ( "abc" )
key := base64 . StdEncoding . EncodeToString ( src )
result , err := decodeBytes ( key )
if err != nil {
t . Fatalf ( "err: %s" , err )
}
if ! bytes . Equal ( src , result ) {
t . Fatalf ( "bad: %#v" , result )
}
// Test with no input
result , err = decodeBytes ( "" )
if err != nil {
t . Fatalf ( "err: %s" , err )
}
if len ( result ) > 0 {
t . Fatalf ( "bad: %#v" , result )
}
}
2019-07-23 20:30:16 +00:00
func parseCIDR ( t * testing . T , cidr string ) * net . IPNet {
_ , x , err := net . ParseCIDR ( cidr )
if err != nil {
t . Fatalf ( "CIDRParse: %v" , err )
}
return x
}
2017-09-25 18:40:42 +00:00
func TestSanitize ( t * testing . T ) {
rt := RuntimeConfig {
2017-09-27 18:47:40 +00:00
BindAddr : & net . IPAddr { IP : net . ParseIP ( "127.0.0.1" ) } ,
2019-06-26 15:43:25 +00:00
CheckOutputMaxSize : checks . DefaultBufSize ,
2017-09-27 18:47:40 +00:00
SerfAdvertiseAddrLAN : & net . TCPAddr { IP : net . ParseIP ( "1.2.3.4" ) , Port : 5678 } ,
DNSAddrs : [ ] net . Addr {
& net . TCPAddr { IP : net . ParseIP ( "1.2.3.4" ) , Port : 5678 } ,
& net . UDPAddr { IP : net . ParseIP ( "1.2.3.4" ) , Port : 5678 } ,
} ,
Added SOA configuration for DNS settings. (#4714)
This will allow to fine TUNE SOA settings sent by Consul in DNS responses,
for instance to be able to control negative ttl.
Will fix: https://github.com/hashicorp/consul/issues/4713
# Example
Override all settings:
* min_ttl: 0 => 60s
* retry: 600 (10m) => 300s (5 minutes),
* expire: 86400 (24h) => 43200 (12h)
* refresh: 3600 (1h) => 1800 (30 minutes)
```
consul agent -dev -hcl 'dns_config={soa={min_ttl=60,retry=300,expire=43200,refresh=1800}}'
```
Result:
```
dig +multiline @localhost -p 8600 service.consul
; <<>> DiG 9.12.1 <<>> +multiline @localhost -p 8600 service.consul
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 36557
;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;service.consul. IN A
;; AUTHORITY SECTION:
consul. 0 IN SOA ns.consul. hostmaster.consul. (
1537959133 ; serial
1800 ; refresh (30 minutes)
300 ; retry (5 minutes)
43200 ; expire (12 hours)
60 ; minimum (1 minute)
)
;; Query time: 4 msec
;; SERVER: 127.0.0.1#8600(127.0.0.1)
;; WHEN: Wed Sep 26 12:52:13 CEST 2018
;; MSG SIZE rcvd: 93
```
2018-10-10 19:50:56 +00:00
DNSSOA : RuntimeSOAConfig { Refresh : 3600 , Retry : 600 , Expire : 86400 , Minttl : 0 } ,
2019-07-23 20:30:16 +00:00
AllowWriteHTTPFrom : [ ] * net . IPNet {
parseCIDR ( t , "127.0.0.0/8" ) ,
parseCIDR ( t , "::1/128" ) ,
} ,
2017-09-27 18:47:40 +00:00
HTTPAddrs : [ ] net . Addr {
& net . TCPAddr { IP : net . ParseIP ( "1.2.3.4" ) , Port : 5678 } ,
& net . UnixAddr { Name : "/var/run/foo" } ,
} ,
ConsulCoordinateUpdatePeriod : 15 * time . Second ,
2017-09-25 18:40:42 +00:00
RetryJoinLAN : [ ] string {
"foo=bar key=baz secret=boom bang=bar" ,
} ,
RetryJoinWAN : [ ] string {
"wan_foo=bar wan_key=baz wan_secret=boom wan_bang=bar" ,
} ,
2017-09-27 18:47:40 +00:00
Services : [ ] * structs . ServiceDefinition {
& structs . ServiceDefinition {
Name : "foo" ,
Token : "bar" ,
Check : structs . CheckType {
2019-06-26 15:43:25 +00:00
Name : "blurb" ,
OutputMaxSize : checks . DefaultBufSize ,
2017-09-27 18:47:40 +00:00
} ,
2018-09-07 14:30:47 +00:00
Weights : & structs . Weights {
Passing : 67 ,
Warning : 3 ,
} ,
2017-09-27 18:47:40 +00:00
} ,
2017-09-25 18:40:42 +00:00
} ,
2017-09-27 18:47:40 +00:00
Checks : [ ] * structs . CheckDefinition {
& structs . CheckDefinition {
2019-06-26 15:43:25 +00:00
Name : "zoo" ,
Token : "zope" ,
OutputMaxSize : checks . DefaultBufSize ,
2017-09-27 18:47:40 +00:00
} ,
2017-09-25 18:40:42 +00:00
} ,
2019-07-24 21:06:39 +00:00
KVMaxValueSize : 1234567800000000 ,
2017-09-25 18:40:42 +00:00
}
2017-09-27 18:47:40 +00:00
rtJSON := ` {
2018-08-29 20:56:58 +00:00
"ACLAgentMasterToken" : "hidden" ,
"ACLAgentToken" : "hidden" ,
"ACLDatacenter" : "" ,
"ACLDefaultPolicy" : "" ,
"ACLDisabledTTL" : "0s" ,
"ACLDownPolicy" : "" ,
"ACLEnableKeyListPolicy" : false ,
2019-02-27 19:28:31 +00:00
"ACLEnableTokenPersistence" : false ,
2018-08-29 20:56:58 +00:00
"ACLEnforceVersion8" : false ,
"ACLMasterToken" : "hidden" ,
2018-10-19 16:04:07 +00:00
"ACLPolicyTTL" : "0s" ,
2018-08-29 20:56:58 +00:00
"ACLReplicationToken" : "hidden" ,
2019-04-15 20:43:19 +00:00
"ACLRoleTTL" : "0s" ,
2018-10-19 16:04:07 +00:00
"ACLTokenReplication" : false ,
"ACLTokenTTL" : "0s" ,
2018-08-29 20:56:58 +00:00
"ACLToken" : "hidden" ,
2018-10-19 16:04:07 +00:00
"ACLsEnabled" : false ,
2018-08-29 20:56:58 +00:00
"AEInterval" : "0s" ,
"AdvertiseAddrLAN" : "" ,
"AdvertiseAddrWAN" : "" ,
"AutopilotCleanupDeadServers" : false ,
"AutopilotDisableUpgradeMigration" : false ,
"AutopilotLastContactThreshold" : "0s" ,
"AutopilotMaxTrailingLogs" : 0 ,
2019-10-29 14:04:41 +00:00
"AutopilotMinQuorum" : 0 ,
2018-08-29 20:56:58 +00:00
"AutopilotRedundancyZoneTag" : "" ,
"AutopilotServerStabilizationTime" : "0s" ,
"AutopilotUpgradeVersionTag" : "" ,
"BindAddr" : "127.0.0.1" ,
"Bootstrap" : false ,
"BootstrapExpect" : 0 ,
"CAFile" : "" ,
"CAPath" : "" ,
"CertFile" : "" ,
"CheckDeregisterIntervalMin" : "0s" ,
2019-06-26 15:43:25 +00:00
"CheckOutputMaxSize" : ` + strconv.Itoa(checks.DefaultBufSize) + ` ,
2018-08-29 20:56:58 +00:00
"CheckReapInterval" : "0s" ,
"CheckUpdateInterval" : "0s" ,
"Checks" : [ {
"AliasNode" : "" ,
"AliasService" : "" ,
"DeregisterCriticalServiceAfter" : "0s" ,
"DockerContainerID" : "" ,
2019-12-10 02:26:41 +00:00
"EnterpriseMeta" : ` + entMetaJSON + ` ,
2019-10-14 20:49:49 +00:00
"SuccessBeforePassing" : 0 ,
"FailuresBeforeCritical" : 0 ,
2018-08-29 20:56:58 +00:00
"GRPC" : "" ,
"GRPCUseTLS" : false ,
"HTTP" : "" ,
"Header" : { } ,
"ID" : "" ,
"Interval" : "0s" ,
"Method" : "" ,
"Name" : "zoo" ,
"Notes" : "" ,
2019-06-26 15:43:25 +00:00
"OutputMaxSize" : ` + strconv.Itoa(checks.DefaultBufSize) + ` ,
2018-08-29 20:56:58 +00:00
"ScriptArgs" : [ ] ,
"ServiceID" : "" ,
"Shell" : "" ,
"Status" : "" ,
"TCP" : "" ,
"TLSSkipVerify" : false ,
"TTL" : "0s" ,
"Timeout" : "0s" ,
"Token" : "hidden"
} ] ,
"ClientAddrs" : [ ] ,
2019-04-26 18:25:03 +00:00
"ConfigEntryBootstrap" : [ ] ,
2019-06-27 20:22:07 +00:00
"AutoEncryptTLS" : false ,
2020-01-17 22:25:26 +00:00
"AutoEncryptDNSSAN" : [ ] ,
"AutoEncryptIPSAN" : [ ] ,
2019-06-27 20:22:07 +00:00
"AutoEncryptAllowTLS" : false ,
2018-08-29 20:56:58 +00:00
"ConnectCAConfig" : { } ,
"ConnectCAProvider" : "" ,
"ConnectEnabled" : false ,
2018-09-27 13:33:12 +00:00
"ConnectSidecarMaxPort" : 0 ,
"ConnectSidecarMinPort" : 0 ,
2019-01-10 12:46:11 +00:00
"ConnectTestCALeafRootChangeSpread" : "0s" ,
2018-08-29 20:56:58 +00:00
"ConsulCoordinateUpdateBatchSize" : 0 ,
"ConsulCoordinateUpdateMaxBatches" : 0 ,
"ConsulCoordinateUpdatePeriod" : "15s" ,
"ConsulRaftElectionTimeout" : "0s" ,
2019-06-26 15:43:25 +00:00
"CheckOutputMaxSize" : ` + strconv.Itoa(checks.DefaultBufSize) + ` ,
2018-08-29 20:56:58 +00:00
"ConsulRaftHeartbeatTimeout" : "0s" ,
"ConsulRaftLeaderLeaseTimeout" : "0s" ,
"GossipLANGossipInterval" : "0s" ,
"GossipLANGossipNodes" : 0 ,
"GossipLANProbeInterval" : "0s" ,
"GossipLANProbeTimeout" : "0s" ,
"GossipLANRetransmitMult" : 0 ,
"GossipLANSuspicionMult" : 0 ,
"GossipWANGossipInterval" : "0s" ,
"GossipWANGossipNodes" : 0 ,
"GossipWANProbeInterval" : "0s" ,
"GossipWANProbeTimeout" : "0s" ,
"GossipWANRetransmitMult" : 0 ,
"GossipWANSuspicionMult" : 0 ,
"ConsulServerHealthInterval" : "0s" ,
"DNSARecordLimit" : 0 ,
"DNSAddrs" : [
"tcp://1.2.3.4:5678" ,
"udp://1.2.3.4:5678"
] ,
"DNSAllowStale" : false ,
"DNSDisableCompression" : false ,
"DNSDomain" : "" ,
2019-06-27 10:00:37 +00:00
"DNSAltDomain" : "" ,
2018-08-29 20:56:58 +00:00
"DNSEnableTruncate" : false ,
"DNSMaxStale" : "0s" ,
"DNSNodeMetaTXT" : false ,
"DNSNodeTTL" : "0s" ,
"DNSOnlyPassing" : false ,
"DNSPort" : 0 ,
"DNSRecursorTimeout" : "0s" ,
"DNSRecursors" : [ ] ,
"DNSServiceTTL" : { } ,
Added SOA configuration for DNS settings. (#4714)
This will allow to fine TUNE SOA settings sent by Consul in DNS responses,
for instance to be able to control negative ttl.
Will fix: https://github.com/hashicorp/consul/issues/4713
# Example
Override all settings:
* min_ttl: 0 => 60s
* retry: 600 (10m) => 300s (5 minutes),
* expire: 86400 (24h) => 43200 (12h)
* refresh: 3600 (1h) => 1800 (30 minutes)
```
consul agent -dev -hcl 'dns_config={soa={min_ttl=60,retry=300,expire=43200,refresh=1800}}'
```
Result:
```
dig +multiline @localhost -p 8600 service.consul
; <<>> DiG 9.12.1 <<>> +multiline @localhost -p 8600 service.consul
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 36557
;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;service.consul. IN A
;; AUTHORITY SECTION:
consul. 0 IN SOA ns.consul. hostmaster.consul. (
1537959133 ; serial
1800 ; refresh (30 minutes)
300 ; retry (5 minutes)
43200 ; expire (12 hours)
60 ; minimum (1 minute)
)
;; Query time: 4 msec
;; SERVER: 127.0.0.1#8600(127.0.0.1)
;; WHEN: Wed Sep 26 12:52:13 CEST 2018
;; MSG SIZE rcvd: 93
```
2018-10-10 19:50:56 +00:00
"DNSSOA" : {
"Refresh" : 3600 ,
"Retry" : 600 ,
"Expire" : 86400 ,
"Minttl" : 0
} ,
2018-08-29 20:56:58 +00:00
"DNSUDPAnswerLimit" : 0 ,
2019-02-25 19:06:01 +00:00
"DNSUseCache" : false ,
"DNSCacheMaxAge" : "0s" ,
2018-08-29 20:56:58 +00:00
"DataDir" : "" ,
"Datacenter" : "" ,
2020-01-17 13:20:57 +00:00
"DefaultQueryTime" : "0s" ,
2018-08-29 20:56:58 +00:00
"DevMode" : false ,
"DisableAnonymousSignature" : false ,
"DisableCoordinates" : false ,
"DisableHTTPUnprintableCharFilter" : false ,
"DisableHostNodeID" : false ,
"DisableKeyringFile" : false ,
"DisableRemoteExec" : false ,
"DisableUpdateCheck" : false ,
"DiscardCheckOutput" : false ,
"DiscoveryMaxStale" : "0s" ,
"EnableAgentTLSForChecks" : false ,
"EnableDebug" : false ,
2019-04-24 13:11:08 +00:00
"EnableCentralServiceConfig" : false ,
2018-10-11 12:22:11 +00:00
"EnableLocalScriptChecks" : false ,
"EnableRemoteScriptChecks" : false ,
2018-08-29 20:56:58 +00:00
"EnableSyslog" : false ,
"EnableUI" : false ,
"EncryptKey" : "hidden" ,
"EncryptVerifyIncoming" : false ,
"EncryptVerifyOutgoing" : false ,
2019-12-10 02:26:41 +00:00
"EnterpriseRuntimeConfig" : ` + entRuntimeConfigSanitize + ` ,
2019-09-26 02:55:52 +00:00
"ExposeMaxPort" : 0 ,
"ExposeMinPort" : 0 ,
2018-10-03 13:05:28 +00:00
"GRPCAddrs" : [ ] ,
"GRPCPort" : 0 ,
2018-08-29 20:56:58 +00:00
"HTTPAddrs" : [
"tcp://1.2.3.4:5678" ,
"unix:///var/run/foo"
] ,
"HTTPBlockEndpoints" : [ ] ,
2020-01-31 16:19:37 +00:00
"HTTPMaxConnsPerClient" : 0 ,
2018-08-29 20:56:58 +00:00
"HTTPPort" : 0 ,
"HTTPResponseHeaders" : { } ,
"HTTPSAddrs" : [ ] ,
2020-01-31 16:19:37 +00:00
"HTTPSHandshakeTimeout" : "0s" ,
2018-08-29 20:56:58 +00:00
"HTTPSPort" : 0 ,
"KeyFile" : "hidden" ,
2019-07-24 21:06:39 +00:00
"KVMaxValueSize" : 1234567800000000 ,
2018-08-29 20:56:58 +00:00
"LeaveDrainTime" : "0s" ,
"LeaveOnTerm" : false ,
"LogLevel" : "" ,
2020-01-28 23:50:41 +00:00
"LogJSON" : false ,
2018-08-29 20:56:58 +00:00
"LogFile" : "" ,
"LogRotateBytes" : 0 ,
"LogRotateDuration" : "0s" ,
2019-07-19 21:36:34 +00:00
"LogRotateMaxFiles" : 0 ,
2020-01-17 13:20:57 +00:00
"MaxQueryTime" : "0s" ,
2018-08-29 20:56:58 +00:00
"NodeID" : "" ,
"NodeMeta" : { } ,
"NodeName" : "" ,
"NonVotingServer" : false ,
"PidFile" : "" ,
2018-10-15 16:17:48 +00:00
"PrimaryDatacenter" : "" ,
2018-08-29 20:56:58 +00:00
"RPCAdvertiseAddr" : "" ,
"RPCBindAddr" : "" ,
2020-01-31 16:19:37 +00:00
"RPCHandshakeTimeout" : "0s" ,
2018-08-29 20:56:58 +00:00
"RPCHoldTimeout" : "0s" ,
"RPCMaxBurst" : 0 ,
2020-01-31 16:19:37 +00:00
"RPCMaxConnsPerClient" : 0 ,
2018-08-29 20:56:58 +00:00
"RPCProtocol" : 0 ,
"RPCRateLimit" : 0 ,
"RaftProtocol" : 0 ,
"RaftSnapshotInterval" : "0s" ,
"RaftSnapshotThreshold" : 0 ,
2019-07-23 14:19:57 +00:00
"RaftTrailingLogs" : 0 ,
2018-08-29 20:56:58 +00:00
"ReconnectTimeoutLAN" : "0s" ,
"ReconnectTimeoutWAN" : "0s" ,
"RejoinAfterLeave" : false ,
"RetryJoinIntervalLAN" : "0s" ,
"RetryJoinIntervalWAN" : "0s" ,
"RetryJoinLAN" : [
"foo=bar key=hidden secret=hidden bang=bar"
] ,
"RetryJoinMaxAttemptsLAN" : 0 ,
"RetryJoinMaxAttemptsWAN" : 0 ,
"RetryJoinWAN" : [
"wan_foo=bar wan_key=hidden wan_secret=hidden wan_bang=bar"
] ,
"Revision" : "" ,
"SegmentLimit" : 0 ,
"SegmentName" : "" ,
"SegmentNameLimit" : 0 ,
"Segments" : [ ] ,
"SerfAdvertiseAddrLAN" : "tcp://1.2.3.4:5678" ,
"SerfAdvertiseAddrWAN" : "" ,
"SerfBindAddrLAN" : "" ,
"SerfBindAddrWAN" : "" ,
"SerfPortLAN" : 0 ,
"SerfPortWAN" : 0 ,
"ServerMode" : false ,
"ServerName" : "" ,
"ServerPort" : 0 ,
"Services" : [ {
"Address" : "" ,
"Check" : {
"AliasNode" : "" ,
"AliasService" : "" ,
"CheckID" : "" ,
"DeregisterCriticalServiceAfter" : "0s" ,
"DockerContainerID" : "" ,
2019-10-14 20:49:49 +00:00
"SuccessBeforePassing" : 0 ,
"FailuresBeforeCritical" : 0 ,
2018-08-29 20:56:58 +00:00
"GRPC" : "" ,
"GRPCUseTLS" : false ,
"HTTP" : "" ,
"Header" : { } ,
"Interval" : "0s" ,
"Method" : "" ,
"Name" : "blurb" ,
"Notes" : "" ,
2019-06-26 15:43:25 +00:00
"OutputMaxSize" : ` + strconv.Itoa(checks.DefaultBufSize) + ` ,
2019-09-26 02:55:52 +00:00
"ProxyGRPC" : "" ,
"ProxyHTTP" : "" ,
2018-08-29 20:56:58 +00:00
"ScriptArgs" : [ ] ,
"Shell" : "" ,
"Status" : "" ,
"TCP" : "" ,
"TLSSkipVerify" : false ,
"TTL" : "0s" ,
"Timeout" : "0s"
} ,
"Checks" : [ ] ,
"Connect" : null ,
"EnableTagOverride" : false ,
2019-12-10 02:26:41 +00:00
"EnterpriseMeta" : ` + entMetaJSON + ` ,
2018-08-29 20:56:58 +00:00
"ID" : "" ,
"Kind" : "" ,
"Meta" : { } ,
"Name" : "foo" ,
"Port" : 0 ,
2018-09-12 16:07:47 +00:00
"Proxy" : null ,
2019-06-17 14:51:50 +00:00
"TaggedAddresses" : { } ,
2018-08-29 20:56:58 +00:00
"Tags" : [ ] ,
2018-09-07 14:30:47 +00:00
"Token" : "hidden" ,
"Weights" : {
"Passing" : 67 ,
"Warning" : 3
}
2018-08-29 20:56:58 +00:00
} ] ,
"SessionTTLMin" : "0s" ,
"SkipLeaveOnInt" : false ,
"StartJoinAddrsLAN" : [ ] ,
"StartJoinAddrsWAN" : [ ] ,
"SyncCoordinateIntervalMin" : "0s" ,
"SyncCoordinateRateTarget" : 0 ,
"SyslogFacility" : "" ,
"TLSCipherSuites" : [ ] ,
"TLSMinVersion" : "" ,
"TLSPreferServerCipherSuites" : false ,
"TaggedAddresses" : { } ,
"Telemetry" : {
"AllowedPrefixes" : [ ] ,
"BlockedPrefixes" : [ ] ,
"CirconusAPIApp" : "" ,
"CirconusAPIToken" : "hidden" ,
"CirconusAPIURL" : "" ,
"CirconusBrokerID" : "" ,
"CirconusBrokerSelectTag" : "" ,
"CirconusCheckDisplayName" : "" ,
"CirconusCheckForceMetricActivation" : "" ,
"CirconusCheckID" : "" ,
"CirconusCheckInstanceID" : "" ,
"CirconusCheckSearchTag" : "" ,
"CirconusCheckTags" : "" ,
"CirconusSubmissionInterval" : "" ,
"CirconusSubmissionURL" : "" ,
"DisableHostname" : false ,
"DogstatsdAddr" : "" ,
"DogstatsdTags" : [ ] ,
"FilterDefault" : false ,
"MetricsPrefix" : "" ,
"PrometheusRetentionTime" : "0s" ,
"StatsdAddr" : "" ,
"StatsiteAddr" : ""
} ,
"TranslateWANAddrs" : false ,
"UIDir" : "" ,
2019-10-09 14:14:48 +00:00
"UIContentPath" : "" ,
2018-08-29 20:56:58 +00:00
"UnixSocketGroup" : "" ,
"UnixSocketMode" : "" ,
"UnixSocketUser" : "" ,
"VerifyIncoming" : false ,
"VerifyIncomingHTTPS" : false ,
"VerifyIncomingRPC" : false ,
"VerifyOutgoing" : false ,
"VerifyServerHostname" : false ,
"Version" : "" ,
"VersionPrerelease" : "" ,
2019-01-10 14:27:26 +00:00
"Watches" : [ ] ,
2019-07-23 20:30:16 +00:00
"AllowWriteHTTPFrom" : [
"127.0.0.0/8" ,
"::1/128"
]
2018-08-29 20:56:58 +00:00
} `
2017-09-27 18:47:40 +00:00
b , err := json . MarshalIndent ( rt . Sanitized ( ) , "" , " " )
if err != nil {
t . Fatal ( err )
}
2018-06-14 12:52:48 +00:00
require . JSONEq ( t , rtJSON , string ( b ) )
2017-09-25 18:40:42 +00:00
}
2018-07-11 21:25:36 +00:00
func TestRuntime_apiAddresses ( t * testing . T ) {
rt := RuntimeConfig {
HTTPAddrs : [ ] net . Addr {
& net . TCPAddr { IP : net . ParseIP ( "198.18.0.1" ) , Port : 5678 } ,
& net . UnixAddr { Name : "/var/run/foo" } ,
} ,
HTTPSAddrs : [ ] net . Addr {
& net . TCPAddr { IP : net . ParseIP ( "198.18.0.2" ) , Port : 5678 } ,
} }
unixAddrs , httpAddrs , httpsAddrs := rt . apiAddresses ( 1 )
require . Len ( t , unixAddrs , 1 )
require . Len ( t , httpAddrs , 1 )
require . Len ( t , httpsAddrs , 1 )
require . Equal ( t , "/var/run/foo" , unixAddrs [ 0 ] )
require . Equal ( t , "198.18.0.1:5678" , httpAddrs [ 0 ] )
require . Equal ( t , "198.18.0.2:5678" , httpsAddrs [ 0 ] )
}
func TestRuntime_APIConfigHTTPS ( t * testing . T ) {
rt := RuntimeConfig {
HTTPAddrs : [ ] net . Addr {
& net . TCPAddr { IP : net . ParseIP ( "198.18.0.1" ) , Port : 5678 } ,
& net . UnixAddr { Name : "/var/run/foo" } ,
} ,
HTTPSAddrs : [ ] net . Addr {
& net . TCPAddr { IP : net . ParseIP ( "198.18.0.2" ) , Port : 5678 } ,
} ,
2018-07-12 11:49:23 +00:00
Datacenter : "dc-test" ,
CAFile : "/etc/consul/ca.crt" ,
CAPath : "/etc/consul/ca.dir" ,
CertFile : "/etc/consul/server.crt" ,
KeyFile : "/etc/consul/ssl/server.key" ,
VerifyOutgoing : false ,
2018-07-11 21:25:36 +00:00
}
cfg , err := rt . APIConfig ( false )
require . NoError ( t , err )
require . Equal ( t , "198.18.0.2:5678" , cfg . Address )
require . Equal ( t , "https" , cfg . Scheme )
require . Equal ( t , rt . CAFile , cfg . TLSConfig . CAFile )
require . Equal ( t , rt . CAPath , cfg . TLSConfig . CAPath )
require . Equal ( t , "" , cfg . TLSConfig . CertFile )
require . Equal ( t , "" , cfg . TLSConfig . KeyFile )
require . Equal ( t , rt . Datacenter , cfg . Datacenter )
2018-07-12 11:49:23 +00:00
require . Equal ( t , true , cfg . TLSConfig . InsecureSkipVerify )
2018-07-11 21:25:36 +00:00
2018-07-12 11:49:23 +00:00
rt . VerifyOutgoing = true
2018-07-11 21:25:36 +00:00
cfg , err = rt . APIConfig ( true )
require . NoError ( t , err )
require . Equal ( t , "198.18.0.2:5678" , cfg . Address )
require . Equal ( t , "https" , cfg . Scheme )
require . Equal ( t , rt . CAFile , cfg . TLSConfig . CAFile )
require . Equal ( t , rt . CAPath , cfg . TLSConfig . CAPath )
require . Equal ( t , rt . CertFile , cfg . TLSConfig . CertFile )
require . Equal ( t , rt . KeyFile , cfg . TLSConfig . KeyFile )
require . Equal ( t , rt . Datacenter , cfg . Datacenter )
2018-07-12 11:49:23 +00:00
require . Equal ( t , false , cfg . TLSConfig . InsecureSkipVerify )
2018-07-11 21:25:36 +00:00
}
func TestRuntime_APIConfigHTTP ( t * testing . T ) {
rt := RuntimeConfig {
HTTPAddrs : [ ] net . Addr {
& net . UnixAddr { Name : "/var/run/foo" } ,
& net . TCPAddr { IP : net . ParseIP ( "198.18.0.1" ) , Port : 5678 } ,
} ,
Datacenter : "dc-test" ,
}
cfg , err := rt . APIConfig ( false )
require . NoError ( t , err )
require . Equal ( t , rt . Datacenter , cfg . Datacenter )
require . Equal ( t , "198.18.0.1:5678" , cfg . Address )
require . Equal ( t , "http" , cfg . Scheme )
require . Equal ( t , "" , cfg . TLSConfig . CAFile )
require . Equal ( t , "" , cfg . TLSConfig . CAPath )
require . Equal ( t , "" , cfg . TLSConfig . CertFile )
require . Equal ( t , "" , cfg . TLSConfig . KeyFile )
}
func TestRuntime_APIConfigUNIX ( t * testing . T ) {
rt := RuntimeConfig {
HTTPAddrs : [ ] net . Addr {
& net . UnixAddr { Name : "/var/run/foo" } ,
} ,
Datacenter : "dc-test" ,
}
cfg , err := rt . APIConfig ( false )
require . NoError ( t , err )
require . Equal ( t , rt . Datacenter , cfg . Datacenter )
require . Equal ( t , "unix:///var/run/foo" , cfg . Address )
require . Equal ( t , "http" , cfg . Scheme )
require . Equal ( t , "" , cfg . TLSConfig . CAFile )
require . Equal ( t , "" , cfg . TLSConfig . CAPath )
require . Equal ( t , "" , cfg . TLSConfig . CertFile )
require . Equal ( t , "" , cfg . TLSConfig . KeyFile )
}
2018-07-16 20:30:15 +00:00
func TestRuntime_APIConfigANYAddrV4 ( t * testing . T ) {
rt := RuntimeConfig {
HTTPAddrs : [ ] net . Addr {
& net . TCPAddr { IP : net . ParseIP ( "0.0.0.0" ) , Port : 5678 } ,
} ,
Datacenter : "dc-test" ,
}
cfg , err := rt . APIConfig ( false )
require . NoError ( t , err )
require . Equal ( t , rt . Datacenter , cfg . Datacenter )
require . Equal ( t , "127.0.0.1:5678" , cfg . Address )
require . Equal ( t , "http" , cfg . Scheme )
require . Equal ( t , "" , cfg . TLSConfig . CAFile )
require . Equal ( t , "" , cfg . TLSConfig . CAPath )
require . Equal ( t , "" , cfg . TLSConfig . CertFile )
require . Equal ( t , "" , cfg . TLSConfig . KeyFile )
}
func TestRuntime_APIConfigANYAddrV6 ( t * testing . T ) {
rt := RuntimeConfig {
HTTPAddrs : [ ] net . Addr {
& net . TCPAddr { IP : net . ParseIP ( "::" ) , Port : 5678 } ,
} ,
Datacenter : "dc-test" ,
}
cfg , err := rt . APIConfig ( false )
require . NoError ( t , err )
require . Equal ( t , rt . Datacenter , cfg . Datacenter )
require . Equal ( t , "[::1]:5678" , cfg . Address )
require . Equal ( t , "http" , cfg . Scheme )
require . Equal ( t , "" , cfg . TLSConfig . CAFile )
require . Equal ( t , "" , cfg . TLSConfig . CAPath )
require . Equal ( t , "" , cfg . TLSConfig . CertFile )
require . Equal ( t , "" , cfg . TLSConfig . KeyFile )
}
func TestRuntime_ClientAddress ( t * testing . T ) {
rt := RuntimeConfig {
HTTPAddrs : [ ] net . Addr {
& net . TCPAddr { IP : net . ParseIP ( "::" ) , Port : 5678 } ,
& net . TCPAddr { IP : net . ParseIP ( "198.18.0.1" ) , Port : 5679 } ,
& net . UnixAddr { Name : "/var/run/foo" , Net : "unix" } ,
} ,
HTTPSAddrs : [ ] net . Addr {
& net . TCPAddr { IP : net . ParseIP ( "::" ) , Port : 5688 } ,
& net . TCPAddr { IP : net . ParseIP ( "198.18.0.1" ) , Port : 5689 } ,
} ,
}
unix , http , https := rt . ClientAddress ( )
require . Equal ( t , "unix:///var/run/foo" , unix )
require . Equal ( t , "198.18.0.1:5679" , http )
require . Equal ( t , "198.18.0.1:5689" , https )
}
func TestRuntime_ClientAddressAnyV4 ( t * testing . T ) {
rt := RuntimeConfig {
HTTPAddrs : [ ] net . Addr {
& net . TCPAddr { IP : net . ParseIP ( "0.0.0.0" ) , Port : 5678 } ,
& net . UnixAddr { Name : "/var/run/foo" , Net : "unix" } ,
} ,
HTTPSAddrs : [ ] net . Addr {
& net . TCPAddr { IP : net . ParseIP ( "0.0.0.0" ) , Port : 5688 } ,
} ,
}
unix , http , https := rt . ClientAddress ( )
require . Equal ( t , "unix:///var/run/foo" , unix )
require . Equal ( t , "127.0.0.1:5678" , http )
require . Equal ( t , "127.0.0.1:5688" , https )
}
func TestRuntime_ClientAddressAnyV6 ( t * testing . T ) {
rt := RuntimeConfig {
HTTPAddrs : [ ] net . Addr {
& net . TCPAddr { IP : net . ParseIP ( "::" ) , Port : 5678 } ,
& net . UnixAddr { Name : "/var/run/foo" , Net : "unix" } ,
} ,
HTTPSAddrs : [ ] net . Addr {
& net . TCPAddr { IP : net . ParseIP ( "::" ) , Port : 5688 } ,
} ,
}
unix , http , https := rt . ClientAddress ( )
require . Equal ( t , "unix:///var/run/foo" , unix )
require . Equal ( t , "[::1]:5678" , http )
require . Equal ( t , "[::1]:5688" , https )
}
2019-02-26 15:52:07 +00:00
func TestRuntime_ToTLSUtilConfig ( t * testing . T ) {
c := & RuntimeConfig {
VerifyIncoming : true ,
VerifyIncomingRPC : true ,
VerifyIncomingHTTPS : true ,
VerifyOutgoing : true ,
2019-03-13 09:29:06 +00:00
VerifyServerHostname : true ,
2019-02-26 15:52:07 +00:00
CAFile : "a" ,
CAPath : "b" ,
CertFile : "c" ,
KeyFile : "d" ,
NodeName : "e" ,
ServerName : "f" ,
2019-03-19 21:35:19 +00:00
DNSDomain : "g" ,
2019-02-26 15:52:07 +00:00
TLSMinVersion : "tls12" ,
TLSCipherSuites : [ ] uint16 { tls . TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305 } ,
TLSPreferServerCipherSuites : true ,
EnableAgentTLSForChecks : true ,
2019-06-27 20:22:07 +00:00
AutoEncryptTLS : true ,
2019-02-26 15:52:07 +00:00
}
r := c . ToTLSUtilConfig ( )
2019-06-27 20:22:07 +00:00
require . True ( t , r . VerifyIncoming )
require . True ( t , r . VerifyIncomingRPC )
require . True ( t , r . VerifyIncomingHTTPS )
require . True ( t , r . VerifyOutgoing )
require . True ( t , r . EnableAgentTLSForChecks )
require . True ( t , r . AutoEncryptTLS )
require . True ( t , r . VerifyServerHostname )
require . True ( t , r . PreferServerCipherSuites )
require . Equal ( t , "a" , r . CAFile )
require . Equal ( t , "b" , r . CAPath )
require . Equal ( t , "c" , r . CertFile )
require . Equal ( t , "d" , r . KeyFile )
require . Equal ( t , "e" , r . NodeName )
require . Equal ( t , "f" , r . ServerName )
require . Equal ( t , "g" , r . Domain )
require . Equal ( t , "tls12" , r . TLSMinVersion )
require . Equal ( t , [ ] uint16 { tls . TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305 } , r . CipherSuites )
2019-02-26 15:52:07 +00:00
}
ui: modify content path (#5950)
* Add ui-content-path flag
* tests complete, regex validator on string, index.html updated
* cleaning up debugging stuff
* ui: Enable ember environment configuration to be set via the go binary at runtime (#5934)
* ui: Only inject {{.ContentPath}} if we are makeing a prod build...
...otherwise we just use the current rootURL
This gets injected into a <base /> node which solves the assets path
problem but not the ember problem
* ui: Pull out the <base href=""> value and inject it into ember env
See previous commit:
The <base href=""> value is 'sometimes' injected from go at index
serve time. We pass this value down to ember by overwriting the ember
config that is injected via a <meta> tag. This has to be done before
ember bootup.
Sometimes (during testing and development, basically not production)
this is injected with the already existing value, in which case this
essentially changes nothing.
The code here is slightly abstracted away from our specific usage to
make it easier for anyone else to use, and also make sure we can cope
with using this same method to pass variables down from the CLI through
to ember in the future.
* ui: We can't use <base /> move everything to javascript (#5941)
Unfortuantely we can't seem to be able to use <base> and rootURL
together as URL paths will get doubled up (`ui/ui/`).
This moves all the things that we need to interpolate with .ContentPath
to the `startup` javascript so we can conditionally print out
`{{.ContentPath}}` in lots of places (now we can't use base)
* fixed when we serve index.html
* ui: For writing a ContentPath, we also need to cope with testing... (#5945)
...and potentially more environments
Testing has more additional things in a separate index.html in `tests/`
This make the entire thing a little saner and uses just javascriopt
template literals instead of a pseudo handbrake synatx for our
templating of these files.
Intead of just templating the entire file this way, we still only
template `{{content-for 'head'}}` and `{{content-for 'body'}}`
in this way to ensure we support other plugins/addons
* build: Loosen up the regex for retrieving the CONSUL_VERSION (#5946)
* build: Loosen up the regex for retrieving the CONSUL_VERSION
1. Previously the `sed` replacement was searching for the CONSUL_VERSION
comment at the start of a line, it no longer does this to allow for
indentation.
2. Both `grep` and `sed` where looking for the omment at the end of the
line. We've removed this restriction here. We don't need to remove it
right now, but if we ever put the comment followed by something here the
searching would break.
3. Added `xargs` for trimming the resulting version string. We aren't
using this already in the rest of the scripts, but we are pretty sure
this is available on most systems.
* ui: Fix erroneous variable, and also force an ember cache clean on build
1. We referenced a variable incorrectly here, this fixes that.
2. We also made sure that every `make` target clears ember's `tmp` cache
to ensure that its not using any caches that have since been edited
everytime we call a `make` target.
* added docs, fixed encoding
* fixed go fmt
* Update agent/config/config.go
Co-Authored-By: R.B. Boyer <public@richardboyer.net>
* Completed Suggestions
* run gofmt on http.go
* fix testsanitize
* fix fullconfig/hcl by setting correct 'want'
* ran gofmt on agent/config/runtime_test.go
* Update website/source/docs/agent/options.html.md
Co-Authored-By: Hans Hasselberg <me@hans.io>
* Update website/source/docs/agent/options.html.md
Co-Authored-By: kaitlincarter-hc <43049322+kaitlincarter-hc@users.noreply.github.com>
* remove contentpath from redirectFS struct
2019-06-26 16:43:30 +00:00
func Test_UIPathBuilder ( t * testing . T ) {
cases := [ ] struct {
name string
path string
expected string
} {
{
"Letters only string" ,
"hello" ,
"/hello/" ,
} ,
{
"Alphanumeric" ,
"Hello1" ,
"/Hello1/" ,
} ,
{
"Hyphen and underscore" ,
"-_" ,
"/-_/" ,
} ,
{
"Many slashes" ,
"/hello/ui/1/" ,
"/hello/ui/1/" ,
} ,
}
for _ , tt := range cases {
actual := UIPathBuilder ( tt . path )
require . Equal ( t , tt . expected , actual )
}
}
2017-09-25 18:40:42 +00:00
func splitIPPort ( hostport string ) ( net . IP , int ) {
h , p , err := net . SplitHostPort ( hostport )
if err != nil {
panic ( err )
}
port , err := strconv . Atoi ( p )
if err != nil {
panic ( err )
}
return net . ParseIP ( h ) , port
}
func ipAddr ( addr string ) * net . IPAddr {
return & net . IPAddr { IP : net . ParseIP ( addr ) }
}
func tcpAddr ( addr string ) * net . TCPAddr {
ip , port := splitIPPort ( addr )
return & net . TCPAddr { IP : ip , Port : port }
}
func udpAddr ( addr string ) * net . UDPAddr {
ip , port := splitIPPort ( addr )
return & net . UDPAddr { IP : ip , Port : port }
}
func unixAddr ( addr string ) * net . UnixAddr {
if ! strings . HasPrefix ( addr , "unix://" ) {
panic ( "not a unix socket addr: " + addr )
}
return & net . UnixAddr { Net : "unix" , Name : addr [ len ( "unix://" ) : ] }
}
func writeFile ( path string , data [ ] byte ) {
if err := os . MkdirAll ( filepath . Dir ( path ) , 0750 ) ; err != nil {
panic ( err )
}
if err := ioutil . WriteFile ( path , data , 0640 ) ; err != nil {
panic ( err )
}
}
2017-10-31 22:30:01 +00:00
func cleanDir ( path string ) {
root := path
err := filepath . Walk ( root , func ( path string , info os . FileInfo , err error ) error {
if path == root {
return nil
}
return os . RemoveAll ( path )
} )
if err != nil {
panic ( err )
}
}
2017-09-25 18:40:42 +00:00
func randomString ( n int ) string {
s := ""
for ; n > 0 ; n -- {
s += "x"
}
return s
}
func metaPairs ( n int , format string ) string {
var s [ ] string
for i := 0 ; i < n ; i ++ {
switch format {
case "json" :
s = append ( s , fmt . Sprintf ( ` "%d":"%d" ` , i , i ) )
case "hcl" :
s = append ( s , fmt . Sprintf ( ` "%d"="%d" ` , i , i ) )
default :
panic ( "invalid format: " + format )
}
}
switch format {
case "json" :
return strings . Join ( s , "," )
case "hcl" :
return strings . Join ( s , " " )
default :
panic ( "invalid format: " + format )
}
}