예제 #1
0
        public void TestConfigurationAndStartup()
        {
            using (EnvVar.Set("IGNITE_NATIVE_TEST_CLASSPATH", bool.TrueString))
            {
                Assert.IsNull(Ignition.TryGetIgnite());

                // Test default config (picks up app.config section).
                CheckCacheAndStop("myGrid1", IgniteDbConfiguration.DefaultCacheNamePrefix, new IgniteDbConfiguration());

                // Specific config section.
                CheckCacheAndStop("myGrid2", "cacheName2",
                                  new IgniteDbConfiguration("igniteConfiguration2", "cacheName2", null));

                // Specific config section, nonexistent cache.
                CheckCacheAndStop("myGrid2", "newCache",
                                  new IgniteDbConfiguration("igniteConfiguration2", "newCache", null));

                // In-code configuration.
                CheckCacheAndStop("myGrid3", "myCache",
                                  new IgniteDbConfiguration(new IgniteConfiguration(TestUtils.GetTestConfiguration())
                {
                    IgniteInstanceName = "myGrid3"
                }, new CacheConfiguration("myCache_metadata")
                {
                    CacheMode     = CacheMode.Replicated,
                    AtomicityMode = CacheAtomicityMode.Transactional
                },
                                                            new CacheConfiguration("myCache_data")
                {
                    CacheMode = CacheMode.Replicated
                }, null),
                                  CacheMode.Replicated);

                // Existing instance.
                var ignite = Ignition.Start(TestUtils.GetTestConfiguration());
                CheckCacheAndStop(null, "123", new IgniteDbConfiguration(ignite,
                                                                         new CacheConfiguration("123_metadata")
                {
                    Backups       = 1,
                    AtomicityMode = CacheAtomicityMode.Transactional
                },
                                                                         new CacheConfiguration("123_data"), null));

                // Non-tx meta cache.
                var ex = Assert.Throws <IgniteException>(() => CheckCacheAndStop(null, "123",
                                                                                 new IgniteDbConfiguration(TestUtils.GetTestConfiguration(),
                                                                                                           new CacheConfiguration("123_metadata"),
                                                                                                           new CacheConfiguration("123_data"), null)));

                Assert.AreEqual("EntityFramework meta cache should be Transactional.", ex.Message);

                // Same cache names.
                var ex2 = Assert.Throws <ArgumentException>(() => CheckCacheAndStop(null, "abc",
                                                                                    new IgniteDbConfiguration(TestUtils.GetTestConfiguration(),
                                                                                                              new CacheConfiguration("abc"),
                                                                                                              new CacheConfiguration("abc"), null)));

                Assert.IsTrue(ex2.Message.Contains("Meta and Data cache can't have the same name."));
            }
        }
예제 #2
0
 public void TestNewMode()
 {
     // Run "TestOldMode" in a separate process with changed setting.
     using (EnvVar.Set(BinaryUtils.IgniteBinaryMarshallerUseStringSerializationVer2, "true"))
     {
         TestUtils.RunTestInNewProcess(GetType().FullName, "TestOldMode");
     }
 }
예제 #3
0
        public void TestBaselineTopologyAutoAdjustEnabledDisabled()
        {
            using (EnvVar.Set("IGNITE_BASELINE_AUTO_ADJUST_FEATURE_SUPPORT", "true"))
            {
                using (var ignite = Ignition.Start(GetPersistentConfiguration()))
                {
                    ICluster cluster = ignite.GetCluster();
                    cluster.SetActive(true);

                    bool isEnabled = cluster.IsBaselineAutoAdjustEnabled();
                    cluster.SetBaselineAutoAdjustEnabledFlag(!isEnabled);

                    Assert.AreNotEqual(isEnabled, cluster.IsBaselineAutoAdjustEnabled());
                }
            }
        }
