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;
@ -98,7 +97,10 @@ namespace DistTestCore.Marketplace
public void AssertThatBalance(IResolveConstraint constraint, string message = "") public void AssertThatBalance(IResolveConstraint constraint, string message = "")
{ {
Assert.That(GetBalance(), constraint, message); Time.Retry(() =>
{
Assert.That(GetBalance(), constraint, message);
}, nameof(AssertThatBalance));
} }
public TestToken GetBalance() public TestToken GetBalance()

View File

@ -28,12 +28,15 @@ namespace DistTestCore.Metrics
public void AssertThat(string metricName, IResolveConstraint constraint, string message = "") public void AssertThat(string metricName, IResolveConstraint constraint, string message = "")
{ {
var metricSet = GetMetricWithTimeout(metricName); Time.Retry(() =>
var metricValue = metricSet.Values[0].Value; {
var metricSet = GetMetricWithTimeout(metricName);
var metricValue = metricSet.Values[0].Value;
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()