You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by yz...@apache.org on 2016/12/28 14:05:08 UTC
[42/50] [abbrv] ignite git commit: IGNITE-4494 .NET: Optimize
ExamplesTest.TestRemoteNodes
IGNITE-4494 .NET: Optimize ExamplesTest.TestRemoteNodes
Reuse standalone nodes between test runs
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7606e662
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7606e662
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7606e662
Branch: refs/heads/ignite-comm-balance-master
Commit: 7606e6624be313a114a1c6350faa83a5f5063938
Parents: df725e8
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Mon Dec 26 18:47:11 2016 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Mon Dec 26 18:47:11 2016 +0300
----------------------------------------------------------------------
.../Examples/Example.cs | 5 +-
.../Examples/ExamplesTest.cs | 107 +++++++++++++------
2 files changed, 78 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7606e662/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/Example.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/Example.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/Example.cs
index 4df012c..e7a264d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/Example.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/Example.cs
@@ -23,7 +23,6 @@ namespace Apache.Ignite.Core.Tests.Examples
using System.Linq;
using System.Text.RegularExpressions;
using Apache.Ignite.Examples.Compute;
- using Apache.Ignite.ExamplesDll.Compute;
using NUnit.Framework;
/// <summary>
@@ -76,8 +75,6 @@ namespace Apache.Ignite.Core.Tests.Examples
Assert.IsTrue(types.Any());
- var examplesDllName = typeof(AverageSalaryJob).Assembly.GetName().Name;
-
foreach (var type in types)
{
var sourceFile = sourceFiles.Single(x => x.EndsWith(string.Format("\\{0}.cs", type.Name)));
@@ -87,7 +84,7 @@ namespace Apache.Ignite.Core.Tests.Examples
yield return new Example
{
ConfigPath = GetConfigPath(sourceCode),
- NeedsTestDll = sourceCode.Contains(examplesDllName),
+ NeedsTestDll = sourceCode.Contains("-assembly="),
_runAction = GetRunAction(type),
Name = type.Name
};
http://git-wip-us.apache.org/repos/asf/ignite/blob/7606e662/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
index 61bfb5c..19e68a6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
@@ -32,8 +32,22 @@ namespace Apache.Ignite.Core.Tests.Examples
public class ExamplesTest
{
/** */
+ private static readonly Example[] AllExamples = Example.GetExamples().ToArray();
+
+ /** */
+ private static readonly string[] LocalOnlyExamples =
+ {
+ "LifecycleExample", "ClientReconnectExample", "MultiTieredCacheExample"
+ };
+
+ /** */
+ private static readonly string[] NoDllExamples = { "BinaryModeExample", "NearCacheExample" };
+
+ /** */
private IDisposable _changedConfig;
+ /** */
+ private bool _remoteNodeStarted;
/// <summary>
/// Tests the example in a single node mode.
/// </summary>
@@ -41,6 +55,14 @@ namespace Apache.Ignite.Core.Tests.Examples
[Test, TestCaseSource("TestCasesLocal")]
public void TestLocalNode(Example example)
{
+ StopRemoteNodes();
+
+ if (LocalOnlyExamples.Contains(example.Name))
+ {
+ Assert.IsFalse(example.NeedsTestDll, "Local-only example should not mention test dll.");
+ Assert.IsNull(example.ConfigPath, "Local-only example should not mention app.config path.");
+ }
+
example.Run();
}
@@ -69,41 +91,65 @@ namespace Apache.Ignite.Core.Tests.Examples
/// </summary>
/// <param name="example">The example to run.</param>
/// <param name="clientMode">Client mode flag.</param>
- private static void TestRemoteNodes(Example example, bool clientMode)
+ private void TestRemoteNodes(Example example, bool clientMode)
{
- Assert.IsNotEmpty(example.ConfigPath);
+ Assert.IsTrue(PathUtil.ExamplesAppConfigPath.EndsWith(example.ConfigPath,
+ StringComparison.OrdinalIgnoreCase), "All examples should use the same app.config.");
- var configPath = Path.Combine(PathUtil.IgniteHome, PathUtil.DevPrefix, example.ConfigPath);
+ Assert.IsTrue(example.NeedsTestDll || NoDllExamples.Contains(example.Name),
+ "Examples that allow standalone nodes should mention test dll.");
- // Try with multiple standalone nodes
- for (var i = 0; i < 2; i++)
- {
- // Start a grid to monitor topology
- // Stop it after topology check so we don't interfere with example
- Ignition.ClientMode = false;
+ StartRemoteNodes();
- using (var ignite = Ignition.StartFromApplicationConfiguration(
- "igniteConfiguration", configPath))
- {
- var args = new List<string> { "-configFileName=" + configPath};
+ Ignition.ClientMode = clientMode;
- if (example.NeedsTestDll)
- args.Add(" -assembly=" + typeof(AverageSalaryJob).Assembly.Location);
+ // Run twice to catch issues with standalone node state
+ example.Run();
+ example.Run();
+ }
- var proc = new IgniteProcess(args.ToArray());
+ /// <summary>
+ /// Starts standalone node.
+ /// </summary>
+ private void StartRemoteNodes()
+ {
+ if (_remoteNodeStarted)
+ return;
+
+ // Start a grid to monitor topology;
+ // Stop it after topology check so we don't interfere with example.
+ Ignition.ClientMode = false;
- Assert.IsTrue(ignite.WaitTopology(i + 2),
- string.Format("Standalone node failed to join topology: [{0}]", proc.GetInfo()));
+ using (var ignite = Ignition.StartFromApplicationConfiguration(
+ "igniteConfiguration", PathUtil.ExamplesAppConfigPath))
+ {
+ var args = new List<string>
+ {
+ "-configFileName=" + PathUtil.ExamplesAppConfigPath,
+ " -assembly=" + typeof(AverageSalaryJob).Assembly.Location
+ };
- Assert.IsTrue(proc.Alive, string.Format("Standalone node stopped unexpectedly: [{0}]",
- proc.GetInfo()));
- }
+ var proc = new IgniteProcess(args.ToArray());
- Ignition.ClientMode = clientMode;
+ Assert.IsTrue(ignite.WaitTopology(2),
+ string.Format("Standalone node failed to join topology: [{0}]", proc.GetInfo()));
+
+ Assert.IsTrue(proc.Alive, string.Format("Standalone node stopped unexpectedly: [{0}]",
+ proc.GetInfo()));
+ }
+
+ _remoteNodeStarted = true;
+ }
- // Run twice to catch issues with standalone node state
- example.Run();
- example.Run();
+ /// <summary>
+ /// Stops standalone nodes.
+ /// </summary>
+ private void StopRemoteNodes()
+ {
+ if (_remoteNodeStarted)
+ {
+ IgniteProcess.KillAll();
+ _remoteNodeStarted = false;
}
}
@@ -127,6 +173,10 @@ namespace Apache.Ignite.Core.Tests.Examples
public void FixtureTearDown()
{
_changedConfig.Dispose();
+
+ Ignition.StopAll(true);
+
+ IgniteProcess.KillAll();
}
/// <summary>
@@ -136,7 +186,6 @@ namespace Apache.Ignite.Core.Tests.Examples
public void TearDown()
{
Ignition.ClientMode = false;
- IgniteProcess.KillAll();
}
/// <summary>
@@ -146,7 +195,7 @@ namespace Apache.Ignite.Core.Tests.Examples
// ReSharper disable once MemberCanBeMadeStatic.Global
public IEnumerable<Example> TestCasesLocal
{
- get { return Example.GetExamples().Where(x => x.Name != "NearCacheExample"); }
+ get { return AllExamples.Where(x => x.Name != "NearCacheExample"); }
}
/// <summary>
@@ -158,9 +207,7 @@ namespace Apache.Ignite.Core.Tests.Examples
{
get
{
- var localOnly = new[] {"LifecycleExample", "ClientReconnectExample", "MultiTieredCacheExample" };
-
- return Example.GetExamples().Where(x => !localOnly.Contains(x.Name));
+ return AllExamples.Where(x => !LocalOnlyExamples.Contains(x.Name));
}
}
}