Skip to content

Commit f84648f

Browse files
committed
Fix flaky metrics integration tests
1 parent 130fd25 commit f84648f

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.datastax.oss.driver.core.metrics;
1717

1818
import static org.assertj.core.api.Assertions.assertThat;
19+
import static org.awaitility.Awaitility.await;
1920

2021
import com.codahale.metrics.Counter;
2122
import com.codahale.metrics.Gauge;
@@ -95,7 +96,7 @@ protected void assertMetricsPresent(CqlSession session) {
9596
break;
9697
case CQL_REQUESTS:
9798
assertThat(m).isInstanceOf(Timer.class);
98-
assertThat(((Timer) m).getCount()).isEqualTo(30);
99+
await().untilAsserted(() -> assertThat(((Timer) m).getCount()).isEqualTo(30));
99100
break;
100101
case CQL_PREPARED_CACHE_SIZE:
101102
assertThat(m).isInstanceOf(Gauge.class);
@@ -144,7 +145,7 @@ protected void assertMetricsPresent(CqlSession session) {
144145
break;
145146
case CQL_MESSAGES:
146147
assertThat(m).isInstanceOf(Timer.class);
147-
assertThat(((Timer) m).getCount()).isEqualTo(10);
148+
await().untilAsserted(() -> assertThat(((Timer) m).getCount()).isEqualTo(10));
148149
break;
149150
case READ_TIMEOUTS:
150151
case WRITE_TIMEOUTS:

integration-tests/src/test/java/com/datastax/oss/driver/metrics/micrometer/MicrometerMetricsIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.datastax.oss.driver.metrics.micrometer;
1717

1818
import static org.assertj.core.api.Assertions.assertThat;
19+
import static org.awaitility.Awaitility.await;
1920

2021
import com.datastax.oss.driver.api.core.CqlSession;
2122
import com.datastax.oss.driver.api.core.metadata.Node;
@@ -86,7 +87,7 @@ protected void assertMetricsPresent(CqlSession session) {
8687
break;
8788
case CQL_REQUESTS:
8889
assertThat(m).isInstanceOf(Timer.class);
89-
assertThat(((Timer) m).count()).isEqualTo(30);
90+
await().untilAsserted(() -> assertThat(((Timer) m).count()).isEqualTo(30));
9091
break;
9192
case CQL_PREPARED_CACHE_SIZE:
9293
assertThat(m).isInstanceOf(Gauge.class);
@@ -128,7 +129,7 @@ protected void assertMetricsPresent(CqlSession session) {
128129
break;
129130
case CQL_MESSAGES:
130131
assertThat(m).isInstanceOf(Timer.class);
131-
assertThat(((Timer) m).count()).isEqualTo(10);
132+
await().untilAsserted(() -> assertThat(((Timer) m).count()).isEqualTo(10));
132133
break;
133134
case READ_TIMEOUTS:
134135
case WRITE_TIMEOUTS:

integration-tests/src/test/java/com/datastax/oss/driver/metrics/microprofile/MicroProfileMetricsIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.datastax.oss.driver.metrics.microprofile;
1717

1818
import static org.assertj.core.api.Assertions.assertThat;
19+
import static org.awaitility.Awaitility.await;
1920

2021
import com.datastax.oss.driver.api.core.CqlSession;
2122
import com.datastax.oss.driver.api.core.metadata.Node;
@@ -91,7 +92,7 @@ protected void assertMetricsPresent(CqlSession session) {
9192
break;
9293
case CQL_REQUESTS:
9394
assertThat(m).isInstanceOf(Timer.class);
94-
assertThat(((Timer) m).getCount()).isEqualTo(30);
95+
await().untilAsserted(() -> assertThat(((Timer) m).getCount()).isEqualTo(30));
9596
break;
9697
case CQL_PREPARED_CACHE_SIZE:
9798
assertThat(m).isInstanceOf(Gauge.class);
@@ -134,7 +135,7 @@ protected void assertMetricsPresent(CqlSession session) {
134135
break;
135136
case CQL_MESSAGES:
136137
assertThat(m).isInstanceOf(Timer.class);
137-
assertThat(((Timer) m).getCount()).isEqualTo(10);
138+
await().untilAsserted(() -> assertThat(((Timer) m).getCount()).isEqualTo(10));
138139
break;
139140
case READ_TIMEOUTS:
140141
case WRITE_TIMEOUTS:

0 commit comments

Comments
 (0)