test: rename *Config vars to 'cfg'
'c' is ambigous since Command also uses this and we want to use 'config' as a package name.
This commit is contained in:
parent
f6cc2c3fbb
commit
5cdfd3789f
|
@ -16,11 +16,11 @@ import (
|
||||||
|
|
||||||
func TestACL_Bad_Config(t *testing.T) {
|
func TestACL_Bad_Config(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
c := TestConfig()
|
cfg := TestConfig()
|
||||||
c.ACLDownPolicy = "nope"
|
cfg.ACLDownPolicy = "nope"
|
||||||
c.DataDir = testutil.TempDir(t, "agent")
|
cfg.DataDir = testutil.TempDir(t, "agent")
|
||||||
|
|
||||||
_, err := NewAgent(c)
|
_, err := NewAgent(cfg)
|
||||||
if err == nil || !strings.Contains(err.Error(), "invalid ACL down policy") {
|
if err == nil || !strings.Contains(err.Error(), "invalid ACL down policy") {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,9 @@ func (m *MockServer) GetPolicy(args *structs.ACLPolicyRequest, reply *structs.AC
|
||||||
|
|
||||||
func TestACL_Version8(t *testing.T) {
|
func TestACL_Version8(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.ACLEnforceVersion8 = &BoolFalse
|
cfg.ACLEnforceVersion8 = &BoolFalse
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
m := MockServer{}
|
m := MockServer{}
|
||||||
|
@ -61,10 +61,10 @@ func TestACL_Version8(t *testing.T) {
|
||||||
|
|
||||||
func TestACL_Disabled(t *testing.T) {
|
func TestACL_Disabled(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.ACLDisabledTTL = 10 * time.Millisecond
|
cfg.ACLDisabledTTL = 10 * time.Millisecond
|
||||||
config.ACLEnforceVersion8 = &BoolTrue
|
cfg.ACLEnforceVersion8 = &BoolTrue
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
m := MockServer{}
|
m := MockServer{}
|
||||||
|
@ -100,7 +100,7 @@ func TestACL_Disabled(t *testing.T) {
|
||||||
|
|
||||||
// Wait the waiting period and make sure it checks again. Do a few tries
|
// Wait the waiting period and make sure it checks again. Do a few tries
|
||||||
// to make sure we don't think it's disabled.
|
// to make sure we don't think it's disabled.
|
||||||
time.Sleep(2 * config.ACLDisabledTTL)
|
time.Sleep(2 * cfg.ACLDisabledTTL)
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
_, err := a.resolveToken("nope")
|
_, err := a.resolveToken("nope")
|
||||||
if err == nil || !strings.Contains(err.Error(), aclNotFound) {
|
if err == nil || !strings.Contains(err.Error(), aclNotFound) {
|
||||||
|
@ -114,11 +114,10 @@ func TestACL_Disabled(t *testing.T) {
|
||||||
|
|
||||||
func TestACL_Special_IDs(t *testing.T) {
|
func TestACL_Special_IDs(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.ACLEnforceVersion8 = &BoolTrue
|
cfg.ACLEnforceVersion8 = &BoolTrue
|
||||||
config.ACLAgentMasterToken = "towel"
|
cfg.ACLAgentMasterToken = "towel"
|
||||||
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
a := NewTestAgent(t.Name(), config)
|
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
m := MockServer{}
|
m := MockServer{}
|
||||||
|
@ -157,21 +156,21 @@ func TestACL_Special_IDs(t *testing.T) {
|
||||||
if acl == nil {
|
if acl == nil {
|
||||||
t.Fatalf("should not be nil")
|
t.Fatalf("should not be nil")
|
||||||
}
|
}
|
||||||
if !acl.AgentRead(config.NodeName) {
|
if !acl.AgentRead(cfg.NodeName) {
|
||||||
t.Fatalf("should be able to read agent")
|
t.Fatalf("should be able to read agent")
|
||||||
}
|
}
|
||||||
if !acl.AgentWrite(config.NodeName) {
|
if !acl.AgentWrite(cfg.NodeName) {
|
||||||
t.Fatalf("should be able to write agent")
|
t.Fatalf("should be able to write agent")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestACL_Down_Deny(t *testing.T) {
|
func TestACL_Down_Deny(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.ACLDownPolicy = "deny"
|
cfg.ACLDownPolicy = "deny"
|
||||||
config.ACLEnforceVersion8 = &BoolTrue
|
cfg.ACLEnforceVersion8 = &BoolTrue
|
||||||
|
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
m := MockServer{}
|
m := MockServer{}
|
||||||
|
@ -190,18 +189,18 @@ func TestACL_Down_Deny(t *testing.T) {
|
||||||
if acl == nil {
|
if acl == nil {
|
||||||
t.Fatalf("should not be nil")
|
t.Fatalf("should not be nil")
|
||||||
}
|
}
|
||||||
if acl.AgentRead(config.NodeName) {
|
if acl.AgentRead(cfg.NodeName) {
|
||||||
t.Fatalf("should deny")
|
t.Fatalf("should deny")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestACL_Down_Allow(t *testing.T) {
|
func TestACL_Down_Allow(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.ACLDownPolicy = "allow"
|
cfg.ACLDownPolicy = "allow"
|
||||||
config.ACLEnforceVersion8 = &BoolTrue
|
cfg.ACLEnforceVersion8 = &BoolTrue
|
||||||
|
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
m := MockServer{}
|
m := MockServer{}
|
||||||
|
@ -220,18 +219,18 @@ func TestACL_Down_Allow(t *testing.T) {
|
||||||
if acl == nil {
|
if acl == nil {
|
||||||
t.Fatalf("should not be nil")
|
t.Fatalf("should not be nil")
|
||||||
}
|
}
|
||||||
if !acl.AgentRead(config.NodeName) {
|
if !acl.AgentRead(cfg.NodeName) {
|
||||||
t.Fatalf("should allow")
|
t.Fatalf("should allow")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestACL_Down_Extend(t *testing.T) {
|
func TestACL_Down_Extend(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.ACLDownPolicy = "extend-cache"
|
cfg.ACLDownPolicy = "extend-cache"
|
||||||
config.ACLEnforceVersion8 = &BoolTrue
|
cfg.ACLEnforceVersion8 = &BoolTrue
|
||||||
|
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
m := MockServer{}
|
m := MockServer{}
|
||||||
|
@ -246,7 +245,7 @@ func TestACL_Down_Extend(t *testing.T) {
|
||||||
Policy: &rawacl.Policy{
|
Policy: &rawacl.Policy{
|
||||||
Agents: []*rawacl.AgentPolicy{
|
Agents: []*rawacl.AgentPolicy{
|
||||||
&rawacl.AgentPolicy{
|
&rawacl.AgentPolicy{
|
||||||
Node: config.NodeName,
|
Node: cfg.NodeName,
|
||||||
Policy: "read",
|
Policy: "read",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -261,10 +260,10 @@ func TestACL_Down_Extend(t *testing.T) {
|
||||||
if acl == nil {
|
if acl == nil {
|
||||||
t.Fatalf("should not be nil")
|
t.Fatalf("should not be nil")
|
||||||
}
|
}
|
||||||
if !acl.AgentRead(config.NodeName) {
|
if !acl.AgentRead(cfg.NodeName) {
|
||||||
t.Fatalf("should allow")
|
t.Fatalf("should allow")
|
||||||
}
|
}
|
||||||
if acl.AgentWrite(config.NodeName) {
|
if acl.AgentWrite(cfg.NodeName) {
|
||||||
t.Fatalf("should deny")
|
t.Fatalf("should deny")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,10 +278,10 @@ func TestACL_Down_Extend(t *testing.T) {
|
||||||
if acl == nil {
|
if acl == nil {
|
||||||
t.Fatalf("should not be nil")
|
t.Fatalf("should not be nil")
|
||||||
}
|
}
|
||||||
if acl.AgentRead(config.NodeName) {
|
if acl.AgentRead(cfg.NodeName) {
|
||||||
t.Fatalf("should deny")
|
t.Fatalf("should deny")
|
||||||
}
|
}
|
||||||
if acl.AgentWrite(config.NodeName) {
|
if acl.AgentWrite(cfg.NodeName) {
|
||||||
t.Fatalf("should deny")
|
t.Fatalf("should deny")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,20 +294,20 @@ func TestACL_Down_Extend(t *testing.T) {
|
||||||
if acl == nil {
|
if acl == nil {
|
||||||
t.Fatalf("should not be nil")
|
t.Fatalf("should not be nil")
|
||||||
}
|
}
|
||||||
if !acl.AgentRead(config.NodeName) {
|
if !acl.AgentRead(cfg.NodeName) {
|
||||||
t.Fatalf("should allow")
|
t.Fatalf("should allow")
|
||||||
}
|
}
|
||||||
if acl.AgentWrite(config.NodeName) {
|
if acl.AgentWrite(cfg.NodeName) {
|
||||||
t.Fatalf("should deny")
|
t.Fatalf("should deny")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestACL_Cache(t *testing.T) {
|
func TestACL_Cache(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.ACLEnforceVersion8 = &BoolTrue
|
cfg.ACLEnforceVersion8 = &BoolTrue
|
||||||
|
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
m := MockServer{}
|
m := MockServer{}
|
||||||
|
@ -324,7 +323,7 @@ func TestACL_Cache(t *testing.T) {
|
||||||
Policy: &rawacl.Policy{
|
Policy: &rawacl.Policy{
|
||||||
Agents: []*rawacl.AgentPolicy{
|
Agents: []*rawacl.AgentPolicy{
|
||||||
&rawacl.AgentPolicy{
|
&rawacl.AgentPolicy{
|
||||||
Node: config.NodeName,
|
Node: cfg.NodeName,
|
||||||
Policy: "read",
|
Policy: "read",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -340,10 +339,10 @@ func TestACL_Cache(t *testing.T) {
|
||||||
if acl == nil {
|
if acl == nil {
|
||||||
t.Fatalf("should not be nil")
|
t.Fatalf("should not be nil")
|
||||||
}
|
}
|
||||||
if !acl.AgentRead(config.NodeName) {
|
if !acl.AgentRead(cfg.NodeName) {
|
||||||
t.Fatalf("should allow")
|
t.Fatalf("should allow")
|
||||||
}
|
}
|
||||||
if acl.AgentWrite(config.NodeName) {
|
if acl.AgentWrite(cfg.NodeName) {
|
||||||
t.Fatalf("should deny")
|
t.Fatalf("should deny")
|
||||||
}
|
}
|
||||||
if acl.NodeRead("nope") {
|
if acl.NodeRead("nope") {
|
||||||
|
@ -362,10 +361,10 @@ func TestACL_Cache(t *testing.T) {
|
||||||
if acl == nil {
|
if acl == nil {
|
||||||
t.Fatalf("should not be nil")
|
t.Fatalf("should not be nil")
|
||||||
}
|
}
|
||||||
if !acl.AgentRead(config.NodeName) {
|
if !acl.AgentRead(cfg.NodeName) {
|
||||||
t.Fatalf("should allow")
|
t.Fatalf("should allow")
|
||||||
}
|
}
|
||||||
if acl.AgentWrite(config.NodeName) {
|
if acl.AgentWrite(cfg.NodeName) {
|
||||||
t.Fatalf("should deny")
|
t.Fatalf("should deny")
|
||||||
}
|
}
|
||||||
if acl.NodeRead("nope") {
|
if acl.NodeRead("nope") {
|
||||||
|
@ -391,7 +390,7 @@ func TestACL_Cache(t *testing.T) {
|
||||||
Policy: &rawacl.Policy{
|
Policy: &rawacl.Policy{
|
||||||
Agents: []*rawacl.AgentPolicy{
|
Agents: []*rawacl.AgentPolicy{
|
||||||
&rawacl.AgentPolicy{
|
&rawacl.AgentPolicy{
|
||||||
Node: config.NodeName,
|
Node: cfg.NodeName,
|
||||||
Policy: "write",
|
Policy: "write",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -407,10 +406,10 @@ func TestACL_Cache(t *testing.T) {
|
||||||
if acl == nil {
|
if acl == nil {
|
||||||
t.Fatalf("should not be nil")
|
t.Fatalf("should not be nil")
|
||||||
}
|
}
|
||||||
if !acl.AgentRead(config.NodeName) {
|
if !acl.AgentRead(cfg.NodeName) {
|
||||||
t.Fatalf("should allow")
|
t.Fatalf("should allow")
|
||||||
}
|
}
|
||||||
if !acl.AgentWrite(config.NodeName) {
|
if !acl.AgentWrite(cfg.NodeName) {
|
||||||
t.Fatalf("should allow")
|
t.Fatalf("should allow")
|
||||||
}
|
}
|
||||||
if acl.NodeRead("nope") {
|
if acl.NodeRead("nope") {
|
||||||
|
@ -437,10 +436,10 @@ func TestACL_Cache(t *testing.T) {
|
||||||
if acl == nil {
|
if acl == nil {
|
||||||
t.Fatalf("should not be nil")
|
t.Fatalf("should not be nil")
|
||||||
}
|
}
|
||||||
if !acl.AgentRead(config.NodeName) {
|
if !acl.AgentRead(cfg.NodeName) {
|
||||||
t.Fatalf("should allow")
|
t.Fatalf("should allow")
|
||||||
}
|
}
|
||||||
if !acl.AgentWrite(config.NodeName) {
|
if !acl.AgentWrite(cfg.NodeName) {
|
||||||
t.Fatalf("should allow")
|
t.Fatalf("should allow")
|
||||||
}
|
}
|
||||||
if acl.NodeRead("nope") {
|
if acl.NodeRead("nope") {
|
||||||
|
@ -487,10 +486,10 @@ func catalogPolicy(req *structs.ACLPolicyRequest, reply *structs.ACLPolicy) erro
|
||||||
|
|
||||||
func TestACL_vetServiceRegister(t *testing.T) {
|
func TestACL_vetServiceRegister(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.ACLEnforceVersion8 = &BoolTrue
|
cfg.ACLEnforceVersion8 = &BoolTrue
|
||||||
|
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
m := MockServer{catalogPolicy}
|
m := MockServer{catalogPolicy}
|
||||||
|
@ -533,10 +532,10 @@ func TestACL_vetServiceRegister(t *testing.T) {
|
||||||
|
|
||||||
func TestACL_vetServiceUpdate(t *testing.T) {
|
func TestACL_vetServiceUpdate(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.ACLEnforceVersion8 = &BoolTrue
|
cfg.ACLEnforceVersion8 = &BoolTrue
|
||||||
|
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
m := MockServer{catalogPolicy}
|
m := MockServer{catalogPolicy}
|
||||||
|
@ -569,10 +568,10 @@ func TestACL_vetServiceUpdate(t *testing.T) {
|
||||||
|
|
||||||
func TestACL_vetCheckRegister(t *testing.T) {
|
func TestACL_vetCheckRegister(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.ACLEnforceVersion8 = &BoolTrue
|
cfg.ACLEnforceVersion8 = &BoolTrue
|
||||||
|
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
m := MockServer{catalogPolicy}
|
m := MockServer{catalogPolicy}
|
||||||
|
@ -652,10 +651,10 @@ func TestACL_vetCheckRegister(t *testing.T) {
|
||||||
|
|
||||||
func TestACL_vetCheckUpdate(t *testing.T) {
|
func TestACL_vetCheckUpdate(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.ACLEnforceVersion8 = &BoolTrue
|
cfg.ACLEnforceVersion8 = &BoolTrue
|
||||||
|
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
m := MockServer{catalogPolicy}
|
m := MockServer{catalogPolicy}
|
||||||
|
@ -708,10 +707,10 @@ func TestACL_vetCheckUpdate(t *testing.T) {
|
||||||
|
|
||||||
func TestACL_filterMembers(t *testing.T) {
|
func TestACL_filterMembers(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.ACLEnforceVersion8 = &BoolTrue
|
cfg.ACLEnforceVersion8 = &BoolTrue
|
||||||
|
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
m := MockServer{catalogPolicy}
|
m := MockServer{catalogPolicy}
|
||||||
|
@ -744,10 +743,10 @@ func TestACL_filterMembers(t *testing.T) {
|
||||||
|
|
||||||
func TestACL_filterServices(t *testing.T) {
|
func TestACL_filterServices(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.ACLEnforceVersion8 = &BoolTrue
|
cfg.ACLEnforceVersion8 = &BoolTrue
|
||||||
|
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
m := MockServer{catalogPolicy}
|
m := MockServer{catalogPolicy}
|
||||||
|
@ -775,10 +774,10 @@ func TestACL_filterServices(t *testing.T) {
|
||||||
|
|
||||||
func TestACL_filterChecks(t *testing.T) {
|
func TestACL_filterChecks(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.ACLEnforceVersion8 = &BoolTrue
|
cfg.ACLEnforceVersion8 = &BoolTrue
|
||||||
|
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
m := MockServer{catalogPolicy}
|
m := MockServer{catalogPolicy}
|
||||||
|
|
|
@ -164,9 +164,9 @@ func TestAgent_Checks_ACLFilter(t *testing.T) {
|
||||||
|
|
||||||
func TestAgent_Self(t *testing.T) {
|
func TestAgent_Self(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
conf := TestConfig()
|
cfg := TestConfig()
|
||||||
conf.Meta = map[string]string{"somekey": "somevalue"}
|
cfg.Meta = map[string]string{"somekey": "somevalue"}
|
||||||
a := NewTestAgent(t.Name(), conf)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
req, _ := http.NewRequest("GET", "/v1/agent/self", nil)
|
req, _ := http.NewRequest("GET", "/v1/agent/self", nil)
|
||||||
|
@ -191,8 +191,8 @@ func TestAgent_Self(t *testing.T) {
|
||||||
if !reflect.DeepEqual(c, val.Coord) {
|
if !reflect.DeepEqual(c, val.Coord) {
|
||||||
t.Fatalf("coordinates are not equal: %v != %v", c, val.Coord)
|
t.Fatalf("coordinates are not equal: %v != %v", c, val.Coord)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(conf.Meta, val.Meta) {
|
if !reflect.DeepEqual(cfg.Meta, val.Meta) {
|
||||||
t.Fatalf("meta fields are not equal: %v != %v", conf.Meta, val.Meta)
|
t.Fatalf("meta fields are not equal: %v != %v", cfg.Meta, val.Meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure there's nothing called "token" that's leaked.
|
// Make sure there's nothing called "token" that's leaked.
|
||||||
|
@ -235,7 +235,7 @@ func TestAgent_Self_ACLDeny(t *testing.T) {
|
||||||
|
|
||||||
func TestAgent_Reload(t *testing.T) {
|
func TestAgent_Reload(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
conf := TestConfig()
|
cfg := TestConfig()
|
||||||
tmpDir := testutil.TempDir(t, "consul")
|
tmpDir := testutil.TempDir(t, "consul")
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ func TestAgent_Reload(t *testing.T) {
|
||||||
"-server",
|
"-server",
|
||||||
"-bind", "127.0.0.1",
|
"-bind", "127.0.0.1",
|
||||||
"-data-dir", tmpDir,
|
"-data-dir", tmpDir,
|
||||||
"-http-port", fmt.Sprintf("%d", conf.Ports.HTTP),
|
"-http-port", fmt.Sprintf("%d", cfg.Ports.HTTP),
|
||||||
"-config-file", tmpFile.Name(),
|
"-config-file", tmpFile.Name(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,10 +495,10 @@ func TestAgent_Leave(t *testing.T) {
|
||||||
a1 := NewTestAgent(t.Name(), nil)
|
a1 := NewTestAgent(t.Name(), nil)
|
||||||
defer a1.Shutdown()
|
defer a1.Shutdown()
|
||||||
|
|
||||||
conf2 := TestConfig()
|
cfg2 := TestConfig()
|
||||||
conf2.Server = false
|
cfg2.Server = false
|
||||||
conf2.Bootstrap = false
|
cfg2.Bootstrap = false
|
||||||
a2 := NewTestAgent(t.Name(), conf2)
|
a2 := NewTestAgent(t.Name(), cfg2)
|
||||||
defer a2.Shutdown()
|
defer a2.Shutdown()
|
||||||
|
|
||||||
// Join first
|
// Join first
|
||||||
|
|
|
@ -80,14 +80,14 @@ func TestAgent_CheckSerfBindAddrsSettings(t *testing.T) {
|
||||||
t.Skip("skip test on macOS to avoid firewall warning dialog")
|
t.Skip("skip test on macOS to avoid firewall warning dialog")
|
||||||
}
|
}
|
||||||
|
|
||||||
c := TestConfig()
|
cfg := TestConfig()
|
||||||
ip, err := externalIP()
|
ip, err := externalIP()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unable to get a non-loopback IP: %v", err)
|
t.Fatalf("Unable to get a non-loopback IP: %v", err)
|
||||||
}
|
}
|
||||||
c.SerfLanBindAddr = ip
|
cfg.SerfLanBindAddr = ip
|
||||||
c.SerfWanBindAddr = ip
|
cfg.SerfWanBindAddr = ip
|
||||||
a := NewTestAgent(t.Name(), c)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
serfWanBind := a.consulConfig().SerfWANConfig.MemberlistConfig.BindAddr
|
serfWanBind := a.consulConfig().SerfWANConfig.MemberlistConfig.BindAddr
|
||||||
|
@ -102,11 +102,11 @@ func TestAgent_CheckSerfBindAddrsSettings(t *testing.T) {
|
||||||
}
|
}
|
||||||
func TestAgent_CheckAdvertiseAddrsSettings(t *testing.T) {
|
func TestAgent_CheckAdvertiseAddrsSettings(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
c := TestConfig()
|
cfg := TestConfig()
|
||||||
c.AdvertiseAddrs.SerfLan, _ = net.ResolveTCPAddr("tcp", "127.0.0.42:1233")
|
cfg.AdvertiseAddrs.SerfLan, _ = net.ResolveTCPAddr("tcp", "127.0.0.42:1233")
|
||||||
c.AdvertiseAddrs.SerfWan, _ = net.ResolveTCPAddr("tcp", "127.0.0.43:1234")
|
cfg.AdvertiseAddrs.SerfWan, _ = net.ResolveTCPAddr("tcp", "127.0.0.43:1234")
|
||||||
c.AdvertiseAddrs.RPC, _ = net.ResolveTCPAddr("tcp", "127.0.0.44:1235")
|
cfg.AdvertiseAddrs.RPC, _ = net.ResolveTCPAddr("tcp", "127.0.0.44:1235")
|
||||||
a := NewTestAgent(t.Name(), c)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
serfLanAddr := a.consulConfig().SerfLANConfig.MemberlistConfig.AdvertiseAddr
|
serfLanAddr := a.consulConfig().SerfLANConfig.MemberlistConfig.AdvertiseAddr
|
||||||
|
@ -126,8 +126,8 @@ func TestAgent_CheckAdvertiseAddrsSettings(t *testing.T) {
|
||||||
t.Fatalf("SerfWan is not properly set to '1234': %d", serfWanPort)
|
t.Fatalf("SerfWan is not properly set to '1234': %d", serfWanPort)
|
||||||
}
|
}
|
||||||
rpc := a.consulConfig().RPCAdvertise
|
rpc := a.consulConfig().RPCAdvertise
|
||||||
if rpc != c.AdvertiseAddrs.RPC {
|
if rpc != cfg.AdvertiseAddrs.RPC {
|
||||||
t.Fatalf("RPC is not properly set to %v: %s", c.AdvertiseAddrs.RPC, rpc)
|
t.Fatalf("RPC is not properly set to %v: %s", cfg.AdvertiseAddrs.RPC, rpc)
|
||||||
}
|
}
|
||||||
expected := map[string]string{
|
expected := map[string]string{
|
||||||
"lan": a.Config.AdvertiseAddr,
|
"lan": a.Config.AdvertiseAddr,
|
||||||
|
@ -142,10 +142,10 @@ func TestAgent_CheckPerformanceSettings(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
// Try a default config.
|
// Try a default config.
|
||||||
{
|
{
|
||||||
c := TestConfig()
|
cfg := TestConfig()
|
||||||
c.Bootstrap = false
|
cfg.Bootstrap = false
|
||||||
c.ConsulConfig = nil
|
cfg.ConsulConfig = nil
|
||||||
a := NewTestAgent(t.Name(), c)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
raftMult := time.Duration(consul.DefaultRaftMultiplier)
|
raftMult := time.Duration(consul.DefaultRaftMultiplier)
|
||||||
|
@ -160,10 +160,10 @@ func TestAgent_CheckPerformanceSettings(t *testing.T) {
|
||||||
|
|
||||||
// Try a multiplier.
|
// Try a multiplier.
|
||||||
{
|
{
|
||||||
c := TestConfig()
|
cfg := TestConfig()
|
||||||
c.Bootstrap = false
|
cfg.Bootstrap = false
|
||||||
c.Performance.RaftMultiplier = 99
|
cfg.Performance.RaftMultiplier = 99
|
||||||
a := NewTestAgent(t.Name(), c)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
const raftMult time.Duration = 99
|
const raftMult time.Duration = 99
|
||||||
|
@ -195,10 +195,10 @@ func TestAgent_ReconnectConfigSettings(t *testing.T) {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
func() {
|
func() {
|
||||||
c := TestConfig()
|
cfg := TestConfig()
|
||||||
c.ReconnectTimeoutLan = 24 * time.Hour
|
cfg.ReconnectTimeoutLan = 24 * time.Hour
|
||||||
c.ReconnectTimeoutWan = 36 * time.Hour
|
cfg.ReconnectTimeoutWan = 36 * time.Hour
|
||||||
a := NewTestAgent(t.Name(), c)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
lan := a.consulConfig().SerfLANConfig.ReconnectTimeout
|
lan := a.consulConfig().SerfLANConfig.ReconnectTimeout
|
||||||
|
@ -215,9 +215,9 @@ func TestAgent_ReconnectConfigSettings(t *testing.T) {
|
||||||
|
|
||||||
func TestAgent_setupNodeID(t *testing.T) {
|
func TestAgent_setupNodeID(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
c := TestConfig()
|
cfg := TestConfig()
|
||||||
c.NodeID = ""
|
cfg.NodeID = ""
|
||||||
a := NewTestAgent(t.Name(), c)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
// The auto-assigned ID should be valid.
|
// The auto-assigned ID should be valid.
|
||||||
|
@ -227,8 +227,8 @@ func TestAgent_setupNodeID(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Running again should get the same ID (persisted in the file).
|
// Running again should get the same ID (persisted in the file).
|
||||||
c.NodeID = ""
|
cfg.NodeID = ""
|
||||||
if err := a.setupNodeID(c); err != nil {
|
if err := a.setupNodeID(cfg); err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
if newID := a.consulConfig().NodeID; id != newID {
|
if newID := a.consulConfig().NodeID; id != newID {
|
||||||
|
@ -236,8 +236,8 @@ func TestAgent_setupNodeID(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set an invalid ID via.Config.
|
// Set an invalid ID via.Config.
|
||||||
c.NodeID = types.NodeID("nope")
|
cfg.NodeID = types.NodeID("nope")
|
||||||
err := a.setupNodeID(c)
|
err := a.setupNodeID(cfg)
|
||||||
if err == nil || !strings.Contains(err.Error(), "uuid string is wrong length") {
|
if err == nil || !strings.Contains(err.Error(), "uuid string is wrong length") {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -247,8 +247,8 @@ func TestAgent_setupNodeID(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
c.NodeID = types.NodeID(strings.ToUpper(newID))
|
cfg.NodeID = types.NodeID(strings.ToUpper(newID))
|
||||||
if err := a.setupNodeID(c); err != nil {
|
if err := a.setupNodeID(cfg); err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
if id := a.consulConfig().NodeID; string(id) != newID {
|
if id := a.consulConfig().NodeID; string(id) != newID {
|
||||||
|
@ -256,12 +256,12 @@ func TestAgent_setupNodeID(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set an invalid ID via the file.
|
// Set an invalid ID via the file.
|
||||||
fileID := filepath.Join(c.DataDir, "node-id")
|
fileID := filepath.Join(cfg.DataDir, "node-id")
|
||||||
if err := ioutil.WriteFile(fileID, []byte("adf4238a!882b!9ddc!4a9d!5b6758e4159e"), 0600); err != nil {
|
if err := ioutil.WriteFile(fileID, []byte("adf4238a!882b!9ddc!4a9d!5b6758e4159e"), 0600); err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
c.NodeID = ""
|
cfg.NodeID = ""
|
||||||
err = a.setupNodeID(c)
|
err = a.setupNodeID(cfg)
|
||||||
if err == nil || !strings.Contains(err.Error(), "uuid is improperly formatted") {
|
if err == nil || !strings.Contains(err.Error(), "uuid is improperly formatted") {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -270,8 +270,8 @@ func TestAgent_setupNodeID(t *testing.T) {
|
||||||
if err := ioutil.WriteFile(fileID, []byte("ADF4238a-882b-9ddc-4a9d-5b6758e4159e"), 0600); err != nil {
|
if err := ioutil.WriteFile(fileID, []byte("ADF4238a-882b-9ddc-4a9d-5b6758e4159e"), 0600); err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
c.NodeID = ""
|
cfg.NodeID = ""
|
||||||
if err := a.setupNodeID(c); err != nil {
|
if err := a.setupNodeID(cfg); err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
if id := a.consulConfig().NodeID; string(id) != "adf4238a-882b-9ddc-4a9d-5b6758e4159e" {
|
if id := a.consulConfig().NodeID; string(id) != "adf4238a-882b-9ddc-4a9d-5b6758e4159e" {
|
||||||
|
@ -281,9 +281,9 @@ func TestAgent_setupNodeID(t *testing.T) {
|
||||||
|
|
||||||
func TestAgent_makeNodeID(t *testing.T) {
|
func TestAgent_makeNodeID(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
c := TestConfig()
|
cfg := TestConfig()
|
||||||
c.NodeID = ""
|
cfg.NodeID = ""
|
||||||
a := NewTestAgent(t.Name(), c)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
// We should get a valid host-based ID initially.
|
// We should get a valid host-based ID initially.
|
||||||
|
@ -885,11 +885,11 @@ func TestAgent_ConsulService(t *testing.T) {
|
||||||
|
|
||||||
func TestAgent_PersistService(t *testing.T) {
|
func TestAgent_PersistService(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.Server = false
|
cfg.Server = false
|
||||||
config.DataDir = testutil.TempDir(t, "agent") // we manage the data dir
|
cfg.DataDir = testutil.TempDir(t, "agent") // we manage the data dir
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer os.RemoveAll(config.DataDir)
|
defer os.RemoveAll(cfg.DataDir)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
svc := &structs.NodeService{
|
svc := &structs.NodeService{
|
||||||
|
@ -953,7 +953,7 @@ func TestAgent_PersistService(t *testing.T) {
|
||||||
a.Shutdown()
|
a.Shutdown()
|
||||||
|
|
||||||
// Should load it back during later start
|
// Should load it back during later start
|
||||||
agent2, err := NewAgent(config)
|
agent2, err := NewAgent(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -1060,9 +1060,9 @@ func TestAgent_PurgeService(t *testing.T) {
|
||||||
|
|
||||||
func TestAgent_PurgeServiceOnDuplicate(t *testing.T) {
|
func TestAgent_PurgeServiceOnDuplicate(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.Server = false
|
cfg.Server = false
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
svc1 := &structs.NodeService{
|
svc1 := &structs.NodeService{
|
||||||
|
@ -1087,8 +1087,8 @@ func TestAgent_PurgeServiceOnDuplicate(t *testing.T) {
|
||||||
Port: 9000,
|
Port: 9000,
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Services = []*ServiceDefinition{svc2}
|
cfg.Services = []*ServiceDefinition{svc2}
|
||||||
agent2, err := NewAgent(config)
|
agent2, err := NewAgent(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -1112,15 +1112,15 @@ func TestAgent_PurgeServiceOnDuplicate(t *testing.T) {
|
||||||
|
|
||||||
func TestAgent_PersistCheck(t *testing.T) {
|
func TestAgent_PersistCheck(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.Server = false
|
cfg.Server = false
|
||||||
config.DataDir = testutil.TempDir(t, "agent") // we manage the data dir
|
cfg.DataDir = testutil.TempDir(t, "agent") // we manage the data dir
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer os.RemoveAll(config.DataDir)
|
defer os.RemoveAll(cfg.DataDir)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
check := &structs.HealthCheck{
|
check := &structs.HealthCheck{
|
||||||
Node: config.NodeName,
|
Node: cfg.NodeName,
|
||||||
CheckID: "mem",
|
CheckID: "mem",
|
||||||
Name: "memory check",
|
Name: "memory check",
|
||||||
Status: api.HealthPassing,
|
Status: api.HealthPassing,
|
||||||
|
@ -1186,7 +1186,7 @@ func TestAgent_PersistCheck(t *testing.T) {
|
||||||
a.Shutdown()
|
a.Shutdown()
|
||||||
|
|
||||||
// Should load it back during later start
|
// Should load it back during later start
|
||||||
agent2, err := NewAgent(config)
|
agent2, err := NewAgent(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -1251,15 +1251,15 @@ func TestAgent_PurgeCheck(t *testing.T) {
|
||||||
|
|
||||||
func TestAgent_PurgeCheckOnDuplicate(t *testing.T) {
|
func TestAgent_PurgeCheckOnDuplicate(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.Server = false
|
cfg.Server = false
|
||||||
config.DataDir = testutil.TempDir(t, "agent") // we manage the data dir
|
cfg.DataDir = testutil.TempDir(t, "agent") // we manage the data dir
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer os.RemoveAll(config.DataDir)
|
defer os.RemoveAll(cfg.DataDir)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
check1 := &structs.HealthCheck{
|
check1 := &structs.HealthCheck{
|
||||||
Node: config.NodeName,
|
Node: cfg.NodeName,
|
||||||
CheckID: "mem",
|
CheckID: "mem",
|
||||||
Name: "memory check",
|
Name: "memory check",
|
||||||
Status: api.HealthPassing,
|
Status: api.HealthPassing,
|
||||||
|
@ -1280,8 +1280,8 @@ func TestAgent_PurgeCheckOnDuplicate(t *testing.T) {
|
||||||
Interval: 30 * time.Second,
|
Interval: 30 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Checks = []*CheckDefinition{check2}
|
cfg.Checks = []*CheckDefinition{check2}
|
||||||
agent2, err := NewAgent(config)
|
agent2, err := NewAgent(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -1298,7 +1298,7 @@ func TestAgent_PurgeCheckOnDuplicate(t *testing.T) {
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("missing check registration")
|
t.Fatalf("missing check registration")
|
||||||
}
|
}
|
||||||
expected := check2.HealthCheck(config.NodeName)
|
expected := check2.HealthCheck(cfg.NodeName)
|
||||||
if !reflect.DeepEqual(expected, result) {
|
if !reflect.DeepEqual(expected, result) {
|
||||||
t.Fatalf("bad: %#v", result)
|
t.Fatalf("bad: %#v", result)
|
||||||
}
|
}
|
||||||
|
@ -1306,14 +1306,14 @@ func TestAgent_PurgeCheckOnDuplicate(t *testing.T) {
|
||||||
|
|
||||||
func TestAgent_loadChecks_token(t *testing.T) {
|
func TestAgent_loadChecks_token(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.Checks = append(config.Checks, &CheckDefinition{
|
cfg.Checks = append(cfg.Checks, &CheckDefinition{
|
||||||
ID: "rabbitmq",
|
ID: "rabbitmq",
|
||||||
Name: "rabbitmq",
|
Name: "rabbitmq",
|
||||||
Token: "abc123",
|
Token: "abc123",
|
||||||
TTL: 10 * time.Second,
|
TTL: 10 * time.Second,
|
||||||
})
|
})
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
checks := a.state.Checks()
|
checks := a.state.Checks()
|
||||||
|
@ -1379,14 +1379,14 @@ func TestAgent_unloadChecks(t *testing.T) {
|
||||||
|
|
||||||
func TestAgent_loadServices_token(t *testing.T) {
|
func TestAgent_loadServices_token(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.Services = append(config.Services, &ServiceDefinition{
|
cfg.Services = append(cfg.Services, &ServiceDefinition{
|
||||||
ID: "rabbitmq",
|
ID: "rabbitmq",
|
||||||
Name: "rabbitmq",
|
Name: "rabbitmq",
|
||||||
Port: 5672,
|
Port: 5672,
|
||||||
Token: "abc123",
|
Token: "abc123",
|
||||||
})
|
})
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
services := a.state.Services()
|
services := a.state.Services()
|
||||||
|
@ -1511,10 +1511,10 @@ func TestAgent_Service_MaintenanceMode(t *testing.T) {
|
||||||
|
|
||||||
func TestAgent_Service_Reap(t *testing.T) {
|
func TestAgent_Service_Reap(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.CheckReapInterval = time.Millisecond
|
cfg.CheckReapInterval = time.Millisecond
|
||||||
config.CheckDeregisterIntervalMin = 0
|
cfg.CheckDeregisterIntervalMin = 0
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
svc := &structs.NodeService{
|
svc := &structs.NodeService{
|
||||||
|
@ -1585,10 +1585,10 @@ func TestAgent_Service_Reap(t *testing.T) {
|
||||||
|
|
||||||
func TestAgent_Service_NoReap(t *testing.T) {
|
func TestAgent_Service_NoReap(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.CheckReapInterval = time.Millisecond
|
cfg.CheckReapInterval = time.Millisecond
|
||||||
config.CheckDeregisterIntervalMin = 0
|
cfg.CheckDeregisterIntervalMin = 0
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
svc := &structs.NodeService{
|
svc := &structs.NodeService{
|
||||||
|
@ -1959,9 +1959,9 @@ func TestAgent_purgeCheckState(t *testing.T) {
|
||||||
func TestAgent_GetCoordinate(t *testing.T) {
|
func TestAgent_GetCoordinate(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
check := func(server bool) {
|
check := func(server bool) {
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.Server = server
|
cfg.Server = server
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
// This doesn't verify the returned coordinate, but it makes
|
// This doesn't verify the returned coordinate, but it makes
|
||||||
|
|
|
@ -182,18 +182,18 @@ func TestCatalogNodes_MetaFilter(t *testing.T) {
|
||||||
|
|
||||||
func TestCatalogNodes_WanTranslation(t *testing.T) {
|
func TestCatalogNodes_WanTranslation(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
c1 := TestConfig()
|
cfg1 := TestConfig()
|
||||||
c1.Datacenter = "dc1"
|
cfg1.Datacenter = "dc1"
|
||||||
c1.TranslateWanAddrs = true
|
cfg1.TranslateWanAddrs = true
|
||||||
c1.ACLDatacenter = ""
|
cfg1.ACLDatacenter = ""
|
||||||
a1 := NewTestAgent(t.Name(), c1)
|
a1 := NewTestAgent(t.Name(), cfg1)
|
||||||
defer a1.Shutdown()
|
defer a1.Shutdown()
|
||||||
|
|
||||||
c2 := TestConfig()
|
cfg2 := TestConfig()
|
||||||
c2.Datacenter = "dc2"
|
cfg2.Datacenter = "dc2"
|
||||||
c2.TranslateWanAddrs = true
|
cfg2.TranslateWanAddrs = true
|
||||||
c2.ACLDatacenter = ""
|
cfg2.ACLDatacenter = ""
|
||||||
a2 := NewTestAgent(t.Name(), c2)
|
a2 := NewTestAgent(t.Name(), cfg2)
|
||||||
defer a2.Shutdown()
|
defer a2.Shutdown()
|
||||||
|
|
||||||
// Wait for the WAN join.
|
// Wait for the WAN join.
|
||||||
|
@ -597,18 +597,18 @@ func TestCatalogServiceNodes_NodeMetaFilter(t *testing.T) {
|
||||||
|
|
||||||
func TestCatalogServiceNodes_WanTranslation(t *testing.T) {
|
func TestCatalogServiceNodes_WanTranslation(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
c1 := TestConfig()
|
cfg1 := TestConfig()
|
||||||
c1.Datacenter = "dc1"
|
cfg1.Datacenter = "dc1"
|
||||||
c1.TranslateWanAddrs = true
|
cfg1.TranslateWanAddrs = true
|
||||||
c1.ACLDatacenter = ""
|
cfg1.ACLDatacenter = ""
|
||||||
a1 := NewTestAgent(t.Name(), c1)
|
a1 := NewTestAgent(t.Name(), cfg1)
|
||||||
defer a1.Shutdown()
|
defer a1.Shutdown()
|
||||||
|
|
||||||
c2 := TestConfig()
|
cfg2 := TestConfig()
|
||||||
c2.Datacenter = "dc2"
|
cfg2.Datacenter = "dc2"
|
||||||
c2.TranslateWanAddrs = true
|
cfg2.TranslateWanAddrs = true
|
||||||
c2.ACLDatacenter = ""
|
cfg2.ACLDatacenter = ""
|
||||||
a2 := NewTestAgent(t.Name(), c2)
|
a2 := NewTestAgent(t.Name(), cfg2)
|
||||||
defer a2.Shutdown()
|
defer a2.Shutdown()
|
||||||
|
|
||||||
// Wait for the WAN join.
|
// Wait for the WAN join.
|
||||||
|
@ -804,18 +804,18 @@ func TestCatalogNodeServices(t *testing.T) {
|
||||||
|
|
||||||
func TestCatalogNodeServices_WanTranslation(t *testing.T) {
|
func TestCatalogNodeServices_WanTranslation(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
c1 := TestConfig()
|
cfg1 := TestConfig()
|
||||||
c1.Datacenter = "dc1"
|
cfg1.Datacenter = "dc1"
|
||||||
c1.TranslateWanAddrs = true
|
cfg1.TranslateWanAddrs = true
|
||||||
c1.ACLDatacenter = ""
|
cfg1.ACLDatacenter = ""
|
||||||
a1 := NewTestAgent(t.Name(), c1)
|
a1 := NewTestAgent(t.Name(), cfg1)
|
||||||
defer a1.Shutdown()
|
defer a1.Shutdown()
|
||||||
|
|
||||||
c2 := TestConfig()
|
cfg2 := TestConfig()
|
||||||
c2.Datacenter = "dc2"
|
cfg2.Datacenter = "dc2"
|
||||||
c2.TranslateWanAddrs = true
|
cfg2.TranslateWanAddrs = true
|
||||||
c2.ACLDatacenter = ""
|
cfg2.ACLDatacenter = ""
|
||||||
a2 := NewTestAgent(t.Name(), c2)
|
a2 := NewTestAgent(t.Name(), cfg2)
|
||||||
defer a2.Shutdown()
|
defer a2.Shutdown()
|
||||||
|
|
||||||
// Wait for the WAN join.
|
// Wait for the WAN join.
|
||||||
|
|
|
@ -105,7 +105,7 @@ func TestRetryJoin(t *testing.T) {
|
||||||
a := NewTestAgent(t.Name(), nil)
|
a := NewTestAgent(t.Name(), nil)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
conf2 := TestConfig()
|
cfg2 := TestConfig()
|
||||||
tmpDir := testutil.TempDir(t, "consul")
|
tmpDir := testutil.TempDir(t, "consul")
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ func TestRetryJoin(t *testing.T) {
|
||||||
"-server",
|
"-server",
|
||||||
"-bind", a.Config.BindAddr,
|
"-bind", a.Config.BindAddr,
|
||||||
"-data-dir", tmpDir,
|
"-data-dir", tmpDir,
|
||||||
"-node", fmt.Sprintf(`"%s"`, conf2.NodeName),
|
"-node", fmt.Sprintf(`"%s"`, cfg2.NodeName),
|
||||||
"-advertise", a.Config.BindAddr,
|
"-advertise", a.Config.BindAddr,
|
||||||
"-retry-join", serfAddr,
|
"-retry-join", serfAddr,
|
||||||
"-retry-interval", "1s",
|
"-retry-interval", "1s",
|
||||||
|
@ -292,7 +292,7 @@ func TestReadCliConfig(t *testing.T) {
|
||||||
|
|
||||||
func TestRetryJoinFail(t *testing.T) {
|
func TestRetryJoinFail(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
conf := TestConfig()
|
cfg := TestConfig()
|
||||||
tmpDir := testutil.TempDir(t, "consul")
|
tmpDir := testutil.TempDir(t, "consul")
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
|
@ -304,10 +304,10 @@ func TestRetryJoinFail(t *testing.T) {
|
||||||
Command: baseCommand(new(cli.MockUi)),
|
Command: baseCommand(new(cli.MockUi)),
|
||||||
}
|
}
|
||||||
|
|
||||||
serfAddr := fmt.Sprintf("%s:%d", conf.BindAddr, conf.Ports.SerfLan)
|
serfAddr := fmt.Sprintf("%s:%d", cfg.BindAddr, cfg.Ports.SerfLan)
|
||||||
|
|
||||||
args := []string{
|
args := []string{
|
||||||
"-bind", conf.BindAddr,
|
"-bind", cfg.BindAddr,
|
||||||
"-data-dir", tmpDir,
|
"-data-dir", tmpDir,
|
||||||
"-retry-join", serfAddr,
|
"-retry-join", serfAddr,
|
||||||
"-retry-max", "1",
|
"-retry-max", "1",
|
||||||
|
@ -321,7 +321,7 @@ func TestRetryJoinFail(t *testing.T) {
|
||||||
|
|
||||||
func TestRetryJoinWanFail(t *testing.T) {
|
func TestRetryJoinWanFail(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
conf := TestConfig()
|
cfg := TestConfig()
|
||||||
tmpDir := testutil.TempDir(t, "consul")
|
tmpDir := testutil.TempDir(t, "consul")
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
|
@ -333,11 +333,11 @@ func TestRetryJoinWanFail(t *testing.T) {
|
||||||
Command: baseCommand(new(cli.MockUi)),
|
Command: baseCommand(new(cli.MockUi)),
|
||||||
}
|
}
|
||||||
|
|
||||||
serfAddr := fmt.Sprintf("%s:%d", conf.BindAddr, conf.Ports.SerfWan)
|
serfAddr := fmt.Sprintf("%s:%d", cfg.BindAddr, cfg.Ports.SerfWan)
|
||||||
|
|
||||||
args := []string{
|
args := []string{
|
||||||
"-server",
|
"-server",
|
||||||
"-bind", conf.BindAddr,
|
"-bind", cfg.BindAddr,
|
||||||
"-data-dir", tmpDir,
|
"-data-dir", tmpDir,
|
||||||
"-retry-join-wan", serfAddr,
|
"-retry-join-wan", serfAddr,
|
||||||
"-retry-max-wan", "1",
|
"-retry-max-wan", "1",
|
||||||
|
|
|
@ -32,8 +32,8 @@ const (
|
||||||
// the provided reply. This is useful for mocking a DNS recursor with
|
// the provided reply. This is useful for mocking a DNS recursor with
|
||||||
// an expected result.
|
// an expected result.
|
||||||
func makeRecursor(t *testing.T, answer []dns.RR) *dns.Server {
|
func makeRecursor(t *testing.T, answer []dns.RR) *dns.Server {
|
||||||
dnsConf := TestConfig()
|
cfg := TestConfig()
|
||||||
dnsAddr := fmt.Sprintf("%s:%d", dnsConf.Addresses.DNS, dnsConf.Ports.DNS)
|
dnsAddr := fmt.Sprintf("%s:%d", cfg.Addresses.DNS, cfg.Ports.DNS)
|
||||||
mux := dns.NewServeMux()
|
mux := dns.NewServeMux()
|
||||||
mux.HandleFunc(".", func(resp dns.ResponseWriter, msg *dns.Msg) {
|
mux.HandleFunc(".", func(resp dns.ResponseWriter, msg *dns.Msg) {
|
||||||
ans := &dns.Msg{Answer: answer[:]}
|
ans := &dns.Msg{Answer: answer[:]}
|
||||||
|
@ -52,8 +52,8 @@ func makeRecursor(t *testing.T, answer []dns.RR) *dns.Server {
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeRecursorWithMessage(t *testing.T, answer dns.Msg) *dns.Server {
|
func makeRecursorWithMessage(t *testing.T, answer dns.Msg) *dns.Server {
|
||||||
dnsConf := TestConfig()
|
cfg := TestConfig()
|
||||||
dnsAddr := fmt.Sprintf("%s:%d", dnsConf.Addresses.DNS, dnsConf.Ports.DNS)
|
dnsAddr := fmt.Sprintf("%s:%d", cfg.Addresses.DNS, cfg.Ports.DNS)
|
||||||
mux := dns.NewServeMux()
|
mux := dns.NewServeMux()
|
||||||
mux.HandleFunc(".", func(resp dns.ResponseWriter, msg *dns.Msg) {
|
mux.HandleFunc(".", func(resp dns.ResponseWriter, msg *dns.Msg) {
|
||||||
answer.SetReply(msg)
|
answer.SetReply(msg)
|
||||||
|
@ -1211,18 +1211,18 @@ func TestDNS_ServiceLookup_ServiceAddressIPV6(t *testing.T) {
|
||||||
|
|
||||||
func TestDNS_ServiceLookup_WanAddress(t *testing.T) {
|
func TestDNS_ServiceLookup_WanAddress(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
c1 := TestConfig()
|
cfg1 := TestConfig()
|
||||||
c1.Datacenter = "dc1"
|
cfg1.Datacenter = "dc1"
|
||||||
c1.TranslateWanAddrs = true
|
cfg1.TranslateWanAddrs = true
|
||||||
c1.ACLDatacenter = ""
|
cfg1.ACLDatacenter = ""
|
||||||
a1 := NewTestAgent(t.Name(), c1)
|
a1 := NewTestAgent(t.Name(), cfg1)
|
||||||
defer a1.Shutdown()
|
defer a1.Shutdown()
|
||||||
|
|
||||||
c2 := TestConfig()
|
cfg2 := TestConfig()
|
||||||
c2.Datacenter = "dc2"
|
cfg2.Datacenter = "dc2"
|
||||||
c2.TranslateWanAddrs = true
|
cfg2.TranslateWanAddrs = true
|
||||||
c2.ACLDatacenter = ""
|
cfg2.ACLDatacenter = ""
|
||||||
a2 := NewTestAgent(t.Name(), c2)
|
a2 := NewTestAgent(t.Name(), cfg2)
|
||||||
defer a2.Shutdown()
|
defer a2.Shutdown()
|
||||||
|
|
||||||
// Join WAN cluster
|
// Join WAN cluster
|
||||||
|
@ -3255,18 +3255,18 @@ func TestDNS_PreparedQuery_TTL(t *testing.T) {
|
||||||
|
|
||||||
func TestDNS_PreparedQuery_Failover(t *testing.T) {
|
func TestDNS_PreparedQuery_Failover(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
c1 := TestConfig()
|
cfg1 := TestConfig()
|
||||||
c1.Datacenter = "dc1"
|
cfg1.Datacenter = "dc1"
|
||||||
c1.TranslateWanAddrs = true
|
cfg1.TranslateWanAddrs = true
|
||||||
c1.ACLDatacenter = ""
|
cfg1.ACLDatacenter = ""
|
||||||
a1 := NewTestAgent(t.Name(), c1)
|
a1 := NewTestAgent(t.Name(), cfg1)
|
||||||
defer a1.Shutdown()
|
defer a1.Shutdown()
|
||||||
|
|
||||||
c2 := TestConfig()
|
cfg2 := TestConfig()
|
||||||
c2.Datacenter = "dc2"
|
cfg2.Datacenter = "dc2"
|
||||||
c2.TranslateWanAddrs = true
|
cfg2.TranslateWanAddrs = true
|
||||||
c2.ACLDatacenter = ""
|
cfg2.ACLDatacenter = ""
|
||||||
a2 := NewTestAgent(t.Name(), c2)
|
a2 := NewTestAgent(t.Name(), cfg2)
|
||||||
defer a2.Shutdown()
|
defer a2.Shutdown()
|
||||||
|
|
||||||
// Join WAN cluster.
|
// Join WAN cluster.
|
||||||
|
|
|
@ -54,9 +54,9 @@ func TestEventFire(t *testing.T) {
|
||||||
|
|
||||||
func TestEventFire_token(t *testing.T) {
|
func TestEventFire_token(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
conf := TestConfig()
|
cfg := TestConfig()
|
||||||
conf.ACLDefaultPolicy = "deny"
|
cfg.ACLDefaultPolicy = "deny"
|
||||||
a := NewTestAgent(t.Name(), conf)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
// Create an ACL token
|
// Create an ACL token
|
||||||
|
|
|
@ -630,18 +630,18 @@ func TestHealthServiceNodes_PassingFilter(t *testing.T) {
|
||||||
|
|
||||||
func TestHealthServiceNodes_WanTranslation(t *testing.T) {
|
func TestHealthServiceNodes_WanTranslation(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
c1 := TestConfig()
|
cfg1 := TestConfig()
|
||||||
c1.Datacenter = "dc1"
|
cfg1.Datacenter = "dc1"
|
||||||
c1.TranslateWanAddrs = true
|
cfg1.TranslateWanAddrs = true
|
||||||
c1.ACLDatacenter = ""
|
cfg1.ACLDatacenter = ""
|
||||||
a1 := NewTestAgent(t.Name(), c1)
|
a1 := NewTestAgent(t.Name(), cfg1)
|
||||||
defer a1.Shutdown()
|
defer a1.Shutdown()
|
||||||
|
|
||||||
c2 := TestConfig()
|
cfg2 := TestConfig()
|
||||||
c2.Datacenter = "dc2"
|
cfg2.Datacenter = "dc2"
|
||||||
c2.TranslateWanAddrs = true
|
cfg2.TranslateWanAddrs = true
|
||||||
c2.ACLDatacenter = ""
|
cfg2.ACLDatacenter = ""
|
||||||
a2 := NewTestAgent(t.Name(), c2)
|
a2 := NewTestAgent(t.Name(), cfg2)
|
||||||
defer a2.Shutdown()
|
defer a2.Shutdown()
|
||||||
|
|
||||||
// Wait for the WAN join.
|
// Wait for the WAN join.
|
||||||
|
|
|
@ -33,14 +33,14 @@ func TestHTTPServer_UnixSocket(t *testing.T) {
|
||||||
defer os.RemoveAll(tempDir)
|
defer os.RemoveAll(tempDir)
|
||||||
socket := filepath.Join(tempDir, "test.sock")
|
socket := filepath.Join(tempDir, "test.sock")
|
||||||
|
|
||||||
c := TestConfig()
|
cfg := TestConfig()
|
||||||
c.Addresses.HTTP = "unix://" + socket
|
cfg.Addresses.HTTP = "unix://" + socket
|
||||||
|
|
||||||
// Only testing mode, since uid/gid might not be settable
|
// Only testing mode, since uid/gid might not be settable
|
||||||
// from test environment.
|
// from test environment.
|
||||||
c.UnixSockets = UnixSocketConfig{}
|
cfg.UnixSockets = UnixSocketConfig{}
|
||||||
c.UnixSockets.Perms = "0777"
|
cfg.UnixSockets.Perms = "0777"
|
||||||
a := NewTestAgent(t.Name(), c)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
// Ensure the socket was created
|
// Ensure the socket was created
|
||||||
|
@ -103,9 +103,9 @@ func TestHTTPServer_UnixSocket_FileExists(t *testing.T) {
|
||||||
t.Fatalf("not a regular file: %s", socket)
|
t.Fatalf("not a regular file: %s", socket)
|
||||||
}
|
}
|
||||||
|
|
||||||
conf := TestConfig()
|
cfg := TestConfig()
|
||||||
conf.Addresses.HTTP = "unix://" + socket
|
cfg.Addresses.HTTP = "unix://" + socket
|
||||||
a := NewTestAgent(t.Name(), conf)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
// Ensure the file was replaced by the socket
|
// Ensure the file was replaced by the socket
|
||||||
|
@ -204,9 +204,9 @@ func TestHTTPAPI_TranslateAddrHeader(t *testing.T) {
|
||||||
|
|
||||||
// Header should be set to true if it's turned on.
|
// Header should be set to true if it's turned on.
|
||||||
{
|
{
|
||||||
c := TestConfig()
|
cfg := TestConfig()
|
||||||
c.TranslateWanAddrs = true
|
cfg.TranslateWanAddrs = true
|
||||||
a := NewTestAgent(t.Name(), c)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
resp := httptest.NewRecorder()
|
resp := httptest.NewRecorder()
|
||||||
|
@ -226,12 +226,12 @@ func TestHTTPAPI_TranslateAddrHeader(t *testing.T) {
|
||||||
|
|
||||||
func TestHTTPAPIResponseHeaders(t *testing.T) {
|
func TestHTTPAPIResponseHeaders(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
c := TestConfig()
|
cfg := TestConfig()
|
||||||
c.HTTPAPIResponseHeaders = map[string]string{
|
cfg.HTTPAPIResponseHeaders = map[string]string{
|
||||||
"Access-Control-Allow-Origin": "*",
|
"Access-Control-Allow-Origin": "*",
|
||||||
"X-XSS-Protection": "1; mode=block",
|
"X-XSS-Protection": "1; mode=block",
|
||||||
}
|
}
|
||||||
a := NewTestAgent(t.Name(), c)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
resp := httptest.NewRecorder()
|
resp := httptest.NewRecorder()
|
||||||
|
@ -519,9 +519,9 @@ func TestACLResolution(t *testing.T) {
|
||||||
|
|
||||||
func TestEnableWebUI(t *testing.T) {
|
func TestEnableWebUI(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
conf := TestConfig()
|
cfg := TestConfig()
|
||||||
conf.EnableUI = true
|
cfg.EnableUI = true
|
||||||
a := NewTestAgent(t.Name(), conf)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
req, _ := http.NewRequest("GET", "/ui/", nil)
|
req, _ := http.NewRequest("GET", "/ui/", nil)
|
||||||
|
|
|
@ -53,9 +53,9 @@ func TestAgent_LoadKeyrings(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client should auto-load only the LAN keyring file
|
// Client should auto-load only the LAN keyring file
|
||||||
conf3 := TestConfig()
|
cfg3 := TestConfig()
|
||||||
conf3.Server = false
|
cfg3.Server = false
|
||||||
a3 := &TestAgent{Name: t.Name(), Config: conf3, Key: key}
|
a3 := &TestAgent{Name: t.Name(), Config: cfg3, Key: key}
|
||||||
a3.Start()
|
a3.Start()
|
||||||
defer a3.Shutdown()
|
defer a3.Shutdown()
|
||||||
|
|
||||||
|
@ -118,11 +118,11 @@ func TestAgentKeyring_ACL(t *testing.T) {
|
||||||
key1 := "tbLJg26ZJyJ9pK3qhc9jig=="
|
key1 := "tbLJg26ZJyJ9pK3qhc9jig=="
|
||||||
key2 := "4leC33rgtXKIVUr9Nr0snQ=="
|
key2 := "4leC33rgtXKIVUr9Nr0snQ=="
|
||||||
|
|
||||||
conf := TestACLConfig()
|
cfg := TestACLConfig()
|
||||||
conf.ACLDatacenter = "dc1"
|
cfg.ACLDatacenter = "dc1"
|
||||||
conf.ACLMasterToken = "root"
|
cfg.ACLMasterToken = "root"
|
||||||
conf.ACLDefaultPolicy = "deny"
|
cfg.ACLDefaultPolicy = "deny"
|
||||||
a := &TestAgent{Name: t.Name(), Config: conf, Key: key1}
|
a := &TestAgent{Name: t.Name(), Config: cfg, Key: key1}
|
||||||
a.Start()
|
a.Start()
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
|
|
|
@ -463,12 +463,12 @@ service "consul" {
|
||||||
|
|
||||||
func TestAgentAntiEntropy_Services_ACLDeny(t *testing.T) {
|
func TestAgentAntiEntropy_Services_ACLDeny(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
conf := TestConfig()
|
cfg := TestConfig()
|
||||||
conf.ACLDatacenter = "dc1"
|
cfg.ACLDatacenter = "dc1"
|
||||||
conf.ACLMasterToken = "root"
|
cfg.ACLMasterToken = "root"
|
||||||
conf.ACLDefaultPolicy = "deny"
|
cfg.ACLDefaultPolicy = "deny"
|
||||||
conf.ACLEnforceVersion8 = &BoolTrue
|
cfg.ACLEnforceVersion8 = &BoolTrue
|
||||||
a := NewTestAgent(t.Name(), conf)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
// Create the ACL
|
// Create the ACL
|
||||||
|
@ -833,12 +833,12 @@ func TestAgentAntiEntropy_Checks(t *testing.T) {
|
||||||
|
|
||||||
func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) {
|
func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
conf := TestConfig()
|
cfg := TestConfig()
|
||||||
conf.ACLDatacenter = "dc1"
|
cfg.ACLDatacenter = "dc1"
|
||||||
conf.ACLMasterToken = "root"
|
cfg.ACLMasterToken = "root"
|
||||||
conf.ACLDefaultPolicy = "deny"
|
cfg.ACLDefaultPolicy = "deny"
|
||||||
conf.ACLEnforceVersion8 = &BoolTrue
|
cfg.ACLEnforceVersion8 = &BoolTrue
|
||||||
a := NewTestAgent(t.Name(), conf)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
// Create the ACL
|
// Create the ACL
|
||||||
|
@ -1069,9 +1069,9 @@ func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) {
|
||||||
|
|
||||||
func TestAgentAntiEntropy_Check_DeferSync(t *testing.T) {
|
func TestAgentAntiEntropy_Check_DeferSync(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
conf := TestConfig()
|
cfg := TestConfig()
|
||||||
conf.CheckUpdateInterval = 500 * time.Millisecond
|
cfg.CheckUpdateInterval = 500 * time.Millisecond
|
||||||
a := NewTestAgent(t.Name(), conf)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
// Create a check
|
// Create a check
|
||||||
|
@ -1242,10 +1242,10 @@ func TestAgentAntiEntropy_Check_DeferSync(t *testing.T) {
|
||||||
|
|
||||||
func TestAgentAntiEntropy_NodeInfo(t *testing.T) {
|
func TestAgentAntiEntropy_NodeInfo(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
conf := TestConfig()
|
cfg := TestConfig()
|
||||||
conf.NodeID = types.NodeID("40e4a748-2192-161a-0510-9bf59fe950b5")
|
cfg.NodeID = types.NodeID("40e4a748-2192-161a-0510-9bf59fe950b5")
|
||||||
conf.Meta["somekey"] = "somevalue"
|
cfg.Meta["somekey"] = "somevalue"
|
||||||
a := NewTestAgent(t.Name(), conf)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
// Register info
|
// Register info
|
||||||
|
@ -1278,9 +1278,9 @@ func TestAgentAntiEntropy_NodeInfo(t *testing.T) {
|
||||||
id := services.NodeServices.Node.ID
|
id := services.NodeServices.Node.ID
|
||||||
addrs := services.NodeServices.Node.TaggedAddresses
|
addrs := services.NodeServices.Node.TaggedAddresses
|
||||||
meta := services.NodeServices.Node.Meta
|
meta := services.NodeServices.Node.Meta
|
||||||
if id != conf.NodeID ||
|
if id != cfg.NodeID ||
|
||||||
!reflect.DeepEqual(addrs, conf.TaggedAddresses) ||
|
!reflect.DeepEqual(addrs, cfg.TaggedAddresses) ||
|
||||||
!reflect.DeepEqual(meta, conf.Meta) {
|
!reflect.DeepEqual(meta, cfg.Meta) {
|
||||||
r.Fatalf("bad: %v", services.NodeServices.Node)
|
r.Fatalf("bad: %v", services.NodeServices.Node)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1301,9 +1301,9 @@ func TestAgentAntiEntropy_NodeInfo(t *testing.T) {
|
||||||
id := services.NodeServices.Node.ID
|
id := services.NodeServices.Node.ID
|
||||||
addrs := services.NodeServices.Node.TaggedAddresses
|
addrs := services.NodeServices.Node.TaggedAddresses
|
||||||
meta := services.NodeServices.Node.Meta
|
meta := services.NodeServices.Node.Meta
|
||||||
if id != conf.NodeID ||
|
if id != cfg.NodeID ||
|
||||||
!reflect.DeepEqual(addrs, conf.TaggedAddresses) ||
|
!reflect.DeepEqual(addrs, cfg.TaggedAddresses) ||
|
||||||
!reflect.DeepEqual(meta, conf.Meta) {
|
!reflect.DeepEqual(meta, cfg.Meta) {
|
||||||
r.Fatalf("bad: %v", services.NodeServices.Node)
|
r.Fatalf("bad: %v", services.NodeServices.Node)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1327,10 +1327,10 @@ func TestAgentAntiEntropy_deleteCheck_fails(t *testing.T) {
|
||||||
|
|
||||||
func TestAgent_serviceTokens(t *testing.T) {
|
func TestAgent_serviceTokens(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.ACLToken = "default"
|
cfg.ACLToken = "default"
|
||||||
l := new(localState)
|
l := new(localState)
|
||||||
l.Init(config, nil)
|
l.Init(cfg, nil)
|
||||||
|
|
||||||
l.AddService(&structs.NodeService{
|
l.AddService(&structs.NodeService{
|
||||||
ID: "redis",
|
ID: "redis",
|
||||||
|
@ -1356,10 +1356,10 @@ func TestAgent_serviceTokens(t *testing.T) {
|
||||||
|
|
||||||
func TestAgent_checkTokens(t *testing.T) {
|
func TestAgent_checkTokens(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.ACLToken = "default"
|
cfg.ACLToken = "default"
|
||||||
l := new(localState)
|
l := new(localState)
|
||||||
l.Init(config, nil)
|
l.Init(cfg, nil)
|
||||||
|
|
||||||
// Returns default when no token is set
|
// Returns default when no token is set
|
||||||
if token := l.CheckToken("mem"); token != "default" {
|
if token := l.CheckToken("mem"); token != "default" {
|
||||||
|
@ -1381,9 +1381,9 @@ func TestAgent_checkTokens(t *testing.T) {
|
||||||
|
|
||||||
func TestAgent_checkCriticalTime(t *testing.T) {
|
func TestAgent_checkCriticalTime(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
l := new(localState)
|
l := new(localState)
|
||||||
l.Init(config, nil)
|
l.Init(cfg, nil)
|
||||||
|
|
||||||
// Add a passing check and make sure it's not critical.
|
// Add a passing check and make sure it's not critical.
|
||||||
checkID := types.CheckID("redis:1")
|
checkID := types.CheckID("redis:1")
|
||||||
|
@ -1474,13 +1474,13 @@ func TestAgent_nestedPauseResume(t *testing.T) {
|
||||||
|
|
||||||
func TestAgent_sendCoordinate(t *testing.T) {
|
func TestAgent_sendCoordinate(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
conf := TestConfig()
|
cfg := TestConfig()
|
||||||
conf.SyncCoordinateRateTarget = 10.0 // updates/sec
|
cfg.SyncCoordinateRateTarget = 10.0 // updates/sec
|
||||||
conf.SyncCoordinateIntervalMin = 1 * time.Millisecond
|
cfg.SyncCoordinateIntervalMin = 1 * time.Millisecond
|
||||||
conf.ConsulConfig.CoordinateUpdatePeriod = 100 * time.Millisecond
|
cfg.ConsulConfig.CoordinateUpdatePeriod = 100 * time.Millisecond
|
||||||
conf.ConsulConfig.CoordinateUpdateBatchSize = 10
|
cfg.ConsulConfig.CoordinateUpdateBatchSize = 10
|
||||||
conf.ConsulConfig.CoordinateUpdateMaxBatches = 1
|
cfg.ConsulConfig.CoordinateUpdateMaxBatches = 1
|
||||||
a := NewTestAgent(t.Name(), conf)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
// Make sure the coordinate is present.
|
// Make sure the coordinate is present.
|
||||||
|
|
|
@ -79,9 +79,9 @@ func TestOperator_KeyringInstall(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
oldKey := "H3/9gBxcKKRf45CaI2DlRg=="
|
oldKey := "H3/9gBxcKKRf45CaI2DlRg=="
|
||||||
newKey := "z90lFx3sZZLtTOkutXcwYg=="
|
newKey := "z90lFx3sZZLtTOkutXcwYg=="
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.EncryptKey = oldKey
|
cfg.EncryptKey = oldKey
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
body := bytes.NewBufferString(fmt.Sprintf("{\"Key\":\"%s\"}", newKey))
|
body := bytes.NewBufferString(fmt.Sprintf("{\"Key\":\"%s\"}", newKey))
|
||||||
|
@ -114,9 +114,9 @@ func TestOperator_KeyringInstall(t *testing.T) {
|
||||||
func TestOperator_KeyringList(t *testing.T) {
|
func TestOperator_KeyringList(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
key := "H3/9gBxcKKRf45CaI2DlRg=="
|
key := "H3/9gBxcKKRf45CaI2DlRg=="
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.EncryptKey = key
|
cfg.EncryptKey = key
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
req, _ := http.NewRequest("GET", "/v1/operator/keyring", nil)
|
req, _ := http.NewRequest("GET", "/v1/operator/keyring", nil)
|
||||||
|
@ -163,9 +163,9 @@ func TestOperator_KeyringRemove(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
key := "H3/9gBxcKKRf45CaI2DlRg=="
|
key := "H3/9gBxcKKRf45CaI2DlRg=="
|
||||||
tempKey := "z90lFx3sZZLtTOkutXcwYg=="
|
tempKey := "z90lFx3sZZLtTOkutXcwYg=="
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.EncryptKey = key
|
cfg.EncryptKey = key
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
_, err := a.InstallKey(tempKey, "", 0)
|
_, err := a.InstallKey(tempKey, "", 0)
|
||||||
|
@ -221,9 +221,9 @@ func TestOperator_KeyringUse(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
oldKey := "H3/9gBxcKKRf45CaI2DlRg=="
|
oldKey := "H3/9gBxcKKRf45CaI2DlRg=="
|
||||||
newKey := "z90lFx3sZZLtTOkutXcwYg=="
|
newKey := "z90lFx3sZZLtTOkutXcwYg=="
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.EncryptKey = oldKey
|
cfg.EncryptKey = oldKey
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
if _, err := a.InstallKey(newKey, "", 0); err != nil {
|
if _, err := a.InstallKey(newKey, "", 0); err != nil {
|
||||||
|
@ -264,9 +264,9 @@ func TestOperator_KeyringUse(t *testing.T) {
|
||||||
func TestOperator_Keyring_InvalidRelayFactor(t *testing.T) {
|
func TestOperator_Keyring_InvalidRelayFactor(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
key := "H3/9gBxcKKRf45CaI2DlRg=="
|
key := "H3/9gBxcKKRf45CaI2DlRg=="
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.EncryptKey = key
|
cfg.EncryptKey = key
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
cases := map[string]string{
|
cases := map[string]string{
|
||||||
|
@ -408,9 +408,9 @@ func TestOperator_AutopilotCASConfiguration(t *testing.T) {
|
||||||
|
|
||||||
func TestOperator_ServerHealth(t *testing.T) {
|
func TestOperator_ServerHealth(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.RaftProtocol = 3
|
cfg.RaftProtocol = 3
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
body := bytes.NewBuffer(nil)
|
body := bytes.NewBuffer(nil)
|
||||||
|
@ -440,11 +440,11 @@ func TestOperator_ServerHealth(t *testing.T) {
|
||||||
|
|
||||||
func TestOperator_ServerHealth_Unhealthy(t *testing.T) {
|
func TestOperator_ServerHealth_Unhealthy(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.RaftProtocol = 3
|
cfg.RaftProtocol = 3
|
||||||
threshold := time.Duration(-1)
|
threshold := time.Duration(-1)
|
||||||
config.Autopilot.LastContactThreshold = &threshold
|
cfg.Autopilot.LastContactThreshold = &threshold
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
body := bytes.NewBuffer(nil)
|
body := bytes.NewBuffer(nil)
|
||||||
|
|
|
@ -358,10 +358,10 @@ func TestPreparedQuery_Execute(t *testing.T) {
|
||||||
|
|
||||||
// Ensure WAN translation occurs for a response outside of the local DC.
|
// Ensure WAN translation occurs for a response outside of the local DC.
|
||||||
t.Run("", func(t *testing.T) {
|
t.Run("", func(t *testing.T) {
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.Datacenter = "dc1"
|
cfg.Datacenter = "dc1"
|
||||||
config.TranslateWanAddrs = true
|
cfg.TranslateWanAddrs = true
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
m := MockPreparedQuery{}
|
m := MockPreparedQuery{}
|
||||||
|
@ -408,10 +408,10 @@ func TestPreparedQuery_Execute(t *testing.T) {
|
||||||
|
|
||||||
// Ensure WAN translation doesn't occur for the local DC.
|
// Ensure WAN translation doesn't occur for the local DC.
|
||||||
t.Run("", func(t *testing.T) {
|
t.Run("", func(t *testing.T) {
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.Datacenter = "dc1"
|
cfg.Datacenter = "dc1"
|
||||||
config.TranslateWanAddrs = true
|
cfg.TranslateWanAddrs = true
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
m := MockPreparedQuery{}
|
m := MockPreparedQuery{}
|
||||||
|
|
|
@ -95,17 +95,16 @@ func TestRexecWriter(t *testing.T) {
|
||||||
|
|
||||||
func TestRemoteExecGetSpec(t *testing.T) {
|
func TestRemoteExecGetSpec(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
testRemoteExecGetSpec(t, nil)
|
||||||
testRemoteExecGetSpec(t, config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRemoteExecGetSpec_ACLToken(t *testing.T) {
|
func TestRemoteExecGetSpec_ACLToken(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.ACLDatacenter = "dc1"
|
cfg.ACLDatacenter = "dc1"
|
||||||
config.ACLToken = "root"
|
cfg.ACLToken = "root"
|
||||||
config.ACLDefaultPolicy = "deny"
|
cfg.ACLDefaultPolicy = "deny"
|
||||||
testRemoteExecGetSpec(t, config)
|
testRemoteExecGetSpec(t, cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testRemoteExecGetSpec(t *testing.T, c *Config) {
|
func testRemoteExecGetSpec(t *testing.T, c *Config) {
|
||||||
|
@ -141,17 +140,16 @@ func testRemoteExecGetSpec(t *testing.T, c *Config) {
|
||||||
|
|
||||||
func TestRemoteExecWrites(t *testing.T) {
|
func TestRemoteExecWrites(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
testRemoteExecWrites(t, nil)
|
||||||
testRemoteExecWrites(t, config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRemoteExecWrites_ACLToken(t *testing.T) {
|
func TestRemoteExecWrites_ACLToken(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.ACLDatacenter = "dc1"
|
cfg.ACLDatacenter = "dc1"
|
||||||
config.ACLToken = "root"
|
cfg.ACLToken = "root"
|
||||||
config.ACLDefaultPolicy = "deny"
|
cfg.ACLDefaultPolicy = "deny"
|
||||||
testRemoteExecWrites(t, config)
|
testRemoteExecWrites(t, cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testRemoteExecWrites(t *testing.T, c *Config) {
|
func testRemoteExecWrites(t *testing.T, c *Config) {
|
||||||
|
|
|
@ -210,10 +210,10 @@ func TestSessionDestroy(t *testing.T) {
|
||||||
func TestSessionCustomTTL(t *testing.T) {
|
func TestSessionCustomTTL(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
ttl := 250 * time.Millisecond
|
ttl := 250 * time.Millisecond
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.SessionTTLMin = ttl
|
cfg.SessionTTLMin = ttl
|
||||||
config.SessionTTLMinRaw = ttl.String()
|
cfg.SessionTTLMinRaw = ttl.String()
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
id := makeTestSessionTTL(t, a.srv, ttl.String())
|
id := makeTestSessionTTL(t, a.srv, ttl.String())
|
||||||
|
@ -252,10 +252,10 @@ func TestSessionCustomTTL(t *testing.T) {
|
||||||
func TestSessionTTLRenew(t *testing.T) {
|
func TestSessionTTLRenew(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
ttl := 250 * time.Millisecond
|
ttl := 250 * time.Millisecond
|
||||||
config := TestConfig()
|
cfg := TestConfig()
|
||||||
config.SessionTTLMin = ttl
|
cfg.SessionTTLMin = ttl
|
||||||
config.SessionTTLMinRaw = ttl.String()
|
cfg.SessionTTLMinRaw = ttl.String()
|
||||||
a := NewTestAgent(t.Name(), config)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
id := makeTestSessionTTL(t, a.srv, ttl.String())
|
id := makeTestSessionTTL(t, a.srv, ttl.String())
|
||||||
|
|
|
@ -225,54 +225,54 @@ func TestConfig() *Config {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
conf := DefaultConfig()
|
cfg := DefaultConfig()
|
||||||
pickRandomPorts(conf)
|
pickRandomPorts(cfg)
|
||||||
|
|
||||||
conf.Version = version.Version
|
cfg.Version = version.Version
|
||||||
conf.VersionPrerelease = "c.d"
|
cfg.VersionPrerelease = "c.d"
|
||||||
|
|
||||||
conf.NodeID = types.NodeID(nodeID)
|
cfg.NodeID = types.NodeID(nodeID)
|
||||||
conf.NodeName = "Node " + nodeID
|
cfg.NodeName = "Node " + nodeID
|
||||||
conf.BindAddr = "127.0.0.1"
|
cfg.BindAddr = "127.0.0.1"
|
||||||
conf.AdvertiseAddr = "127.0.0.1"
|
cfg.AdvertiseAddr = "127.0.0.1"
|
||||||
conf.Datacenter = "dc1"
|
cfg.Datacenter = "dc1"
|
||||||
conf.Bootstrap = true
|
cfg.Bootstrap = true
|
||||||
conf.Server = true
|
cfg.Server = true
|
||||||
conf.ACLEnforceVersion8 = &BoolFalse
|
cfg.ACLEnforceVersion8 = &BoolFalse
|
||||||
conf.ACLDatacenter = conf.Datacenter
|
cfg.ACLDatacenter = cfg.Datacenter
|
||||||
conf.ACLMasterToken = "root"
|
cfg.ACLMasterToken = "root"
|
||||||
|
|
||||||
cons := consul.DefaultConfig()
|
ccfg := consul.DefaultConfig()
|
||||||
conf.ConsulConfig = cons
|
cfg.ConsulConfig = ccfg
|
||||||
|
|
||||||
cons.SerfLANConfig.MemberlistConfig.SuspicionMult = 3
|
ccfg.SerfLANConfig.MemberlistConfig.SuspicionMult = 3
|
||||||
cons.SerfLANConfig.MemberlistConfig.ProbeTimeout = 100 * time.Millisecond
|
ccfg.SerfLANConfig.MemberlistConfig.ProbeTimeout = 100 * time.Millisecond
|
||||||
cons.SerfLANConfig.MemberlistConfig.ProbeInterval = 100 * time.Millisecond
|
ccfg.SerfLANConfig.MemberlistConfig.ProbeInterval = 100 * time.Millisecond
|
||||||
cons.SerfLANConfig.MemberlistConfig.GossipInterval = 100 * time.Millisecond
|
ccfg.SerfLANConfig.MemberlistConfig.GossipInterval = 100 * time.Millisecond
|
||||||
|
|
||||||
cons.SerfWANConfig.MemberlistConfig.SuspicionMult = 3
|
ccfg.SerfWANConfig.MemberlistConfig.SuspicionMult = 3
|
||||||
cons.SerfWANConfig.MemberlistConfig.ProbeTimeout = 100 * time.Millisecond
|
ccfg.SerfWANConfig.MemberlistConfig.ProbeTimeout = 100 * time.Millisecond
|
||||||
cons.SerfWANConfig.MemberlistConfig.ProbeInterval = 100 * time.Millisecond
|
ccfg.SerfWANConfig.MemberlistConfig.ProbeInterval = 100 * time.Millisecond
|
||||||
cons.SerfWANConfig.MemberlistConfig.GossipInterval = 100 * time.Millisecond
|
ccfg.SerfWANConfig.MemberlistConfig.GossipInterval = 100 * time.Millisecond
|
||||||
|
|
||||||
cons.RaftConfig.LeaderLeaseTimeout = 20 * time.Millisecond
|
ccfg.RaftConfig.LeaderLeaseTimeout = 20 * time.Millisecond
|
||||||
cons.RaftConfig.HeartbeatTimeout = 40 * time.Millisecond
|
ccfg.RaftConfig.HeartbeatTimeout = 40 * time.Millisecond
|
||||||
cons.RaftConfig.ElectionTimeout = 40 * time.Millisecond
|
ccfg.RaftConfig.ElectionTimeout = 40 * time.Millisecond
|
||||||
|
|
||||||
cons.CoordinateUpdatePeriod = 100 * time.Millisecond
|
ccfg.CoordinateUpdatePeriod = 100 * time.Millisecond
|
||||||
cons.ServerHealthInterval = 10 * time.Millisecond
|
ccfg.ServerHealthInterval = 10 * time.Millisecond
|
||||||
return conf
|
return cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestACLConfig returns a default configuration for testing an agent
|
// TestACLConfig returns a default configuration for testing an agent
|
||||||
// with ACLs.
|
// with ACLs.
|
||||||
func TestACLConfig() *Config {
|
func TestACLConfig() *Config {
|
||||||
c := TestConfig()
|
cfg := TestConfig()
|
||||||
c.ACLDatacenter = c.Datacenter
|
cfg.ACLDatacenter = cfg.Datacenter
|
||||||
c.ACLDefaultPolicy = "deny"
|
cfg.ACLDefaultPolicy = "deny"
|
||||||
c.ACLMasterToken = "root"
|
cfg.ACLMasterToken = "root"
|
||||||
c.ACLAgentToken = "root"
|
cfg.ACLAgentToken = "root"
|
||||||
c.ACLAgentMasterToken = "towel"
|
cfg.ACLAgentMasterToken = "towel"
|
||||||
c.ACLEnforceVersion8 = &BoolTrue
|
cfg.ACLEnforceVersion8 = &BoolTrue
|
||||||
return c
|
return cfg
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,9 @@ func TestUiIndex(t *testing.T) {
|
||||||
defer os.RemoveAll(uiDir)
|
defer os.RemoveAll(uiDir)
|
||||||
|
|
||||||
// Make the server
|
// Make the server
|
||||||
c := TestConfig()
|
cfg := TestConfig()
|
||||||
c.UIDir = uiDir
|
cfg.UIDir = uiDir
|
||||||
a := NewTestAgent(t.Name(), c)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
// Create file
|
// Create file
|
||||||
|
|
|
@ -183,9 +183,9 @@ func TestFireReceiveEvent(t *testing.T) {
|
||||||
|
|
||||||
func TestUserEventToken(t *testing.T) {
|
func TestUserEventToken(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
conf := TestConfig()
|
cfg := TestConfig()
|
||||||
conf.ACLDefaultPolicy = "deny" // Set the default policies to deny
|
cfg.ACLDefaultPolicy = "deny" // Set the default policies to deny
|
||||||
a := NewTestAgent(t.Name(), conf)
|
a := NewTestAgent(t.Name(), cfg)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
// Create an ACL token
|
// Create an ACL token
|
||||||
|
|
|
@ -28,8 +28,8 @@ func TestExecCommand_implements(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExecCommandRun(t *testing.T) {
|
func TestExecCommandRun(t *testing.T) {
|
||||||
a1 := testAgentWithConfig(t, func(c *agent.Config) {
|
a1 := testAgentWithConfig(t, func(cfg *agent.Config) {
|
||||||
c.DisableRemoteExec = agent.Bool(false)
|
cfg.DisableRemoteExec = agent.Bool(false)
|
||||||
})
|
})
|
||||||
defer a1.Shutdown()
|
defer a1.Shutdown()
|
||||||
waitForLeader(t, a1.httpAddr)
|
waitForLeader(t, a1.httpAddr)
|
||||||
|
@ -48,14 +48,14 @@ func TestExecCommandRun(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExecCommandRun_CrossDC(t *testing.T) {
|
func TestExecCommandRun_CrossDC(t *testing.T) {
|
||||||
a1 := testAgentWithConfig(t, func(c *agent.Config) {
|
a1 := testAgentWithConfig(t, func(cfg *agent.Config) {
|
||||||
c.DisableRemoteExec = agent.Bool(false)
|
cfg.DisableRemoteExec = agent.Bool(false)
|
||||||
})
|
})
|
||||||
defer a1.Shutdown()
|
defer a1.Shutdown()
|
||||||
|
|
||||||
a2 := testAgentWithConfig(t, func(c *agent.Config) {
|
a2 := testAgentWithConfig(t, func(cfg *agent.Config) {
|
||||||
c.Datacenter = "dc2"
|
cfg.Datacenter = "dc2"
|
||||||
c.DisableRemoteExec = agent.Bool(false)
|
cfg.DisableRemoteExec = agent.Bool(false)
|
||||||
})
|
})
|
||||||
defer a2.Shutdown()
|
defer a2.Shutdown()
|
||||||
|
|
||||||
|
@ -143,8 +143,8 @@ func TestExecCommand_Validate(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExecCommand_Sessions(t *testing.T) {
|
func TestExecCommand_Sessions(t *testing.T) {
|
||||||
a1 := testAgentWithConfig(t, func(c *agent.Config) {
|
a1 := testAgentWithConfig(t, func(cfg *agent.Config) {
|
||||||
c.DisableRemoteExec = agent.Bool(false)
|
cfg.DisableRemoteExec = agent.Bool(false)
|
||||||
})
|
})
|
||||||
defer a1.Shutdown()
|
defer a1.Shutdown()
|
||||||
waitForLeader(t, a1.httpAddr)
|
waitForLeader(t, a1.httpAddr)
|
||||||
|
@ -186,8 +186,8 @@ func TestExecCommand_Sessions(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExecCommand_Sessions_Foreign(t *testing.T) {
|
func TestExecCommand_Sessions_Foreign(t *testing.T) {
|
||||||
a1 := testAgentWithConfig(t, func(c *agent.Config) {
|
a1 := testAgentWithConfig(t, func(cfg *agent.Config) {
|
||||||
c.DisableRemoteExec = agent.Bool(false)
|
cfg.DisableRemoteExec = agent.Bool(false)
|
||||||
})
|
})
|
||||||
defer a1.Shutdown()
|
defer a1.Shutdown()
|
||||||
waitForLeader(t, a1.httpAddr)
|
waitForLeader(t, a1.httpAddr)
|
||||||
|
@ -239,8 +239,8 @@ func TestExecCommand_Sessions_Foreign(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExecCommand_UploadDestroy(t *testing.T) {
|
func TestExecCommand_UploadDestroy(t *testing.T) {
|
||||||
a1 := testAgentWithConfig(t, func(c *agent.Config) {
|
a1 := testAgentWithConfig(t, func(cfg *agent.Config) {
|
||||||
c.DisableRemoteExec = agent.Bool(false)
|
cfg.DisableRemoteExec = agent.Bool(false)
|
||||||
})
|
})
|
||||||
defer a1.Shutdown()
|
defer a1.Shutdown()
|
||||||
waitForLeader(t, a1.httpAddr)
|
waitForLeader(t, a1.httpAddr)
|
||||||
|
@ -298,8 +298,8 @@ func TestExecCommand_UploadDestroy(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExecCommand_StreamResults(t *testing.T) {
|
func TestExecCommand_StreamResults(t *testing.T) {
|
||||||
a1 := testAgentWithConfig(t, func(c *agent.Config) {
|
a1 := testAgentWithConfig(t, func(cfg *agent.Config) {
|
||||||
c.DisableRemoteExec = agent.Bool(false)
|
cfg.DisableRemoteExec = agent.Bool(false)
|
||||||
})
|
})
|
||||||
defer a1.Shutdown()
|
defer a1.Shutdown()
|
||||||
waitForLeader(t, a1.httpAddr)
|
waitForLeader(t, a1.httpAddr)
|
||||||
|
|
|
@ -28,8 +28,8 @@ func TestKeyringCommandRun(t *testing.T) {
|
||||||
key2 := "kZyFABeAmc64UMTrm9XuKA=="
|
key2 := "kZyFABeAmc64UMTrm9XuKA=="
|
||||||
|
|
||||||
// Begin with a single key
|
// Begin with a single key
|
||||||
a1 := testAgentWithConfig(t, func(c *agent.Config) {
|
a1 := testAgentWithConfig(t, func(cfg *agent.Config) {
|
||||||
c.EncryptKey = key1
|
cfg.EncryptKey = key1
|
||||||
})
|
})
|
||||||
defer a1.Shutdown()
|
defer a1.Shutdown()
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,8 @@ func TestRTTCommand_Run_BadArgs(t *testing.T) {
|
||||||
|
|
||||||
func TestRTTCommand_Run_LAN(t *testing.T) {
|
func TestRTTCommand_Run_LAN(t *testing.T) {
|
||||||
updatePeriod := 10 * time.Millisecond
|
updatePeriod := 10 * time.Millisecond
|
||||||
a := testAgentWithConfig(t, func(c *agent.Config) {
|
a := testAgentWithConfig(t, func(cfg *agent.Config) {
|
||||||
c.ConsulConfig.CoordinateUpdatePeriod = updatePeriod
|
cfg.ConsulConfig.CoordinateUpdatePeriod = updatePeriod
|
||||||
})
|
})
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
waitForLeader(t, a.httpAddr)
|
waitForLeader(t, a.httpAddr)
|
||||||
|
|
|
@ -44,7 +44,7 @@ func testAgent(t *testing.T) *server {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAgentWithAPIClient(t *testing.T) (*server, *api.Client) {
|
func testAgentWithAPIClient(t *testing.T) (*server, *api.Client) {
|
||||||
agent := testAgentWithConfig(t, func(c *agent.Config) {})
|
agent := testAgentWithConfig(t, func(cfg *agent.Config) {})
|
||||||
client, err := api.NewClient(&api.Config{Address: agent.httpAddr})
|
client, err := api.NewClient(&api.Config{Address: agent.httpAddr})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("consul client: %#v", err)
|
t.Fatalf("consul client: %#v", err)
|
||||||
|
@ -52,7 +52,7 @@ func testAgentWithAPIClient(t *testing.T) (*server, *api.Client) {
|
||||||
return agent, client
|
return agent, client
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAgentWithConfig(t *testing.T, cb func(c *agent.Config)) *server {
|
func testAgentWithConfig(t *testing.T, cb func(cfg *agent.Config)) *server {
|
||||||
conf := nextConfig()
|
conf := nextConfig()
|
||||||
if cb != nil {
|
if cb != nil {
|
||||||
cb(conf)
|
cb(conf)
|
||||||
|
|
Loading…
Reference in New Issue