You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/09/22 09:19:13 UTC
[11/37] ignite git commit: IGNITE-1513: WIP on .Net.
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTestAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTestAsync.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTestAsync.cs
deleted file mode 100644
index b0e507a..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTestAsync.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Services
-{
- using Apache.Ignite.Core.Services;
-
- /// <summary>
- /// Services async tests.
- /// </summary>
- public class ServicesTestAsync : ServicesTest
- {
- /** <inheritdoc /> */
- protected override IServices Services
- {
- get { return new ServicesAsyncWrapper(Grid1.GetServices()); }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
deleted file mode 100644
index 2b0ab8e..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests
-{
- using System;
- using System.Diagnostics;
- using System.Reflection;
- using Apache.Ignite.Core.Tests.Memory;
- using NUnit.ConsoleRunner;
-
- public static class TestRunner
- {
- [STAThread]
- static void Main()
- {
- Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
- Debug.AutoFlush = true;
-
- //TestOne(typeof(ContinuousQueryAtomiclBackupTest), "TestInitialQuery");
-
- TestAll(typeof (ExecutableTest));
- //TestAllInAssembly();
- }
-
- private static void TestOne(Type testClass, string method)
- {
- string[] args = { "/run:" + testClass.FullName + "." + method, Assembly.GetAssembly(testClass).Location };
-
- int returnCode = Runner.Main(args);
-
- if (returnCode != 0)
- Console.Beep();
- }
-
- private static void TestAll(Type testClass)
- {
- string[] args = { "/run:" + testClass.FullName, Assembly.GetAssembly(testClass).Location };
-
- int returnCode = Runner.Main(args);
-
- if (returnCode != 0)
- Console.Beep();
- }
-
- private static void TestAllInAssembly()
- {
- string[] args = { Assembly.GetAssembly(typeof(InteropMemoryTest)).Location };
-
- int returnCode = Runner.Main(args);
-
- if (returnCode != 0)
- Console.Beep();
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs
deleted file mode 100644
index 3287e2f..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests
-{
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading;
- using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Tests.Process;
- using NUnit.Framework;
-
- /// <summary>
- /// Test utility methods.
- /// </summary>
- public static class TestUtils
- {
- /** Indicates long running and/or memory/cpu intensive test. */
- public const string CategoryIntensive = "LONG_TEST";
-
- /** */
- public const int DfltBusywaitSleepInterval = 200;
-
- /** */
-
- private static readonly IList<string> TestJvmOpts = Environment.Is64BitProcess
- ? new List<string>
- {
- "-XX:+HeapDumpOnOutOfMemoryError",
- "-Xms1g",
- "-Xmx4g",
- "-ea"
- }
- : new List<string>
- {
- "-XX:+HeapDumpOnOutOfMemoryError",
- "-Xms512m",
- "-Xmx512m",
- "-ea",
- "-DIGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE=1000"
- };
-
- /** */
- private static readonly IList<string> JvmDebugOpts =
- new List<string> { "-Xdebug", "-Xnoagent", "-Djava.compiler=NONE", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" };
-
- /** */
- public static bool JvmDebug = true;
-
- /** */
- [ThreadStatic]
- private static Random _random;
-
- /** */
- private static int _seed = Environment.TickCount;
-
- /// <summary>
- /// Kill Ignite processes.
- /// </summary>
- public static void KillProcesses()
- {
- IgniteProcess.KillAll();
- }
-
- /// <summary>
- ///
- /// </summary>
- public static Random Random
- {
- get { return _random ?? (_random = new Random(Interlocked.Increment(ref _seed))); }
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- public static IList<string> TestJavaOptions()
- {
- IList<string> ops = new List<string>(TestJvmOpts);
-
- if (JvmDebug)
- {
- foreach (string opt in JvmDebugOpts)
- ops.Add(opt);
- }
-
- return ops;
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- public static string CreateTestClasspath()
- {
- return IgniteManager.CreateClasspath(forceTestClasspath: true);
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="action"></param>
- /// <param name="threadNum"></param>
- public static void RunMultiThreaded(Action action, int threadNum)
- {
- List<Thread> threads = new List<Thread>(threadNum);
-
- var errors = new ConcurrentBag<Exception>();
-
- for (int i = 0; i < threadNum; i++)
- {
- threads.Add(new Thread(() =>
- {
- try
- {
- action();
- }
- catch (Exception e)
- {
- errors.Add(e);
- }
- }));
- }
-
- foreach (Thread thread in threads)
- thread.Start();
-
- foreach (Thread thread in threads)
- thread.Join();
-
- foreach (var ex in errors)
- Assert.Fail("Unexpected exception: " + ex);
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="action"></param>
- /// <param name="threadNum"></param>
- /// <param name="duration">Duration of test execution in seconds</param>
- public static void RunMultiThreaded(Action action, int threadNum, int duration)
- {
- List<Thread> threads = new List<Thread>(threadNum);
-
- var errors = new ConcurrentBag<Exception>();
-
- bool stop = false;
-
- for (int i = 0; i < threadNum; i++)
- {
- threads.Add(new Thread(() =>
- {
- try
- {
- while (true)
- {
- Thread.MemoryBarrier();
-
- // ReSharper disable once AccessToModifiedClosure
- if (stop)
- break;
-
- action();
- }
- }
- catch (Exception e)
- {
- errors.Add(e);
- }
- }));
- }
-
- foreach (Thread thread in threads)
- thread.Start();
-
- Thread.Sleep(duration * 1000);
-
- stop = true;
-
- Thread.MemoryBarrier();
-
- foreach (Thread thread in threads)
- thread.Join();
-
- foreach (var ex in errors)
- Assert.Fail("Unexpected exception: " + ex);
- }
-
- /// <summary>
- /// Wait for particular topology size.
- /// </summary>
- /// <param name="grid">Grid.</param>
- /// <param name="size">Size.</param>
- /// <param name="timeout">Timeout.</param>
- /// <returns>
- /// <c>True</c> if topology took required size.
- /// </returns>
- public static bool WaitTopology(this IIgnite grid, int size, int timeout)
- {
- int left = timeout;
-
- while (true)
- {
- if (grid.GetCluster().GetNodes().Count != size)
- {
- if (left > 0)
- {
- Thread.Sleep(100);
-
- left -= 100;
- }
- else
- break;
- }
- else
- return true;
- }
-
- return false;
- }
-
- /// <summary>
- /// Asserts that the handle registry is empty.
- /// </summary>
- /// <param name="timeout">Timeout, in milliseconds.</param>
- /// <param name="grids">Grids to check.</param>
- public static void AssertHandleRegistryIsEmpty(int timeout, params IIgnite[] grids)
- {
- foreach (var g in grids)
- AssertHandleRegistryIsEmpty(g, timeout);
- }
-
- /// <summary>
- /// Asserts that the handle registry is empty.
- /// </summary>
- /// <param name="grid">The grid to check.</param>
- /// <param name="timeout">Timeout, in milliseconds.</param>
- public static void AssertHandleRegistryIsEmpty(IIgnite grid, int timeout)
- {
- var handleRegistry = ((Ignite)grid).HandleRegistry;
-
- if (WaitForCondition(() => handleRegistry.Count == 0, timeout))
- return;
-
- var items = handleRegistry.GetItems();
-
- if (items.Any())
- Assert.Fail("HandleRegistry is not empty in grid '{0}':\n '{1}'", grid.Name,
- items.Select(x => x.ToString()).Aggregate((x, y) => x + "\n" + y));
- }
-
- /// <summary>
- /// Waits for condition, polling in busy wait loop.
- /// </summary>
- /// <param name="cond">Condition.</param>
- /// <param name="timeout">Timeout, in milliseconds.</param>
- /// <returns>True if condition predicate returned true within interval; false otherwise.</returns>
- public static bool WaitForCondition(Func<bool> cond, int timeout)
- {
- if (timeout <= 0)
- return cond();
-
- var maxTime = DateTime.Now.AddMilliseconds(timeout + DfltBusywaitSleepInterval);
-
- while (DateTime.Now < maxTime)
- {
- if (cond())
- return true;
-
- Thread.Sleep(DfltBusywaitSleepInterval);
- }
-
- return false;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs
deleted file mode 100644
index a49ee1b..0000000
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using Apache.Ignite.Core.Impl.Portable;
- using Apache.Ignite.Core.Tests.TestDll;
- using NUnit.Framework;
-
- /// <summary>
- /// <see cref="TypeResolver"/> tests.
- /// </summary>
- public class TypeResolverTest
- {
- /// <summary>
- /// Tests generic type resolve.
- /// </summary>
- [Test]
- public void TestGenerics()
- {
- var testTypes = new[]
- {
- typeof (TestGenericPortable<int>),
- typeof (TestGenericPortable<string>),
- typeof (TestGenericPortable<TestGenericPortable<int>>),
- typeof (TestGenericPortable<List<Tuple<int, string>>>),
- typeof (TestGenericPortable<List<TestGenericPortable<List<Tuple<int, string>>>>>),
- typeof (List<TestGenericPortable<List<TestGenericPortable<List<Tuple<int, string>>>>>>),
- typeof (TestGenericPortable<int, string>),
- typeof (TestGenericPortable<int, TestGenericPortable<string>>),
- typeof (TestGenericPortable<int, string, Type>),
- typeof (TestGenericPortable<int, string, TestGenericPortable<int, string, Type>>)
- };
-
- foreach (var type in testTypes)
- {
- // Without assembly
- var resolvedType = new TypeResolver().ResolveType(type.FullName);
- Assert.AreEqual(type.FullName, resolvedType.FullName);
-
- // With assembly
- resolvedType = new TypeResolver().ResolveType(type.FullName, type.Assembly.FullName);
- Assert.AreEqual(type.FullName, resolvedType.FullName);
-
- // Assembly-qualified
- resolvedType = new TypeResolver().ResolveType(type.AssemblyQualifiedName);
- Assert.AreEqual(type.FullName, resolvedType.FullName);
- }
- }
-
- /// <summary>
- /// Tests loading a type from referenced assembly that is not yet loaded.
- /// </summary>
- [Test]
- public void TestReferencedAssemblyLoading()
- {
- const string dllName = "Apache.Ignite.Core.Tests.TestDll";
-
- const string typeName = "Apache.Ignite.Core.Tests.TestDll.TestClass";
-
- // Check that the dll is not yet loaded
- Assert.IsFalse(AppDomain.CurrentDomain.GetAssemblies().Any(x => x.FullName.StartsWith(dllName)));
-
- // Check that the dll is referenced by current assembly
- Assert.IsTrue(Assembly.GetExecutingAssembly().GetReferencedAssemblies()
- .Any(x => x.FullName.StartsWith(dllName)));
-
- // Check resolver
- var type = new TypeResolver().ResolveType(typeName);
-
- Assert.IsNotNull(type);
- Assert.AreEqual(typeName, type.FullName);
- Assert.IsNotNull(Activator.CreateInstance(type));
-
- // At this moment the dll should be loaded
- Assert.IsTrue(AppDomain.CurrentDomain.GetAssemblies().Any(x => x.FullName.StartsWith(dllName)));
- }
-
- /// <summary>
- /// Unused method that forces C# compiler to include TestDll assembly reference.
- /// Without this, compiler will remove the reference as unused.
- /// However, since it is never called, TestDll does not get loaded.
- /// </summary>
- public void UnusedMethod()
- {
- Assert.IsNotNull(typeof(TestClass));
- }
- }
-}
\ No newline at end of file