diff --git a/server/pse/pse_test.go b/server/pse/pse_test.go index 7a03c6718f..0685735d37 100644 --- a/server/pse/pse_test.go +++ b/server/pse/pse_test.go @@ -17,6 +17,8 @@ func TestPSEmulation(t *testing.T) { var rss, vss, psRss, psVss int64 var pcpu, psPcpu float64 + runtime.GC() + // PS version first pidStr := fmt.Sprintf("%d", os.Getpid()) out, err := exec.Command("ps", "o", "pcpu=,rss=,vsz=", "-p", pidStr).Output() @@ -28,6 +30,8 @@ func TestPSEmulation(t *testing.T) { psRss *= 1024 // 1k blocks, want bytes. psVss *= 1024 // 1k blocks, want bytes. + runtime.GC() + // Our internal version ProcUsage(&pcpu, &rss, &vss) @@ -45,7 +49,7 @@ func TestPSEmulation(t *testing.T) { if delta < 0 { delta = -delta } - if delta > 512*1024 { // 512k + if delta > 1024*1024 { // 1MB t.Fatalf("RSSs did not match close enough: %d vs %d", rss, psRss) } } diff --git a/server/pse/pse_windows_test.go b/server/pse/pse_windows_test.go index 978ce833ff..3598e7ba6c 100644 --- a/server/pse/pse_windows_test.go +++ b/server/pse/pse_windows_test.go @@ -6,6 +6,7 @@ package pse import ( "fmt" "os/exec" + "runtime" "strconv" "strings" "testing" @@ -26,7 +27,7 @@ func checkValues(t *testing.T, pcpu, tPcpu float64, rss, tRss int64) { if delta < 0 { delta = -delta } - if delta > 200*1024 { // 200k - basically sanity check + if delta > 1024*1024 { // 1MB t.Fatalf("RSSs did not match close enough: %d vs %d", rss, tRss) } } @@ -36,10 +37,14 @@ func TestPSEmulationWin(t *testing.T) { var pcpu, tPcpu float64 var rss, vss, tRss int64 + runtime.GC() + if err := ProcUsage(&pcpu, &rss, &vss); err != nil { t.Fatalf("Error: %v", err) } + runtime.GC() + imageName := getProcessImageName() // query the counters using typeperf out, err := exec.Command("typeperf.exe", @@ -70,6 +75,8 @@ func TestPSEmulationWin(t *testing.T) { checkValues(t, pcpu, tPcpu, rss, tRss) + runtime.GC() + // Again to test caching if err = ProcUsage(&pcpu, &rss, &vss); err != nil { t.Fatalf("Error: %v", err)