Beispiel #1
0
        public async Task source_should_update_last_synchronized_etag_if_all_docs_are_filtered_out_to_be_able_to_process_next_docs()
        {
            var sourceClient      = NewAsyncClient(0);
            var destinationClient = NewAsyncClient(1);

            for (int i = 0; i < SynchronizationTask.NumberOfFilesToCheckForSynchronization + 1; i++)
            {
                await sourceClient.UploadAsync("file", new RandomStream(128), new RavenJObject());
            }

            SyncTestUtils.TurnOnSynchronization(sourceClient, destinationClient);

            await sourceClient.Synchronization.StartAsync();

            var lastSynchronization = await destinationClient.Synchronization.GetLastSynchronizationFromAsync(await sourceClient.GetServerIdAsync());

            Assert.NotEqual(Etag.Empty, lastSynchronization.LastSourceFileEtag);

            await sourceClient.Synchronization.StartAsync();

            lastSynchronization = await destinationClient.Synchronization.GetLastSynchronizationFromAsync(await sourceClient.GetServerIdAsync());

            var sourceMetadataWithEtag = await sourceClient.GetMetadataForAsync("file");

            Assert.Equal(sourceMetadataWithEtag.Value <string>(Constants.MetadataEtagField), lastSynchronization.LastSourceFileEtag.ToString());
        }
Beispiel #2
0
        public async Task Should_transfer_entire_file_even_if_rename_operation_was_performed()
        {
            var source      = NewAsyncClient(0);
            var destination = NewAsyncClient(1);

            var fileContent = new MemoryStream(new byte[] { 1, 2, 3 });
            await source.UploadAsync("test.bin", fileContent);

            await source.RenameAsync("test.bin", "renamed.bin");

            SyncTestUtils.TurnOnSynchronization(source, destination);

            var destinationSyncResults = await source.Synchronization.StartAsync();

            Assert.Equal(1, destinationSyncResults.Length);

            var reports = destinationSyncResults[0].Reports.ToArray();

            Assert.Null(reports[0].Exception);
            Assert.Equal(SynchronizationType.ContentUpdate, reports[0].Type);
            Assert.Equal(FileHeader.Canonize("renamed.bin"), reports[0].FileName);

            fileContent.Position = 0;

            var metadata = await destination.GetMetadataForAsync("renamed.bin");

            Assert.Equal(fileContent.GetMD5Hash(), metadata.Value <string>("Content-MD5"));
        }
Beispiel #3
0
        public async Task Synchronization_to_empty_fs_must_not_get_stuck_after_filtering_out_all_deletions()
        {
            var source      = NewAsyncClient(0);
            var destination = NewAsyncClient(1);

            for (int i = 0; i < SynchronizationTask.NumberOfFilesToCheckForSynchronization; i++)
            {
                await source.UploadAsync("test.bin-" + i, new RandomStream(1));
            }

            for (int i = 0; i < SynchronizationTask.NumberOfFilesToCheckForSynchronization; i++)
            {
                await source.DeleteAsync("test.bin-" + i);
            }

            for (int i = 0; i < 10; i++)
            {
                await source.UploadAsync("test.bin-" + (SynchronizationTask.NumberOfFilesToCheckForSynchronization + i), new RandomStream(1));
            }

            SyncTestUtils.TurnOnSynchronization(source, destination);

            var report = await source.Synchronization.StartAsync();

            Assert.NotEmpty(report[0].Reports);
            Assert.True(report[0].Reports.All(x => x.Exception == null));

            var lastSynchronization = await destination.Synchronization.GetLastSynchronizationFromAsync(await source.GetServerIdAsync());

            Assert.NotEqual(Etag.Empty, lastSynchronization.LastSourceFileEtag);
        }