Skip to content

Commit 4f9e2c2

Browse files
authored
chore: fixed flaky test (#207)
1 parent 50c5817 commit 4f9e2c2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

client/src/test/java/com/influxdb/client/ITWriteQueryApi.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ void flush() throws InterruptedException {
485485
}
486486

487487
@Test
488-
void flushByTime() throws InterruptedException {
488+
void flushByTime() {
489489

490490
String bucketName = bucket.getName();
491491

@@ -498,12 +498,15 @@ void flushByTime() throws InterruptedException {
498498
String record4 = "h2o_feet,location=coyote_creek level\\ water_level=4.0 4";
499499
String record5 = "h2o_feet,location=coyote_creek level\\ water_level=5.0 5";
500500

501+
WriteEventListener<WriteSuccessEvent> successListener = new WriteEventListener<>();
502+
writeApi.listenEvents(WriteSuccessEvent.class, successListener);
503+
501504
writeApi.writeRecords(bucketName, organization.getId(), WritePrecision.NS, Arrays.asList(record1, record2, record3, record4, record5));
502505

503506
List<FluxTable> query = queryApi.query("from(bucket:\"" + bucketName + "\") |> range(start: 1970-01-01T00:00:00.000000001Z)", organization.getId());
504507
Assertions.assertThat(query).hasSize(0);
505508

506-
Thread.sleep(600);
509+
waitToCallback(successListener.countDownLatch, 10);
507510

508511
query = queryApi.query("from(bucket:\"" + bucketName + "\") |> range(start: 1970-01-01T00:00:00.000000001Z)", organization.getId());
509512

0 commit comments

Comments
 (0)