Skip to content

Commit

Permalink
Fix single dataset test.
Browse files Browse the repository at this point in the history
The "two pool, one metic" test was only passing because of previous calls to Gather() had already populated the values.
  • Loading branch information
allenpetersen committed Dec 8, 2015
1 parent eb78b92 commit e3c8a11
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions plugins/zfs/zfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -225,6 +225,7 @@ func TestZfsGeneratesMetrics(t *testing.T) {
}

z = &Zfs{KstatPath: testKstatPath}
acc = testutil.Accumulator{}
err = z.Gather(&acc)
require.NoError(t, err)

Expand All @@ -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)

Expand All @@ -247,7 +251,7 @@ func TestZfsGeneratesMetrics(t *testing.T) {
require.NoError(t, err)
}

func getKstatMetrics() []*metrics {
func getKstatMetricsArcOnly() []*metrics {
return []*metrics{
{
name: "arcstats_hits",
Expand Down Expand Up @@ -593,6 +597,11 @@ func getKstatMetrics() []*metrics {
name: "arcstats_arc_meta_max",
value: 18327165696,
},
}
}

func getKstatMetricsAll() []*metrics {
otherMetrics := []*metrics{
{
name: "zfetchstats_hits",
value: 7812959060,
Expand Down Expand Up @@ -650,6 +659,8 @@ func getKstatMetrics() []*metrics {
value: 0,
},
}

return append(getKstatMetricsArcOnly(), otherMetrics...)
}

func getPoolMetrics() []*metrics {
Expand Down

0 comments on commit e3c8a11

Please sign in to comment.