Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,11 @@ jobs:
exit 1
fi

- name: Run dotnet format (checks formatting)
run: |
dotnet format --verify-no-changes --severity warn --verbosity diagnostic src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj
dotnet format --verify-no-changes --severity warn --verbosity diagnostic src/Cassandra/Cassandra.csproj
dotnet format --verify-no-changes --severity warn --verbosity diagnostic src/Cassandra.Tests/Cassandra.Tests.csproj

- name: Run integration tests on Scylla
run: SCYLLA_EXT_OPTS="--smp 2 --memory 4G" SIMULACRON_PATH=../../../../../ci/simulacron-standalone-0.12.0.jar dotnet test src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj -f net8 -l "console;verbosity=detailed" --filter "(FullyQualifiedName!~ClientWarningsTests & FullyQualifiedName!~CustomPayloadTests & FullyQualifiedName!~Connect_With_Ssl_Test & FullyQualifiedName!~Should_UpdateHosts_When_HostIpChanges & FullyQualifiedName!~Should_UseNewHostInQueryPlans_When_HostIsDecommissionedAndJoinsAgain & FullyQualifiedName!~Should_RemoveNodeMetricsAndDisposeMetricsContext_When_HostIsRemoved & FullyQualifiedName!~Virtual_Keyspaces_Are_Included & FullyQualifiedName!~Virtual_Table_Metadata_Test & FullyQualifiedName!~SessionAuthenticationTests & FullyQualifiedName!~TypeSerializersTests & FullyQualifiedName!~Custom_MetadataTest & FullyQualifiedName!~LinqWhere_WithVectors & FullyQualifiedName!~SimpleStatement_With_No_Compact_Enabled_Should_Reveal_Non_Schema_Columns & FullyQualifiedName!~SimpleStatement_With_No_Compact_Disabled_Should_Not_Reveal_Non_Schema_Columns & FullyQualifiedName!~ColumnClusteringOrderReversedTest & FullyQualifiedName!~GetMaterializedView_Should_Refresh_View_Metadata_Via_Events & FullyQualifiedName!~MaterializedView_Base_Table_Column_Addition & FullyQualifiedName!~MultipleSecondaryIndexTest & FullyQualifiedName!~RaiseErrorOnInvalidMultipleSecondaryIndexTest & FullyQualifiedName!~TableMetadataAllTypesTest & FullyQualifiedName!~TableMetadataClusteringOrderTest & FullyQualifiedName!~TableMetadataCollectionsSecondaryIndexTest & FullyQualifiedName!~TableMetadataCompositePartitionKeyTest & FullyQualifiedName!~TupleMetadataTest & FullyQualifiedName!~Udt_Case_Sensitive_Metadata_Test & FullyQualifiedName!~UdtMetadataTest & FullyQualifiedName!~Should_Retrieve_Table_Metadata & FullyQualifiedName!~CreateTable_With_Frozen_Key & FullyQualifiedName!~CreateTable_With_Frozen_Udt & FullyQualifiedName!~CreateTable_With_Frozen_Value & FullyQualifiedName!~Should_AllMetricsHaveValidValues_When_AllNodesAreUp & FullyQualifiedName!~SimpleStatement_Dictionary_Parameters_CaseInsensitivity_ExcessOfParams & FullyQualifiedName!~SimpleStatement_Dictionary_Parameters_CaseInsensitivity_NoOverload & FullyQualifiedName!~TokenAware_TransientReplication_NoHopsAndOnlyFullReplicas & FullyQualifiedName!~GetFunction_Should_Return_Most_Up_To_Date_Metadata_Via_Events & FullyQualifiedName!~LargeDataTests & FullyQualifiedName!~MetadataTests & FullyQualifiedName!~MultiThreadingTests & FullyQualifiedName!~PoolTests & FullyQualifiedName!~PrepareLongTests & FullyQualifiedName!~SpeculativeExecutionLongTests & FullyQualifiedName!~StressTests & FullyQualifiedName!~TransitionalAuthenticationTests & FullyQualifiedName!~ProxyAuthenticationTests & FullyQualifiedName!~SessionDseAuthenticationTests & FullyQualifiedName!~CloudIntegrationTests & FullyQualifiedName!~CoreGraphTests & FullyQualifiedName!~GraphTests & FullyQualifiedName!~InsightsIntegrationTests & FullyQualifiedName!~DateRangeTests & FullyQualifiedName!~FoundBugTests & FullyQualifiedName!~GeometryTests & FullyQualifiedName!~LoadBalancingPolicyTests & FullyQualifiedName!~ConsistencyTests & FullyQualifiedName!~LoadBalancingPolicyTests & FullyQualifiedName!~ReconnectionPolicyTests & FullyQualifiedName!~RetryPolicyTests)"
8 changes: 4 additions & 4 deletions src/Cassandra.IntegrationTests/Ado/AdoBasicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override void SetUp()
base.SetUp();
var cb = new CassandraConnectionStringBuilder
{
ContactPoints = new[] { TestCluster.InitialContactPoint.Address.ToString() },
ContactPoints = new[] { TestCluster.InitialContactPoint.Address.ToString() },
Port = 9042
};
_connection = new CqlConnection(cb.ToString());
Expand Down Expand Up @@ -80,7 +80,7 @@ public void ExecuteNonQueryInsertAndSelectTest()
int RowsNo = 300;
for (int i = 0; i < RowsNo; i++)
{
longQ.AppendFormat("INSERT INTO {0} (tweet_id, author, isok, body) VALUES ({1},'test{2}',{3},'body{2}');", tableName, guids[i], i, i%2 == 0 ? "false" : "true");
longQ.AppendFormat("INSERT INTO {0} (tweet_id, author, isok, body) VALUES ({1},'test{2}',{3},'body{2}');", tableName, guids[i], i, i % 2 == 0 ? "false" : "true");
}
longQ.AppendLine("APPLY BATCH;");
cmd.CommandText = longQ.ToString();
Expand All @@ -94,7 +94,7 @@ public void ExecuteNonQueryInsertAndSelectTest()
TestCluster.PrimeFluent(
b => b.WhenQuery($"SELECT * from {tableName} LIMIT 10000;")
.ThenRowsSuccess(
new[] {"tweet_id", "author", "body", "isok"},
new[] { "tweet_id", "author", "body", "isok" },
r => r.WithRows(guids.Select((guid, idx) => new object[] { guid, $"test{idx}", $"body{idx}", idx % 2 != 0 }).ToArray())));

