mongodb input: fix version 2.2 panic

closes #1628
This commit is contained in:
Cameron Sparr 2016-09-06 11:34:57 +01:00
parent 6b1cc67664
commit 2fe427b3b3
4 changed files with 8 additions and 7 deletions

View File

@ -20,6 +20,7 @@
### Bugfixes ### Bugfixes
- [#1628](https://github.com/influxdata/telegraf/issues/1628): Fix mongodb input panic on version 2.2.
## v1.0 [unreleased] ## v1.0 [unreleased]

View File

@ -118,7 +118,7 @@ func TestRandomSleep(t *testing.T) {
s = time.Now() s = time.Now()
RandomSleep(time.Millisecond*50, make(chan struct{})) RandomSleep(time.Millisecond*50, make(chan struct{}))
elapsed = time.Since(s) elapsed = time.Since(s)
assert.True(t, elapsed < time.Millisecond*50) assert.True(t, elapsed < time.Millisecond*100)
// test that shutdown is respected // test that shutdown is respected
s = time.Now() s = time.Now()

View File

@ -43,7 +43,7 @@ func TestRunParser(t *testing.T) {
k.parser, _ = parsers.NewInfluxParser() k.parser, _ = parsers.NewInfluxParser()
go k.receiver() go k.receiver()
in <- saramaMsg(testMsg) in <- saramaMsg(testMsg)
time.Sleep(time.Millisecond) time.Sleep(time.Millisecond * 5)
assert.Equal(t, acc.NFields(), 1) assert.Equal(t, acc.NFields(), 1)
} }
@ -58,7 +58,7 @@ func TestRunParserInvalidMsg(t *testing.T) {
k.parser, _ = parsers.NewInfluxParser() k.parser, _ = parsers.NewInfluxParser()
go k.receiver() go k.receiver()
in <- saramaMsg(invalidMsg) in <- saramaMsg(invalidMsg)
time.Sleep(time.Millisecond) time.Sleep(time.Millisecond * 5)
assert.Equal(t, acc.NFields(), 0) assert.Equal(t, acc.NFields(), 0)
} }
@ -73,7 +73,7 @@ func TestRunParserAndGather(t *testing.T) {
k.parser, _ = parsers.NewInfluxParser() k.parser, _ = parsers.NewInfluxParser()
go k.receiver() go k.receiver()
in <- saramaMsg(testMsg) in <- saramaMsg(testMsg)
time.Sleep(time.Millisecond) time.Sleep(time.Millisecond * 5)
k.Gather(&acc) k.Gather(&acc)
@ -92,7 +92,7 @@ func TestRunParserAndGatherGraphite(t *testing.T) {
k.parser, _ = parsers.NewGraphiteParser("_", []string{}, nil) k.parser, _ = parsers.NewGraphiteParser("_", []string{}, nil)
go k.receiver() go k.receiver()
in <- saramaMsg(testMsgGraphite) in <- saramaMsg(testMsgGraphite)
time.Sleep(time.Millisecond) time.Sleep(time.Millisecond * 5)
k.Gather(&acc) k.Gather(&acc)
@ -111,7 +111,7 @@ func TestRunParserAndGatherJSON(t *testing.T) {
k.parser, _ = parsers.NewJSONParser("kafka_json_test", []string{}, nil) k.parser, _ = parsers.NewJSONParser("kafka_json_test", []string{}, nil)
go k.receiver() go k.receiver()
in <- saramaMsg(testMsgJSON) in <- saramaMsg(testMsgJSON)
time.Sleep(time.Millisecond) time.Sleep(time.Millisecond * 5)
k.Gather(&acc) k.Gather(&acc)

View File

@ -514,7 +514,7 @@ func NewStatLine(oldMongo, newMongo MongoStatus, key string, all bool, sampleSec
returnVal.Command = diff(newStat.Opcounters.Command, oldStat.Opcounters.Command, sampleSecs) returnVal.Command = diff(newStat.Opcounters.Command, oldStat.Opcounters.Command, sampleSecs)
} }
if newStat.Metrics.TTL != nil && oldStat.Metrics.TTL != nil { if newStat.Metrics != nil && newStat.Metrics.TTL != nil && oldStat.Metrics.TTL != nil {
returnVal.Passes = diff(newStat.Metrics.TTL.Passes, oldStat.Metrics.TTL.Passes, sampleSecs) returnVal.Passes = diff(newStat.Metrics.TTL.Passes, oldStat.Metrics.TTL.Passes, sampleSecs)
returnVal.DeletedDocuments = diff(newStat.Metrics.TTL.DeletedDocuments, oldStat.Metrics.TTL.DeletedDocuments, sampleSecs) returnVal.DeletedDocuments = diff(newStat.Metrics.TTL.DeletedDocuments, oldStat.Metrics.TTL.DeletedDocuments, sampleSecs)
} }