diff --git a/test/SlowTests/Sharding/ETL/ShardedEtlFailoverTests.cs b/test/SlowTests/Sharding/ETL/ShardedEtlFailoverTests.cs index 980ef644b31f..aa1332d888df 100644 --- a/test/SlowTests/Sharding/ETL/ShardedEtlFailoverTests.cs +++ b/test/SlowTests/Sharding/ETL/ShardedEtlFailoverTests.cs @@ -18,11 +18,13 @@ using Raven.Client.ServerWide; using Raven.Client.ServerWide.Operations; using Raven.Client.ServerWide.Sharding; +using Raven.Server; using Raven.Server.Documents.Sharding; using Raven.Server.ServerWide.Context; using Raven.Server.Utils; using Raven.Tests.Core.Utils.Entities; using SlowTests.Server.Documents.ETL.Olap; +using Sparrow.Json; using Sparrow.Utils; using Tests.Infrastructure; using Xunit; @@ -152,7 +154,7 @@ public async Task ReplicateFromSingleSource(int replicationFactor) ex = e; } - Assert.True(ex is NodeIsPassiveException, await AddDebugInfo(ex)); + Assert.True(ex is NodeIsPassiveException, await AddDebugInfo(ex, originalTaskNode)); /*Assert.Throws(() => { @@ -851,13 +853,52 @@ await session.StoreAsync(new Query.Order Assert.True(files.Length > count); } - private async Task AddDebugInfo(Exception ex) + private async Task AddDebugInfo(Exception ex, RavenServer node) { var sb = new StringBuilder() .AppendLine($"Failed. Expected NodeIsPassiveException but {(ex == null ? "none" : ex.GetType())} was thrown.") .AppendLine("Cluster debug logs:"); - await GetClusterDebugLogsAsync(sb); + + sb.AppendLine().AppendLine($"Debug logs for removed node '{node.ServerStore.NodeTag}':"); + + var prevStates = node.ServerStore.Engine.PrevStates; + sb.AppendLine($"{Environment.NewLine}States:{Environment.NewLine}-----------------------"); + foreach (var state in prevStates) + { + sb.AppendLine($"{state}{Environment.NewLine}"); + } + sb.AppendLine(); + + using (node.ServerStore.Engine.ContextPool.AllocateOperationContext(out ClusterOperationContext clusterOperationContext)) + using (clusterOperationContext.OpenReadTransaction()) + { + var historyLogs = node.ServerStore.Engine.LogHistory.GetHistoryLogs(clusterOperationContext); + sb.AppendLine($"HistoryLogs:{Environment.NewLine}-----------------------"); + + using (var context = JsonOperationContext.ShortTermSingleUse()) + { + var c = 0; + foreach (var log in historyLogs) + { + var json = context.ReadObject(log, nameof(log) + $"{c++}"); + sb.AppendLine(json.ToString()); + } + } + sb.AppendLine(); + + var inMemoryDebug = node.ServerStore.Engine.InMemoryDebug.ToJson(); + if (inMemoryDebug != null) + { + sb.AppendLine($"RachisDebug:{Environment.NewLine}-----------------------"); + using (var context = JsonOperationContext.ShortTermSingleUse()) + { + var json = context.ReadObject(inMemoryDebug, nameof(inMemoryDebug)); + sb.AppendLine(json.ToString()); + } + } + } + return sb.ToString(); }