cmd.CommandText = string.Format(@"SELECT * from {0} LIMIT 10000;", tableName);
Expand All @@ -118,7 +118,7 @@ public void ExecuteScalarReturnsFirstColumn()

TestCluster.PrimeFluent(
b => b.WhenQuery("SELECT key FROM system.local")
.ThenRowsSuccess(new [] { "key" }, r => r.WithRow("local")));
.ThenRowsSuccess(new[] { "key" }, r => r.WithRow("local")));

TestCluster.PrimeFluent(
b => b.WhenQuery("SELECT * FROM system.local WHERE key = 'does not exist'")
Expand Down
32 changes: 16 additions & 16 deletions src/Cassandra.IntegrationTests/BaseIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected BaseIntegrationTest()
"schema.propertyKey('title').Text().ifNotExists().create();\n" +
"schema.propertyKey('tags').Text().multiple().ifNotExists().create();\n" +
"schema.vertexLabel('movie').properties('title', 'tags').ifNotExists().create();\n";

protected const string CoreSchemaGremlinQuery =
"schema.vertexLabel('person')" +
".partitionBy('name', Text)" +
Expand All @@ -66,7 +66,7 @@ protected BaseIntegrationTest()
".create();\n" +
"schema.type('address')" +
".property('address1', Text)" +
".property('address2', Text)" +
".property('address2', Text)" +
".property('city_code', Text)" +
".property('state_code', Text)" +
".property('zip_code', Text)" +
Expand All @@ -86,12 +86,12 @@ protected BaseIntegrationTest()
".property('emails', setOf(Text))" +
".property('nullable_long', Bigint)" +
".create();\n" +
"schema.vertexLabel('users')" +
".partitionBy('id', Int)" +
"schema.vertexLabel('users')" +
".partitionBy('id', Int)" +
".property('main_phone', frozen(typeOf('phone')))" +
".create();\n" +
"schema.vertexLabel('users_contacts')" +
".partitionBy('id', Int)" +
"schema.vertexLabel('users_contacts')" +
".partitionBy('id', Int)" +
".property('contacts', listOf(frozen(typeOf('contact'))))" +
".create();\n" +
"schema.type('user_feedback')" +
Expand All @@ -102,27 +102,27 @@ protected BaseIntegrationTest()
".from('users').to('software')" +
".property('feedback', typeOf('user_feedback'))" +
".create();\n" +
"schema.vertexLabel('tuple_test')" +
".partitionBy('id', Int)" +
"schema.vertexLabel('tuple_test')" +
".partitionBy('id', Int)" +
".property('tuple_property', tupleOf(typeOf('phone'), Instant, UUID, listOf(Text), setOf(Int),mapOf(Text, Int)))" +
".create();\n";

/// <summary>
/// Reference graph: http://www.tinkerpop.com/docs/3.0.0.M1/
/// </summary>
protected const string CoreLoadGremlinQuery =
protected const string CoreLoadGremlinQuery =
"g.addV('person')" +
".property('name', 'marko')" +
".property('age', 29)" +
".as('marko')" +
".as('marko')" +
".addV('person')" +
".property('name', 'vadas')" +
".property('age', 27)" +
".as('vadas')" +
".addV('software')" +
".property('name', 'lop')" +
".property('lang', 'java')" +
".as('lop')" +
".as('lop')" +
".addV('person')" +
".property('name', 'josh')" +
".property('age', 32)" +
Expand Down Expand Up @@ -155,7 +155,7 @@ protected BaseIntegrationTest()
".from('peter').to('lop')" +
".addV('users_contacts')" +
".property('id', 1923)" +
".property('contacts', " +
".property('contacts', " +
"[ " +
"typeOf('contact').create(" +
"'Jimmy', " +
Expand All @@ -182,7 +182,7 @@ protected BaseIntegrationTest()
/// <summary>
/// Reference graph: http://www.tinkerpop.com/docs/3.0.0.M1/
/// </summary>
protected const string ClassicLoadGremlinQuery =
protected const string ClassicLoadGremlinQuery =
"Vertex marko = graph.addVertex(label, 'person', 'name', 'marko', 'age', 29);\n" +
"Vertex vadas = graph.addVertex(label, 'person', 'name', 'vadas', 'age', 27);\n" +
"Vertex lop = graph.addVertex(label, 'software', 'name', 'lop', 'lang', 'java');\n" +
Expand All @@ -198,7 +198,7 @@ protected BaseIntegrationTest()

protected const string MakeStrict = "schema.config().option(\"graph.schema_mode\").set(\"production\");";
protected const string AllowScans = "schema.config().option(\"graph.allow_scan\").set(\"true\");";

/// <summary>
/// Creates a graph using the current session
/// </summary>
Expand Down Expand Up @@ -231,7 +231,7 @@ public void CreateClassicGraph(string contactPoint, string name)
CreateClassicGraph(cluster.Connect(), name);
}
}

