-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathFaultTolerantIndexingTwoSiloRunner.cs
145 lines (111 loc) · 5.9 KB
/
FaultTolerantIndexingTwoSiloRunner.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
namespace Orleans.Indexing.Tests
{
using ITC = IndexingTestConstants;
public abstract class FaultTolerantIndexingTwoSiloRunner : IndexingTestRunnerBase
{
protected FaultTolerantIndexingTwoSiloRunner(BaseIndexingFixture fixture, ITestOutputHelper output)
: base(fixture, output)
{
}
/// <summary>
/// Tests basic functionality of HashIndexSingleBucket
/// </summary>
[Fact, TestCategory("BVT"), TestCategory("Indexing")]
public async Task Test_Lookup_3Grains_FT_TI_LZ_SB()
{
IPlayer_FT_TI_LZ_SB p1 = base.GetGrain<IPlayer_FT_TI_LZ_SB>(1);
await p1.SetLocation(ITC.Seattle);
IPlayer_FT_TI_LZ_SB p2 = base.GetGrain<IPlayer_FT_TI_LZ_SB>(2);
IPlayer_FT_TI_LZ_SB p3 = base.GetGrain<IPlayer_FT_TI_LZ_SB>(3);
await p2.SetLocation(ITC.Seattle);
await p3.SetLocation(ITC.SanFrancisco);
var locIdx = await base.GetAndWaitForIndex<string, IPlayer_FT_TI_LZ_SB>(ITC.LocationProperty);
Task<int> getLocationCount(string location) => this.GetPlayerLocationCount<IPlayer_FT_TI_LZ_SB, PlayerProperties_FT_TI_LZ_SB>(location, ITC.DelayUntilIndexesAreUpdatedLazily);
Assert.Equal(2, await getLocationCount(ITC.Seattle));
await p2.Deactivate();
await Task.Delay(ITC.DelayUntilIndexesAreUpdatedLazily);
Assert.Equal(2, await getLocationCount(ITC.Seattle));
p2 = base.GetGrain<IPlayer_FT_TI_LZ_SB>(2);
Assert.Equal(ITC.Seattle, await p2.GetLocation());
Assert.Equal(2, await getLocationCount(ITC.Seattle));
}
/// <summary>
/// Tests basic functionality of HashIndexPartitionedPerKey
/// </summary>
[Fact, TestCategory("BVT"), TestCategory("Indexing")]
public async Task Test_Lookup_3Grains_FT_TI_LZ_PK()
{
IPlayer_FT_TI_LZ_PK p1 = base.GetGrain<IPlayer_FT_TI_LZ_PK>(1);
await p1.SetLocation(ITC.Seattle);
IPlayer_FT_TI_LZ_PK p2 = base.GetGrain<IPlayer_FT_TI_LZ_PK>(2);
IPlayer_FT_TI_LZ_PK p3 = base.GetGrain<IPlayer_FT_TI_LZ_PK>(3);
await p2.SetLocation(ITC.Seattle);
await p3.SetLocation(ITC.SanFrancisco);
var locIdx = await base.GetAndWaitForIndex<string, IPlayer_FT_TI_LZ_PK>(ITC.LocationProperty);
Task<int> getLocationCount(string location) => this.GetPlayerLocationCount<IPlayer_FT_TI_LZ_PK, PlayerProperties_FT_TI_LZ_PK>(location, ITC.DelayUntilIndexesAreUpdatedLazily);
Assert.Equal(2, await getLocationCount(ITC.Seattle));
await p2.Deactivate();
await Task.Delay(ITC.DelayUntilIndexesAreUpdatedLazily);
Assert.Equal(2, await getLocationCount(ITC.Seattle));
p2 = base.GetGrain<IPlayer_FT_TI_LZ_PK>(2);
Assert.Equal(ITC.Seattle, await p2.GetLocation());
Assert.Equal(2, await getLocationCount(ITC.Seattle));
}
/// <summary>
/// Tests basic transactional functionality of HashIndexPartitionedPerKey
/// </summary>
[Fact, TestCategory("BVT"), TestCategory("Indexing"), TestCategory("TransactionalIndexing")]
public async Task Test_Lookup_3Grains_TXN_TI_EG_PK()
{
var p1 = base.GetGrain<IPlayer_TXN_TI_EG_PK>(1);
await p1.SetLocation(ITC.Seattle);
var p2 = base.GetGrain<IPlayer_TXN_TI_EG_PK>(2);
var p3 = base.GetGrain<IPlayer_TXN_TI_EG_PK>(3);
await p2.SetLocation(ITC.Seattle);
await p3.SetLocation(ITC.SanFrancisco);
var locIdx = await base.GetAndWaitForIndex<string, IPlayer_TXN_TI_EG_PK>(ITC.LocationProperty);
Task<int> getLocationCount(string location) => this.GetPlayerLocationCountTxn<IPlayer_TXN_TI_EG_PK, PlayerProperties_TXN_TI_EG_PK>(location, ITC.DelayUntilIndexesAreUpdatedLazily);
Assert.Equal(2, await getLocationCount(ITC.Seattle));
await p2.Deactivate();
await Task.Delay(ITC.DelayUntilIndexesAreUpdatedLazily);
Assert.Equal(2, await getLocationCount(ITC.Seattle)); // Transactional indexes are always Total, so the count remains 2
p2 = base.GetGrain<IPlayer_TXN_TI_EG_PK>(2);
Assert.Equal(ITC.Seattle, await p2.GetLocation());
Assert.Equal(2, await getLocationCount(ITC.Seattle));
}
/// <summary>
/// Tests basic functionality of HashIndexPartitionedPerKey
/// </summary>
[Fact, TestCategory("BVT"), TestCategory("Indexing")]
public async Task Test_Lookup_5Grains_FT_TI_LZ_PK()
{
//await base.StartAndWaitForSecondSilo();
IPlayer_FT_TI_LZ_PK p1 = base.GetGrain<IPlayer_FT_TI_LZ_PK>(1);
await p1.SetLocation(ITC.Seattle);
IPlayer_FT_TI_LZ_PK p2 = base.GetGrain<IPlayer_FT_TI_LZ_PK>(2);
IPlayer_FT_TI_LZ_PK p3 = base.GetGrain<IPlayer_FT_TI_LZ_PK>(3);
IPlayer_FT_TI_LZ_PK p4 = base.GetGrain<IPlayer_FT_TI_LZ_PK>(4);
IPlayer_FT_TI_LZ_PK p5 = base.GetGrain<IPlayer_FT_TI_LZ_PK>(5);
await p2.SetLocation(ITC.Seattle);
await p3.SetLocation(ITC.SanFrancisco);
await p4.SetLocation(ITC.Tehran);
await p5.SetLocation(ITC.Yazd);
for (int i = 0; i < 100; ++i)
{
var tasks = new List<Task>();
const int offset = 10000; // Make unique to avoid conflict with other tests using this grain interface
for (int j = offset; j < offset + 10; ++j)
{
p1 = base.GetGrain<IPlayer_FT_TI_LZ_PK>(j);
tasks.Add(p1.SetLocation(ITC.Yazd + i + "-" + j));
}
await Task.WhenAll(tasks);
}
}
}
}