public void StopReplication(Replication replication)
        {
            if (replication.Status == ReplicationStatus.Stopped)
            {
                return;
            }

            var replicationDoneSignal      = new CountdownEvent(1);
            var replicationStoppedObserver = new ReplicationStoppedObserver(replicationDoneSignal);

            replication.Changed += replicationStoppedObserver.Changed;
            replication.Stop();

            var success = replicationDoneSignal.Wait(TimeSpan.FromSeconds(10));

            Assert.IsTrue(success);

            // give a little padding to give it a chance to save a checkpoint
            Sleep(2 * 1000);
        }
        public void TestCloseDatabaseWhileReplicating()
        {
            var signal = new CountdownEvent(1);
            var rso = new ReplicationStoppedObserver(signal);

            using (var remoteDb = _sg.CreateDatabase(TempDbName())) {
                CreateDocuments(database, 100);
                var pusher = database.CreatePushReplication(remoteDb.RemoteUri);
                pusher.Changed += rso.Changed;
                pusher.Start();
                Sleep(500);
                Assert.IsTrue(database.Close().Wait(15000));
                Assert.IsFalse(database.IsOpen);
                Assert.IsNull(database.Storage);
                Assert.IsTrue(signal.Wait(10000));
            }
        }
Exemplo n.º 3
0
        public void StopReplication(Replication replication)
        {
            if (replication.Status == ReplicationStatus.Stopped) {
                return;
            }

            var replicationDoneSignal = new CountdownEvent(1);
            var replicationStoppedObserver = new ReplicationStoppedObserver(replicationDoneSignal);
            replication.Changed += replicationStoppedObserver.Changed;
            replication.Stop();

            var success = replicationDoneSignal.Wait(TimeSpan.FromSeconds(10));
            Assert.IsTrue(success);

            // give a little padding to give it a chance to save a checkpoint
            Thread.Sleep(2 * 1000);
        }