예제 #4
0
        public void FixtureSetUp()
        {
            _changedEnvVar = EnvVar.Set(Classpath.EnvIgniteNativeTestClasspath, bool.TrueString);

            Directory.SetCurrentDirectory(PathUtil.IgniteHome);

            // Copy file to a temp location and replace multicast IP finder with static.
            _configPath = Path.GetTempFileName();

            var configText = File.ReadAllText(PathUtil.ExamplesAppConfigPath)
                             .Replace("TcpDiscoveryMulticastIpFinder", "TcpDiscoveryStaticIpFinder");

            File.WriteAllText(_configPath, configText);

            _changedConfig = TestAppConfig.Change(_configPath);
        }
예제 #5
0
        public void TestBaselineTopologyAutoAdjustTimeoutWriteRead()
        {
            const long newTimeout = 333000;

            using (EnvVar.Set("IGNITE_BASELINE_AUTO_ADJUST_FEATURE_SUPPORT", "true"))
            {
                using (var ignite = Ignition.Start(GetPersistentConfiguration()))
                {
                    ICluster cluster = ignite.GetCluster();
                    cluster.SetActive(true);

                    cluster.SetBaselineAutoAdjustTimeout(newTimeout);

                    Assert.AreEqual(newTimeout, cluster.GetBaselineAutoAdjustTimeout());
                }
            }
        }
예제 #6
0
        public void TestBaselineTopology()
        {
            using (EnvVar.Set("IGNITE_BASELINE_AUTO_ADJUST_ENABLED", "false"))
            {
                var cfg1 = new IgniteConfiguration(GetPersistentConfiguration())
                {
                    ConsistentId = "node1"
                };
                var cfg2 = new IgniteConfiguration(GetPersistentConfiguration())
                {
                    ConsistentId       = "node2",
                    IgniteInstanceName = "2"
                };

                using (var ignite = Ignition.Start(cfg1))
                {
                    // Start and stop to bump topology version.
                    Ignition.Start(cfg2);
                    Ignition.Stop(cfg2.IgniteInstanceName, true);

                    var cluster = ignite.GetCluster();
                    Assert.AreEqual(3, cluster.TopologyVersion);

                    // Can not set baseline while inactive.
                    var ex = Assert.Throws <IgniteException>(() => cluster.SetBaselineTopology(2));
                    Assert.AreEqual("Changing BaselineTopology on inactive cluster is not allowed.", ex.Message);

                    cluster.SetActive(true);

                    // Can not set baseline with offline node.
                    ex = Assert.Throws <IgniteException>(() => cluster.SetBaselineTopology(2));
                    Assert.AreEqual("Check arguments. Node with consistent ID [node2] not found in server nodes.",
                                    ex.Message);

                    cluster.SetBaselineTopology(1);
                    Assert.AreEqual("node1", cluster.GetBaselineTopology().Single().ConsistentId);

                    // Set with node.
                    cluster.SetBaselineTopology(cluster.GetBaselineTopology());

                    var res = cluster.GetBaselineTopology();
                    CollectionAssert.AreEquivalent(new[] { "node1" }, res.Select(x => x.ConsistentId));

                    cluster.SetBaselineTopology(cluster.GetTopology(1));
                    Assert.AreEqual("node1", cluster.GetBaselineTopology().Single().ConsistentId);

                    // Can not set baseline with offline node.
                    ex = Assert.Throws <IgniteException>(() => cluster.SetBaselineTopology(cluster.GetTopology(2)));
                    Assert.AreEqual("Check arguments. Node with consistent ID [node2] not found in server nodes.",
                                    ex.Message);
                }

                // Check auto activation on cluster restart.
                using (var ignite = Ignition.Start(cfg1))
                    using (Ignition.Start(cfg2))
                    {
                        var cluster = ignite.GetCluster();
                        Assert.IsTrue(cluster.IsActive());

                        var res = cluster.GetBaselineTopology();
                        CollectionAssert.AreEquivalent(new[] { "node1" }, res.Select(x => x.ConsistentId));
                    }
            }
        }