public void TestXmlConfigurationReferencesTypesFromDynamicallyLoadedAssemblies() { const string code = @" using System; using Apache.Ignite.Core.Log; namespace CustomNs { class CustomLogger : ILogger { public void Log(LogLevel level, string message, object[] args, IFormatProvider formatProvider, string category, string nativeErrorInfo, Exception ex) {} public bool IsEnabled(LogLevel level) { return true; } } }"; var dllPath = GenerateDll("CustomAsm.dll", true, code); var proc = new IgniteProcess( "-configFileName=config\\ignite-dotnet-cfg-logger.xml", "-assembly=" + dllPath); Assert.IsTrue(proc.Alive); Assert.IsTrue(_grid.WaitTopology(2)); var remoteCfg = RemoteConfig(); Assert.AreEqual("CustomNs.CustomLogger", remoteCfg.LoggerTypeName); }
public void TestCustomDeployment() { // Create temp folder var folder = _tempFolder; DeployTo(folder); // Build classpath var classpath = string.Join(";", Directory.GetFiles(folder).Select(Path.GetFileName)); // Copy config var springPath = Path.GetFullPath("config\\compute\\compute-grid2.xml"); var springFile = Path.GetFileName(springPath); File.Copy(springPath, Path.Combine(folder, springFile)); // Start a node and make sure it works properly var exePath = Path.Combine(folder, "Apache.Ignite.exe"); var proc = IgniteProcess.Start(exePath, string.Empty, args: new[] { "-springConfigUrl=" + springFile, "-jvmClasspath=" + classpath, "-assembly=" + Path.GetFileName(GetType().Assembly.Location), "-J-ea", "-J-Xms512m", "-J-Xmx512m" }); Assert.IsNotNull(proc); VerifyNodeStarted(exePath); }
public void TestConfig() { IgniteProcess.ReplaceConfiguration("config\\Apache.Ignite.exe.config.test"); GenerateDll("test-1.dll"); GenerateDll("test-2.dll"); var proc = new IgniteProcess(); Assert.IsTrue(proc.Alive); Assert.IsTrue(_grid.WaitTopology(2)); var cfg = RemoteConfig(); Assert.AreEqual(SpringCfgPath, cfg.SpringConfigUrl); Assert.AreEqual(602, cfg.JvmInitialMemoryMb); Assert.AreEqual(702, cfg.JvmMaxMemoryMb); CollectionAssert.Contains(cfg.LoadedAssemblies, "test-1"); CollectionAssert.Contains(cfg.LoadedAssemblies, "test-2"); Assert.Null(cfg.Assemblies); CollectionAssert.Contains(cfg.JvmOptions, "-DOPT1"); CollectionAssert.Contains(cfg.JvmOptions, "-DOPT2"); }
public void TestMissingJarsCauseProperException() { // Create temp folder var folder = _tempFolder; DeployTo(folder); // Build classpath var classpath = string.Join(";", Directory.GetFiles(folder).Where(x => !x.Contains("ignite-core-")).Select(Path.GetFileName)); // Start a node and check the exception. var exePath = Path.Combine(folder, "Apache.Ignite.exe"); var reader = new ListDataReader(); var proc = IgniteProcess.Start(exePath, string.Empty, args: new[] { "-jvmClasspath=" + classpath, "-J-ea", "-J-Xms512m", "-J-Xmx512m" }, outReader: reader); // Wait for process to fail. Assert.IsNotNull(proc); Assert.IsTrue(proc.WaitForExit(10000)); Assert.IsTrue(proc.HasExited); Assert.AreEqual(-1, proc.ExitCode); // Check error message. Assert.AreEqual("ERROR: Apache.Ignite.Core.Common.IgniteException: Java class is not found " + "(did you set IGNITE_HOME environment variable?): " + "org/apache/ignite/internal/processors/platform/PlatformIgnition", reader.GetOutput().First()); }
public void TearDown() { Ignition.StopAll(true); IgniteProcess.KillAll(); Directory.Delete(_tempFolder, true); }
public void TearDown() { Ignition.StopAll(true); TestUtils.KillProcesses(); IgniteProcess.RestoreConfigurationBackup(); }
/// <summary> /// Stops standalone nodes. /// </summary> private void StopRemoteNodes() { if (_remoteNodeStarted) { IgniteProcess.KillAll(); _remoteNodeStarted = false; } }
public void FixtureTearDown() { _changedConfig.Dispose(); Ignition.StopAll(true); IgniteProcess.KillAll(); }
public void SetUp() { TestUtils.KillProcesses(); Assert.IsTrue(_grid.WaitTopology(1, 30000)); IgniteProcess.SaveConfigurationBackup(); }
public void StopClient() { Ignition.StopAll(true); if (_fork) { IgniteProcess.KillAll(); } }
public void SetUp() { TestUtils.KillProcesses(); _grid = Ignition.Start(Configuration(SpringCfgPath)); Assert.IsTrue(_grid.WaitTopology(1)); IgniteProcess.SaveConfigurationBackup(); }
public void TearDown() { Ignition.StopAll(true); TestUtils.KillProcesses(); IgniteProcess.RestoreConfigurationBackup(); Directory.Delete(_tempDir, true); }
public void TestInvalidCmdArgs() { var ignoredWarns = new[] { "WARNING: An illegal reflective access operation has occurred", "WARNING: Illegal reflective access by org.apache.ignite.internal.util.GridUnsafe$2 " + "(file:/C:/w/incubator-ignite/modules/core/target/classes/) to field java.nio.Buffer.address", "WARNING: Please consider reporting this to the maintainers of org.apache.ignite.internal.util." + "GridUnsafe$2", "WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations", "WARNING: All illegal access operations will be denied in a future release" }; Action <string, string> checkError = (args, err) => { var reader = new ListDataReader(); var proc = new IgniteProcess(reader, args); int exitCode; Assert.IsTrue(proc.Join(30000, out exitCode)); Assert.AreEqual(-1, exitCode); Assert.AreEqual(err, reader.GetOutput() .Except(ignoredWarns) .FirstOrDefault(x => !string.IsNullOrWhiteSpace(x))); }; checkError("blabla", "ERROR: Apache.Ignite.Core.Common.IgniteException: Missing argument value: " + "'blabla'. See 'Apache.Ignite.exe /help'"); checkError("blabla=foo", "ERROR: Apache.Ignite.Core.Common.IgniteException: " + "Unknown argument: 'blabla'. See 'Apache.Ignite.exe /help'"); checkError("assembly=", "ERROR: Apache.Ignite.Core.Common.IgniteException: Missing argument value: " + "'assembly'. See 'Apache.Ignite.exe /help'"); checkError("assembly=x.dll", "ERROR: Apache.Ignite.Core.Common.IgniteException: Failed to start " + "Ignite.NET, check inner exception for details ---> Apache.Ignite.Core." + "Common.IgniteException: Failed to load assembly: x.dll"); checkError("configFileName=wrong.config", "ERROR: System.Configuration.ConfigurationErrorsException: " + "Specified config file does not exist: wrong.config"); checkError("configSectionName=wrongSection", "ERROR: System.Configuration.ConfigurationErrorsException: " + "Could not find IgniteConfigurationSection " + "in current application configuration"); checkError("JvmInitialMemoryMB=A_LOT", "ERROR: System.InvalidOperationException: Failed to configure " + "Ignite: property 'JvmInitialMemoryMB' has value 'A_LOT', " + "which is not an integer."); checkError("JvmMaxMemoryMB=ALL_OF_IT", "ERROR: System.InvalidOperationException: Failed to configure " + "Ignite: property 'JvmMaxMemoryMB' has value 'ALL_OF_IT', " + "which is not an integer."); }
public void FixtureTearDown() { _changedConfig.Dispose(); Ignition.StopAll(true); IgniteProcess.KillAll(); File.Delete(_configPath); _changedEnvVar.Dispose(); }
/// <summary> /// Tests the example with standalone Apache.Ignite.exe nodes. /// </summary> /// <param name="example">The example to run.</param> /// <param name="clientMode">Client mode flag.</param> private static void TestRemoteNodes(Example example, bool clientMode) { // Exclude CrossPlatformExample and LifecycleExample if (string.IsNullOrEmpty(example.SpringConfigUrl)) { Assert.IsTrue(new[] { "CrossPlatformExample", "LifecycleExample" }.Contains(example.Name)); return; } // First node to start in current process defines JVM options. var gridConfig = new IgniteConfiguration { SpringConfigUrl = example.SpringConfigUrl, JvmOptions = new[] { "-Xms512m", "-Xmx1024m", "-Xdebug", "-Xnoagent", "-Djava.compiler=NONE", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" } }; // 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; using (var ignite = Ignition.Start(gridConfig)) { var args = new List <string> { "-springConfigUrl=" + example.SpringConfigUrl }; if (example.NeedsTestDll) { args.Add(" -assembly=" + typeof(AverageSalaryJob).Assembly.Location); } var proc = new IgniteProcess(args.ToArray()); Assert.IsTrue(ignite.WaitTopology(i + 2, 30000)); Assert.IsTrue(proc.Alive); } Ignition.ClientMode = clientMode; // Run twice to catch issues with standalone node state example.Run(); example.Run(); } }
public void InitClient() { TestUtils.KillProcesses(); if (_fork) { Grid1 = Ignition.Start(Configuration("config\\compute\\compute-standalone.xml")); _proc2 = Fork("config\\compute\\compute-standalone.xml"); while (true) { if (!_proc2.Alive) { throw new Exception("Process 2 died unexpectedly: " + _proc2.Join()); } if (Grid1.GetCluster().GetNodes().Count < 2) { Thread.Sleep(100); } else { break; } } _proc3 = Fork("config\\compute\\compute-standalone.xml"); while (true) { if (!_proc3.Alive) { throw new Exception("Process 3 died unexpectedly: " + _proc3.Join()); } if (Grid1.GetCluster().GetNodes().Count < 3) { Thread.Sleep(100); } else { break; } } } else { Grid1 = Ignition.Start(Configuration("config\\compute\\compute-grid1.xml")); _grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml")); _grid3 = Ignition.Start(Configuration("config\\compute\\compute-grid3.xml")); } }
/// <summary> /// Tests the peer deployment. /// </summary> public static void TestDeployment(Action <IIgnite> test, bool enablePeerDeployment = true) { // Copy Apache.Ignite.exe and Apache.Ignite.Core.dll // to a separate folder so that it does not locate our assembly automatically. var folder = PathUtils.GetTempDirectoryName(); foreach (var asm in new[] { typeof(IgniteRunner).Assembly, typeof(Ignition).Assembly }) { Assert.IsNotNull(asm.Location); File.Copy(asm.Location, Path.Combine(folder, Path.GetFileName(asm.Location))); } var exePath = Path.Combine(folder, "Apache.Ignite.exe"); // Start separate Ignite process without loading current dll. // ReSharper disable once AssignNullToNotNullAttribute var config = Path.Combine( Path.GetDirectoryName(typeof(PeerAssemblyLoadingTest).Assembly.Location), "Deployment", "peer_assembly_app.config"); var proc = IgniteProcess.Start(exePath, IgniteHome.Resolve(), null, "-ConfigFileName=" + config, "-ConfigSectionName=igniteConfiguration"); try { Thread.Sleep(300); Assert.IsFalse(proc.HasExited); // Start Ignite and execute computation on remote node. var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { PeerAssemblyLoadingMode = enablePeerDeployment ? PeerAssemblyLoadingMode.CurrentAppDomain : PeerAssemblyLoadingMode.Disabled }; using (var ignite = Ignition.Start(cfg)) { Assert.IsTrue(ignite.WaitTopology(2)); for (var i = 0; i < 10; i++) { test(ignite); } } } finally { proc.Kill(); proc.WaitForExit(); } }
public void TestProcessorInit() { var cfg = new IgniteConfiguration { SpringConfigUrl = "Config\\spring-test.xml", JvmOptions = TestUtils.TestJavaOptions(), JvmClasspath = TestUtils.CreateTestClasspath() }; // Start local node var grid = Ignition.Start(cfg); // Start remote node in a separate process // ReSharper disable once UnusedVariable var proc = new IgniteProcess( "-jvmClasspath=" + TestUtils.CreateTestClasspath(), "-springConfigUrl=" + Path.GetFullPath(cfg.SpringConfigUrl), "-J-Xms512m", "-J-Xmx512m"); Assert.IsTrue(proc.Alive); var cts = new CancellationTokenSource(); var token = cts.Token; // Spam message subscriptions on a separate thread // to test race conditions during processor init on remote node var listenTask = Task.Factory.StartNew(() => { var filter = new MessageListener(); while (!token.IsCancellationRequested) { var listenId = grid.GetMessaging().RemoteListen(filter); grid.GetMessaging().StopRemoteListen(listenId); } // ReSharper disable once FunctionNeverReturns }); // Wait for remote node to join Assert.IsTrue(grid.WaitTopology(2)); // Wait some more for initialization Thread.Sleep(1000); // Cancel listen task and check that it finishes cts.Cancel(); Assert.IsTrue(listenTask.Wait(5000)); }
public void TestXmlConfigurationCmd() { var proc = new IgniteProcess("-jvmClasspath=" + TestUtils.CreateTestClasspath(), "-configFileName=config\\ignite-dotnet-cfg.xml"); Assert.IsTrue(_grid.WaitTopology(2)); var remoteCfg = RemoteConfig(); Assert.IsTrue(remoteCfg.JvmOptions.Contains("-DOPT25")); proc.Kill(); Assert.IsTrue(_grid.WaitTopology(1)); }
public void TestJvmOptsCmd() { var proc = new IgniteProcess( "-jvmClasspath=" + TestUtils.CreateTestClasspath(), "-springConfigUrl=" + SpringCfgPath, "-J-DOPT1", "-J-DOPT2" ); Assert.IsTrue(_grid.WaitTopology(2)); var cfg = RemoteConfig(); Assert.IsTrue(cfg.JvmOptions.Contains("-DOPT1") && cfg.JvmOptions.Contains("-DOPT2")); }
public void TestJvmOptsCmd() { var proc = new IgniteProcess( "-springConfigUrl=" + SpringCfgPath, "-J-DOPT1", "-J-DOPT2" ); Assert.IsTrue(proc.Alive); Assert.IsTrue(_grid.WaitTopology(2)); var cfg = RemoteConfig(); Assert.IsTrue(cfg.JvmOptions.Contains("-DOPT1") && cfg.JvmOptions.Contains("-DOPT2")); }
public void TestXmlConfigurationAppConfig() { IgniteProcess.ReplaceConfiguration("config\\Apache.Ignite.exe.config.test3"); var proc = new IgniteProcess("-jvmClasspath=" + TestUtils.CreateTestClasspath()); Assert.IsTrue(_grid.WaitTopology(2)); var remoteCfg = RemoteConfig(); Assert.IsTrue(remoteCfg.JvmOptions.Contains("-DOPT25")); proc.Kill(); Assert.IsTrue(_grid.WaitTopology(1)); }
/// <summary> /// Stops the service and uninstalls it. /// </summary> private static void StopServiceAndUninstall() { var controller = GetIgniteService(); if (controller != null) { if (controller.CanStop) { controller.Stop(); } controller.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(30)); var exePath = typeof(IgniteRunner).Assembly.Location; IgniteProcess.Start(exePath, string.Empty, args: new[] { "/uninstall" }).WaitForExit(); } }
public void TestStopFromJava() { var startTime = DateTime.Now.AddSeconds(-1); var exePath = typeof(IgniteRunner).Assembly.Location; var springPath = Path.GetFullPath(@"config\compute\compute-grid1.xml"); JvmDll.Load(null, new NoopLogger()); var jvmDll = System.Diagnostics.Process.GetCurrentProcess().Modules .OfType <ProcessModule>() .Single(x => JvmDll.FileJvmDll.Equals(x.ModuleName, StringComparison.OrdinalIgnoreCase)); IgniteProcess.Start(exePath, string.Empty, args: new[] { "/install", "ForceTestClasspath=true", "-springConfigUrl=" + springPath, "-jvmDll=" + jvmDll.FileName }).WaitForExit(); var service = GetIgniteService(); Assert.IsNotNull(service); service.Start(); // see IGNITE_HOME\work\log for service instance logs WaitForStatus(service, startTime, ServiceControllerStatus.Running); using (var ignite = Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration()) { SpringConfigUrl = springPath })) { Assert.IsTrue(ignite.WaitTopology(2), "Failed to join with service node"); // Stop remote node via Java task // Doing so will fail the task execution Assert.Throws <ClusterGroupEmptyException>(() => ignite.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask <object>( "org.apache.ignite.platform.PlatformStopIgniteTask", ignite.Name)); Assert.IsTrue(ignite.WaitTopology(1), "Failed to stop remote node"); // Check that service has stopped. WaitForStatus(service, startTime, ServiceControllerStatus.Stopped); } }
public void TestInvalidCmdArgs() { Action <string, string> checkError = (args, err) => { var reader = new ListDataReader(); var proc = new IgniteProcess(reader, args); int exitCode; Assert.IsTrue(proc.Join(30000, out exitCode)); Assert.AreEqual(-1, exitCode); lock (reader.List) { Assert.AreEqual(err, reader.List.FirstOrDefault(x => !string.IsNullOrWhiteSpace(x))); } }; checkError("blabla", "ERROR: Apache.Ignite.Core.Common.IgniteException: Missing argument value: " + "'blabla'. See 'Apache.Ignite.exe /help'"); checkError("blabla=foo", "ERROR: Apache.Ignite.Core.Common.IgniteException: " + "Unknown argument: 'blabla'. See 'Apache.Ignite.exe /help'"); checkError("assembly=", "ERROR: Apache.Ignite.Core.Common.IgniteException: Missing argument value: " + "'assembly'. See 'Apache.Ignite.exe /help'"); checkError("assembly=x.dll", "ERROR: Apache.Ignite.Core.Common.IgniteException: Failed to start " + "Ignite.NET, check inner exception for details ---> Apache.Ignite.Core." + "Common.IgniteException: Failed to load assembly: x.dll"); checkError("configFileName=wrong.config", "ERROR: System.Configuration.ConfigurationErrorsException: " + "Specified config file does not exist: wrong.config"); checkError("configSectionName=wrongSection", "ERROR: System.Configuration.ConfigurationErrorsException: " + "Could not find IgniteConfigurationSection " + "in current application configuration"); checkError("JvmInitialMemoryMB=A_LOT", "ERROR: System.InvalidOperationException: Failed to configure " + "Ignite: property 'JvmInitialMemoryMB' has value 'A_LOT', " + "which is not an integer."); checkError("JvmMaxMemoryMB=ALL_OF_IT", "ERROR: System.InvalidOperationException: Failed to configure " + "Ignite: property 'JvmMaxMemoryMB' has value 'ALL_OF_IT', " + "which is not an integer."); }
public void TestAssemblyCmd() { GenerateDll("test-1.dll"); GenerateDll("test-2.dll"); var proc = new IgniteProcess( "-jvmClasspath=" + TestUtils.CreateTestClasspath(), "-springConfigUrl=" + SpringCfgPath, "-assembly=test-1.dll", "-assembly=test-2.dll" ); Assert.IsTrue(_grid.WaitTopology(2)); var cfg = RemoteConfig(); Assert.IsTrue(cfg.Assemblies.Contains("test-1.dll") && cfg.Assemblies.Contains("test-2.dll")); }
public void TestAssemblyCmd() { var dll1 = GenerateDll("test-1.dll", true); var dll2 = GenerateDll("test-2.dll", true); var proc = new IgniteProcess( "-springConfigUrl=" + SpringCfgPath, "-assembly=" + dll1, "-assembly=" + dll2); Assert.IsTrue(proc.Alive); Assert.IsTrue(_grid.WaitTopology(2)); var cfg = RemoteConfig(); CollectionAssert.Contains(cfg.LoadedAssemblies, "test-1"); CollectionAssert.Contains(cfg.LoadedAssemblies, "test-2"); }
/// <summary> /// Tests the example with standalone Apache.Ignite.exe nodes. /// </summary> /// <param name="example">The example to run.</param> /// <param name="clientMode">Client mode flag.</param> private static void TestRemoteNodes(Example example, bool clientMode) { // Exclude LifecycleExample if (string.IsNullOrEmpty(example.ConfigPath)) { Assert.AreEqual("LifecycleExample", example.Name); return; } var configPath = Path.Combine(PathUtil.IgniteHome, PathUtil.DevPrefix, example.ConfigPath); // 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; using (var ignite = Ignition.StartFromApplicationConfiguration( "igniteConfiguration", configPath)) { var args = new List <string> { "-configFileName=" + configPath }; if (example.NeedsTestDll) { args.Add(" -assembly=" + typeof(AverageSalaryJob).Assembly.Location); } var proc = new IgniteProcess(args.ToArray()); Assert.IsTrue(ignite.WaitTopology(i + 2)); Assert.IsTrue(proc.Alive); } Ignition.ClientMode = clientMode; // Run twice to catch issues with standalone node state example.Run(); example.Run(); } }
/// <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; var fileMap = new ExeConfigurationFileMap { ExeConfigFilename = _configPath }; var config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); var section = (IgniteConfigurationSection)config.GetSection("igniteConfiguration"); // Disable client connector so that temporary node does not occupy the port. var cfg = new IgniteConfiguration(section.IgniteConfiguration) { ClientConnectorConfigurationEnabled = false, CacheConfiguration = null }; using (var ignite = Ignition.Start(cfg)) { var args = new List <string> { "-configFileName=" + _configPath, "-assembly=" + typeof(ExamplesDll::Apache.Ignite.ExamplesDll.Compute.AverageSalaryJob) .Assembly.Location }; var proc = new IgniteProcess(args.ToArray()); 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; }
public void TestJvmMemoryOptsCmdCustom() { var proc = new IgniteProcess( "-jvmClasspath=" + TestUtils.CreateTestClasspath(), "-springConfigUrl=" + SpringCfgPath, "-JvmInitialMemoryMB=615", "-JvmMaxMemoryMB=863" ); Assert.IsTrue(_grid.WaitTopology(2)); var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask <long>(MinMemTask, null); Assert.AreEqual((long)615 * 1024 * 1024, minMem); var maxMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask <long>(MaxMemTask, null); AssertJvmMaxMemory((long)863 * 1024 * 1024, maxMem); }