Skip to content

Commit b38fe30

Browse files
committed
IGNITE-1628 .NET: Compile and run on Mono
This closes apache#3380
1 parent 792ab3f commit b38fe30

File tree

12 files changed

+172
-114
lines changed

12 files changed

+172
-114
lines changed

Diff for: modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj

+11-13
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@
5959
<HintPath>..\packages\NUnit.Runners.2.6.3\tools\nunit.framework.dll</HintPath>
6060
</Reference>
6161
<Reference Include="System" />
62-
<Reference Include="System.configuration" />
62+
<Reference Include="System.Configuration" />
6363
<Reference Include="System.Core" />
6464
<Reference Include="System.Data" />
6565
<Reference Include="System.Runtime.Serialization" />
6666
<Reference Include="System.ServiceProcess" />
6767
<Reference Include="System.Transactions" />
68-
<Reference Include="System.XML" />
68+
<Reference Include="System.Xml" />
6969
<Reference Include="System.Xml.Linq" />
7070
</ItemGroup>
7171
<ItemGroup>
@@ -323,7 +323,7 @@
323323
<Project>{5b571661-17f4-4f29-8c7d-0edb38ca9b55}</Project>
324324
<Name>Apache.Ignite.Linq</Name>
325325
</ProjectReference>
326-
<ProjectReference Include="..\Apache.Ignite.log4net\Apache.Ignite.Log4Net.csproj">
326+
<ProjectReference Include="..\Apache.Ignite.Log4Net\Apache.Ignite.Log4Net.csproj">
327327
<Project>{6F82D669-382E-4435-8092-68C4440146D8}</Project>
328328
<Name>Apache.Ignite.Log4Net</Name>
329329
</ProjectReference>
@@ -335,12 +335,12 @@
335335
<Project>{27F7F3C6-BDDE-43A9-B565-856F8395A04B}</Project>
336336
<Name>Apache.Ignite</Name>
337337
</ProjectReference>
338-
<ProjectReference Include="..\Examples\Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj">
338+
<ProjectReference Include="..\examples\Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj">
339339
<Project>{dfb08363-202e-412d-8812-349ef10a8702}</Project>
340340
<Name>Apache.Ignite.ExamplesDll</Name>
341341
<Aliases>ExamplesDll</Aliases>
342342
</ProjectReference>
343-
<ProjectReference Include="..\Examples\Apache.Ignite.Examples\Apache.Ignite.Examples.csproj">
343+
<ProjectReference Include="..\examples\Apache.Ignite.Examples\Apache.Ignite.Examples.csproj">
344344
<Project>{069fa680-3c4d-43a9-b84f-e67513b87827}</Project>
345345
<Name>Apache.Ignite.Examples</Name>
346346
</ProjectReference>
@@ -490,14 +490,12 @@
490490
<Compile Include="TestUtils.Windows.cs" />
491491
</ItemGroup>
492492
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
493-
<PropertyGroup Condition="'$(Platform)' != 'AnyCPU'">
494-
<PostBuildEvent>copy /Y $(SolutionDir)Apache.Ignite\bin\$(PlatformName)\$(ConfigurationName)\Apache.Ignite.exe $(ProjectDir)$(OutDir)
495-
copy /Y $(SolutionDir)Apache.Ignite\bin\$(PlatformName)\$(ConfigurationName)\Apache.Ignite.exe.config $(ProjectDir)$(OutDir)</PostBuildEvent>
496-
</PropertyGroup>
497-
<PropertyGroup Condition="'$(Platform)' == 'AnyCPU'">
498-
<PostBuildEvent>copy /Y $(SolutionDir)Apache.Ignite\bin\$(ConfigurationName)\Apache.Ignite.exe $(ProjectDir)$(OutDir)
499-
copy /Y $(SolutionDir)Apache.Ignite\bin\$(ConfigurationName)\Apache.Ignite.exe.config $(ProjectDir)$(OutDir)</PostBuildEvent>
500-
</PropertyGroup>
493+
494+
<Target Name="AfterBuild">
495+
<Copy SourceFiles="$(SolutionDir)Apache.Ignite\bin\$(ConfigurationName)\Apache.Ignite.exe;$(SolutionDir)Apache.Ignite\bin\$(ConfigurationName)\Apache.Ignite.exe.config" DestinationFolder="$(ProjectDir)$(OutDir)" SkipUnchangedFiles="false" />
496+
</Target>
497+
498+
501499
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
502500
Other similar extension points exist, see Microsoft.Common.targets.
503501
<Target Name="BeforeBuild">

