mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-12-24 19:29:56 +01:00
a8c94d48e6
This patch makes stylistic changes to error strings, unexports method names by lower casing them, removes unused dataSetMetric, and adds copyright/licence information. Signed-Off-By: Corey Stewart <stewa169@purdue.edu>
56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
// Copyright 2016 The Prometheus Authors
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package collector
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestArcstatsParsing(t *testing.T) {
|
|
arcstatsFile, err := os.Open("fixtures/proc/spl/kstat/zfs/arcstats")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer arcstatsFile.Close()
|
|
|
|
c := zfsCollector{}
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
handlerCalled := false
|
|
err = c.parseArcstatsProcfsFile(arcstatsFile, func(s zfsSysctl, v zfsMetricValue) {
|
|
|
|
if s != zfsSysctl("kstat.zfs.misc.arcstats.hits") {
|
|
return
|
|
}
|
|
|
|
handlerCalled = true
|
|
|
|
if v != zfsMetricValue(8772612) {
|
|
t.Fatalf("Incorrect value parsed from procfs data")
|
|
}
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if !handlerCalled {
|
|
t.Fatal("Arcstats parsing handler was not called for some expected sysctls")
|
|
}
|
|
}
|