Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar committed Sep 15, 2018
1 parent 260b566 commit 32f9da9
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 67 deletions.
6 changes: 3 additions & 3 deletions client/allocrunner/taskrunner/task_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func testTaskRunnerFromAlloc(t *testing.T, restarts bool, alloc *structs.Allocat

vclient := vaultclient.NewMockVaultClient()
cclient := consul.NewMockAgent()
serviceClient := consul.NewServiceClient(cclient, logger, true)
serviceClient := consul.NewServiceClient(cclient, testlog.HCLogger(t), true)
go serviceClient.Run()
tr := NewTaskRunner(logger, conf, db, upd.Update, taskDir, alloc, task, vclient, serviceClient)
if !restarts {
Expand Down Expand Up @@ -633,7 +633,7 @@ func TestTaskRunner_UnregisterConsul_Retries(t *testing.T) {
ctx := testTaskRunnerFromAlloc(t, true, alloc)

// Use mockConsulServiceClient
consul := consulApi.NewMockConsulServiceClient(t)
consul := consulApi.NewMockConsulServiceClient(t, testlog.HCLogger(t))
ctx.tr.consul = consul

ctx.tr.MarkReceived()
Expand Down Expand Up @@ -1851,7 +1851,7 @@ func TestTaskRunner_CheckWatcher_Restart(t *testing.T) {
// backed by a mock consul whose checks are always unhealthy.
consulAgent := consul.NewMockAgent()
consulAgent.SetStatus("critical")
consulClient := consul.NewServiceClient(consulAgent, ctx.tr.logger, true)
consulClient := consul.NewServiceClient(consulAgent, testlog.HCLogger(t), true)
go consulClient.Run()
defer consulClient.Shutdown()

Expand Down
2 changes: 1 addition & 1 deletion command/agent/consul/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ func (c *ServiceClient) sync() error {
}
}

c.logger.Debug("sync complete", "registed_services", sreg, "deregistered_services", sdereg,
c.logger.Debug("sync complete", "registered_services", sreg, "deregistered_services", sdereg,
"registered_checks", creg, "deregistered_checks", cdereg)
return nil
}
Expand Down
10 changes: 1 addition & 9 deletions nomad/drainer/draining_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"testing"
"time"

"github.com/hashicorp/nomad/helper/testlog"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/state"
"github.com/hashicorp/nomad/nomad/structs"
Expand All @@ -15,14 +14,7 @@ import (
// testDrainingNode creates a *drainingNode with a 1h deadline but no allocs
func testDrainingNode(t *testing.T) *drainingNode {
t.Helper()

sconfig := &state.StateStoreConfig{
LogOutput: testlog.NewWriter(t),
Region: "global",
}
state, err := state.NewStateStore(sconfig)
require.Nil(t, err)

state := state.TestStateStore(t)
node := mock.Node()
node.DrainStrategy = &structs.DrainStrategy{
DrainSpec: structs.DrainSpec{
Expand Down
11 changes: 1 addition & 10 deletions nomad/drainer/watch_nodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,7 @@ import (

func testNodeDrainWatcher(t *testing.T) (*nodeDrainWatcher, *state.StateStore, *MockNodeTracker) {
t.Helper()

sconfig := &state.StateStoreConfig{
LogOutput: testlog.NewWriter(t),
Region: "global",
}
state, err := state.NewStateStore(sconfig)
if err != nil {
t.Fatalf("failed to create state store: %v", err)
}

state := state.TestStateStore(t)
limiter := rate.NewLimiter(100.0, 100)
logger := testlog.HCLogger(t)
m := NewMockNodeTracker()
Expand Down
73 changes: 36 additions & 37 deletions nomad/fsm.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions nomad/leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ func (s *Server) replicateACLPolicies(stopCh chan struct{}) {
},
}
limiter := rate.NewLimiter(replicationRateLimit, int(replicationRateLimit))
s.logger.Debug("starting ACL policy replication from authoritative region", "authorative_region", req.Region)
s.logger.Debug("starting ACL policy replication from authoritative region", "authoritative_region", req.Region)

START:
for {
Expand Down Expand Up @@ -1073,7 +1073,7 @@ func (s *Server) replicateACLTokens(stopCh chan struct{}) {
},
}
limiter := rate.NewLimiter(replicationRateLimit, int(replicationRateLimit))
s.logger.Debug("starting ACL token replication from authoritative region", "authorative_region", req.Region)
s.logger.Debug("starting ACL token replication from authoritative region", "authoritative_region", req.Region)

START:
for {
Expand Down
2 changes: 1 addition & 1 deletion nomad/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func NewServer(config *Config, consulCatalog consul.CatalogAPI) (*Server, error)
// Setup the Consul syncer
if err := s.setupConsulSyncer(); err != nil {
s.logger.Error("failed to create server consul syncer", "error", err)
return nil, fmt.Errorf("failed to create server Consul syncer: %v", "error", err)
return nil, fmt.Errorf("failed to create server Consul syncer: %v", err)
}

// Setup the deployment watcher.
Expand Down
8 changes: 4 additions & 4 deletions plugins/shared/loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,15 @@ func TestPluginLoader_External_Config_Bad(t *testing.T) {
Config: map[string]interface{}{
"foo": "1",
"bar": "2",
"non-existant": "3",
"non-existent": "3",
},
},
},
}

_, err := NewPluginLoader(lconfig)
require.Error(err)
require.Contains(err.Error(), "No argument or block type is named \"non-existant\"")
require.Contains(err.Error(), "No argument or block type is named \"non-existent\"")
}

func TestPluginLoader_External_VersionOverlap(t *testing.T) {
Expand Down Expand Up @@ -452,15 +452,15 @@ func TestPluginLoader_Internal_Config_Bad(t *testing.T) {
Config: map[string]interface{}{
"foo": "1",
"bar": "2",
"non-existant": "3",
"non-existent": "3",
},
},
},
}

_, err := NewPluginLoader(lconfig)
require.Error(err)
require.Contains(err.Error(), "No argument or block type is named \"non-existant\"")
require.Contains(err.Error(), "No argument or block type is named \"non-existent\"")
}

func TestPluginLoader_InternalOverrideExternal(t *testing.T) {
Expand Down

0 comments on commit 32f9da9

Please sign in to comment.