Diff for: modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheForkedTest.cs

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public void SetUp()
4747
"-J-Xmx512m",
4848
"-J-DIGNITE_QUIET=false"
4949
);
50+
Assert.IsTrue(proc.Alive);
5051

5152
_grid = Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration())
5253
{

Diff for: modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs

+10
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public void TestConfig()
103103
"-jvmClasspath=" + TestUtils.CreateTestClasspath()
104104
);
105105

106+
Assert.IsTrue(proc.Alive);
106107
Assert.IsTrue(_grid.WaitTopology(2));
107108

108109
var cfg = RemoteConfig();
@@ -130,6 +131,7 @@ public void TestAssemblyCmd()
130131
"-assembly=test-2.dll"
131132
);
132133

134+
Assert.IsTrue(proc.Alive);
133135
Assert.IsTrue(_grid.WaitTopology(2));
134136

135137
var cfg = RemoteConfig();
@@ -150,6 +152,7 @@ public void TestJvmOptsCmd()
150152
"-J-DOPT2"
151153
);
152154

155+
Assert.IsTrue(proc.Alive);
153156
Assert.IsTrue(_grid.WaitTopology(2));
154157

155158
var cfg = RemoteConfig();
@@ -170,6 +173,7 @@ public void TestJvmMemoryOptsCmdRaw()
170173
"-J-Xmx607m"
171174
);
172175

176+
Assert.IsTrue(proc.Alive);
173177
Assert.IsTrue(_grid.WaitTopology(2));
174178

175179
var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
@@ -192,6 +196,7 @@ public void TestJvmMemoryOptsCmdCustom()
192196
"-JvmMaxMemoryMB=863"
193197
);
194198

199+
Assert.IsTrue(proc.Alive);
195200
Assert.IsTrue(_grid.WaitTopology(2));
196201

197202
var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
@@ -215,6 +220,7 @@ public void TestJvmMemoryOptsAppConfig(
215220

216221
var proc = new IgniteProcess("-jvmClasspath=" + TestUtils.CreateTestClasspath());
217222

223+
Assert.IsTrue(proc.Alive);
218224
Assert.IsTrue(_grid.WaitTopology(2));
219225

220226
var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
@@ -232,6 +238,7 @@ public void TestJvmMemoryOptsAppConfig(
232238
proc = new IgniteProcess("-jvmClasspath=" + TestUtils.CreateTestClasspath(),
233239
"-J-Xms605m", "-J-Xmx706m");
234240

241+
Assert.IsTrue(proc.Alive);
235242
Assert.IsTrue(_grid.WaitTopology(2));
236243

237244
minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask<long>(MinMemTask, null);
@@ -256,6 +263,7 @@ public void TestJvmMemoryOptsCmdCombined()
256263
"-JvmMaxMemoryMB=256"
257264
);
258265

266+
Assert.IsTrue(proc.Alive);
259267
Assert.IsTrue(_grid.WaitTopology(2));
260268

261269
// Raw JVM options (Xms/Xmx) should override custom options
@@ -276,6 +284,7 @@ public void TestXmlConfigurationAppConfig()
276284

277285
var proc = new IgniteProcess("-jvmClasspath=" + TestUtils.CreateTestClasspath());
278286

287+
Assert.IsTrue(proc.Alive);
279288
Assert.IsTrue(_grid.WaitTopology(2));
280289

281290
var remoteCfg = RemoteConfig();
@@ -295,6 +304,7 @@ public void TestXmlConfigurationCmd()
295304
var proc = new IgniteProcess("-jvmClasspath=" + TestUtils.CreateTestClasspath(),
296305
"-configFileName=config\\ignite-dotnet-cfg.xml");
297306

307+
Assert.IsTrue(proc.Alive);
298308
Assert.IsTrue(_grid.WaitTopology(2));
299309

300310
var remoteCfg = RemoteConfig();

Diff for: modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ public void TestProcessorInit()
337337
"-jvmClasspath=" + TestUtils.CreateTestClasspath(),
338338
"-springConfigUrl=" + Path.GetFullPath(cfg.SpringConfigUrl),
339339
"-J-Xms512m", "-J-Xmx512m");
340+
341+
Assert.IsTrue(proc.Alive);
340342

