Skip to content

Commit

Permalink
Fix lustre2 input plugin config parse regression (#6114)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeMac authored Jul 18, 2019
1 parent f93441d commit 56c6539
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugins/inputs/lustre2/lustre2.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ type tags struct {
// Lustre proc files can change between versions, so we want to future-proof
// by letting people choose what to look at.
type Lustre2 struct {
Ost_procfiles []string `toml:"ost_jobstat"`
Mds_procfiles []string `toml:"mds_jobstat"`
Ost_procfiles []string `toml:"ost_procfiles"`
Mds_procfiles []string `toml:"mds_procfiles"`

// allFields maps and OST name to the metric fields associated with that OST
allFields map[tags]map[string]interface{}
Expand Down
38 changes: 38 additions & 0 deletions plugins/inputs/lustre2/lustre2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import (
"testing"

"github.com/influxdata/telegraf/testutil"
"github.com/influxdata/toml"
"github.com/influxdata/toml/ast"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -330,3 +333,38 @@ func TestLustre2GeneratesJobstatsMetrics(t *testing.T) {
err = os.RemoveAll(os.TempDir() + "/telegraf")
require.NoError(t, err)
}

func TestLustre2CanParseConfiguration(t *testing.T) {
config := []byte(`
[[inputs.lustre2]]
ost_procfiles = [
"/proc/fs/lustre/obdfilter/*/stats",
"/proc/fs/lustre/osd-ldiskfs/*/stats",
]
mds_procfiles = [
"/proc/fs/lustre/mdt/*/md_stats",
]`)

table, err := toml.Parse([]byte(config))
require.NoError(t, err)

inputs, ok := table.Fields["inputs"]
require.True(t, ok)

lustre2, ok := inputs.(*ast.Table).Fields["lustre2"]
require.True(t, ok)

var plugin Lustre2

require.NoError(t, toml.UnmarshalTable(lustre2.([]*ast.Table)[0], &plugin))

assert.Equal(t, Lustre2{
Ost_procfiles: []string{
"/proc/fs/lustre/obdfilter/*/stats",
"/proc/fs/lustre/osd-ldiskfs/*/stats",
},
Mds_procfiles: []string{
"/proc/fs/lustre/mdt/*/md_stats",
},
}, plugin)
}

0 comments on commit 56c6539

Please sign in to comment.