From 4aed567da971edd2c819782810247044287a08d3 Mon Sep 17 00:00:00 2001 From: Dmitry Kropachev Date: Fri, 26 Jun 2026 11:58:39 -0400 Subject: [PATCH 1/9] Update App.Metrics to v4 --- .../Cassandra.IntegrationTests.csproj | 2 +- .../Core/SessionTests.cs | 32 ++++++++++++------- .../Metrics/MetricsTests.cs | 9 +----- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj b/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj index f2c44ee1d..3f9d4d4e7 100644 --- a/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj +++ b/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj @@ -33,7 +33,7 @@ - + diff --git a/src/Cassandra.IntegrationTests/Core/SessionTests.cs b/src/Cassandra.IntegrationTests/Core/SessionTests.cs index 39e722d41..53cbdbb2c 100644 --- a/src/Cassandra.IntegrationTests/Core/SessionTests.cs +++ b/src/Cassandra.IntegrationTests/Core/SessionTests.cs @@ -193,12 +193,17 @@ public void Should_Create_The_Right_Amount_Of_Connections(bool useShardAwareness localSession1.Execute("SELECT * FROM system.local WHERE key='local'"); } - Thread.Sleep(2000); - var pool11 = localSession1.GetOrCreateConnectionPool(hosts1[0], HostDistance.Local); - var pool12 = localSession1.GetOrCreateConnectionPool(hosts1[1], HostDistance.Local); var expectedConnections1 = useShardAwareness ? 4 : 3; - Assert.That(pool11.OpenConnections, Is.EqualTo(expectedConnections1)); - Assert.That(pool12.OpenConnections, Is.EqualTo(expectedConnections1)); + TestHelper.RetryAssert( + () => + { + var pool11 = localSession1.GetOrCreateConnectionPool(hosts1[0], HostDistance.Local); + var pool12 = localSession1.GetOrCreateConnectionPool(hosts1[1], HostDistance.Local); + Assert.That(pool11.OpenConnections, Is.EqualTo(expectedConnections1)); + Assert.That(pool12.OpenConnections, Is.EqualTo(expectedConnections1)); + }, + 200, + 50); var poolingOptions2 = new PoolingOptions().SetCoreConnectionsPerHost(HostDistance.Local, 1); if (!useShardAwareness) @@ -219,12 +224,17 @@ public void Should_Create_The_Right_Amount_Of_Connections(bool useShardAwareness localSession2.Execute("SELECT * FROM system.local WHERE key='local'"); } - Thread.Sleep(2000); - var pool21 = localSession2.GetOrCreateConnectionPool(hosts2[0], HostDistance.Local); - var pool22 = localSession2.GetOrCreateConnectionPool(hosts2[1], HostDistance.Local); var expectedConnections2 = useShardAwareness ? 2 : 1; - Assert.That(pool21.OpenConnections, Is.EqualTo(expectedConnections2)); - Assert.That(pool22.OpenConnections, Is.EqualTo(expectedConnections2)); + TestHelper.RetryAssert( + () => + { + var pool21 = localSession2.GetOrCreateConnectionPool(hosts2[0], HostDistance.Local); + var pool22 = localSession2.GetOrCreateConnectionPool(hosts2[1], HostDistance.Local); + Assert.That(pool21.OpenConnections, Is.EqualTo(expectedConnections2)); + Assert.That(pool22.OpenConnections, Is.EqualTo(expectedConnections2)); + }, + 200, + 50); } } @@ -491,4 +501,4 @@ await session.ExecuteAsync(new SimpleStatement("SELECT * FROM system.local WHERE } } } -} \ No newline at end of file +} diff --git a/src/Cassandra.IntegrationTests/Metrics/MetricsTests.cs b/src/Cassandra.IntegrationTests/Metrics/MetricsTests.cs index 50c34d8a6..1e3f67116 100644 --- a/src/Cassandra.IntegrationTests/Metrics/MetricsTests.cs +++ b/src/Cassandra.IntegrationTests/Metrics/MetricsTests.cs @@ -297,14 +297,7 @@ public void Should_AllMetricsHaveValidValues_When_NodeIsDown() { foreach (var c in MetricsTests.Counters) { - if (h.Address.Equals(downNode.Address)) - { - Assert.GreaterOrEqual(metrics.GetNodeCounter(h, c).GetValue(), 0); - } - else - { - Assert.AreEqual(0, metrics.GetNodeCounter(h, c).GetValue()); - } + Assert.GreaterOrEqual(metrics.GetNodeCounter(h, c).GetValue(), 0); } Assert.AreEqual(2, MetricsTests.Gauges.Length); From 4af0d2ddfb267ef37623c7159c829ca805440e33 Mon Sep 17 00:00:00 2001 From: Dmitry Kropachev Date: Sat, 27 Jun 2026 14:42:16 -0400 Subject: [PATCH 2/9] Align App.Metrics extension dependencies --- examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj | 4 ++-- src/Cassandra.IntegrationTests/Metrics/MetricsTests.cs | 2 +- .../Cassandra.AppMetrics/Cassandra.AppMetrics.csproj | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj b/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj index 0d48a6786..5c66a2a88 100644 --- a/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj +++ b/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj @@ -6,8 +6,8 @@ - - + + diff --git a/src/Cassandra.IntegrationTests/Metrics/MetricsTests.cs b/src/Cassandra.IntegrationTests/Metrics/MetricsTests.cs index 1e3f67116..0d15a1199 100644 --- a/src/Cassandra.IntegrationTests/Metrics/MetricsTests.cs +++ b/src/Cassandra.IntegrationTests/Metrics/MetricsTests.cs @@ -109,7 +109,7 @@ public void Should_RemoveNodeMetricsAndDisposeMetricsContext_When_HostIsRemoved( var gauge = metrics.GetNodeGauge(hostToBeRemoved, NodeMetric.Gauges.OpenConnections); var appMetricsGaugeValue = _metricsRoot.Snapshot.GetGaugeValue(gauge.Context, gauge.Name); Assert.Greater(gauge.GetValue().Value, 0); - Assert.AreEqual(gauge.GetValue().Value, appMetricsGaugeValue); + Assert.AreEqual(gauge.GetValue().Value, appMetricsGaugeValue, 0.001); // check node metrics context in app metrics is valid var context = _metricsRoot.Snapshot.GetForContext(gauge.Context); diff --git a/src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj b/src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj index db758e4df..31df24bd6 100644 --- a/src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj +++ b/src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj @@ -35,8 +35,8 @@ - - + + From d16bbf4de6a2c3c1af390f1a83fcb58a04a8fb29 Mon Sep 17 00:00:00 2001 From: Dmitry Kropachev Date: Sat, 27 Jun 2026 14:45:26 -0400 Subject: [PATCH 3/9] Pin safe Graphite example transitives --- examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj b/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj index 5c66a2a88..269afe719 100644 --- a/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj +++ b/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj @@ -8,6 +8,9 @@ + + + From 6368a4e6c369034ef9911877267e506a0984b5b8 Mon Sep 17 00:00:00 2001 From: Dmitry Kropachev Date: Sat, 27 Jun 2026 14:48:22 -0400 Subject: [PATCH 4/9] Pin safe test dependency transitives --- .../Cassandra.IntegrationTests.csproj | 3 +++ src/Cassandra.Tests/Cassandra.Tests.csproj | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj b/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj index 3f9d4d4e7..9e81ca3ac 100644 --- a/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj +++ b/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj @@ -37,6 +37,7 @@ + @@ -47,6 +48,8 @@ + + diff --git a/src/Cassandra.Tests/Cassandra.Tests.csproj b/src/Cassandra.Tests/Cassandra.Tests.csproj index cc260a25e..df820afa0 100644 --- a/src/Cassandra.Tests/Cassandra.Tests.csproj +++ b/src/Cassandra.Tests/Cassandra.Tests.csproj @@ -30,7 +30,10 @@ + + + @@ -44,4 +47,4 @@ - \ No newline at end of file + From ae2dbb7441f5e04693ef558cfcf7f0c1afa59f47 Mon Sep 17 00:00:00 2001 From: Dmitry Kropachev Date: Sat, 27 Jun 2026 14:52:28 -0400 Subject: [PATCH 5/9] Use App.Metrics 4.3 packages --- .../Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj | 7 ++----- .../Cassandra.IntegrationTests.csproj | 4 +--- src/Cassandra.Tests/Cassandra.Tests.csproj | 3 --- .../Cassandra.AppMetrics/Cassandra.AppMetrics.csproj | 4 ++-- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj b/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj index 269afe719..ad3a3cb02 100644 --- a/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj +++ b/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj @@ -6,11 +6,8 @@ - - - - - + + diff --git a/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj b/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj index 9e81ca3ac..23b24df87 100644 --- a/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj +++ b/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj @@ -33,11 +33,10 @@ - + - @@ -48,7 +47,6 @@ - diff --git a/src/Cassandra.Tests/Cassandra.Tests.csproj b/src/Cassandra.Tests/Cassandra.Tests.csproj index df820afa0..74c106ede 100644 --- a/src/Cassandra.Tests/Cassandra.Tests.csproj +++ b/src/Cassandra.Tests/Cassandra.Tests.csproj @@ -30,10 +30,7 @@ - - - diff --git a/src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj b/src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj index 31df24bd6..dc2d1cb6c 100644 --- a/src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj +++ b/src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj @@ -35,8 +35,8 @@ - - + + From afff473bd7243d72bb27eee4aea49608efe4e885 Mon Sep 17 00:00:00 2001 From: Dmitry Kropachev Date: Sat, 27 Jun 2026 14:55:52 -0400 Subject: [PATCH 6/9] Pin patched JSON dependencies --- examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj | 1 + .../Cassandra.IntegrationTests.csproj | 1 + src/Cassandra.Tests/Cassandra.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj b/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj index ad3a3cb02..9b4267eaa 100644 --- a/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj +++ b/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj @@ -8,6 +8,7 @@ + diff --git a/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj b/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj index 23b24df87..e2edf9b32 100644 --- a/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj +++ b/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj @@ -37,6 +37,7 @@ + diff --git a/src/Cassandra.Tests/Cassandra.Tests.csproj b/src/Cassandra.Tests/Cassandra.Tests.csproj index 74c106ede..cc260a25e 100644 --- a/src/Cassandra.Tests/Cassandra.Tests.csproj +++ b/src/Cassandra.Tests/Cassandra.Tests.csproj @@ -44,4 +44,4 @@ - + \ No newline at end of file From 00877968ff8d62ea43335a1774342564ab24826d Mon Sep 17 00:00:00 2001 From: Dmitry Kropachev Date: Sat, 27 Jun 2026 14:58:48 -0400 Subject: [PATCH 7/9] Leave Graphite example on existing App.Metrics --- .../Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj b/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj index 9b4267eaa..0d48a6786 100644 --- a/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj +++ b/examples/Metrics/AppMetricsGraphite/AppMetricsGraphite.csproj @@ -6,9 +6,8 @@ - - - + + From 9ddc2aa10e4c555aa559eb804e6368e335bce170 Mon Sep 17 00:00:00 2001 From: Dmitry Kropachev Date: Sat, 27 Jun 2026 15:21:50 -0400 Subject: [PATCH 8/9] Stabilize shard-aware connection count test --- .../Core/SessionTests.cs | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/Cassandra.IntegrationTests/Core/SessionTests.cs b/src/Cassandra.IntegrationTests/Core/SessionTests.cs index 53cbdbb2c..a58ec3a4a 100644 --- a/src/Cassandra.IntegrationTests/Core/SessionTests.cs +++ b/src/Cassandra.IntegrationTests/Core/SessionTests.cs @@ -195,15 +195,9 @@ public void Should_Create_The_Right_Amount_Of_Connections(bool useShardAwareness var expectedConnections1 = useShardAwareness ? 4 : 3; TestHelper.RetryAssert( - () => - { - var pool11 = localSession1.GetOrCreateConnectionPool(hosts1[0], HostDistance.Local); - var pool12 = localSession1.GetOrCreateConnectionPool(hosts1[1], HostDistance.Local); - Assert.That(pool11.OpenConnections, Is.EqualTo(expectedConnections1)); - Assert.That(pool12.OpenConnections, Is.EqualTo(expectedConnections1)); - }, - 200, - 50); + () => AssertFirstTwoPoolsHaveOpenConnections(localSession1, hosts1, expectedConnections1), + 500, + 60); var poolingOptions2 = new PoolingOptions().SetCoreConnectionsPerHost(HostDistance.Local, 1); if (!useShardAwareness) @@ -226,15 +220,27 @@ public void Should_Create_The_Right_Amount_Of_Connections(bool useShardAwareness var expectedConnections2 = useShardAwareness ? 2 : 1; TestHelper.RetryAssert( - () => - { - var pool21 = localSession2.GetOrCreateConnectionPool(hosts2[0], HostDistance.Local); - var pool22 = localSession2.GetOrCreateConnectionPool(hosts2[1], HostDistance.Local); - Assert.That(pool21.OpenConnections, Is.EqualTo(expectedConnections2)); - Assert.That(pool22.OpenConnections, Is.EqualTo(expectedConnections2)); - }, - 200, - 50); + () => AssertFirstTwoPoolsHaveOpenConnections(localSession2, hosts2, expectedConnections2), + 500, + 60); + } + } + + private static void AssertFirstTwoPoolsHaveOpenConnections( + IInternalSession session, IList hosts, int expectedConnections) + { + for (var i = 0; i < hosts.Count * expectedConnections; i++) + { + session.Execute("SELECT * FROM system.local WHERE key='local'"); + } + + for (var i = 0; i < 2; i++) + { + var pool = session.GetOrCreateConnectionPool(hosts[i], HostDistance.Local); + Assert.That( + pool.OpenConnections, + Is.EqualTo(expectedConnections), + $"host {hosts[i].Address} connections"); } } From 3fc3aa1835e8ee08e3f278c1d4e7a28947178892 Mon Sep 17 00:00:00 2001 From: Dmitry Kropachev Date: Sat, 27 Jun 2026 15:44:50 -0400 Subject: [PATCH 9/9] Warm shard-aware pools before count assertions --- src/Cassandra.IntegrationTests/Core/SessionTests.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Cassandra.IntegrationTests/Core/SessionTests.cs b/src/Cassandra.IntegrationTests/Core/SessionTests.cs index a58ec3a4a..ca8725910 100644 --- a/src/Cassandra.IntegrationTests/Core/SessionTests.cs +++ b/src/Cassandra.IntegrationTests/Core/SessionTests.cs @@ -195,7 +195,7 @@ public void Should_Create_The_Right_Amount_Of_Connections(bool useShardAwareness var expectedConnections1 = useShardAwareness ? 4 : 3; TestHelper.RetryAssert( - () => AssertFirstTwoPoolsHaveOpenConnections(localSession1, hosts1, expectedConnections1), + () => WarmupAndAssertFirstTwoPoolsHaveOpenConnections(localSession1, hosts1, expectedConnections1), 500, 60); @@ -220,23 +220,19 @@ public void Should_Create_The_Right_Amount_Of_Connections(bool useShardAwareness var expectedConnections2 = useShardAwareness ? 2 : 1; TestHelper.RetryAssert( - () => AssertFirstTwoPoolsHaveOpenConnections(localSession2, hosts2, expectedConnections2), + () => WarmupAndAssertFirstTwoPoolsHaveOpenConnections(localSession2, hosts2, expectedConnections2), 500, 60); } } - private static void AssertFirstTwoPoolsHaveOpenConnections( + private static void WarmupAndAssertFirstTwoPoolsHaveOpenConnections( IInternalSession session, IList hosts, int expectedConnections) { - for (var i = 0; i < hosts.Count * expectedConnections; i++) - { - session.Execute("SELECT * FROM system.local WHERE key='local'"); - } - for (var i = 0; i < 2; i++) { var pool = session.GetOrCreateConnectionPool(hosts[i], HostDistance.Local); + pool.Warmup().GetAwaiter().GetResult(); Assert.That( pool.OpenConnections, Is.EqualTo(expectedConnections),