341343
var cts = new CancellationTokenSource();
342344
var token = cts.Token;

Diff for: modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs

+4-8
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,6 @@ public void TestVoidMethods()
134134
prx.VoidMethod(10);
135135
Assert.AreEqual(_svc.InvokeResult, prx.InvokeResult);
136136

137-
prx.VoidMethod(10, "string");
138-
Assert.AreEqual(_svc.InvokeResult, prx.InvokeResult);
139-
140137
prx.VoidMethod(10, "string", "arg");
141138
Assert.AreEqual(_svc.InvokeResult, prx.InvokeResult);
142139

@@ -154,7 +151,6 @@ public void TestObjectMethods()
154151

155152
Assert.AreEqual("ObjectMethod", prx.ObjectMethod());
156153
Assert.AreEqual("ObjectMethod987", prx.ObjectMethod(987));
157-
Assert.AreEqual("ObjectMethod987str123", prx.ObjectMethod(987, "str123"));
158154
Assert.AreEqual("ObjectMethod987str123TestClass", prx.ObjectMethod(987, "str123", new TestClass()));
159155
Assert.AreEqual("ObjectMethod987str123TestClass34arg5arg6",
160156
prx.ObjectMethod(987, "str123", new TestClass(), 3, 4, "arg5", "arg6"));
@@ -411,10 +407,10 @@ public interface ITestIgniteServiceProxyInterface
411407
void VoidMethod(int arg);
412408

413409
/** */
414-
void VoidMethod(int arg, string arg1, object arg2 = null);
410+
void VoidMethod(int arg, string arg1, object arg2);
415411

416412
/** */
417-
void VoidMethod(int arg, string arg1, object arg2 = null, params object[] args);
413+
void VoidMethod(int arg, string arg1, object arg2, params object[] args);
418414

419415
/** */
420416
object ObjectMethod();
@@ -423,10 +419,10 @@ public interface ITestIgniteServiceProxyInterface
423419
object ObjectMethod(int arg);
424420

425421
/** */
426-
object ObjectMethod(int arg, string arg1, object arg2 = null);
422+
object ObjectMethod(int arg, string arg1, object arg2);
427423

428424
/** */
429-
object ObjectMethod(int arg, string arg1, object arg2 = null, params object[] args);
425+
object ObjectMethod(int arg, string arg1, object arg2, params object[] args);
430426

431427
/** */
432428
void ExceptionMethod();

Diff for: modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs

