Skip to content

Commit

Permalink
RavenDB-21606 : flaky test adjustments - increase WaitForDocumentInCl…
Browse files Browse the repository at this point in the history
…uster timeout, add replication performance stats to failure message
  • Loading branch information
aviv86 committed Dec 24, 2023
1 parent d7a22ef commit 3b6f7ea
Showing 1 changed file with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FastTests;
using Newtonsoft.Json;
using Raven.Client.Documents;
using Raven.Client.Documents.Conventions;
using Raven.Client.Documents.Indexes.TimeSeries;
using Raven.Client.Documents.Operations.Backups;
using Raven.Client.Documents.Operations.Replication;
using Raven.Server;
using Raven.Server.ServerWide.Context;
using Raven.Tests.Core.Utils.Entities;
using Tests.Infrastructure;
Expand Down Expand Up @@ -332,7 +338,10 @@ public async Task CleanTimeSeriesTombstonesInTheClusterWithOnlyFullBackup(Option
var markerId = $"marker/{Guid.NewGuid()}$user/322";
session.Store(new User { Name = "Karmel" }, markerId);
session.SaveChanges();
Assert.True(await WaitForDocumentInClusterAsync<User>(cluster.Nodes, dbName, markerId, (u) => u.Id == markerId, Debugger.IsAttached ? TimeSpan.FromSeconds(60) : TimeSpan.FromSeconds(15)));
Assert.True(await WaitForDocumentInClusterAsync<User>(cluster.Nodes, dbName, markerId,
(u) => u.Id == markerId,
Debugger.IsAttached ? TimeSpan.FromSeconds(60) : TimeSpan.FromSeconds(30)),
userMessage: await GetReplicationDebugInfo(cluster.Nodes, dbName));
}

Assert.True(await WaitForChangeVectorInClusterForModeAsync(cluster.Nodes, dbName, options.DatabaseMode), "await WaitForChangeVectorInClusterAsync(cluster.Nodes, database)");
Expand Down Expand Up @@ -497,6 +506,29 @@ public async Task CanReplicateWhenStatsNameIsNull(Options options)
}
}

private async Task<string> GetReplicationDebugInfo(List<RavenServer> nodes, string database)
{
var stores = GetDocumentStores(nodes, database, disableTopologyUpdates: true, certificate: null);
var sb = new StringBuilder();

for (int i = 0; i < stores.Count; i++)
{
var nodeTag = nodes[i].ServerStore.NodeTag;
using (var re = stores[i].GetRequestExecutor(database))
using (re.ContextPool.AllocateOperationContext(out var context))
{
var cmd = new GetReplicationPerformanceStatisticsOperation().GetCommand(DocumentConventions.Default, context);
await re.ExecuteAsync(cmd, context);

sb.AppendLine($"ReplicationPerformanceStatistics for node {nodeTag}:")
.AppendLine(JsonConvert.SerializeObject(cmd.Result))
.AppendLine("-----------------------------------------");
}
}

return sb.ToString();
}

private class MyTsIndex : AbstractTimeSeriesIndexCreationTask<User>
{
public MyTsIndex()
Expand Down

0 comments on commit 3b6f7ea

Please sign in to comment.