示例#1
0
        public async Task Should_Remove_Decommissioned_Node()
        {
            const int numberOfNodes = 2;

            _realCluster = TestClusterManager.CreateNew(numberOfNodes);
            using (var cluster = Cluster.Builder().AddContactPoint(_realCluster.InitialContactPoint).Build())
            {
                await Connect(cluster, false, session =>
                {
                    Assert.AreEqual(numberOfNodes, cluster.AllHosts().Count);
                    if (TestClusterManager.SupportsDecommissionForcefully())
                    {
                        _realCluster.DecommissionNodeForcefully(numberOfNodes);
                    }
                    else
                    {
                        _realCluster.DecommissionNode(numberOfNodes);
                    }
                    _realCluster.Stop(numberOfNodes);
                    Trace.TraceInformation("Node decommissioned");
                    string decommisionedNode = null;
                    TestHelper.RetryAssert(() =>
                    {
                        decommisionedNode = _realCluster.ClusterIpPrefix + 2;
                        Assert.False(TestUtils.IsNodeReachable(IPAddress.Parse(decommisionedNode)));
                        //New node should be part of the metadata
                        Assert.AreEqual(1, cluster.AllHosts().Count);
                    }, 100, 100);
                    var queried = false;
                    for (var i = 0; i < 10; i++)
                    {
                        var rs = session.Execute("SELECT key FROM system.local");
                        if (rs.Info.QueriedHost.Address.ToString() == decommisionedNode)
                        {
                            queried = true;
                            break;
                        }
                    }
                    Assert.False(queried, "Removed node should be queried");
                }).ConfigureAwait(false);
            }
        }
        public async Task Should_Remove_Decommissioned_Node(bool asyncConnect)
        {
            const int numberOfNodes = 2;

            _testCluster = TestClusterManager.CreateNew(numberOfNodes);
            var cluster = Cluster.Builder()
                          .AddContactPoints(_testCluster.InitialContactPoint, _testCluster.ClusterIpPrefix + numberOfNodes)
                          .Build();

            await Run(cluster, asyncConnect, session =>
            {
                Assert.AreEqual(numberOfNodes, cluster.AllHosts().Count);
                if (TestClusterManager.DseVersion >= Version.Parse("5.1.0"))
                {
                    _testCluster.DecommissionNodeForcefully(numberOfNodes);
                }
                else
                {
                    _testCluster.DecommissionNode(numberOfNodes);
                }
                Trace.TraceInformation("Node decommissioned");
                Thread.Sleep(10000);
                var decommisionedNode = _testCluster.ClusterIpPrefix + numberOfNodes;
                Assert.False(TestUtils.IsNodeReachable(IPAddress.Parse(decommisionedNode)));
                //New node should be part of the metadata
                Assert.AreEqual(numberOfNodes - 1, cluster.AllHosts().Count);
                var queried = false;
                for (var i = 0; i < 10; i++)
                {
                    var rs = session.Execute("SELECT key FROM system.local");
                    if (rs.Info.QueriedHost.Address.ToString() == decommisionedNode)
                    {
                        queried = true;
                        break;
                    }
                }
                Assert.False(queried, "Removed node should be queried");
            });
        }