DBZ-3099 Race condition in waiting for metrics

This commit is contained in:
Jiri Pechanec 2021-02-15 12:46:33 +01:00 committed by Gunnar Morling
parent 21b15facb2
commit b0f906df35

View File

@ -10,6 +10,7 @@
import java.lang.management.ManagementFactory;
import java.nio.file.Path;
import java.sql.Connection;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import javax.management.InstanceNotFoundException;
@ -17,6 +18,7 @@
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import org.awaitility.Awaitility;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@ -251,6 +253,8 @@ private void assertStreamingMetrics(long events) throws Exception {
assertThat((Long) mBeanServer.getAttribute(getStreamingMetricsObjectName(), "TotalNumberOfEventsSeen"))
.isGreaterThanOrEqualTo(events);
Awaitility.await().atMost(Duration.ofMinutes(1)).until(() -> ((String[]) mBeanServer
.getAttribute(getStreamingMetricsObjectName(), "MonitoredTables")).length > 0);
assertThat(mBeanServer.getAttribute(getStreamingMetricsObjectName(), "MonitoredTables"))
.isEqualTo(new String[]{ DATABASE.qualifiedTableName("simple") });
}