コード例 #1
0
ファイル: status_test.go プロジェクト: radoondas/apachebeat
func TestFetch(t *testing.T) {

	config := helper.ModuleConfig{
		Hosts: []string{mysql.GetMySQLEnvDSN()},
	}
	module := &helper.Module{
		Config: config,
	}

	ms, msErr := helper.NewMetricSet("status", New, module)
	assert.NoError(t, msErr)

	var err error

	// Setup metricset
	err = ms.Setup()
	assert.NoError(t, err)

	// Load events
	event, err := ms.MetricSeter.Fetch(ms, module.Config.Hosts[0])
	assert.NoError(t, err)

	// Check event fields
	connections := event["Connections"].(int)
	open := event["open"].(common.MapStr)
	openTables := open["Open_tables"].(int)
	openFiles := open["Open_files"].(int)
	openStreams := open["Open_streams"].(int)

	assert.True(t, connections > 0)
	assert.True(t, openTables > 0)
	assert.True(t, openFiles >= 0)
	assert.True(t, openStreams == 0)
}
コード例 #2
0
func getConfig() map[string]interface{} {
	return map[string]interface{}{
		"module":     "mysql",
		"metricsets": []string{"status"},
		"hosts":      []string{mysql.GetMySQLEnvDSN()},
	}
}
コード例 #3
0
ファイル: status_test.go プロジェクト: jarpy/beats
func TestFetch(t *testing.T) {

	if testing.Short() {
		t.Skip("Skipping in short mode, because it requires MySQL")
	}

	// Setup Metric
	m := New()

	config := helper.ModuleConfig{
		Hosts: []string{mysql.GetMySQLEnvDSN()},
	}
	module := &helper.Module{
		Config: config,
	}
	ms := helper.NewMetricSet("status", m, module)

	// Load events
	events, err := m.Fetch(ms)
	assert.NoError(t, err)

	// Check event fields
	connections := events[0]["Connections"].(int)
	openTables := events[0]["Open_tables"].(int)
	openFiles := events[0]["Open_files"].(int)
	openStreams := events[0]["Open_streams"].(int)

	assert.True(t, connections > 0)
	assert.True(t, openTables > 0)
	assert.True(t, openFiles > 0)
	assert.True(t, openStreams == 0)
}