Skip to content

Commit

Permalink
[test] remind to close table commit
Browse files Browse the repository at this point in the history
  • Loading branch information
schnappi17 committed Oct 19, 2023
1 parent 7e8319c commit 990dbda
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.paimon.metrics.Metric;
import org.apache.paimon.metrics.MetricGroup;
import org.apache.paimon.metrics.Metrics;
import org.apache.paimon.utils.ExceptionUtils;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -58,7 +59,19 @@ public void afterEach() {
@Test
public void testGenericMetricsRegistration() {
MetricGroup genericMetricGroup = commitMetrics.getMetricGroup();
assertThat(Metrics.getInstance().getMetricGroups().size()).isEqualTo(1);
AssertionError error = null;
try {
assertThat(Metrics.getInstance().getMetricGroups().size()).isEqualTo(1);
} catch (AssertionError e) {
error =
ExceptionUtils.firstOrSuppressed(
e,
new AssertionError(
"Please close the created TableCommit objects in case of metrics resource leak."));
}
if (error != null) {
throw error;
}
assertThat(genericMetricGroup.getGroupName()).isEqualTo(CommitMetrics.GROUP_NAME);
Map<String, Metric> registeredMetrics = genericMetricGroup.getMetrics();
assertThat(registeredMetrics.keySet())
Expand Down

0 comments on commit 990dbda

Please sign in to comment.