Adds retry for assertions of metrics and account balances.

This commit is contained in:
benbierens 2023-06-01 16:09:38 +02:00
parent 44e237e60e
commit 9328f04f4a
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
2 changed files with 11 additions and 6 deletions

View File

@ -1,5 +1,4 @@
using DistTestCore.Codex; using DistTestCore.Codex;
using Logging;
using NUnit.Framework; using NUnit.Framework;
using NUnit.Framework.Constraints; using NUnit.Framework.Constraints;
using System.Numerics; using System.Numerics;
@ -97,8 +96,11 @@ namespace DistTestCore.Marketplace
} }
public void AssertThatBalance(IResolveConstraint constraint, string message = "") public void AssertThatBalance(IResolveConstraint constraint, string message = "")
{
Time.Retry(() =>
{ {
Assert.That(GetBalance(), constraint, message); Assert.That(GetBalance(), constraint, message);
}, nameof(AssertThatBalance));
} }
public TestToken GetBalance() public TestToken GetBalance()

View File

@ -27,6 +27,8 @@ namespace DistTestCore.Metrics
} }
public void AssertThat(string metricName, IResolveConstraint constraint, string message = "") public void AssertThat(string metricName, IResolveConstraint constraint, string message = "")
{
Time.Retry(() =>
{ {
var metricSet = GetMetricWithTimeout(metricName); var metricSet = GetMetricWithTimeout(metricName);
var metricValue = metricSet.Values[0].Value; var metricValue = metricSet.Values[0].Value;
@ -34,6 +36,7 @@ namespace DistTestCore.Metrics
log.Log($"{node.Name} metric '{metricName}' = {metricValue}"); log.Log($"{node.Name} metric '{metricName}' = {metricValue}");
Assert.That(metricValue, constraint, message); Assert.That(metricValue, constraint, message);
}, nameof(AssertThat));
} }
public Metrics? GetAllMetrics() public Metrics? GetAllMetrics()