private async Task ValidateSource(IAsyncFilesCommands source) { var stats = await source.GetStatisticsAsync(); Assert.Equal(10, stats.FileCount); Assert.Equal(0, stats.ActiveSyncs.Count); Assert.Equal(0, stats.PendingSyncs.Count); var headers = await source.BrowseAsync(); Assert.Equal(10, headers.Length); for (int i = 0; i < 10; i++) { var metadata = new Reference <RavenJObject>(); var stream = await source.DownloadAsync(SynchronizedFileName(i), metadata); Assert.Equal(stream.GetMD5Hash(), CreateUniformFileStream(i, (char)i).GetMD5Hash()); } var search = await source.SearchAsync(""); Assert.Equal(10, search.Files.Count); Assert.Equal(10, search.FileCount); }
private async Task CreateSampleData(IAsyncFilesCommands commands, int startIndex = 1, int count = 2) { for (var i = startIndex; i < startIndex + count; i++) { await commands.UploadAsync(string.Format("file{0}.bin", i), StringToStream("Secret records / " + i)); } }
private async Task ValidateDestination(IAsyncFilesCommands destination) { var stats = await destination.GetStatisticsAsync(); Assert.Equal(20, stats.FileCount); var headers = await destination.BrowseAsync(); Assert.Equal(20, headers.Length); for (int i = 0; i < 10; i++) { var metadata = new Reference <RavenJObject>(); var stream = await destination.DownloadAsync(SynchronizedFileName(i), metadata); Assert.Equal(stream.GetMD5Hash(), CreateUniformFileStream(i, (char)i).GetMD5Hash()); stream = await destination.DownloadAsync(FileName(i), metadata); Assert.Equal(stream.GetMD5Hash(), CreateUniformFileStream(i, (char)i).GetMD5Hash()); var searchResult = await destination.SearchAsync("ETag:" + metadata.Value[Constants.MetadataEtagField]); Assert.Equal(1, searchResult.Files.Count); Assert.Equal(1, searchResult.FileCount); var config = await destination.Configuration.GetKeyAsync <RavenJObject>(ConfigurationName(i)); Assert.Equal(string.Format("value-{0}", i), config["key"].ToString()); } }
public static SynchronizationDestination ToSynchronizationDestination(this IAsyncFilesCommands self) { var selfImpl = (IAsyncFilesCommandsImpl)self; var result = new SynchronizationDestination { FileSystem = self.FileSystemName, ServerUrl = selfImpl.ServerUrl, }; if (self.PrimaryCredentials != null) { var networkCredential = self.PrimaryCredentials.Credentials as NetworkCredential; if (networkCredential != null) { result.Username = networkCredential.UserName; result.Password = networkCredential.Password; result.Domain = networkCredential.Domain; } else { throw new InvalidOperationException("Expected NetworkCredential object while get: " + self.PrimaryCredentials.Credentials); } result.ApiKey = self.PrimaryCredentials.ApiKey; } return(result); }
protected void WaitForBackup(IAsyncFilesCommands filesCommands, bool checkError) { var done = SpinWait.SpinUntil(() => { var backupStatus = AsyncHelpers.RunSync(() => filesCommands.Configuration.GetKeyAsync <BackupStatus>(BackupStatus.RavenBackupStatusDocumentKey)); if (backupStatus == null) { return(true); } if (backupStatus.IsRunning == false) { if (checkError) { var firstOrDefault = backupStatus.Messages.FirstOrDefault(x => x.Severity == BackupStatus.BackupMessageSeverity.Error); if (firstOrDefault != null) { Assert.True(false, string.Format("{0}\n\nDetails: {1}", firstOrDefault.Message, firstOrDefault.Details)); } } return(true); } return(false); }, Debugger.IsAttached ? TimeSpan.FromMinutes(120) : TimeSpan.FromMinutes(15)); Assert.True(done); }
public static void TurnOffSynchronization(IAsyncFilesCommands source) { var destinations = source.Synchronization.GetDestinationsAsync().Result; foreach ( var destination in destinations ) destination.Enabled = false; source.Synchronization.SetDestinationsAsync(destinations).Wait(); }
public SynchronizationNotificationTests() { sourceStore = NewStore(0); sourceClient = sourceStore.AsyncFilesCommands; destinationStore = NewStore(1); destinationClient = destinationStore.AsyncFilesCommands; }
public AbstractFilesQuery(InMemoryFilesSessionOperations theSession, IAsyncFilesCommands commands) { this.conventions = theSession == null ? new FilesConvention() : theSession.Conventions; this.linqPathProvider = new LinqPathProvider(conventions); this.Session = theSession; this.Commands = commands; }
private static void ZeroTimeoutTest(IAsyncFilesCommands destinationClient, Action action) { destinationClient.Configuration.SetKeyAsync(RavenFileNameHelper.SyncLockNameForFile("test.bin"), SynchronizationConfig(DateTime.MinValue)).Wait(); destinationClient.Configuration.SetKeyAsync(SynchronizationConstants.RavenSynchronizationLockTimeout, TimeSpan.FromSeconds(0)).Wait(); Assert.DoesNotThrow(() => action()); }
private string[] FetchMd5Sums(IAsyncFilesCommands filesCommands, int filesCount = 2) { return(Enumerable.Range(1, filesCount).Select(i => { var meta = filesCommands.GetMetadataForAsync(string.Format("file{0}.bin", i)).Result; return meta.Value <string>("Content-MD5"); }).ToArray()); }
/// <summary> /// Initializes a new instance of the <see cref="AsyncFilesSession"/> class. /// </summary> public AsyncFilesSession(FilesStore filesStore, IAsyncFilesCommands asyncFilesCommands, FilesSessionListeners listeners, Guid id) : base(filesStore, listeners, id) { Commands = asyncFilesCommands; filesStore.Changes().ForConflicts().Subscribe(this); }
private static async Task ValidateSourceEtags(IAsyncFilesCommands source) { foreach (var syncResultName in (await source.Configuration.SearchAsync("Syncing/")).ConfigNames) { var syncDetails = await source.Configuration.GetKeyAsync <SynchronizationDetails>(syncResultName); Assert.Equal(1, syncDetails.FileETag.Restarts); // make sure that etags are valid after conversion from guids } }
private string[] ComputeMd5Sums(IAsyncFilesCommands filesCommands, int filesCount = 2) { return(Enumerable.Range(1, filesCount).Select(i => { using (var stream = filesCommands.DownloadAsync(string.Format("file{0}.bin", i)).Result) { return stream.GetMD5Hash(); } }).ToArray()); }
/// <summary> /// Initializes a new instance of the <see cref="AsyncFilesSession"/> class. /// </summary> public AsyncFilesSession(FilesStore filesStore, IAsyncFilesCommands asyncFilesCommands, FilesSessionListeners listeners, Guid id) : base(filesStore, listeners, id) { Commands = asyncFilesCommands; conflictCacheRemoval = filesStore.Changes(this.FileSystemName) .ForConflicts() .Subscribe <ConflictNotification>(this.OnFileConflict); }
/// <summary> /// Initializes a new instance of the <see cref="AsyncFilesSession"/> class. /// </summary> public AsyncFilesSession(FilesStore filesStore, IAsyncFilesCommands asyncFilesCommands, FilesSessionListeners listeners, Guid id) : base(filesStore, listeners, id) { Commands = asyncFilesCommands; conflictCacheRemoval = filesStore.Changes(this.FileSystemName) .ForConflicts() .Subscribe(new FileConflictObserver(this)); }
/// <summary> /// Initializes a new instance of the <see cref="AsyncFilesSession"/> class. /// </summary> public AsyncFilesSession(FilesStore filesStore, IAsyncFilesCommands asyncFilesCommands, FilesSessionListeners listeners, Guid id) : base(filesStore, listeners, id) { Commands = asyncFilesCommands; conflictCacheRemoval = filesStore.Changes(this.FileSystemName) .ForConflicts() .Subscribe<ConflictNotification>(this.OnFileConflict); }
public static void TurnOffSynchronization(IAsyncFilesCommands source) { var destinations = source.Synchronization.GetDestinationsAsync().Result; foreach (var destination in destinations) { destination.Enabled = false; } source.Synchronization.SetDestinationsAsync(destinations).Wait(); }
public static SynchronizationReport ResolveConflictAndSynchronize(IAsyncFilesCommands sourceClient, IAsyncFilesCommands destinationClient, string fileName) { var shouldBeConflict = sourceClient.Synchronization.StartAsync(fileName, destinationClient).Result; Assert.NotNull(shouldBeConflict.Exception); destinationClient.Synchronization.ResolveConflictAsync(fileName, ConflictResolutionStrategy.RemoteVersion).Wait(); return(sourceClient.Synchronization.StartAsync(fileName, destinationClient).Result); }
public static SynchronizationReport ResolveConflictAndSynchronize(IAsyncFilesCommands sourceClient, IAsyncFilesCommands destinationClient, string fileName) { var shouldBeConflict = sourceClient.Synchronization.StartAsync(fileName, destinationClient).Result; Assert.NotNull(shouldBeConflict.Exception); destinationClient.Synchronization.ResolveConflictAsync(fileName, ConflictResolutionStrategy.RemoteVersion).Wait(); return sourceClient.Synchronization.StartAsync(fileName, destinationClient).Result; }
private void UploadFilesSynchronously(out IAsyncFilesCommands sourceClient, out IAsyncFilesCommands destinationClient, string fileName = "test.bin") { sourceClient = NewAsyncClient(1); destinationClient = NewAsyncClient(0); var sourceContent = new RandomlyModifiedStream(new RandomStream(10, 1), 0.01); var destinationContent = new RandomlyModifiedStream(new RandomStream(10, 1), 0.01); destinationClient.UploadAsync(fileName, destinationContent).Wait(); sourceClient.UploadAsync(fileName, sourceContent).Wait(); }
public static async Task EnsureFileSystemExistsAsync(this IAsyncFilesCommands commands) { var existingSystems = await commands.Admin.GetNamesAsync().ConfigureAwait(false); if (existingSystems.Any(x => x.Equals(commands.FileSystemName, StringComparison.OrdinalIgnoreCase))) { return; } var fileSystemDocument = MultiDatabase.CreateFileSystemDocument(commands.FileSystemName); await commands.Admin.CreateFileSystemAsync(fileSystemDocument).ConfigureAwait(false); }
protected void WaitForFile(IAsyncFilesCommands filesCommands, string fileName) { var done = SpinWait.SpinUntil(() => { var file = filesCommands.GetMetadataForAsync(fileName).Result; return(file != null); }, TimeSpan.FromSeconds(15)); if (!done) { throw new Exception("WaitForDocument failed"); } }
public WhatAreCommands() { IFilesStore store = null; #region commands_access IAsyncFilesCommands commands = store.AsyncFilesCommands; #endregion #region commands_different_fs IAsyncFilesCommands southwindCommands = store .AsyncFilesCommands .ForFileSystem("SouthwindFS") .With(new NetworkCredential("user", "pass")); #endregion }
private static IAsyncFilesCommands SetupCommandsAsync(IAsyncFilesCommands filesCommands, OpenFilesSessionOptions options) { if (string.IsNullOrWhiteSpace(options.FileSystem)) { throw new ArgumentException("Filesystem cannot be null, empty or whitespace.", "FileSystem"); } filesCommands = filesCommands.ForFileSystem(options.FileSystem); if (options.ApiKey != null || options.Credentials != null) { filesCommands = filesCommands.With(new OperationCredentials(options.ApiKey, options.Credentials)); } return(filesCommands); }
private static async Task RunMetadataSynchronization(IAsyncFilesCommands sourceClient, IAsyncFilesCommands destinationClient, Action action = null) { await destinationClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("metadata-test")), new RavenJObject { { "Sample-Header", "destination" } }); if (action != null) { action(); } await sourceClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("metadata-test")), new RavenJObject { { "Sample-Header", "source" } }); var report = await sourceClient.Synchronization.StartAsync("test", destinationClient); Assert.Null(report.Exception); Assert.Equal(SynchronizationType.MetadataUpdate, report.Type); }
private static async Task ValidateDestinationEtags(IAsyncFilesCommands destination, Guid sourceServeId) { var lastSynchronizedEtag = (await destination.Synchronization.GetLastSynchronizationFromAsync(sourceServeId)).LastSourceFileEtag; Assert.Equal(1, lastSynchronizedEtag.Restarts); // make sure that etags are valid after conversion from guids var sourceInfo = await destination.Configuration.GetKeyAsync <SourceSynchronizationInformation>(SynchronizationConstants.RavenSynchronizationSourcesBasePath + "/" + sourceServeId); Assert.Equal(1, sourceInfo.LastSourceFileEtag.Restarts); // make sure that etags are valid after conversion from guids foreach (var syncResultName in (await destination.Configuration.SearchAsync("SyncResult/")).ConfigNames) { var syncResult = await destination.Configuration.GetKeyAsync <SynchronizationReport>(syncResultName); Assert.Equal(1, syncResult.FileETag.Restarts); // make sure that etags are valid after conversion from guids } }
public static async Task EnsureFileSystemExistsAsync(this IAsyncFilesCommands commands) { var existingSystems = await commands.Admin.GetNamesAsync().ConfigureAwait(false); if (existingSystems.Any(x => x.Equals(commands.FileSystemName, StringComparison.OrdinalIgnoreCase))) { return; } await commands.Admin.CreateFileSystemAsync(new FileSystemDocument { Id = "Raven/FileSystem/" + commands.FileSystemName, Settings = { { Constants.FileSystem.DataDirectory, Path.Combine("FileSystems", commands.FileSystemName) } } }).ConfigureAwait(false); }
public static async Task EnsureFileSystemExistsAsync(this IAsyncFilesCommands commands) { var existingSystems = await commands.Admin.GetNamesAsync(); if (existingSystems.Any(x => x.Equals(commands.FileSystem, StringComparison.InvariantCultureIgnoreCase))) { return; } await commands.Admin.CreateFileSystemAsync(new FileSystemDocument { Id = "Raven/FileSystem/" + commands.FileSystem, Settings = { { "Raven/FileSystem/DataDir", Path.Combine("FileSystems", commands.FileSystem) } } }); }
private static async Task RunDeleteSynchronization(IAsyncFilesCommands sourceClient, IAsyncFilesCommands destinationClient, Action action = null) { await destinationClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("delete-test"))); if (action != null) { action(); } await sourceClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("delete-test"))); await sourceClient.DeleteAsync("test"); var report = await sourceClient.Synchronization.StartAsync("test", destinationClient); Assert.Null(report.Exception); Assert.Equal(SynchronizationType.Delete, report.Type); }
private static async Task <string> RunContentSynchronization(IAsyncFilesCommands sourceClient, IAsyncFilesCommands destinationClient, Action action = null) { await destinationClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("destination"))); if (action != null) { action(); } await sourceClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("source"))); var report = await sourceClient.Synchronization.StartAsync("test", destinationClient); Assert.Null(report.Exception); Assert.Equal(SynchronizationType.ContentUpdate, report.Type); var stream = await destinationClient.DownloadAsync("test"); return(StreamToString(stream)); }
private static async Task <string> ExecuteRawSynchronizationRequest(IAsyncFilesCommands sourceClient, IAsyncFilesCommands destinationClient, Action action = null) { await destinationClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("destination"))); if (action != null) { action(); } await sourceClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("source"))); var sourceStream = new MemoryStream(); (await sourceClient.DownloadAsync("test")).CopyTo(sourceStream); var metadata = await sourceClient.GetMetadataForAsync("test"); var request = new SynchronizationMultipartRequest(destinationClient.Synchronization, new ServerInfo() { FileSystemUrl = sourceClient.UrlFor(), Id = sourceClient.GetServerIdAsync().Result }, "test", metadata, sourceStream, new[] { new RdcNeed() { BlockLength = 6, BlockType = RdcNeedType.Source, FileOffset = 0 } }); var synchronizationReport = await request.PushChangesAsync(CancellationToken.None); Assert.Null(synchronizationReport.Exception); var stream = await destinationClient.DownloadAsync("test"); return(StreamToString(stream)); }
private static void WaitForFileDelete(IAsyncFilesCommands client, string fileName) { var result = SpinWait.SpinUntil(() => { try { var file = AsyncHelpers.RunSync(() => client.DownloadAsync(fileName)); return(file == null); } catch (FileNotFoundException) { return(true); } }, TimeSpan.FromSeconds(30)); if (result) { return; } throw new TimeoutException("Could retrieve file " + fileName + " while it was supposed to be deleted"); }
private new static void WaitForFile(IAsyncFilesCommands client, string fileName) { var result = SpinWait.SpinUntil(() => { try { var file = AsyncHelpers.RunSync(() => client.DownloadAsync(fileName)); return(file != null); } catch (FileNotFoundException) { return(false); } }, TimeSpan.FromSeconds(30)); if (result) { return; } throw new TimeoutException("Could not download file " + fileName); }
private static async Task<string> ExecuteRawSynchronizationRequest(IAsyncFilesCommands sourceClient, IAsyncFilesCommands destinationClient, Action action = null) { await destinationClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("destination"))); if (action != null) action(); await sourceClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("source"))); var sourceStream = new MemoryStream(); (await sourceClient.DownloadAsync("test")).CopyTo(sourceStream); var metadata = await sourceClient.GetMetadataForAsync("test"); var request = new SynchronizationMultipartRequest(destinationClient.Synchronization, new ServerInfo() { FileSystemUrl = sourceClient.UrlFor(), Id = sourceClient.GetServerIdAsync().Result }, "test", metadata, sourceStream, new[] { new RdcNeed() { BlockLength = 6, BlockType = RdcNeedType.Source, FileOffset = 0 } }); var synchronizationReport = await request.PushChangesAsync(CancellationToken.None); Assert.Null(synchronizationReport.Exception); var stream = await destinationClient.DownloadAsync("test"); return StreamToString(stream); }
private static IAsyncFilesCommands SetupCommandsAsync(IAsyncFilesCommands filesCommands, OpenFilesSessionOptions options) { if (string.IsNullOrWhiteSpace(options.FileSystem)) throw new ArgumentException("Filesystem cannot be null, empty or whitespace.", "FileSystem"); filesCommands = filesCommands.ForFileSystem(options.FileSystem); if (options.ApiKey != null || options.Credentials != null) filesCommands = filesCommands.With(new OperationCredentials(options.ApiKey, options.Credentials)); return filesCommands; }
private string[] FetchMd5Sums(IAsyncFilesCommands filesCommands, int filesCount = 2) { return Enumerable.Range(1, filesCount).Select(i => { var meta = filesCommands.GetMetadataForAsync(string.Format("file{0}.bin", i)).Result; return meta.Value<string>("Content-MD5"); }).ToArray(); }
private static async Task ValidateDestinationEtags(IAsyncFilesCommands destination, Guid sourceServeId) { var lastSynchronizedEtag = (await destination.Synchronization.GetLastSynchronizationFromAsync(sourceServeId)).LastSourceFileEtag; Assert.Equal(1, lastSynchronizedEtag.Restarts); // make sure that etags are valid after conversion from guids var sourceInfo = await destination.Configuration.GetKeyAsync<SourceSynchronizationInformation>(SynchronizationConstants.RavenSynchronizationSourcesBasePath + "/" + sourceServeId); Assert.Equal(1, sourceInfo.LastSourceFileEtag.Restarts); // make sure that etags are valid after conversion from guids foreach (var syncResultName in (await destination.Configuration.SearchAsync("SyncResult/")).ConfigNames) { var syncResult = await destination.Configuration.GetKeyAsync<SynchronizationReport>(syncResultName); Assert.Equal(1, syncResult.FileETag.Restarts); // make sure that etags are valid after conversion from guids } }
public static void TurnOnSynchronization(IAsyncFilesCommands source, params IAsyncFilesCommands[] destinations) { source.Synchronization.SetDestinationsAsync(destinations.Select(x => x.ToSynchronizationDestination()).ToArray()).Wait(); }
private static async Task<string> RunContentSynchronization(IAsyncFilesCommands sourceClient, IAsyncFilesCommands destinationClient, Action action = null) { await destinationClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("destination"))); if (action != null) action(); await sourceClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("source"))); var report = await sourceClient.Synchronization.StartAsync("test", destinationClient); Assert.Null(report.Exception); Assert.Equal(SynchronizationType.ContentUpdate, report.Type); var stream = await destinationClient.DownloadAsync("test"); return StreamToString(stream); }
private static async Task ValidateSourceEtags(IAsyncFilesCommands source) { foreach (var syncResultName in (await source.Configuration.SearchAsync("Syncing/")).ConfigNames) { var syncDetails = await source.Configuration.GetKeyAsync<SynchronizationDetails>(syncResultName); Assert.Equal(1, syncDetails.FileETag.Restarts); // make sure that etags are valid after conversion from guids } }
private static async Task RunDeleteSynchronization(IAsyncFilesCommands sourceClient, IAsyncFilesCommands destinationClient, Action action = null) { await destinationClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("delete-test"))); if (action != null) action(); await sourceClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("delete-test"))); await sourceClient.DeleteAsync("test"); var report = await sourceClient.Synchronization.StartAsync("test", destinationClient); Assert.Null(report.Exception); Assert.Equal(SynchronizationType.Delete, report.Type); }
private static async Task RunMetadataSynchronization(IAsyncFilesCommands sourceClient, IAsyncFilesCommands destinationClient, Action action = null) { await destinationClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("metadata-test")), new RavenJObject { { "Sample-Header", "destination" } }); if (action != null) action(); await sourceClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("metadata-test")), new RavenJObject { { "Sample-Header", "source" } }); var report = await sourceClient.Synchronization.StartAsync("test", destinationClient); Assert.Null(report.Exception); Assert.Equal(SynchronizationType.MetadataUpdate, report.Type); }
private static void ZeroTimeoutTest(IAsyncFilesCommands destinationClient, Action action) { destinationClient.Configuration.SetKeyAsync(RavenFileNameHelper.SyncLockNameForFile("test.bin"), SynchronizationConfig(DateTime.MinValue)).Wait(); destinationClient.Configuration.SetKeyAsync(SynchronizationConstants.RavenSynchronizationLockTimeout, TimeSpan.FromSeconds(0) ).Wait(); Assert.DoesNotThrow(() => action()); }
private async Task ValidateSource(IAsyncFilesCommands source) { var stats = await source.GetStatisticsAsync(); Assert.Equal(10, stats.FileCount); Assert.Equal(0, stats.ActiveSyncs.Count); Assert.Equal(0, stats.PendingSyncs.Count); var headers = await source.BrowseAsync(); Assert.Equal(10, headers.Length); for (int i = 0; i < 10; i++) { var metadata = new Reference<RavenJObject>(); var stream = await source.DownloadAsync(SynchronizedFileName(i), metadata); Assert.Equal(stream.GetMD5Hash(), CreateUniformFileStream(i, (char) i).GetMD5Hash()); } var search = await source.SearchAsync(""); Assert.Equal(10, search.Files.Count); Assert.Equal(10, search.FileCount); }
private async Task ValidateDestination(IAsyncFilesCommands destination) { var stats = await destination.GetStatisticsAsync(); Assert.Equal(20, stats.FileCount); var headers = await destination.BrowseAsync(); Assert.Equal(20, headers.Length); for (int i = 0; i < 10; i++) { var metadata = new Reference<RavenJObject>(); var stream = await destination.DownloadAsync(SynchronizedFileName(i), metadata); Assert.Equal(stream.GetMD5Hash(), CreateUniformFileStream(i, (char) i).GetMD5Hash()); stream = await destination.DownloadAsync(FileName(i), metadata); Assert.Equal(stream.GetMD5Hash(), CreateUniformFileStream(i, (char) i).GetMD5Hash()); var searchResult = await destination.SearchAsync("ETag:" + metadata.Value[Constants.MetadataEtagField]); Assert.Equal(1, searchResult.Files.Count); Assert.Equal(1, searchResult.FileCount); var config = await destination.Configuration.GetKeyAsync<RavenJObject>(ConfigurationName(i)); Assert.Equal(string.Format("value-{0}", i), config["key"].ToString()); } }
private string[] ComputeMd5Sums(IAsyncFilesCommands filesCommands, int filesCount = 2) { return Enumerable.Range(1, filesCount).Select(i => { using (var stream = filesCommands.DownloadAsync(string.Format("file{0}.bin", i)).Result) { return stream.GetMD5Hash(); } }).ToArray(); }
protected void WaitForBackup(IAsyncFilesCommands filesCommands, bool checkError) { var done = SpinWait.SpinUntil(() => { var backupStatus = filesCommands.Configuration.GetKeyAsync<BackupStatus>(BackupStatus.RavenBackupStatusDocumentKey).ResultUnwrap(); if (backupStatus == null) return true; if (backupStatus.IsRunning == false) { if (checkError) { var firstOrDefault = backupStatus.Messages.FirstOrDefault(x => x.Severity == BackupStatus.BackupMessageSeverity.Error); if (firstOrDefault != null) Assert.True(false, string.Format("{0}\n\nDetails: {1}", firstOrDefault.Message, firstOrDefault.Details)); } return true; } return false; }, Debugger.IsAttached ? TimeSpan.FromMinutes(120) : TimeSpan.FromMinutes(15)); Assert.True(done); }