ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [13/19] ignite git commit: IGNITE-5333 .NET: Include Apache.Ignite.exe in the main NuGet package
Date Wed, 31 May 2017 07:35:44 GMT
IGNITE-5333 .NET: Include Apache.Ignite.exe in the main NuGet package

This closes #2028


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8237ac6f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8237ac6f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8237ac6f

Branch: refs/heads/ignite-5075
Commit: 8237ac6f6b8071dcb18b2a05a429e94cba22e71d
Parents: b0e49ad
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Tue May 30 16:04:28 2017 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Tue May 30 16:04:28 2017 +0300

----------------------------------------------------------------------
 .../StartupTest.cs                              | 78 ++++++++++++++++++++
 .../Apache.Ignite.Core.Tests.NuGet/TestUtil.cs  | 30 ++++++++
 .../Apache.Ignite.Core.nuspec                   |  7 +-
 .../Impl/Common/IgniteHome.cs                   |  3 +-
 .../platforms/dotnet/Apache.Ignite/App.config   | 11 +++
 5 files changed, 125 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8237ac6f/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/StartupTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/StartupTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/StartupTest.cs
index 5b38bde..db62e09 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/StartupTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/StartupTest.cs
@@ -17,6 +17,11 @@
 
 namespace Apache.Ignite.Core.Tests.NuGet
 {
+    using System;
+    using System.Diagnostics;
+    using System.IO;
+    using System.Linq;
+    using System.Threading;
     using Apache.Ignite.Core.Cache.Configuration;
     using NUnit.Framework;
 
@@ -26,6 +31,24 @@ namespace Apache.Ignite.Core.Tests.NuGet
     public class StartupTest
     {
         /// <summary>
+        /// Tears down the test.
+        /// </summary>
+        [TearDown]
+        public void TearDown()
+        {
+            Ignition.StopAll(true);
+
+            foreach (var proc in Process.GetProcesses())
+            {
+                if (proc.ProcessName.Equals("Apache.Ignite"))
+                {
+                    proc.Kill();
+                    proc.WaitForExit();
+                }
+            }
+        }
+
+        /// <summary>
         /// Tests code configuration.
         /// </summary>
         [Test]
@@ -62,5 +85,60 @@ namespace Apache.Ignite.Core.Tests.NuGet
                 Assert.AreEqual(5, cache[1]);
             }
         }
+
+        /// <summary>
+        /// Tests the executable that is included in NuGet.
+        /// </summary>
+        [Test]
+        public void TestApacheIgniteExe()
+        {
+            var asm = GetType().Assembly;
+            var version = asm.GetName().Version.ToString(3);
+            var packageDirName = "Apache.Ignite." + version + "*";
+            
+            var asmDir = Path.GetDirectoryName(asm.Location);
+            Assert.IsNotNull(asmDir, asmDir);
+
+            var packagesDir = Path.GetFullPath(Path.Combine(asmDir, @"..\..\packages"));
+            Assert.IsTrue(Directory.Exists(packagesDir), packagesDir);
+
+            var packageDir = Directory.GetDirectories(packagesDir, packageDirName).Single();
+            Assert.IsTrue(Directory.Exists(packageDir), packageDir);
+
+            var exePath = Path.Combine(packageDir, @"lib\net40\Apache.Ignite.exe");
+            Assert.IsTrue(File.Exists(exePath), exePath);
+
+            var springPath = Path.GetFullPath(@"config\ignite-config.xml");
+            Assert.IsTrue(File.Exists(springPath), springPath);
+
+            var procInfo = new ProcessStartInfo(exePath, "-springConfigUrl=" + springPath)
+            {
+                CreateNoWindow = true,
+                UseShellExecute = false,
+                RedirectStandardOutput = true,
+                RedirectStandardError = true
+            };
+            
+            var proc = Process.Start(procInfo);
+            Assert.IsNotNull(proc);
+            Assert.IsFalse(proc.HasExited);
+
+            TestUtil.AttachProcessConsoleReader(proc);
+
+            using (var ignite = Ignition.Start(@"config\ignite-config.xml"))
+            {
+                for (var i = 0; i < 100; i++)
+                {
+                    if (ignite.GetCluster().GetNodes().Count == 2)
+                    {
+                        return;
+                    }
+
+                    Thread.Sleep(100);
+                }
+                
+                Assert.Fail("Failed to join to remote node.");
+            }
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/8237ac6f/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/TestUtil.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/TestUtil.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/TestUtil.cs
index 43e5097..2f0a110 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/TestUtil.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/TestUtil.cs
@@ -17,6 +17,10 @@
 
 namespace Apache.Ignite.Core.Tests.NuGet
 {
+    using System;
+    using System.Diagnostics;
+    using System.IO;
+    using System.Threading;
     using Apache.Ignite.Core.Discovery;
     using Apache.Ignite.Core.Discovery.Tcp;
     using Apache.Ignite.Core.Discovery.Tcp.Static;
@@ -39,5 +43,31 @@ namespace Apache.Ignite.Core.Tests.NuGet
                 }
             };
         }
