From 9328f04f4ad1b5f90e156f93d91e7f61a3ce2e76 Mon Sep 17 00:00:00 2001 From: benbierens Date: Thu, 1 Jun 2023 16:09:38 +0200 Subject: [PATCH] Adds retry for assertions of metrics and account balances. --- DistTestCore/Marketplace/MarketplaceAccess.cs | 6 ++++-- DistTestCore/Metrics/MetricsAccess.cs | 11 +++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/DistTestCore/Marketplace/MarketplaceAccess.cs b/DistTestCore/Marketplace/MarketplaceAccess.cs index 33f68e6..ad9bc7a 100644 --- a/DistTestCore/Marketplace/MarketplaceAccess.cs +++ b/DistTestCore/Marketplace/MarketplaceAccess.cs @@ -1,5 +1,4 @@ using DistTestCore.Codex; -using Logging; using NUnit.Framework; using NUnit.Framework.Constraints; using System.Numerics; @@ -98,7 +97,10 @@ namespace DistTestCore.Marketplace public void AssertThatBalance(IResolveConstraint constraint, string message = "") { - Assert.That(GetBalance(), constraint, message); + Time.Retry(() => + { + Assert.That(GetBalance(), constraint, message); + }, nameof(AssertThatBalance)); } public TestToken GetBalance() diff --git a/DistTestCore/Metrics/MetricsAccess.cs b/DistTestCore/Metrics/MetricsAccess.cs index e52c175..2032839 100644 --- a/DistTestCore/Metrics/MetricsAccess.cs +++ b/DistTestCore/Metrics/MetricsAccess.cs @@ -28,12 +28,15 @@ namespace DistTestCore.Metrics public void AssertThat(string metricName, IResolveConstraint constraint, string message = "") { - var metricSet = GetMetricWithTimeout(metricName); - var metricValue = metricSet.Values[0].Value; + Time.Retry(() => + { + 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()