Skip to content

Commit

Permalink
RavenDB-20836 : flaky test adjustments + debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
aviv committed Jan 31, 2024
1 parent b0a16f8 commit 0e6f7bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ await WaitForValueAsync(async () =>
return ongoingTask.ResponsibleNode.NodeTag != responsibleNodeNodeTag;
}, true);

Assert.True(WaitForDocument<User>(dest, "users/2", u => u.Name == "Joe Doe2"));
Assert.True(WaitForDocument<User>(dest, "users/2", u => u.Name == "Joe Doe2", timeout: 30_000),
userMessage: await Etl.GetEtlDebugInfo(src.Database, server: srcRaft.Nodes.Single(s => s.ServerStore.NodeTag == ongoingTask.ResponsibleNode.NodeTag)));
}
}

Expand Down
9 changes: 5 additions & 4 deletions test/Tests.Infrastructure/RavenTestBase.Etl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using System.Text;
using Newtonsoft.Json;
using Raven.Client.Util;
using Raven.Server;
using Tests.Infrastructure;

namespace FastTests
Expand Down Expand Up @@ -321,16 +322,16 @@ public async Task<DocumentDatabase> GetDatabaseFor(IDocumentStore store, string
return await _parent.GetDocumentDatabaseInstanceFor(store, databaseName);
}

public async Task<string> GetEtlDebugInfo(string database, TimeSpan timeout, RavenDatabaseMode databaseMode = RavenDatabaseMode.Single)
public async Task<string> GetEtlDebugInfo(string database, TimeSpan? timeout = null, RavenDatabaseMode databaseMode = RavenDatabaseMode.Single, RavenServer server = null)
{
IEnumerable<DocumentDatabase> databases = databaseMode switch
{
RavenDatabaseMode.Single => new[] { await _parent.GetDatabase(database) },
RavenDatabaseMode.Sharded => await _parent.Sharding.GetShardsDocumentDatabaseInstancesFor(database).ToListAsync(),
RavenDatabaseMode.Single => new[] { await GetDatabase(server ?? _parent.Server, database) },
RavenDatabaseMode.Sharded => await _parent.Sharding.GetShardsDocumentDatabaseInstancesFor(database, server == null ? null : [server]).ToListAsync(),
_ => throw new ArgumentOutOfRangeException(nameof(databaseMode), databaseMode, null)
};

var sb = new StringBuilder($"ETL did not finish in {timeout.TotalSeconds} seconds.");
var sb = new StringBuilder($"ETL did not finish in {timeout?.TotalSeconds ?? 30} seconds.");

foreach (var documentDatabase in databases)
{
Expand Down

0 comments on commit 0e6f7bf

Please sign in to comment.