Skip to content

Commit

Permalink
Merge pull request #2622 from hashicorp/f-2594-support-consul-unix
Browse files Browse the repository at this point in the history
Update consul/api to support unix socket addrs
  • Loading branch information
schmichael committed May 8, 2017
2 parents d9882e6 + f4a0c86 commit c778fce
Show file tree
Hide file tree
Showing 34 changed files with 3,424 additions and 506 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ IMPROVEMENTS:
addresses [GH-2536]
* client: Hash host ID so its stable and well distributed [GH-2541]
* client: Environment variables for client DC and Region [GH-2507]
* config: Support Unix socket addresses for Consul [GH-2622]
* driver/docker: Allow specifying extra hosts [GH-2547]
* driver/docker: Allow setting container IP with user defined networks
[GH-2535]
Expand Down
29 changes: 16 additions & 13 deletions client/consul_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ func newTestHarness(t *testing.T, templates []*structs.Template, consul, vault b
harness.taskDir = d

if consul {
harness.consul = ctestutil.NewTestServer(t)
harness.consul, err = ctestutil.NewTestServer()
if err != nil {
t.Fatalf("error starting test Consul server: %v", err)
}
harness.config.ConsulConfig = &sconfig.ConsulConfig{
Addr: harness.consul.HTTPAddr,
}
Expand Down Expand Up @@ -445,7 +448,7 @@ func TestTaskTemplateManager_Unblock_Consul(t *testing.T) {
}

// Write the key to Consul
harness.consul.SetKV(key, []byte(content))
harness.consul.SetKV(t, key, []byte(content))

// Wait for the unblock
select {
Expand Down Expand Up @@ -563,7 +566,7 @@ func TestTaskTemplateManager_Unblock_Multi_Template(t *testing.T) {
}

// Write the key to Consul
harness.consul.SetKV(consulKey, []byte(consulContent))
harness.consul.SetKV(t, consulKey, []byte(consulContent))

// Wait for the unblock
select {
Expand Down Expand Up @@ -612,7 +615,7 @@ func TestTaskTemplateManager_Rerender_Noop(t *testing.T) {
}

// Write the key to Consul
harness.consul.SetKV(key, []byte(content1))
harness.consul.SetKV(t, key, []byte(content1))

// Wait for the unblock
select {
Expand All @@ -633,7 +636,7 @@ func TestTaskTemplateManager_Rerender_Noop(t *testing.T) {
}

// Update the key in Consul
harness.consul.SetKV(key, []byte(content2))
harness.consul.SetKV(t, key, []byte(content2))

select {
case <-harness.mockHooks.RestartCh:
Expand Down Expand Up @@ -697,8 +700,8 @@ func TestTaskTemplateManager_Rerender_Signal(t *testing.T) {
}

// Write the key to Consul
harness.consul.SetKV(key1, []byte(content1_1))
harness.consul.SetKV(key2, []byte(content2_1))
harness.consul.SetKV(t, key1, []byte(content1_1))
harness.consul.SetKV(t, key2, []byte(content2_1))

// Wait for the unblock
select {
Expand All @@ -712,8 +715,8 @@ func TestTaskTemplateManager_Rerender_Signal(t *testing.T) {
}

// Update the keys in Consul
harness.consul.SetKV(key1, []byte(content1_2))
harness.consul.SetKV(key2, []byte(content2_2))
harness.consul.SetKV(t, key1, []byte(content1_2))
harness.consul.SetKV(t, key2, []byte(content2_2))

// Wait for signals
timeout := time.After(time.Duration(1*testutil.TestMultiplier()) * time.Second)
Expand Down Expand Up @@ -782,7 +785,7 @@ func TestTaskTemplateManager_Rerender_Restart(t *testing.T) {
}

// Write the key to Consul
harness.consul.SetKV(key1, []byte(content1_1))
harness.consul.SetKV(t, key1, []byte(content1_1))

// Wait for the unblock
select {
Expand All @@ -792,7 +795,7 @@ func TestTaskTemplateManager_Rerender_Restart(t *testing.T) {
}

// Update the keys in Consul
harness.consul.SetKV(key1, []byte(content1_2))
harness.consul.SetKV(t, key1, []byte(content1_2))

// Wait for restart
timeout := time.After(time.Duration(1*testutil.TestMultiplier()) * time.Second)
Expand Down Expand Up @@ -878,7 +881,7 @@ func TestTaskTemplateManager_Signal_Error(t *testing.T) {
harness.mockHooks.SignalError = fmt.Errorf("test error")

// Write the key to Consul
harness.consul.SetKV(key1, []byte(content1))
harness.consul.SetKV(t, key1, []byte(content1))

// Wait a little
select {
Expand All @@ -888,7 +891,7 @@ func TestTaskTemplateManager_Signal_Error(t *testing.T) {
}

// Write the key to Consul
harness.consul.SetKV(key1, []byte(content2))
harness.consul.SetKV(t, key1, []byte(content2))

// Wait for kill channel
select {
Expand Down
5 changes: 4 additions & 1 deletion command/agent/consul/int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@ func TestConsul_Integration(t *testing.T) {
}
}
// Create an embedded Consul server
testconsul := testutil.NewTestServerConfig(t, func(c *testutil.TestServerConfig) {
testconsul, err := testutil.NewTestServerConfig(func(c *testutil.TestServerConfig) {
// If -v wasn't specified squelch consul logging
if !testing.Verbose() {
c.Stdout = ioutil.Discard
c.Stderr = ioutil.Discard
}
})
if err != nil {
t.Fatalf("error starting test consul server: %v", err)
}
defer testconsul.Stop()

conf := config.DefaultConfig()
Expand Down
2 changes: 1 addition & 1 deletion nomad/structs/config/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (a *ConsulConfig) Merge(b *ConsulConfig) *ConsulConfig {
return result
}

// ApiConfig() returns a usable Consul config that can be passed directly to
// ApiConfig returns a usable Consul config that can be passed directly to
// hashicorp/consul/api. NOTE: datacenter is not set
func (c *ConsulConfig) ApiConfig() (*consul.Config, error) {
config := consul.DefaultConfig()
Expand Down
872 changes: 872 additions & 0 deletions vendor/github.com/hashicorp/consul/CHANGELOG.md

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions vendor/github.com/hashicorp/consul/GNUmakefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions vendor/github.com/hashicorp/consul/ISSUE_TEMPLATE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

87 changes: 87 additions & 0 deletions vendor/github.com/hashicorp/consul/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/hashicorp/consul/api/agent.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c778fce

Please sign in to comment.