public void TestIisBehavior() { var ignite = Ignition.Start(GetConfig()); var cache = ignite.CreateCache <int, int>(new CacheConfiguration { Name = CacheName, CacheMode = CacheMode.Replicated // Use Replicated to avoid data loss due to node stop. }); cache[1] = 1; // Check same domain. new DomainRunner().RunTest(); var type = typeof(DomainRunner); Assert.IsNotNull(type.FullName); // Start and stop domains. for (var i = 0; i < 10; i++) { var domain = CreateDomain(i); var runner = (DomainRunner)domain.CreateInstanceAndUnwrap(type.Assembly.FullName, type.FullName); runner.RunTest(); // Verify node start. var expectedNodeCount = Math.Min(i + 3, 7); Assert.AreEqual(expectedNodeCount, ignite.GetCluster().GetNodes().Count); // Current AppDomain does not see other instances. Assert.AreEqual(2, Ignition.GetAll().Count); if (i > 3) { var oldDomain = _domains[i - 3]; _domains[i - 3] = null; AppDomain.Unload(oldDomain); // Verify node exit. TestUtils.WaitForCondition( () => ignite.GetCluster().GetNodes().Count == expectedNodeCount - 1, 5000); } } UnloadDomains(); // Verify node exit: only two nodes from current domain should be there. TestUtils.WaitForCondition(() => ignite.GetCluster().GetNodes().Count == 2, 5000); }
/// <summary> /// Waits for server node to fully start. /// </summary> private static bool WaitForStart() { return(TestUtils.WaitForCondition(() => { try { // Port 10890 is set in Runner.java using (var client = Ignition.StartClient(GetClientConfiguration())) { // Create cache to ensure valid grid state. client.GetOrCreateCache <int, int>(typeof(JavaServer).FullName); return true; } } catch (Exception) { return false; } }, 180000)); }
/// <summary> /// Waits for server node to fully start. /// </summary> private static bool WaitForStart(ListDataReader reader) { return(TestUtils.WaitForCondition( () => reader.GetOutput().Any(m => m.Contains("Ignite node started OK")), 60 * 3 * 1000)); }
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); } }