Ejemplo n.º 1
0
        public void TestInitialConfigurationUpdate()
        {
            _mreConfig.Reset();
            _counters.Reset();

            // Send a config with two nodes
            var servers = new List <string>()
            {
                "127.0.0.1:11210", "127.0.0.2:11212"
            };

            _cluster.HandleConfigurationUpdate(GetValidConfig(servers));

            Assert.IsTrue(_mreConfig.Wait(TimeSpan.FromSeconds(2)), "The Couchbase cluster failed to receive the new config");

            Assert.AreEqual(2, _counters.NodesAdded, "nodes added");
            Assert.AreEqual(0, _counters.NodesRemoved, "nodes removed");
            Assert.AreEqual(0, _counters.Errors, "errors");
            CollectionAssert.AreEquivalent(servers, _cluster.Nodes.Select(n => n.EndPoint.ToString()), "Compare clusters nodes against the configuration (3)");

            var locator = _cluster.Locator as VBucketServerMapLocator;

            Assert.IsNotNull(locator);

            Assert.AreEqual(2, locator.Nodes.Count, "number of nodes");
            Assert.AreEqual(1024, locator.VBucketMap.Length);
            Assert.AreEqual(2, locator.VBucketMap[0].Length);
        }
        public void TestInitialConfigurationUpdate()
        {
            _nodesAdded = _nodesRemoved = 0;

            using (var update = new MemoryStream(Encoding.UTF8.GetBytes(SampleValidConfiguration)))
                _cluster.HandleConfigurationUpdate(update);

            Assert.AreEqual(2, _nodesAdded);
            Assert.AreEqual(0, _nodesRemoved);

            var locator = _cluster.Locator as VBucketServerMapLocator;

            Assert.IsNotNull(locator);

            Assert.AreEqual(2, locator.Nodes.Count);
            Assert.AreEqual(1024, locator.VBucketMap.Length);
            Assert.AreEqual(2, locator.VBucketMap[0].Length);
        }