2
2
using System . IO ;
3
3
using System . Threading . Tasks ;
4
4
using System . Collections . Generic ;
5
+ using Orleans ;
6
+ using Orleans . Runtime ;
7
+ using Orleans . Runtime . Configuration ;
5
8
using UnitTests . GrainInterfaces ;
6
9
using Orleans . TestingHost ;
7
10
using Xunit ;
10
13
11
14
namespace Tests . GeoClusterTests
12
15
{
13
- public class BasicLogTestGrainTests : TestingSiloHost
16
+ public class BasicLogTestGrainTests : IClassFixture < BasicLogTestGrainTests . Fixture >
14
17
{
18
+ private readonly Fixture fixture ;
19
+ private Random random ;
20
+
21
+ public class Fixture : BaseTestClusterFixture
22
+ {
23
+ protected override TestCluster CreateTestCluster ( )
24
+ {
25
+ var options = new TestClusterOptions ( 1 ) ;
26
+
27
+ options . ClusterConfiguration . AddMemoryStorageProvider ( "Default" ) ;
28
+ options . ClusterConfiguration . AddMemoryStorageProvider ( "MemoryStore" ) ;
29
+ options . ClusterConfiguration . AddAzureTableStorageProvider ( "AzureStore" ) ;
15
30
31
+ options . ClusterConfiguration . AddAzureTableStorageProvider ( ) ;
32
+ options . ClusterConfiguration . AddStateStorageBasedLogConsistencyProvider ( ) ;
33
+ options . ClusterConfiguration . AddLogStorageBasedLogConsistencyProvider ( ) ;
34
+ options . ClusterConfiguration . AddCustomStorageInterfaceBasedLogConsistencyProvider ( "CustomStorage" ) ;
16
35
17
- public BasicLogTestGrainTests ( ) :
18
- base (
19
- new TestingSiloOptions
20
- {
21
- StartFreshOrleans = true ,
22
- StartPrimary = true ,
23
- StartSecondary = false ,
24
- SiloConfigFile = new FileInfo ( "OrleansConfigurationForTesting.xml" ) ,
25
- AdjustConfig = cfg => LogConsistencyProviderConfiguration . ConfigureLogConsistencyProvidersForTesting ( TestDefaultConfiguration . DataConnectionString , cfg )
26
- }
27
- )
36
+ options . ClusterConfiguration . AddCustomStorageInterfaceBasedLogConsistencyProvider ( "CustomStoragePrimaryCluster" , "A" ) ;
28
37
38
+ options . ClusterConfiguration . ApplyToAllNodes ( o=> o . TraceLevelOverrides . Add ( new Tuple < string , Severity > ( "LogViews" , Severity . Verbose2 ) ) ) ;
39
+
40
+ return new TestCluster ( options ) ;
41
+ }
42
+ }
43
+ public BasicLogTestGrainTests ( Fixture fixture )
29
44
{
45
+ this . fixture = fixture ;
30
46
this . random = new Random ( ) ;
31
47
}
32
48
33
- private Random random ;
34
-
35
49
[ Fact , TestCategory ( "GeoCluster" ) ]
36
50
public async Task DefaultStorage ( )
37
51
{
@@ -81,7 +95,7 @@ private async Task ThreeCheckers(string grainClass, int phases)
81
95
Func < Task > checker1 = async ( ) =>
82
96
{
83
97
int x = GetRandom ( ) ;
84
- var grain = GrainFactory . GetGrain < ILogTestGrain > ( x , grainClass ) ;
98
+ var grain = this . fixture . GrainFactory . GetGrain < ILogTestGrain > ( x , grainClass ) ;
85
99
await grain . SetAGlobal ( x ) ;
86
100
int a = await grain . GetAGlobal ( ) ;
87
101
Assert . Equal ( x , a ) ; // value of A survive grain call
@@ -92,7 +106,7 @@ private async Task ThreeCheckers(string grainClass, int phases)
92
106
Func < Task > checker2 = async ( ) =>
93
107
{
94
108
int x = GetRandom ( ) ;
95
- var grain = GrainFactory . GetGrain < ILogTestGrain > ( x , grainClass ) ;
109
+ var grain = this . fixture . GrainFactory . GetGrain < ILogTestGrain > ( x , grainClass ) ;
96
110
Assert . Equal ( 0 , await grain . GetConfirmedVersion ( ) ) ;
97
111
await grain . SetALocal ( x ) ;
98
112
int a = await grain . GetALocal ( ) ;
@@ -104,7 +118,7 @@ private async Task ThreeCheckers(string grainClass, int phases)
104
118
{
105
119
// Local then Global
106
120
int x = GetRandom ( ) ;
107
- var grain = GrainFactory . GetGrain < ILogTestGrain > ( x , grainClass ) ;
121
+ var grain = this . fixture . GrainFactory . GetGrain < ILogTestGrain > ( x , grainClass ) ;
108
122
await grain . SetALocal ( x ) ;
109
123
int a = await grain . GetAGlobal ( ) ;
110
124
Assert . Equal ( x , a ) ;
0 commit comments