[Test] Fix managed cursor metrics test
### Motivation
The two test methods in class `ManagedCursorMetricsTest` will affect each other.
### Modifications
Call the setup method before the test method and call the cleanup method after the test method.
@@ -27,23 +27,23 @@ import org.apache.pulsar.client.api.Producer;
import org.apache.pulsar.client.api.SubscriptionType;
import org.apache.pulsar.common.stats.Metrics;
import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.List;
import java.util.concurrent.TimeUnit;
-@Test(groups = "quarantine")
+@Test(groups = "broker")
public class ManagedCursorMetricsTest extends MockedPulsarServiceBaseTest {
- @BeforeClass(alwaysRun = true)
+ @BeforeMethod(alwaysRun = true)
@Override
protected void setup() throws Exception {
super.internalSetup();
}
- @AfterClass(alwaysRun = true)
+ @AfterMethod(alwaysRun = true)
@Override
protected void cleanup() throws Exception {
super.internalCleanup();
@@ -140,7 +140,7 @@ public class ManagedCursorMetricsTest extends MockedPulsarServiceBaseTest {
}
}
metricsList = metrics.generate();
- Assert.assertEquals(metricsList.size(), 3);
+ Assert.assertEquals(metricsList.size(), 2);
Assert.assertEquals(metricsList.get(0).getMetrics().get("brk_ml_cursor_writeLedgerSize"), 26L);
Assert.assertEquals(metricsList.get(0).getMetrics().get("brk_ml_cursor_writeLedgerLogicalSize"), 13L);
Assert.assertEquals(metricsList.get(0).getMetrics().get("brk_ml_cursor_readLedgerSize"), 0L);
@@ -148,9 +148,5 @@ public class ManagedCursorMetricsTest extends MockedPulsarServiceBaseTest {
Assert.assertEquals(metricsList.get(1).getMetrics().get("brk_ml_cursor_writeLedgerSize"), 26L);
Assert.assertEquals(metricsList.get(1).getMetrics().get("brk_ml_cursor_writeLedgerLogicalSize"), 13L);
Assert.assertEquals(metricsList.get(1).getMetrics().get("brk_ml_cursor_readLedgerSize"), 0L);
-
- Assert.assertEquals(metricsList.get(2).getMetrics().get("brk_ml_cursor_writeLedgerSize"), 52L);
- Assert.assertEquals(metricsList.get(2).getMetrics().get("brk_ml_cursor_writeLedgerLogicalSize"), 26L);
- Assert.assertEquals(metricsList.get(2).getMetrics().get("brk_ml_cursor_readLedgerSize"), 0L);
}
}
