Skip to content

Commit

Permalink
refactor test
Browse files Browse the repository at this point in the history
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
  • Loading branch information
hawkingrei committed Mar 2, 2023
1 parent 0534ccb commit 78b80aa
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions util/cpu/cpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ func TestCPUValue(t *testing.T) {
}()
}
observer.Start()
time.Sleep(5 * time.Second)
value, unsupported := GetCPUUsage()
require.False(t, unsupported)
require.GreaterOrEqual(t, value, 0.0)
value, unsupported = GetCPUUsage()
require.False(t, unsupported)
require.Less(t, value, 1.0)
for n := 0; n < 10; n++ {
time.Sleep(1 * time.Second)
value, unsupported := GetCPUUsage()
require.False(t, unsupported)
require.GreaterOrEqual(t, value, 0.0)
require.Less(t, value, 1.0)
}

observer.Stop()
close(exit)
wg.Wait()
Expand Down

0 comments on commit 78b80aa

Please sign in to comment.