Skip to content

Commit 16b7883

Browse files
committed
be generous for should_evict_down_node_metrics_when_timeout_fires
1 parent bb9bb11 commit 16b7883

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

integration-tests/src/test/java/com/datastax/oss/driver/core/metrics/MetricsITBase.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,13 @@ public void should_evict_down_node_metrics_when_timeout_fires() throws Exception
174174
// trigger node1 UP -> DOWN
175175
eventBus.fire(NodeStateEvent.changed(NodeState.UP, NodeState.DOWN, node1));
176176

177-
Thread.sleep(expireAfter.toMillis());
177+
Thread.sleep(expireAfter.toMillis() + 100);
178178

179179
// then node-level metrics should be evicted from node1, but
180180
// node2 and node3 metrics should not have been evicted
181-
await().untilAsserted(() -> assertNodeMetricsEvicted(session, node1));
181+
await()
182+
.atMost(Duration.ofSeconds(15))
183+
.untilAsserted(() -> assertNodeMetricsEvicted(session, node1));
182184
assertNodeMetricsNotEvicted(session, node2);
183185
assertNodeMetricsNotEvicted(session, node3);
184186

@@ -226,7 +228,8 @@ public void should_not_evict_down_node_metrics_when_node_is_back_up_before_timeo
226228
eventBus.fire(NodeStateEvent.changed(NodeState.FORCED_DOWN, NodeState.UP, node2));
227229
eventBus.fire(NodeStateEvent.added(node3));
228230

229-
Thread.sleep(expireAfter.toMillis());
231+
// Add a small buffer to ensure the timeout would have fired if it wasn't cancelled
232+
Thread.sleep(expireAfter.toMillis() + 100);
230233

231234
// then no node-level metrics should be evicted
232235
assertNodeMetricsNotEvicted(session, node1);

0 commit comments

Comments
 (0)