Skip to content

Commit

Permalink
fix InstanceDataCollectionCollection_CopyTo by retrying on 0 values
Browse files Browse the repository at this point in the history
Previously, when pcc.ReadCategory() returned 0 values, we did not retry,
which broke the test that asserted its length > 0. This time, we retry
when there are 0 values, by triggering the RetryHelper's exception
handler.

Fixes dotnet#68291
  • Loading branch information
smasher164 committed Jun 1, 2022
1 parent f002cdc commit dd3bbc9
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,16 @@ public static void InstanceDataCollectionCollection_CopyTo()

public static InstanceDataCollectionCollection GetInstanceDataCollectionCollection()
{
PerformanceCounterCategory pcc = Helpers.RetryOnAllPlatforms(() => new PerformanceCounterCategory("Processor"));
return Helpers.RetryOnAllPlatforms(() => pcc.ReadCategory());
PerformanceCounterCategory pcc = Helpers.RetryOnAllPlatforms(() => new PerformanceCounterCategory("Processor"));
return Helpers.RetryOnAllPlatforms(() =>
{
var idcc = pcc.ReadCategory();
if (idcc.Values.Count == 0)
{
throw new Exception();
}
return idcc;
});
}

public static InstanceDataCollection GetInstanceDataCollection()
Expand Down

0 comments on commit dd3bbc9

Please sign in to comment.