Skip to content

Commit

Permalink
updated armon/go-metrics dependency to remove race conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Baker committed Apr 29, 2019
1 parent 45d6457 commit 205c5b0
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 18 deletions.
19 changes: 9 additions & 10 deletions command/agent/metrics_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ import (
"testing"
"time"

"github.com/hashicorp/nomad/nomad/structs"

"github.com/hashicorp/nomad/nomad/mock"

"github.com/stretchr/testify/require"

"github.com/armon/go-metrics"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestHTTP_MetricsWithIllegalMethod(t *testing.T) {
Expand Down Expand Up @@ -83,13 +80,13 @@ func TestHTTP_FreshClientAllocMetrics(t *testing.T) {
job.TaskGroups[0].Count = numTasks
testutil.RegisterJob(t, s.RPC, job)
testutil.WaitForResult(func() (bool, error) {
time.Sleep(200 * time.Millisecond)
args := &structs.JobSpecificRequest{}
args.JobID = job.ID
args.QueryOptions.Region = "global"
var resp structs.SingleJobResponse
err := s.RPC("Job.GetJob", args, &resp)
require.NoError(err)
return resp.Job.Status != "dead", nil
return err == nil && resp.Job.Status == "dead", err
}, func(err error) {
require.Fail("timed-out waiting for job to complete")
})
Expand All @@ -98,13 +95,14 @@ func TestHTTP_FreshClientAllocMetrics(t *testing.T) {
var pending, running, terminal float32 = -1.0, -1.0, -1.0
testutil.WaitForResultRetries(100, func() (bool, error) {
time.Sleep(100 * time.Millisecond)
// client alloc metrics should reflect that there is one running alloc and zero pending allocs
req, err := http.NewRequest("GET", "/v1/metrics", nil)
require.NoError(err)
respW := httptest.NewRecorder()

obj, err := s.Server.MetricsRequest(respW, req)
require.NoError(err)
if err != nil {
return false, err
}

metrics := obj.(metrics.MetricsSummary)
for _, g := range metrics.Gauges {
Expand All @@ -118,6 +116,7 @@ func TestHTTP_FreshClientAllocMetrics(t *testing.T) {
terminal = g.Value
}
}
// client alloc metrics should reflect that there is numTasks terminal allocs and no other allocs
return pending == float32(0) && running == float32(0) &&
terminal == float32(numTasks), nil
}, func(err error) {
Expand Down
1 change: 1 addition & 0 deletions vendor/github.com/armon/go-metrics/go.mod

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

9 changes: 9 additions & 0 deletions vendor/github.com/armon/go-metrics/go.sum

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

4 changes: 2 additions & 2 deletions vendor/github.com/armon/go-metrics/inmem.go

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

10 changes: 10 additions & 0 deletions vendor/github.com/armon/go-metrics/inmem_endpoint.go

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

2 changes: 1 addition & 1 deletion vendor/github.com/armon/go-metrics/metrics.go

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

2 changes: 1 addition & 1 deletion vendor/github.com/hashicorp/memberlist/state.go

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

8 changes: 4 additions & 4 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
{"path":"github.com/appc/spec/schema/types","checksumSHA1":"kYXCle7Ikc8WqiMs7NXz99bUWqo=","revision":"cbe99b7160b1397bf89f9c8bb1418f69c9424049","revisionTime":"2017-09-19T09:55:19Z"},
{"path":"github.com/appc/spec/schema/types/resource","checksumSHA1":"VgPsPj5PH7LKXMa3ZLe5/+Avydo=","revision":"cbe99b7160b1397bf89f9c8bb1418f69c9424049","revisionTime":"2017-09-19T09:55:19Z"},
{"path":"github.com/armon/circbuf","checksumSHA1":"l0iFqayYAaEip6Olaq3/LCOa/Sg=","revision":"bbbad097214e2918d8543d5201d12bfd7bca254d"},
{"path":"github.com/armon/go-metrics","checksumSHA1":"WBL8jVG+Z5q7L/xeOYBda3/SyVk=","revision":"19afeffa34d4296ef5f7d916e04d79b6252b04ec","revisionTime":"2019-04-23T19:29:45Z"},
{"path":"github.com/armon/go-metrics/circonus","checksumSHA1":"xCsGGM9TKBogZDfSN536KtQdLko=","revision":"19afeffa34d4296ef5f7d916e04d79b6252b04ec","revisionTime":"2019-04-23T19:29:45Z"},
{"path":"github.com/armon/go-metrics/datadog","checksumSHA1":"Dt0n1sSivvvdZQdzc4Hu/yOG+T0=","revision":"19afeffa34d4296ef5f7d916e04d79b6252b04ec","revisionTime":"2019-04-23T19:29:45Z"},
{"path":"github.com/armon/go-metrics/prometheus","checksumSHA1":"vxr0X6/jCQ4FkMxdhzUaBEWrFGA=","revision":"19afeffa34d4296ef5f7d916e04d79b6252b04ec","revisionTime":"2019-04-23T19:29:45Z"},
{"path":"github.com/armon/go-metrics","checksumSHA1":"dmBkYum50Z9ep4I6lBQnq5CtakE=","revision":"8b3201776bcbae545bf35c3a1042fe2cc5f621c1","revisionTime":"2019-04-29T20:10:13Z"},
{"path":"github.com/armon/go-metrics/circonus","checksumSHA1":"xCsGGM9TKBogZDfSN536KtQdLko=","revision":"8b3201776bcbae545bf35c3a1042fe2cc5f621c1","revisionTime":"2019-04-29T20:10:13Z"},
{"path":"github.com/armon/go-metrics/datadog","checksumSHA1":"Dt0n1sSivvvdZQdzc4Hu/yOG+T0=","revision":"8b3201776bcbae545bf35c3a1042fe2cc5f621c1","revisionTime":"2019-04-29T20:10:13Z"},
{"path":"github.com/armon/go-metrics/prometheus","checksumSHA1":"vxr0X6/jCQ4FkMxdhzUaBEWrFGA=","revision":"8b3201776bcbae545bf35c3a1042fe2cc5f621c1","revisionTime":"2019-04-29T20:10:13Z"},
{"path":"github.com/armon/go-radix","checksumSHA1":"gNO0JNpLzYOdInGeq7HqMZUzx9M=","revision":"4239b77079c7b5d1243b7b4736304ce8ddb6f0f2","revisionTime":"2016-01-15T23:47:25Z"},
{"path":"github.com/aws/aws-sdk-go/aws","checksumSHA1":"gMMx/JVSQVE4KHKoJQC7cqjTIZc=","comment":"v1.0.6-2-g80dd495","revision":"80dd4951fdb3f711d31843b8d87871130ef2df67"},
{"path":"github.com/aws/aws-sdk-go/aws/awserr","checksumSHA1":"OlpdlsDV2Qv50MuHlpH9heaHjQc=","comment":"v1.0.6-2-g80dd495","revision":"80dd4951fdb3f711d31843b8d87871130ef2df67"},
Expand Down

0 comments on commit 205c5b0

Please sign in to comment.