+62-27
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,21 @@
1818
namespace Apache.Ignite.Core.Tests
1919
{
2020
using System;
21+
using System.Collections.Generic;
2122
using System.Diagnostics;
2223
using System.Linq;
2324
using System.Reflection;
25+
using Apache.Ignite.Core.Tests.Binary.Serializable;
26+
using Apache.Ignite.Core.Tests.Cache;
27+
using Apache.Ignite.Core.Tests.Cache.Query.Linq;
28+
using Apache.Ignite.Core.Tests.Client.Cache;
29+
using Apache.Ignite.Core.Tests.Compute;
2430
using Apache.Ignite.Core.Tests.Memory;
2531
using NUnit.ConsoleRunner;
2632

33+
/// <summary>
34+
/// Console test runner.
35+
/// </summary>
2736
public static class TestRunner
2837
{
2938
[STAThread]
@@ -32,6 +41,13 @@ static void Main(string[] args)
3241
Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
3342
Debug.AutoFlush = true;
3443

44+
if (args.Length == 1 && args[0] == "-basicTests")
45+
{
46+
RunBasicTests();
47+
48+
return;
49+
}
50+
3551
if (args.Length == 2)
3652
{
3753
//Debugger.Launch();
@@ -45,56 +61,75 @@ static void Main(string[] args)
4561
return;
4662
}
4763

48-
TestOne(typeof(ConsoleRedirectTest), "TestMultipleDomains");
49-
50-
//TestAll(typeof (AffinityFunctionTest));
51-
//TestAllInAssembly();
64+
Environment.ExitCode = TestAllInAssembly();
5265
}
5366

54-
private static int TestOne(Type testClass, string method)
67+
/// <summary>
68+
/// Runs some basic tests.
69+
/// </summary>
70+
private static void RunBasicTests()
5571
{
56-
string[] args =
72+
Console.WriteLine(">>> Starting basic tests...");
73+
74+
var basicTests = new[]
5775
{
58-
"/noshadow",
59-
"/run:" + testClass.FullName + "." + method,
60-
Assembly.GetAssembly(testClass).Location
76+
typeof(ComputeApiTest),
77+
typeof(CacheLinqTest),
78+
typeof(SqlDmlTest),
79+
typeof(LinqTest),
80+
typeof(PersistenceTest)
6181
};
6282

63-
int returnCode = Runner.Main(args);
83+
Environment.ExitCode = TestAll(basicTests, true);
6484

65-
if (returnCode != 0)
66-
Console.Beep();
67-
68-
return returnCode;
85+
Console.WriteLine(">>> Test run finished.");
6986
}
7087

71-
private static void TestAll(Type testClass)
88+
/// <summary>
89+
/// Runs specified test method.
90+
/// </summary>
91+
private static int TestOne(Type testClass, string method, bool sameDomain = false)
7292
{
7393
string[] args =
7494
{
75-
"/noshadow",
76-
"/run:" + testClass.FullName, Assembly.GetAssembly(testClass).Location
95+
"-noshadow",
96+
"-domain:" + (sameDomain ? "None" : "Single"),
97+
"-run:" + testClass.FullName + "." + method,
98+
Assembly.GetAssembly(testClass).Location
7799
};
78100

79-
int returnCode = Runner.Main(args);
101+
return Runner.Main(args);
102+
}
80103

81-
if (returnCode != 0)
82-
Console.Beep();
104+
/// <summary>
105+
/// Runs all tests in specified class.
106+
/// </summary>
107+
private static int TestAll(IEnumerable<Type> testClass, bool sameDomain = false)
108+
{
109+
var args = new List<string>
110+
{
111+
"-noshadow",
112+
"-domain:" + (sameDomain ? "None" : "Single"),
113+
"-run:" + string.Join(",", testClass.Select(x => x.FullName)),
114+
Assembly.GetAssembly(typeof(TestRunner)).Location
115+
};
116+
117+
return Runner.Main(args.ToArray());
83118
}
84119

85-
private static void TestAllInAssembly()
120+
/// <summary>
121+
/// Runs all tests in assembly.
122+
/// </summary>
123+
private static int TestAllInAssembly(bool sameDomain = false)
86124
{
87125
string[] args =
88126
{
89-
"/noshadow",
127+
"-noshadow",
128+
"-domain:" + (sameDomain ? "None" : "Single"),
90129
Assembly.GetAssembly(typeof(InteropMemoryTest)).Location
91130
};
92131

93-
int returnCode = Runner.Main(args);
94-
95-
if (returnCode != 0)
96-
Console.Beep();
132+
return Runner.Main(args);
97133
}
98-
99134
}
100135
}

0 commit comments

Comments
 (0)