Fix single dataset test.

The "two pool, one metic" test was only passing because of previous calls to Gather() had already populated the values.
This commit is contained in:
Allen Petersen 2015-12-08 05:53:11 -08:00
parent eb78b9268f
commit e3c8a1131a
1 changed files with 13 additions and 2 deletions

View File

@ -195,7 +195,7 @@ func TestZfsGeneratesMetrics(t *testing.T) {
err = ioutil.WriteFile(testKstatPath+"/vdev_cache_stats", []byte(vdev_cache_statsContents), 0644)
require.NoError(t, err)
intMetrics := getKstatMetrics()
intMetrics := getKstatMetricsAll()
var acc testutil.Accumulator
@ -225,6 +225,7 @@ func TestZfsGeneratesMetrics(t *testing.T) {
}
z = &Zfs{KstatPath: testKstatPath}
acc = testutil.Accumulator{}
err = z.Gather(&acc)
require.NoError(t, err)
@ -233,8 +234,11 @@ func TestZfsGeneratesMetrics(t *testing.T) {
assert.True(t, acc.CheckTaggedValue(metric.name, metric.value, tags))
}
intMetrics = getKstatMetricsArcOnly()
//two pools, one metric
z = &Zfs{KstatPath: testKstatPath, KstatMetrics: []string{"arcstats"}}
acc = testutil.Accumulator{}
err = z.Gather(&acc)
require.NoError(t, err)
@ -247,7 +251,7 @@ func TestZfsGeneratesMetrics(t *testing.T) {
require.NoError(t, err)
}
func getKstatMetrics() []*metrics {
func getKstatMetricsArcOnly() []*metrics {
return []*metrics{
{
name: "arcstats_hits",
@ -593,6 +597,11 @@ func getKstatMetrics() []*metrics {
name: "arcstats_arc_meta_max",
value: 18327165696,
},
}
}
func getKstatMetricsAll() []*metrics {
otherMetrics := []*metrics{
{
name: "zfetchstats_hits",
value: 7812959060,
@ -650,6 +659,8 @@ func getKstatMetrics() []*metrics {
value: 0,
},
}
return append(getKstatMetricsArcOnly(), otherMetrics...)
}
func getPoolMetrics() []*metrics {