/// <summary>
/// Creates a core graph using the current session
/// </summary>
Expand Down Expand Up @@ -279,7 +279,7 @@ private void WaitUntilKeyspaceMetadataRefresh(ISession session, string graphName

Task.Delay(500).GetAwaiter().GetResult();
}

Assert.Fail("Keyspace metadata does not have the correct graph engine.");
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/Cassandra.IntegrationTests/Core/BasicTypeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ public void DecimalWithNegativeScaleTest()

TestCluster.PrimeFluent(
b => b.WhenQuery("SELECT * FROM decimal_neg_scale")
.ThenRowsSuccess(new[] {"id", "value"}, r => r.WithRow(firstRowValues.First(), (decimal) 50)));
.ThenRowsSuccess(new[] { "id", "value" }, r => r.WithRow(firstRowValues.First(), (decimal)50)));

var row = Session.Execute("SELECT * FROM decimal_neg_scale").First();
var decValue = row.GetValue<decimal>("value");

Assert.AreEqual(50, decValue);
}

Expand Down Expand Up @@ -245,7 +245,7 @@ public void ExceedingCassandraType(Type toExceed, Type toExceedWith, bool sameOu
TestCluster.PrimeFluent(
b => b.WhenQuery($"SELECT * FROM {tableName};", when => when.WithConsistency(ConsistencyLevel.One))
.ThenRowsSuccess(
new[] {"tweet_id", "label", "number"},
new[] { "tweet_id", "label", "number" },
r => r.WithRow(toInsertAndCheck[0][0], toInsertAndCheck[0][1], toInsertAndCheck[0][2])
.WithRow(toInsertAndCheck[1][0], toInsertAndCheck[1][1], toInsertAndCheck[1][2])));

Expand Down Expand Up @@ -282,7 +282,7 @@ public void TestCounters()

TestCluster.PrimeFluent(
b => b.WhenQuery($"SELECT * FROM {tableName};", when => when.WithConsistency(ConsistencyLevel.LocalOne))
.ThenRowsSuccess(new[] {"tweet_id", "incdec"}, r => r.WithRow(tweet_id, (Int64) 50)));
.ThenRowsSuccess(new[] { "tweet_id", "incdec" }, r => r.WithRow(tweet_id, (Int64)50)));

