Пример #1
0
func TestDropwizardJsonInput(t *testing.T) {
	fixtureFilePath := path.Join(test_utils.DirectoryOfCurrentFile(), "/../../fixtures/dropwizard_data.json")
	dat, err := ioutil.ReadFile(fixtureFilePath)

	assert.Nil(t, err)

	metrics, err := parseUWSGIMetrics(&dat)
	assert.Nil(t, err)
	assert.Equal(t, 560, len(metrics))
}
Пример #2
0
func TestCpuInfoCollect(t *testing.T) {
	config := make(map[string]interface{})
	config["procPath"] = path.Join(test_utils.DirectoryOfCurrentFile(), "/../../fixtures/proc/cpuinfo")
	testChannel := make(chan metric.Metric)
	testLogger := test_utils.BuildLogger()

	cpuInfo := newCPUInfo(testChannel, 100, testLogger)
	cpuInfo.Configure(config)

	go cpuInfo.Collect()

	select {
	case m := <-cpuInfo.Channel():
		assert.Equal(t, 2.0, m.Value)
		assert.Equal(t, "Xeon(R) CPU E5-2630 0 @ 2.30GHz", m.Dimensions["model"])
		return
	case <-time.After(2 * time.Second):
		t.Fail()
	}
}