Adding upstream version 1.34.4.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
e393c3af3f
commit
4978089aab
4963 changed files with 677545 additions and 0 deletions
54
plugins/inputs/sysstat/sysstat_interval_test.go
Normal file
54
plugins/inputs/sysstat/sysstat_interval_test.go
Normal file
|
@ -0,0 +1,54 @@
|
|||
//go:build !race && linux
|
||||
|
||||
package sysstat
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/influxdata/telegraf/testutil"
|
||||
)
|
||||
|
||||
// TestInterval verifies that the correct interval is created. It is not
|
||||
// run with -race option, because in that scenario interval between the two
|
||||
// Gather calls is greater than wantedInterval.
|
||||
func TestInterval(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("Skipping test with sleep in short mode.")
|
||||
}
|
||||
// overwriting exec commands with mock commands
|
||||
execCommand = fakeExecCommand
|
||||
defer func() { execCommand = exec.Command }()
|
||||
var acc testutil.Accumulator
|
||||
|
||||
s := &Sysstat{
|
||||
Log: testutil.Logger{},
|
||||
interval: 0,
|
||||
Sadc: "/usr/lib/sa/sadc",
|
||||
Sadf: "/usr/bin/sadf",
|
||||
Group: false,
|
||||
Activities: []string{"DISK", "SNMP"},
|
||||
Options: map[string]string{
|
||||
"C": "cpu",
|
||||
"d": "disk",
|
||||
},
|
||||
DeviceTags: map[string][]map[string]string{
|
||||
"sda": {
|
||||
{
|
||||
"vg": "rootvg",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
require.NoError(t, s.Init())
|
||||
require.NoError(t, acc.GatherError(s.Gather))
|
||||
|
||||
wantedInterval := 3
|
||||
time.Sleep(time.Duration(wantedInterval) * time.Second)
|
||||
|
||||
require.NoError(t, acc.GatherError(s.Gather))
|
||||
require.Equalf(t, wantedInterval, s.interval, "wrong interval: got %d, want %d", s.interval, wantedInterval)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue