feat(timeout): Use timeout setting
* Use timeout as parameter in the http request * A bit of cleanup * More tests
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/influxdata/telegraf/testutil"
|
||||
@@ -86,9 +87,6 @@ func TestMesosMaster(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveGroup(t *testing.T) {
|
||||
//t.Skip("needs refactoring")
|
||||
// FIXME: removeGroup() behavior is the opposite as it was,
|
||||
// this test has to be refactored
|
||||
generateMetrics()
|
||||
|
||||
m := Mesos{
|
||||
@@ -111,3 +109,42 @@ func TestRemoveGroup(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMasterBlocks(t *testing.T) {
|
||||
a := "wrong_key"
|
||||
expect := []string{}
|
||||
got := masterBlocks(a)
|
||||
|
||||
if !reflect.DeepEqual(got, expect) {
|
||||
t.Errorf("Expected empty string slice, got: %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSampleConfig(t *testing.T) {
|
||||
expect := `
|
||||
# Timeout, in ms.
|
||||
timeout = 100
|
||||
# A list of Mesos masters. e.g. master1:5050, master2:5080, etc.
|
||||
# The port can be skipped if using the default (5050)
|
||||
# Default value is localhost:5050.
|
||||
servers = ["localhost:5050"]
|
||||
# Metrics groups to be collected.
|
||||
# Default, all enabled.
|
||||
metrics_collection = ["resources","master","system","slaves","frameworks","messages","evqueue","registrar"]
|
||||
`
|
||||
|
||||
got := new(Mesos).SampleConfig()
|
||||
|
||||
if expect != got {
|
||||
t.Errorf("Got %s", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDescription(t *testing.T) {
|
||||
expect := "Telegraf plugin for gathering metrics from N Mesos masters"
|
||||
got := new(Mesos).Description()
|
||||
|
||||
if expect != got {
|
||||
t.Errorf("Got %s", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user