disable TestInterval with -race test option
This commit is contained in:
parent
5943e20a29
commit
997fd16de8
|
@ -0,0 +1,40 @@
|
||||||
|
// +build +linux !race
|
||||||
|
|
||||||
|
package sysstat
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os/exec"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"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) {
|
||||||
|
// overwriting exec commands with mock commands
|
||||||
|
execCommand = fakeExecCommand
|
||||||
|
defer func() { execCommand = exec.Command }()
|
||||||
|
var acc testutil.Accumulator
|
||||||
|
|
||||||
|
s.interval = 0
|
||||||
|
wantedInterval := 3
|
||||||
|
|
||||||
|
err := s.Gather(&acc)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
time.Sleep(time.Duration(wantedInterval) * time.Second)
|
||||||
|
|
||||||
|
err = s.Gather(&acc)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if s.interval != wantedInterval {
|
||||||
|
t.Errorf("wrong interval: got %d, want %d", s.interval, wantedInterval)
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
)
|
)
|
||||||
|
@ -304,30 +303,3 @@ dell-xps 5 2016-03-25 16:18:10 UTC sdb %util 0.30
|
||||||
// some code here to check arguments perhaps?
|
// some code here to check arguments perhaps?
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestGatherInterval checks that interval is correctly set.
|
|
||||||
func TestGatherInterval(t *testing.T) {
|
|
||||||
// overwriting exec commands with mock commands
|
|
||||||
execCommand = fakeExecCommand
|
|
||||||
defer func() { execCommand = exec.Command }()
|
|
||||||
var acc testutil.Accumulator
|
|
||||||
|
|
||||||
s.interval = 0
|
|
||||||
wantedInterval := 3
|
|
||||||
|
|
||||||
err := s.Gather(&acc)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
time.Sleep(time.Duration(wantedInterval) * time.Second)
|
|
||||||
|
|
||||||
err = s.Gather(&acc)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if s.interval != wantedInterval {
|
|
||||||
t.Errorf("wrong interval: got %d, want %d", s.interval, wantedInterval)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue