Skip to content

Commit

Permalink
RavenDB-22611 : add debug info to flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
aviv committed Jul 29, 2024
1 parent c24d357 commit 235caec
Showing 1 changed file with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Raven.Client.Documents.Operations;
using Raven.Client.Documents.Operations.Attachments;
using Raven.Client.Documents.Operations.Backups;
using Raven.Client.Documents.Operations.Backups.Sharding;
using Raven.Client.Documents.Operations.CompareExchange;
using Raven.Client.Documents.Operations.OngoingTasks;
using Raven.Client.Documents.Operations.TimeSeries;
Expand Down Expand Up @@ -4023,7 +4024,24 @@ public async Task can_backup_and_restore_with_deleted_timeseries_ranges(Options
Assert.Null(ts);
}

await Backup.RunBackupForDatabaseModeAsync(Server, config, store, options.DatabaseMode, isFullBackup: false, backupTaskId);
// add debug info in order to investigate RavenDB-22611
// can revert this change when RavenDB-22611 is fixed

WaitHandle[] waitHandles;
if (options.DatabaseMode == RavenDatabaseMode.Sharded)
{
waitHandles = await Sharding.Backup.WaitForBackupsToComplete(new[] { store });
await Sharding.Backup.RunBackupAsync(store.Database, backupTaskId, isFullBackup : false);
}
else
{
waitHandles = await Backup.WaitForBackupToComplete(store);
await Backup.RunBackupAsync(Server, backupTaskId, store, isFullBackup : false);
}

Assert.True(WaitHandle.WaitAll(waitHandles, TimeSpan.FromMinutes(1)), AddDebugInfo(store, backupTaskId, options.DatabaseMode));

//await Backup.RunBackupForDatabaseModeAsync(Server, config, store, options.DatabaseMode, isFullBackup: false, backupTaskId);
}

using (var store = GetDocumentStore(options))
Expand Down Expand Up @@ -4366,5 +4384,32 @@ private static string AddDebugInfo(PeriodicBackupStatus fullBackupStatus, Period
.AppendLine(JsonConvert.SerializeObject(incrementalBackupStatus));
return sb.ToString();
}

private static string AddDebugInfo(IDocumentStore store, long backupTaskId, RavenDatabaseMode databaseMode)
{
var sb = new StringBuilder();
sb.AppendLine("backup failed to complete in 60 seconds");

if (databaseMode == RavenDatabaseMode.Sharded)
{
var shardedBackupStatus = store.Maintenance.Send(new GetShardedPeriodicBackupStatusOperation(backupTaskId));
sb.AppendLine("sharded backup statuses: ");
foreach (var kvp in shardedBackupStatus.Statuses)
{
sb.AppendLine()
.AppendLine($"shard {kvp.Key}:")
.AppendLine(JsonConvert.SerializeObject(kvp.Value));
}
}
else
{
var backupStatus = store.Maintenance.Send(new GetPeriodicBackupStatusOperation(backupTaskId)).Status;
sb.AppendLine("backup status: ")
.AppendLine(JsonConvert.SerializeObject(backupStatus));
}

return sb.ToString();

}
}
}

0 comments on commit 235caec

Please sign in to comment.