Merge pull request #5260 from hashicorp/b-driver-stats-timestamp
executor: fix bug and add tests for incorrect stats timestamp reporting
This commit is contained in:
commit
4fd95aca01
|
@ -284,6 +284,8 @@ func TestExecDriver_Stats(t *testing.T) {
|
||||||
select {
|
select {
|
||||||
case stats := <-statsCh:
|
case stats := <-statsCh:
|
||||||
require.NotZero(stats.ResourceUsage.MemoryStats.RSS)
|
require.NotZero(stats.ResourceUsage.MemoryStats.RSS)
|
||||||
|
require.NotZero(stats.Timestamp)
|
||||||
|
require.WithinDuration(time.Now(), time.Unix(0, stats.Timestamp), time.Second)
|
||||||
case <-time.After(time.Second):
|
case <-time.After(time.Second):
|
||||||
require.Fail("timeout receiving from channel")
|
require.Fail("timeout receiving from channel")
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,9 +178,9 @@ func TestExecutor_WaitExitSignal(pt *testing.T) {
|
||||||
case <-time.After(time.Second):
|
case <-time.After(time.Second):
|
||||||
return false, fmt.Errorf("stats failed to send on interval")
|
return false, fmt.Errorf("stats failed to send on interval")
|
||||||
case ru := <-ch:
|
case ru := <-ch:
|
||||||
if len(ru.Pids) == 0 {
|
assert.NotEmpty(t, ru.Pids, "no pids recorded in stats")
|
||||||
return false, fmt.Errorf("no pids recorded in stats")
|
assert.NotZero(t, ru.ResourceUsage.MemoryStats.RSS)
|
||||||
}
|
assert.WithinDuration(t, time.Now(), time.Unix(0, ru.Timestamp), time.Second)
|
||||||
}
|
}
|
||||||
proc, err := os.FindProcess(ps.Pid)
|
proc, err := os.FindProcess(ps.Pid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -412,7 +412,7 @@ func TaskStatsFromProto(pb *proto.TaskStats) (*TaskResourceUsage, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
stats := &TaskResourceUsage{
|
stats := &TaskResourceUsage{
|
||||||
Timestamp: timestamp.Unix(),
|
Timestamp: timestamp.UnixNano(),
|
||||||
ResourceUsage: resourceUsageFromProto(pb.AggResourceUsage),
|
ResourceUsage: resourceUsageFromProto(pb.AggResourceUsage),
|
||||||
Pids: pids,
|
Pids: pids,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue