Example #1
0
        public void Session_Execute_Throws_TimeoutException_When_QueryAbortTimeout_Elapsed()
        {
            var dummyCluster = Cluster.Builder().AddContactPoint("0.0.0.0").Build();

            Assert.AreNotEqual(dummyCluster.Configuration.ClientOptions.QueryAbortTimeout, Timeout.Infinite);
            try
            {
                using (var localCluster = Cluster.Builder()
                                          .AddContactPoint(TestCluster.InitialContactPoint)
                                          //Disable socket read timeout
                                          .WithSocketOptions(new SocketOptions().SetReadTimeoutMillis(0))
                                          //Set abort timeout at a low value
                                          .WithQueryTimeout(1500)
                                          .Build())
                {
                    var localSession = localCluster.Connect("system");
                    localSession.Execute("SELECT * FROM local");
                    TestCluster.PauseNode(1);
                    TestCluster.PauseNode(2);
                    Assert.Throws <TimeoutException>(() => localSession.Execute("SELECT * FROM local"));
                }
            }
            finally
            {
                TestCluster.ResumeNode(1);
                TestCluster.ResumeNode(2);
            }
        }
        public async Task Should_SchemaInAgreementReturnFalse_When_ADdlStatementIsExecutedAndOneNodeIsDown()
        {
            //// this test can't be done with simulacron because there's no support for schema_changed responses
            TestCluster.PauseNode(2);
            var tableName = TestUtils.GetUniqueTableName().ToLower();

            var cql = new SimpleStatement(
                $"CREATE TABLE {tableName} (id int PRIMARY KEY, description text)");
            var rowSet = await _session.ExecuteAsync(cql).ConfigureAwait(false);

            Assert.IsFalse(rowSet.Info.IsSchemaInAgreement);
        }
        public void SpeculativeExecution_Should_Execute_On_Next_Node()
        {
            var session = GetSession(new ConstantSpeculativeExecutionPolicy(50L, 1));

            TestCluster.PauseNode(2);
            Trace.TraceInformation("Node 2 paused");
            TestHelper.ParallelInvoke(() =>
            {
                var rs = session.Execute(new SimpleStatement(QueryLocal).SetIdempotence(true));
                Assert.AreNotEqual(_addressNode2, rs.Info.QueriedHost.Address);
            }, 10);
            TestCluster.ResumeNode(2);
        }
Example #4
0
        public void SpeculativeExecution_Should_Not_Execute_On_Next_Node_When_Not_Idempotent()
        {
            var lbp     = new OrderedLoadBalancingPolicy(2, 1, 3);
            var session = GetSession(new ConstantSpeculativeExecutionPolicy(50L, 1), true, lbp);

            TestCluster.PauseNode(2);
            var t = session.ExecuteAsync(new SimpleStatement(QueryLocal).SetIdempotence(false));

            Thread.Sleep(200);
            Assert.AreEqual(TaskStatus.WaitingForActivation, t.Status);
            TestCluster.ResumeNode(2);
            Thread.Sleep(200);
            Assert.AreEqual(TaskStatus.RanToCompletion, t.Status);
        }
        public async Task SpeculativeExecution_Should_Not_Execute_On_Next_Node_When_Not_Idempotent()
        {
            var lbp     = new OrderedLoadBalancingPolicy(2, 1);
            var session = GetSession(new ConstantSpeculativeExecutionPolicy(50L, 1), true, lbp);

            TestCluster.PauseNode(2);
            var t = session.ExecuteAsync(new SimpleStatement(QueryLocal).SetIdempotence(false));
            await Task.Delay(200).ConfigureAwait(false);

            Assert.AreEqual(TaskStatus.WaitingForActivation, t.Status);

            TestCluster.ResumeNode(2);
            var rs = await t.ConfigureAwait(false);

            // Used the first host in the query plan
            Assert.AreEqual(2, TestHelper.GetLastAddressByte(rs.Info.QueriedHost));
        }