ceph metrics test

This commit is contained in:
madz 2015-07-03 14:08:34 +08:00
parent 97b4f68d72
commit a8f4e1d443
1 changed files with 45 additions and 67 deletions
plugins/ceph

View File

@ -19,60 +19,53 @@ func TestCephGenerateMetrics(t *testing.T) {
err := p.Gather(&acc)
require.NoError(t, err)
intMetrics := []string{
"ceph_pool",
// "osd_count",
// "osd_utilization",
// "total_storage",
// "used",
// "available",
// "client_io_kbs",
// "client_io_ops",
// "pool_used",
// "pool_usedKb",
// "pool_maxbytes",
// "pool_utilization",
sample := p.SampleConfig()
assert.NotNil(t, sample)
assert.Equal(t, p.Cluster, "ceph", "Same Cluster")
// "osd_used",
// "osd_total",
// "osd_epoch",
// "osd_latency_commit",
// "osd_latency_apply",
// "op",
// "op_in_bytes",
// "op_out_bytes",
// "op_r",
// "op_r_out_byes",
// "op_w",
// "op_w_in_bytes",
// "op_rw",
// "op_rw_in_bytes",
// "op_rw_out_bytes",
// "pool_objects",
// "pg_map_count",
// "pg_data_bytes",
// "pg_data_avail",
// "pg_data_total",
// "pg_data_used",
// "pg_distribution",
// "pg_distribution_pool",
// "pg_distribution_osd",
}
floatMetrics := []string{
"sum",
}
intMetrics := []string{"pg_map_count"}
// "pg_data_avail",
// "osd_count",
// "osd_utilization",
// "total_storage",
// "used",
// "available",
// "client_io_kbs",
// "client_io_ops",
// "pool_used",
// "pool_usedKb",
// "pool_maxbytes",
// "pool_utilization",
// "osd_used",
// "osd_total",
// "osd_epoch",
// "osd_latency_commit",
// "osd_latency_apply",
// "op",
// "op_in_bytes",
// "op_out_bytes",
// "op_r",
// "op_r_out_byes",
// "op_w",
// "op_w_in_bytes",
// "op_rw",
// "op_rw_in_bytes",
// "op_rw_out_bytes",
// "pool_objects",
// "pg_map_count",
// "pg_data_bytes",
// "pg_data_avail",
// "pg_data_total",
// "pg_data_used",
// "pg_distribution",
// "pg_distribution_pool",
// "pg_distribution_osd",
// }
for _, metric := range intMetrics {
assert.True(t, acc.HasIntValue(metric))
}
for _, metric := range floatMetrics {
assert.True(t, acc.HasFloatValue(metric))
}
}
func TestCephGenerateMetricsDefault(t *testing.T) {
@ -82,25 +75,10 @@ func TestCephGenerateMetricsDefault(t *testing.T) {
err := p.Gather(&acc)
require.NoError(t, err)
assert.True(t, len(acc.Points) > 0)
point, ok := acc.Get("ceph_osd_count")
require.True(t, ok)
assert.Equal(t, "ceph", point.Tags["cluster"])
// point, ok := acc.Get("ceph_op_wip")
// require.True(t, ok)
// assert.Equal(t, "ceph", point.Tags["cluster"])
}
func TestCephTagsMetricsWithDifferentCluster(t *testing.T) {
p := &CephMetrics{
Cluster: "cephTest",
}
var acc testutil.Accumulator
err := p.Gather(&acc)
require.NoError(t, err)
point, ok := acc.Get("cephTest_osd_count")
require.True(t, ok)
assert.Equal(t, "cephTest", point.Tags["cluster"])
}