diff --git a/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj b/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj
index f2c44ee1d..e2edf9b32 100644
--- a/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj
+++ b/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj
@@ -33,10 +33,11 @@
-
+
+
@@ -47,6 +48,7 @@
+
diff --git a/src/Cassandra.IntegrationTests/Core/SessionTests.cs b/src/Cassandra.IntegrationTests/Core/SessionTests.cs
index 39e722d41..ca8725910 100644
--- a/src/Cassandra.IntegrationTests/Core/SessionTests.cs
+++ b/src/Cassandra.IntegrationTests/Core/SessionTests.cs
@@ -193,12 +193,11 @@ 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(
+ () => WarmupAndAssertFirstTwoPoolsHaveOpenConnections(localSession1, hosts1, expectedConnections1),
+ 500,
+ 60);
var poolingOptions2 = new PoolingOptions().SetCoreConnectionsPerHost(HostDistance.Local, 1);
if (!useShardAwareness)
@@ -219,12 +218,25 @@ 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(
+ () => WarmupAndAssertFirstTwoPoolsHaveOpenConnections(localSession2, hosts2, expectedConnections2),
+ 500,
+ 60);
+ }
+ }
+
+ private static void WarmupAndAssertFirstTwoPoolsHaveOpenConnections(
+ IInternalSession session, IList hosts, int expectedConnections)
+ {
+ 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),
+ $"host {hosts[i].Address} connections");
}
}
@@ -491,4 +503,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..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);
@@ -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);
diff --git a/src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj b/src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj
index db758e4df..dc2d1cb6c 100644
--- a/src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj
+++ b/src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj
@@ -35,8 +35,8 @@
-
-
+
+