1
0
Fork 0

Adding upstream version 1.34.4.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-24 07:26:29 +02:00
parent e393c3af3f
commit 4978089aab
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
4963 changed files with 677545 additions and 0 deletions

View 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)
}