This repository has been archived by the owner on Oct 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathSimpleIndexingTestsTwoSilos.cs
85 lines (66 loc) · 3.21 KB
/
SimpleIndexingTestsTwoSilos.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
using System.Threading.Tasks;
using UnitTests.GrainInterfaces;
using Xunit;
using Orleans;
using Orleans.Indexing;
using Xunit.Abstractions;
using System.Threading;
using TestExtensions;
namespace UnitTests.IndexingTests
{
//[Serializable]
//public class PlayerLocIndexGen : IndexUpdateGenerator<string, PlayerProperties>
//{
// public override string ExtractIndexImage(PlayerProperties g)
// {
// return g.Location;
// }
//}
//[Serializable]
//public class PlayerScoreIndexGen : IndexUpdateGenerator<int, PlayerProperties>
//{
// public override int ExtractIndexImage(PlayerProperties g)
// {
// return g.Score;
// }
//}
public class SimpleIndexingTestsTwoSilos : HostedTestClusterEnsureDefaultStarted
{
private readonly ITestOutputHelper output;
public SimpleIndexingTestsTwoSilos(DefaultClusterFixture fixture, ITestOutputHelper output)
: base(fixture)
{
this.output = output;
}
/// <summary>
/// Tests basic functionality of ActiveHashIndexPartitionedPerSiloImpl with 2 Silos
/// </summary>
[Fact, TestCategory("BVT"), TestCategory("Indexing")]
public async Task Test_Indexing_IndexLookup3()
{
//await GrainClient.GrainFactory.DropAllIndexes<IPlayerGrain>();
if (HostedCluster.SecondarySilos.Count == 0)
{
HostedCluster.StartAdditionalSilo();
await HostedCluster.WaitForLivenessToStabilizeAsync();
}
IPlayer2GrainNonFaultTolerant p1 = GrainClient.GrainFactory.GetGrain<IPlayer2GrainNonFaultTolerant>(1);
await p1.SetLocation("Seattle");
//bool isLocIndexCreated = await GrainClient.GrainFactory.CreateAndRegisterIndex<HashIndexSingleBucketInterface<string, IPlayerGrain>, PlayerLocIndexGen>("__GetLocation");
//Assert.IsTrue(isLocIndexCreated);
IPlayer2GrainNonFaultTolerant p2 = GrainClient.GrainFactory.GetGrain<IPlayer2GrainNonFaultTolerant>(2);
IPlayer2GrainNonFaultTolerant p3 = GrainClient.GrainFactory.GetGrain<IPlayer2GrainNonFaultTolerant>(3);
await p2.SetLocation("Seattle");
await p3.SetLocation("San Fransisco");
IndexInterface<string, IPlayer2GrainNonFaultTolerant> locIdx = GrainClient.GrainFactory.GetIndex<string, IPlayer2GrainNonFaultTolerant>("__Location");
while (!await locIdx.IsAvailable()) Thread.Sleep(50);
Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn<IPlayer2GrainNonFaultTolerant, Player2PropertiesNonFaultTolerant>("Seattle", output));
await p2.Deactivate();
Thread.Sleep(1000);
Assert.Equal(1, await IndexingTestUtils.CountPlayersStreamingIn<IPlayer2GrainNonFaultTolerant, Player2PropertiesNonFaultTolerant>("Seattle", output));
p2 = GrainClient.GrainFactory.GetGrain<IPlayer2GrainNonFaultTolerant>(2);
Assert.Equal("Seattle", await p2.GetLocation());
Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn<IPlayer2GrainNonFaultTolerant, Player2PropertiesNonFaultTolerant>("Seattle", output));
}
}
}