QueryTools.ExecuteSyncQuery(Session, $"SELECT * FROM {tableName};",
Session.Cluster.Configuration.QueryOptions.GetConsistencyLevel(),
Expand Down Expand Up @@ -310,7 +310,7 @@ public void InsertingSingleValue(Type tp)
var query =
$"INSERT INTO {tableName}(tweet_id,value) VALUES (" +
$"{toInsert[0][0]}, " +
$"{(row1[1].GetType() == typeof(byte[]) ? "0x" + CqlQueryTools.ToHex((byte[]) toInsert[0][1]) : "'" + toInsert[0][1] + "'")}" +
$"{(row1[1].GetType() == typeof(byte[]) ? "0x" + CqlQueryTools.ToHex((byte[])toInsert[0][1]) : "'" + toInsert[0][1] + "'")}" +
");";
QueryTools.ExecuteSyncNonQuery(Session, query, null);
VerifyStatement(QueryType.Query, query, 1);
Expand All @@ -333,7 +333,7 @@ public void InsertingSingleValue(Type tp)

TestCluster.PrimeFluent(
b => b.WhenQuery($"SELECT * FROM {tableName};", when => when.WithConsistency(ConsistencyLevel.LocalOne))
.ThenRowsSuccess(new[] {"tweet_id", "value"}, r => r.WithRow(toInsert[0][0], toInsert[0][1])));
.ThenRowsSuccess(new[] { "tweet_id", "value" }, r => r.WithRow(toInsert[0][0], toInsert[0][1])));

