open-nomad/client/stats/cpu_test.go

18 lines
349 B
Go
Raw Normal View History

package stats
import (
"testing"
2016-05-21 06:16:24 +00:00
"time"
)
func TestCpuStatsPercent(t *testing.T) {
cs := NewCpuStats()
2016-05-21 06:16:24 +00:00
cs.Percent(79.7)
time.Sleep(1 * time.Second)
percent := cs.Percent(80.69)
expectedPercent := 98.00
if percent < expectedPercent && percent > (expectedPercent+1.00) {
t.Fatalf("expected: %v, actual: %v", expectedPercent, percent)
}
}