Exemple #1
0
        public void TestMissingJarsCauseProperException()
        {
            var dllFolder  = Path.Combine(_tempFolder, "foo");
            var jarFolder  = Path.Combine(_tempFolder, "bar", "libs");
            var homeFolder = Directory.GetParent(jarFolder).FullName;

            DeployTo(dllFolder, jarFolder);

            // Remove some jars.
            Directory.GetFiles(jarFolder, "cache-api-1.0.0.jar").ToList().ForEach(File.Delete);

            // Start a node and check the exception.
            var exePath = Path.Combine(dllFolder, "Apache.Ignite.exe");
            var reader  = new ListDataReader();

            var proc = IgniteProcess.Start(exePath, homeFolder, reader);

            // Wait for process to fail.
            Assert.IsNotNull(proc);
            Assert.IsTrue(proc.WaitForExit(30000));
            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/utils/PlatformUtils",
                            reader.GetOutput().First());
        }
Exemple #2
0
        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());
        }
Exemple #3
0
        /// <summary>
        /// Tests deployment to custom folders.
        /// </summary>
        private void TestDeployment(string dllFolder, string jarFolder, bool buildClasspath)
        {
            DeployTo(dllFolder, jarFolder);

            // Copy config
            var springPath = Path.GetFullPath("config\\compute\\compute-grid2.xml");
            var springFile = Path.GetFileName(springPath);

            File.Copy(springPath, Path.Combine(dllFolder, springFile));

            // Start a node and make sure it works properly
            var exePath = Path.Combine(dllFolder, "Apache.Ignite.exe");

            var args = new List <string>
            {
                "-springConfigUrl=" + springFile,
                "-assembly=" + Path.GetFileName(GetType().Assembly.Location),
                "-J-ea",
                "-J-Xms512m",
                "-J-Xmx512m"
            };

            if (buildClasspath)
            {
                args.Add("-jvmClasspath=" + string.Join(";", Directory.GetFiles(jarFolder)));
            }

            var proc = IgniteProcess.Start(exePath, string.Empty, args: args.ToArray());

            Assert.IsNotNull(proc);

            VerifyNodeStarted(exePath);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        /// <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, typeof(ConfigurationManager).Assembly })
            {
                Assert.IsNotNull(asm.Location);
                File.Copy(asm.Location, Path.Combine(folder, Path.GetFileName(asm.Location)));
            }

            // ReSharper disable once AssignNullToNotNullAttribute
            var cfgMan = Path.Combine(
                Path.GetDirectoryName(typeof(Ignition).Assembly.Location),
                "System.Configuration.ConfigurationManager.dll");

            File.Copy(cfgMan, Path.Combine(folder, Path.GetFileName(cfgMan)));

            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();
            }
        }
Exemple #6
0
        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);
            }
        }
Exemple #7
0
        /// <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();
            }
        }
Exemple #8
0
        /// <summary>
        /// Tests deployment to custom folders.
        /// </summary>
        private void TestDeployment(string dllFolder, string jarFolder, bool buildClasspath)
        {
            DeployTo(dllFolder, jarFolder);

            // Copy config
            var springPath = Path.GetFullPath("Config/Compute/compute-grid2.xml");
            var springFile = Path.GetFileName(springPath);

            File.Copy(springPath, Path.Combine(dllFolder, springFile));

            // Start a node and make sure it works properly
            var exePath = Path.Combine(dllFolder, "Apache.Ignite.exe");

            Assert.IsTrue(File.Exists(exePath));

            var args = new List <string>
            {
                "-springConfigUrl=" + springFile,
                "-assembly=" + Path.GetFileName(GetType().Assembly.Location),
                "-J-ea",
                "-J-Xms512m",
                "-J-Xmx512m"
            };

            if (buildClasspath)
            {
                args.Add("-jvmClasspath=" + string.Join(";", Directory.GetFiles(jarFolder)));
            }

            var reader = new ListDataReader();
            var proc   = IgniteProcess.Start(exePath, string.Empty, reader, args.ToArray());

            Assert.IsNotNull(proc);

            if (proc.WaitForExit(300))
            {
                Assert.Fail("Node failed to start: " + string.Join("\n", reader.GetOutput()));
            }

            VerifyNodeStarted(exePath);
        }
Exemple #9
0
        public void TestStopFromJava()
        {
            var exePath    = typeof(IgniteRunner).Assembly.Location;
            var springPath = Path.GetFullPath(@"config\compute\compute-grid1.xml");

            IgniteProcess.Start(exePath, string.Empty, args: new[]
            {
                "/install",
                "ForceTestClasspath=true",
                "-springConfigUrl=" + springPath,
                "-J-Xms513m",
                "-J-Xmx555m"
            }).WaitForExit();

            var service = GetIgniteService();

            Assert.IsNotNull(service);

            service.Start();  // see IGNITE_HOME\work\log for service instance logs
            service.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(30));

            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
                service.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(30));
            }
        }
        public void TestCustomDeployment()
        {
            // Create temp folder
            var folder = GetTempFolder();

            // Copy jars
            var home = IgniteHome.Resolve(null);

            var jarNames = new[] { @"\ignite-core-", @"\cache-api-1.0.0.jar", @"\modules\spring\" };

            var jars = Directory.GetFiles(home, "*.jar", SearchOption.AllDirectories)
                       .Where(jarPath => jarNames.Any(jarPath.Contains)).ToArray();

            Assert.Greater(jars.Length, 3);

            foreach (var jar in jars)
            {
                // ReSharper disable once AssignNullToNotNullAttribute
                File.Copy(jar, Path.Combine(folder, Path.GetFileName(jar)), true);
            }

            // Build classpath
            var classpath = string.Join(";", Directory.GetFiles(folder).Select(Path.GetFileName));

            // Copy .NET binaries
            foreach (var asm in new[] { typeof(IgniteRunner).Assembly, typeof(Ignition).Assembly, GetType().Assembly })
            {
                File.Copy(asm.Location, Path.Combine(folder, Path.GetFileName(asm.Location)));
            }

            // 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,
                "-J-ea",
                "-J-Xcheck:jni",
                "-J-Xms512m",
                "-J-Xmx512m"
            });

            Assert.IsNotNull(proc);

            try
            {
                VerifyNodeStarted(exePath);
            }
            finally
            {
                proc.Kill();

                Assert.IsTrue(
                    TestUtils.WaitForCondition(() =>
                {
                    try
                    {
                        Directory.Delete(folder, true);
                        return(true);
                    }
                    catch (Exception)
                    {
                        return(false);
                    }
                }, 1000), "Failed to remove temp directory: " + folder);
            }
        }