forked from ravendb/ravendb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MultihopReplication.cs
62 lines (48 loc) · 1.42 KB
/
MultihopReplication.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using Raven.Abstractions.Replication;
using Raven.Client;
using Raven.Client.Document;
using Raven.Tests.Common;
using Xunit;
namespace Raven.Tests.Bundles.Replication
{
public class MultihopReplication : ReplicationBase
{
IDocumentStore store1;
IDocumentStore store2;
IDocumentStore store3;
string tracerId;
[Fact]
public void Can_run_replication_through_multiple_instances()
{
store1 = CreateStore();
store2 = CreateStore();
store3 = CreateStore();
tracerId = WriteTracer(store1);
WaitForDocument<object>(store1, tracerId);
RunReplication(store1, store2);
WaitForDocument<object>(store2, tracerId);
RunReplication(store2, store3, TransitiveReplicationOptions.Replicate);
WaitForDocument<object>(store3, tracerId);
}
[Fact]
public void When_source_is_reset_can_replicate_back()
{
Can_run_replication_through_multiple_instances();
var store1DatabaseName = ((DocumentStore)store1).DefaultDatabase;
store1 = ResetDatabase(0, databaseName: store1DatabaseName);
RunReplication(store3, store1, TransitiveReplicationOptions.Replicate);
WaitForDocument<object>(store1, tracerId);
}
private string WriteTracer(IDocumentStore store1)
{
var targetStore = store1;
using(var session = targetStore.OpenSession())
{
var tracer = new {};
session.Store(tracer);
session.SaveChanges();
return session.Advanced.GetDocumentId(tracer);
}
}
}
}