Skip to content

Commit

Permalink
RavenDB-21095 : add some debug info to flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
aviv86 committed Sep 7, 2023
1 parent 3dc847a commit b580804
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2725,7 +2725,8 @@ public async Task Can_restore_backup_when_document_with_attachment_changed_colle

var config = Backup.CreateBackupConfiguration(backupPath, backupType: BackupType.Snapshot);
var backupTaskId = await Backup.UpdateConfigAndRunBackupAsync(Server, config, store);
var fullBackupOpId = (await store.Maintenance.SendAsync(new GetPeriodicBackupStatusOperation(backupTaskId))).Status.LastOperationId;
var fullBackupStatus = (await store.Maintenance.SendAsync(new GetPeriodicBackupStatusOperation(backupTaskId))).Status;
var fullBackupOpId = fullBackupStatus.LastOperationId;
Assert.NotNull(fullBackupOpId);

using (var session = store.OpenAsyncSession())
Expand All @@ -2748,7 +2749,7 @@ public async Task Can_restore_backup_when_document_with_attachment_changed_colle

var status = await Backup.RunBackupAndReturnStatusAsync(Server, backupTaskId, store, isFullBackup: false);
Assert.NotNull(status.LastOperationId);
Assert.NotEqual(fullBackupOpId, status.LastOperationId);
Assert.True(fullBackupOpId != status.LastOperationId, AddDebugInfo(fullBackupStatus, status));

// to have a different count of docs in databases
using (var session = store.OpenAsyncSession())
Expand Down Expand Up @@ -3713,7 +3714,6 @@ private static IDisposable ReadOnly(string path)
});
}


public IDocumentStore RestoreAndGetStore(IDocumentStore store, string backupPath, out IDisposable releaseDatabase, TimeSpan? timeout = null)
{
var restoredDatabaseName = GetDatabaseName();
Expand All @@ -3731,5 +3731,17 @@ public IDocumentStore RestoreAndGetStore(IDocumentStore store, string backupPath
DeleteDatabaseOnDispose = true
});
}

private static string AddDebugInfo(PeriodicBackupStatus fullBackupStatus, PeriodicBackupStatus incrementalBackupStatus)
{
var sb = new StringBuilder()
.AppendLine($"full and incremental backup statuses have the same 'LastOperationId' = {fullBackupStatus.LastOperationId}")
.AppendLine("full backup status:")
.AppendLine(JsonConvert.SerializeObject(fullBackupStatus))
.AppendLine()
.AppendLine("incremental backup status:")
.AppendLine(JsonConvert.SerializeObject(incrementalBackupStatus));
return sb.ToString();
}
}
}

0 comments on commit b580804

Please sign in to comment.