Skip to content

Commit

Permalink
Prevent stdinservice_test being flaky
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 572580900
  • Loading branch information
torsm committed Oct 12, 2023
1 parent 3f544e0 commit 05106e5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions fleetspeak/src/client/stdinservice/stdinservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,14 @@ while time.time() - t0 < 1.:
t.Fatalf("unexpected output; StdinServiceOutputMessage.resource_usage.mean_system_cpu_rate not set: %q", om)
}

// We don't test for ResourceUsage.MeanResidentMemory because memory can't be queried after the
// process has terminated. Relying on memory usage during execution can result in "0" being
// recorded which would be indistinguishable from it not being set at all, resulting in a flaky
// test case. The fact that the other resource usage metrics have been set here is good enough.

if om.Timestamp.Seconds <= 0 {
t.Fatalf("unexpected output; StdinServiceOutputMessage.timestamp.seconds not set: %q", om)
}

if om.ResourceUsage.MeanResidentMemory <= 0 {
t.Fatalf("unexpected output; StdinServiceOutputMessage.resource_usage.mean_resident_memory not set: %q", om)
}
}

func TestStdinServiceCancellation(t *testing.T) {
Expand Down

0 comments on commit 05106e5

Please sign in to comment.