Fix lustre2 input plugin config parse regression (#6114)
This commit is contained in:
parent
f93441d2a4
commit
56c6539a91
|
@ -25,8 +25,8 @@ type tags struct {
|
||||||
// Lustre proc files can change between versions, so we want to future-proof
|
// Lustre proc files can change between versions, so we want to future-proof
|
||||||
// by letting people choose what to look at.
|
// by letting people choose what to look at.
|
||||||
type Lustre2 struct {
|
type Lustre2 struct {
|
||||||
Ost_procfiles []string `toml:"ost_jobstat"`
|
Ost_procfiles []string `toml:"ost_procfiles"`
|
||||||
Mds_procfiles []string `toml:"mds_jobstat"`
|
Mds_procfiles []string `toml:"mds_procfiles"`
|
||||||
|
|
||||||
// allFields maps and OST name to the metric fields associated with that OST
|
// allFields maps and OST name to the metric fields associated with that OST
|
||||||
allFields map[tags]map[string]interface{}
|
allFields map[tags]map[string]interface{}
|
||||||
|
|
|
@ -6,6 +6,9 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
|
"github.com/influxdata/toml"
|
||||||
|
"github.com/influxdata/toml/ast"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -330,3 +333,38 @@ func TestLustre2GeneratesJobstatsMetrics(t *testing.T) {
|
||||||
err = os.RemoveAll(os.TempDir() + "/telegraf")
|
err = os.RemoveAll(os.TempDir() + "/telegraf")
|
||||||
require.NoError(t, err)
|
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)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue