示例#1
0
        public void Warnings_With_Tracing_And_Custom_Payload_Test()
        {
            const string    query    = "BEGIN UNLOGGED BATCH INSERT INTO {0} (k, t) VALUES ('{1}', '{2}') APPLY BATCH";
            SimpleStatement insert   = new SimpleStatement(String.Format(query, Table, "warn1", String.Join("", Enumerable.Repeat("a", 5 * 1025))));
            var             outgoing = new Dictionary <string, byte[]> {
                { "k1", Encoding.UTF8.GetBytes("value1") }, { "k2", Encoding.UTF8.GetBytes("value2") }
            };

            insert.SetOutgoingPayload(outgoing);
            var rs = Session.Execute(insert.EnableTracing());

            Assert.NotNull(rs.Info.QueryTrace);
            CollectionAssert.AreEqual(outgoing["k1"], rs.Info.IncomingPayload["k1"]);
            CollectionAssert.AreEqual(outgoing["k2"], rs.Info.IncomingPayload["k2"]);
            //at cassandra 3.6 warnings changed according to CASSANDRA-10876
            var warningsChangingVersion = new Version(3, 6);

            if (CassandraVersion.CompareTo(warningsChangingVersion) < 0)
            {
                Assert.NotNull(rs.Info.Warnings);
                Assert.AreEqual(1, rs.Info.Warnings.Length);
                StringAssert.Contains("batch", rs.Info.Warnings[0].ToLowerInvariant());
                StringAssert.Contains("exceeding", rs.Info.Warnings[0].ToLowerInvariant());
            }
        }
 public void Query_Payload_Test()
 {
     var outgoing = new Dictionary<string, byte[]> { { "k1", Encoding.UTF8.GetBytes("value1") }, { "k2", Encoding.UTF8.GetBytes("value2") } };
     var stmt = new SimpleStatement("SELECT * FROM system.local");
     stmt.SetOutgoingPayload(outgoing);
     var rs = Session.Execute(stmt);
     Assert.NotNull(rs.Info.IncomingPayload);
     Assert.AreEqual(outgoing.Count, rs.Info.IncomingPayload.Count);
     CollectionAssert.AreEqual(outgoing["k1"], rs.Info.IncomingPayload["k1"]);
     CollectionAssert.AreEqual(outgoing["k2"], rs.Info.IncomingPayload["k2"]);
 }
        public static Task <RowSet> CreateKeyspaceWithThroughputInCustomPayloadAsync(
            ISession session,
            string keyspaceName,
            int throughputToProvision)
        {
            SimpleStatement createKeyspaceStatement
                = new SimpleStatement($"CREATE KEYSPACE IF NOT EXISTS {keyspaceName} WITH REPLICATION = {{'class': 'NetworkTopologyStrategy', 'datacenter1' : 1 }}");
            Dictionary <string, byte[]> customPayload = CustomPayloadHelpers.CreateCustomPayload(throughputToProvision);

            createKeyspaceStatement.SetOutgoingPayload(customPayload);

            return(session.ExecuteAsync(createKeyspaceStatement));
        }
示例#4
0
        public void Query_Payload_Test()
        {
            var outgoing = new Dictionary <string, byte[]> {
                { "k1", Encoding.UTF8.GetBytes("value1") }, { "k2", Encoding.UTF8.GetBytes("value2") }
            };
            var stmt = new SimpleStatement("SELECT * FROM system.local");

            stmt.SetOutgoingPayload(outgoing);
            var rs = Session.Execute(stmt);

            Assert.NotNull(rs.Info.IncomingPayload);
            Assert.AreEqual(outgoing.Count, rs.Info.IncomingPayload.Count);
            CollectionAssert.AreEqual(outgoing["k1"], rs.Info.IncomingPayload["k1"]);
            CollectionAssert.AreEqual(outgoing["k2"], rs.Info.IncomingPayload["k2"]);
        }
 public void Warnings_With_Custom_Payload_Test()
 {
     const string query = "BEGIN UNLOGGED BATCH INSERT INTO {0} (k, t) VALUES ('{1}', '{2}') APPLY BATCH";
     SimpleStatement insert = new SimpleStatement(String.Format(query, Table, "warn1", String.Join("", Enumerable.Repeat("a", 5 * 1025))));
     var outgoing = new Dictionary<string, byte[]> { { "k1", Encoding.UTF8.GetBytes("value1") }, { "k2", Encoding.UTF8.GetBytes("value2") } };
     insert.SetOutgoingPayload(outgoing);
     var rs = Session.Execute(insert);
     
     Assert.NotNull(rs.Info.Warnings);
     Assert.AreEqual(1, rs.Info.Warnings.Length);
     StringAssert.Contains("batch", rs.Info.Warnings[0].ToLowerInvariant());
     StringAssert.Contains("exceeding", rs.Info.Warnings[0].ToLowerInvariant());
     CollectionAssert.AreEqual(outgoing["k1"], rs.Info.IncomingPayload["k1"]);
     CollectionAssert.AreEqual(outgoing["k2"], rs.Info.IncomingPayload["k2"]);
 }
        public void Warnings_With_Custom_Payload_Test()
        {
            const string    query    = "BEGIN UNLOGGED BATCH INSERT INTO {0} (k, t) VALUES ('{1}', '{2}') APPLY BATCH";
            SimpleStatement insert   = new SimpleStatement(String.Format(query, Table, "warn1", String.Join("", Enumerable.Repeat("a", 5 * 1025))));
            var             outgoing = new Dictionary <string, byte[]> {
                { "k1", Encoding.UTF8.GetBytes("value1") }, { "k2", Encoding.UTF8.GetBytes("value2") }
            };

            insert.SetOutgoingPayload(outgoing);
            var rs = Session.Execute(insert);

            Assert.NotNull(rs.Info.Warnings);
            Assert.AreEqual(1, rs.Info.Warnings.Length);
            StringAssert.Contains("batch", rs.Info.Warnings[0].ToLowerInvariant());
            StringAssert.Contains("exceeding", rs.Info.Warnings[0].ToLowerInvariant());
            CollectionAssert.AreEqual(outgoing["k1"], rs.Info.IncomingPayload["k1"]);
            CollectionAssert.AreEqual(outgoing["k2"], rs.Info.IncomingPayload["k2"]);
        }