QueryTools.ExecuteSyncQuery(
Session, $"SELECT * FROM {tableName};", Session.Cluster.Configuration.QueryOptions.GetConsistencyLevel(), toInsert);
Expand Down
24 changes: 12 additions & 12 deletions src/Cassandra.IntegrationTests/Core/ClientTimeoutTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void Should_Move_To_Next_Host_For_Simple_Queries()
var node = nodes[0];
node.PrimeFluent(b => b
.WhenQuery("SELECT key FROM system.local")
.ThenRowsSuccess(new [] { ("key", DataType.Ascii) }, rows => rows.WithRow("123"))
.ThenRowsSuccess(new[] { ("key", DataType.Ascii) }, rows => rows.WithRow("123"))
.WithDelayInMs(2000));
TestHelper.Invoke(() =>
{
Expand All @@ -85,7 +85,7 @@ public void Should_Move_To_Next_Host_For_Bound_Statements()
var node = nodes[0];
node.PrimeFluent(
b => b.WhenQuery("SELECT key FROM system.local")
.ThenRowsSuccess(new [] { ("key", DataType.Ascii) }, rows => rows.WithRow("123"))
.ThenRowsSuccess(new[] { ("key", DataType.Ascii) }, rows => rows.WithRow("123"))
.WithDelayInMs(2000));
TestHelper.Invoke(() =>
{
Expand Down Expand Up @@ -135,7 +135,7 @@ public void Should_Throw_OperationTimedOutException_When_Retry_Is_False()
var node = nodes[1];
node.PrimeFluent(
b => b.WhenQuery("SELECT key FROM system.local")
.ThenRowsSuccess(new [] { ("key", DataType.Ascii) }, rows => rows.WithRow("123"))
.ThenRowsSuccess(new[] { ("key", DataType.Ascii) }, rows => rows.WithRow("123"))
.WithDelayInMs(2000));
var coordinators = new HashSet<string>();
var exceptions = new List<OperationTimedOutException>();
Expand Down Expand Up @@ -166,7 +166,7 @@ public void Should_Wait_When_ReadTimeout_Is_Zero()
const string cql = "SELECT key FROM system.local";
simulacronCluster.PrimeFluent(
b => b.WhenQuery(cql)
.ThenRowsSuccess(new [] { ("key", DataType.Ascii) }, rows => rows.WithRow("123"))
.ThenRowsSuccess(new[] { ("key", DataType.Ascii) }, rows => rows.WithRow("123"))
.WithDelayInMs(30000));

using (var cluster = ClusterBuilder().AddContactPoint(simulacronCluster.InitialContactPoint).WithSocketOptions(socketOptions).Build())
Expand Down Expand Up @@ -213,7 +213,7 @@ public void Should_Use_Statement_ReadTimeout()
var node = nodes[0];
node.PrimeFluent(
b => b.WhenQuery("SELECT key FROM system.local")
.ThenRowsSuccess(new [] { ("key", DataType.Ascii) }, rows => rows.WithRow("123"))
.ThenRowsSuccess(new[] { ("key", DataType.Ascii) }, rows => rows.WithRow("123"))
.WithDelayInMs(30000));
var stopWatch = new Stopwatch();
stopWatch.Start();
Expand Down Expand Up @@ -259,7 +259,7 @@ public void Should_Throw_NoHostAvailableException_When_All_Hosts_Down()
TestHelper.Invoke(() => session.Execute("SELECT key FROM system.local"), 10);
_testCluster.PrimeFluent(
b => b.WhenQuery("SELECT key FROM system.local")
.ThenRowsSuccess(new [] { ("key", DataType.Ascii) }, rows => rows.WithRow("123"))
.ThenRowsSuccess(new[] { ("key", DataType.Ascii) }, rows => rows.WithRow("123"))
.WithDelayInMs(10000));
var ex = Assert.Throws<NoHostAvailableException>(() => session.Execute("SELECT key FROM system.local"));
Assert.AreEqual(2, ex.Errors.Count);
Expand Down Expand Up @@ -296,7 +296,7 @@ public void Should_Not_Leak_Connections_Test()
var listeners = new List<TraceListener>();
foreach (var l in Trace.Listeners)
{
listeners.Add((TraceListener) l);
listeners.Add((TraceListener)l);
}

Trace.Listeners.Clear();
Expand Down Expand Up @@ -395,7 +395,7 @@ public void Should_Not_Leak_Connections_Test()
}
}
}

/// <summary>
/// CSHARP-958
/// </summary>
Expand All @@ -405,7 +405,7 @@ public async Task Should_Not_Leak_Connections_With_InvalidKeyspace_Test()
var listeners = new List<TraceListener>();
foreach (var l in Trace.Listeners)
{
listeners.Add((TraceListener) l);
listeners.Add((TraceListener)l);
}

Trace.Listeners.Clear();
Expand Down Expand Up @@ -478,7 +478,7 @@ public async Task Should_Not_Leak_Connections_With_InvalidKeyspace_Test()
Exception ex = null;
try
{
using (await c.ConnectAsync($"keyspace_{i+numberOfDefaultKsClusters}").ConfigureAwait(false))
using (await c.ConnectAsync($"keyspace_{i + numberOfDefaultKsClusters}").ConfigureAwait(false))
{
}
}
Expand Down Expand Up @@ -514,12 +514,12 @@ public async Task Should_Not_Leak_Connections_With_InvalidKeyspace_Test()
await Task.Delay(1000).ConfigureAwait(false);

decimal initialMemory = GC.GetTotalMemory(true);

await connectClustersFunc(100).ConfigureAwait(false);

GC.Collect();
await Task.Delay(1000).ConfigureAwait(false);

var connectedPorts = await _testCluster.GetConnectedPortsAsync().ConfigureAwait(false);
Assert.AreEqual(20, connectedPorts.Count); // control connections

Expand Down
Loading