Fix MQTT input exits if Broker is not available on startup (#3202)

(cherry picked from commit 5488f4b3ac)
This commit is contained in:
DanKans
2017-09-11 20:24:51 +01:00
committed by Daniel Nelson
parent 34b7a4c361
commit e9a12bb694
3 changed files with 52 additions and 20 deletions

View File

@@ -22,11 +22,13 @@ const (
func newTestMQTTConsumer() (*MQTTConsumer, chan mqtt.Message) {
in := make(chan mqtt.Message, 100)
n := &MQTTConsumer{
Topics: []string{"telegraf"},
Servers: []string{"localhost:1883"},
in: in,
done: make(chan struct{}),
Topics: []string{"telegraf"},
Servers: []string{"localhost:1883"},
in: in,
done: make(chan struct{}),
connected: true,
}
return n, in
}
@@ -131,6 +133,7 @@ func TestRunParserAndGather(t *testing.T) {
n, in := newTestMQTTConsumer()
acc := testutil.Accumulator{}
n.acc = &acc
defer close(n.done)
n.parser, _ = parsers.NewInfluxParser()