+
+        /// <summary>
+        /// Attaches the process console reader.
+        /// </summary>
+        public static void AttachProcessConsoleReader(Process process)
+        {
+            Attach(process, process.StandardOutput, false);
+            Attach(process, process.StandardError, true);
+        }
+
+        /// <summary>
+        /// Attach output reader to the process.
+        /// </summary>
+        private static void Attach(Process proc, TextReader reader, bool err)
+        {
+            new Thread(() =>
+            {
+                while (!proc.HasExited)
+                {
+                    Console.WriteLine(err ? ">>> {0} ERR: {1}" : ">>> {0}
OUT: {1}", proc.Id, reader.ReadLine());
+                }
+            })
+            {
+                IsBackground = true
+            }.Start();
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/8237ac6f/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.nuspec
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.nuspec b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.nuspec
index 8f562f1..7dc9f9a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.nuspec
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.nuspec
@@ -53,9 +53,10 @@ More info: https://apacheignite-net.readme.io/
         <file src="NuGet\Install.ps1" target="tools" />
         <file src="NuGet\Uninstall.ps1" target="tools" />
         <file src="NuGet\PostBuild.ps1" target="tools" />
-        
-        <!-- Other files should go to Content folder to be automatically included in project.
-->
-        <!--<file src="..\..\..\..\config\default-config.xml" target="Content\Config"
/>-->
+
+        <!-- Include Apache.Ignite.exe -->
+        <file src="..\Apache.Ignite\bin\$configuration$\Apache.Ignite.exe" target="lib\net40"
/>
+        <file src="..\Apache.Ignite\bin\$configuration$\Apache.Ignite.exe.config" target="lib\net40"
/>
         
         <!-- 
             Library files (jars) should not be included in project, so that NuGet package
restore works properly.

http://git-wip-us.apache.org/repos/asf/ignite/blob/8237ac6f/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteHome.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteHome.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteHome.cs
index 0290095..3d4ad4d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteHome.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteHome.cs
@@ -116,7 +116,8 @@ namespace Apache.Ignite.Core.Impl.Common
                        || // NuGet home
                        (dir.EnumerateDirectories().Any(x => x.Name == "Libs") &&
                         (dir.EnumerateFiles("Apache.Ignite.Core.dll").Any() ||
-                         dir.EnumerateFiles("Apache.Ignite.*.nupkg").Any()));
+                         dir.EnumerateFiles("Apache.Ignite.*.nupkg").Any() ||
+                         dir.EnumerateFiles("Apache.Ignite.nuspec").Any()));
             }
             catch (IOException)
             {

http://git-wip-us.apache.org/repos/asf/ignite/blob/8237ac6f/modules/platforms/dotnet/Apache.Ignite/App.config
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite/App.config b/modules/platforms/dotnet/Apache.Ignite/App.config
index d1d6643..8550529 100644
--- a/modules/platforms/dotnet/Apache.Ignite/App.config
+++ b/modules/platforms/dotnet/Apache.Ignite/App.config
@@ -23,6 +23,10 @@
 -->
 
 <configuration>
+    <configSections>
+        <section name="igniteConfiguration" type="Apache.Ignite.Core.IgniteConfigurationSection,
Apache.Ignite.Core" />
+    </configSections>
+    
     <startup>
         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
     </startup>
@@ -31,7 +35,14 @@
         <gcServer enabled="true" />
     </runtime>
 
+    <igniteConfiguration xmlns="http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection">
+        <!-- Customize Ignite configuration here. -->
+    </igniteConfiguration>
+
     <appSettings>
+        <!-- Use Ignite configuration section defined above. -->
+        <add key="Ignite.ConfigSectionName" value="igniteConfiguration" />
+        
         <!-- Path to spring configuration file relative from IGNITE_HOME (if not provided
"config/default-config.xml" is used) -->
         <!-- <add key="Ignite.SpringConfigUrl" value="my-config.xml"/> -->
 


Mime
View raw message