コード例 #1
0
		public SynchronizationStorageTests()
		{
            source = (IAsyncFilesCommandsImpl)NewAsyncClient(0);
            destination = (IAsyncFilesCommandsImpl) NewAsyncClient(1);

			sourceRfs = GetFileSystem(0);
			destinationRfs = GetFileSystem(1);
		}
コード例 #2
0
        public SynchronizationStorageTests()
        {
            source      = (IAsyncFilesCommandsImpl)NewAsyncClient(0);
            destination = (IAsyncFilesCommandsImpl)NewAsyncClient(1);

            sourceRfs      = GetRavenFileSystem(0);
            destinationRfs = GetRavenFileSystem(1);
        }
コード例 #3
0
        public async Task failover_with_three_servers(string storage)
        {
            IAsyncFilesCommandsImpl sourceClient1 = null;

            try
            {
                using (var store1 = NewStore(0, fiddler: true, fileSystemName: "fs1"))
                    using (var store2 = NewStore(1, fiddler: true, fileSystemName: "fs2"))
                        using (var store3 = NewStore(2, fiddler: true, fileSystemName: "fs3"))
                        {
                            sourceClient1 = (IAsyncFilesCommandsImpl)store1.AsyncFilesCommands;
                            var destinationClient1 = store2.AsyncFilesCommands;
                            var destinationClient2 = store3.AsyncFilesCommands;

                            var destination1 = destinationClient1.ToSynchronizationDestination();
                            var destination2 = destinationClient2.ToSynchronizationDestination();
                            await sourceClient1.Synchronization.SetDestinationsAsync(destination1, destination2);

                            sourceClient1.ReplicationInformer.RefreshReplicationInformation(sourceClient1);
                            await sourceClient1.Synchronization.StartAsync();

                            await sourceClient1.UploadAsync(FileName, StringToStream(FileText));

                            var test1 = StreamToString(await sourceClient1.DownloadAsync(FileName));
                            Assert.Equal(FileText, test1);

                            await WaitForSynchronization(store2);

                            var server = GetServer(0);
                            server.Dispose();
                            using (var session = store1.OpenAsyncSession())
                            {
                                var test2 = StreamToString(await session.DownloadAsync(FileName));
                                Assert.Equal(FileText, test2);
                            }

                            await WaitForSynchronization(store3);

                            server = GetServer(1);
                            server.Dispose();

                            using (var session = store1.OpenAsyncSession())
                            {
                                var test2 = StreamToString(await session.DownloadAsync(FileName));
                                Assert.Equal(FileText, test2);
                            }
                        }
            }
            finally
            {
                if (sourceClient1 != null)
                {
                    sourceClient1.ReplicationInformer.ClearReplicationInformationLocalCache(sourceClient1);
                }
            }
        }
コード例 #4
0
        public SynchronizationStorageTests()
        {
            configuration = new InMemoryRavenConfiguration();
            configuration.Initialize();

            source      = (IAsyncFilesCommandsImpl)NewAsyncClient(0);
            destination = (IAsyncFilesCommandsImpl)NewAsyncClient(1);

            sourceRfs      = GetFileSystem(0);
            destinationRfs = GetFileSystem(1);
        }
コード例 #5
0
        public async Task failover_throws(string storage)
        {
            IAsyncFilesCommandsImpl sourceClient = null;

            try
            {
                using (var store0 = NewStore(0, fiddler: true, fileSystemName: "fs1"))
                    using (var store1 = NewStore(1, fiddler: true, fileSystemName: "fs2"))
                    {
                        sourceClient = (IAsyncFilesCommandsImpl)store0.AsyncFilesCommands;
                        var destinationClient = store1.AsyncFilesCommands;

                        var destination = destinationClient.ToSynchronizationDestination();
                        await sourceClient.Synchronization.SetDestinationsAsync(destination);

                        sourceClient.ReplicationInformer.RefreshReplicationInformation(sourceClient);
                        await sourceClient.Synchronization.StartAsync();

                        await sourceClient.UploadAsync(FileName, StringToStream(FileText));

                        var test1 = StreamToString(await sourceClient.DownloadAsync(FileName));
                        Assert.Equal(FileText, test1);

                        await WaitForSynchronization(store1);

                        var server = GetServer(0);
                        server.Dispose();

                        var  expected = typeof(HttpRequestException);
                        Type actual   = null;
                        try
                        {
                            await sourceClient.DownloadAsync(FileName);
                        }
                        catch (Exception e)
                        {
                            actual = e.GetType();
                        }
                        Assert.Equal(expected, actual);
                    }
            }
            finally
            {
                if (sourceClient != null)
                {
                    sourceClient.ReplicationInformer.ClearReplicationInformationLocalCache(sourceClient);
                }
            }
        }
コード例 #6
0
        public async Task load_balancing_with_two_master_master_servers(string storage)
        {
            IAsyncFilesCommandsImpl sourceClient = null;

            try
            {
                using (var store1 = NewStore(0, fiddler: true, fileSystemName: "fs1"))
                    using (var store2 = NewStore(1, fiddler: true, fileSystemName: "fs2"))
                    {
                        sourceClient = (IAsyncFilesCommandsImpl)store1.AsyncFilesCommands;
                        var destinationClient = store2.AsyncFilesCommands;

                        var destination = destinationClient.ToSynchronizationDestination();
                        await sourceClient.Synchronization.SetDestinationsAsync(destination);

                        sourceClient.ReplicationInformer.RefreshReplicationInformation(sourceClient);
                        await sourceClient.Synchronization.StartAsync();

                        await sourceClient.UploadAsync(FileName, StringToStream(FileText));
                        await WaitForSynchronization(store2);

                        var test = StreamToString(await sourceClient.DownloadAsync(FileName));
                        Assert.Equal(FileText, test);

                        for (var i = 0; i < 6; i++)
                        {
                            /*sourceClient.ReplicationInformer.FailoverStatusChanged += (sender, args) =>
                             * {
                             *      var url = i%2 == 0 ? destinationClient.UrlFor() : sourceClient.UrlFor();
                             *      Assert.Equal(url, args.Url);
                             * };*/
                            using (var session = store1.OpenAsyncSession())
                            {
                                var test2 = StreamToString(await session.DownloadAsync(FileName));
                                Assert.Equal(FileText, test2);
                            }
                        }
                    }
            }
            finally
            {
                if (sourceClient != null)
                {
                    sourceClient.ReplicationInformer.ClearReplicationInformationLocalCache(sourceClient);
                }
            }
        }