diff --git a/pulsar-broker/src/test/java/org/apache/bookkeeper/mledger/impl/MangedLedgerInterceptorImplTest2.java b/pulsar-broker/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerInterceptorImplTest2.java similarity index 76% rename from pulsar-broker/src/test/java/org/apache/bookkeeper/mledger/impl/MangedLedgerInterceptorImplTest2.java rename to pulsar-broker/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerInterceptorImplTest2.java index 080ef9ea4c5fe..b5a610512749c 100644 --- a/pulsar-broker/src/test/java/org/apache/bookkeeper/mledger/impl/MangedLedgerInterceptorImplTest2.java +++ b/pulsar-broker/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerInterceptorImplTest2.java @@ -19,7 +19,7 @@ package org.apache.bookkeeper.mledger.impl; import static org.testng.Assert.assertEquals; -import static org.apache.pulsar.broker.intercept.MangedLedgerInterceptorImplTest.TestPayloadProcessor; +import static org.apache.pulsar.broker.intercept.ManagedLedgerInterceptorImplTest.TestPayloadProcessor; import java.util.HashSet; import java.util.Set; import lombok.extern.slf4j.Slf4j; @@ -28,20 +28,40 @@ import org.apache.bookkeeper.mledger.intercept.ManagedLedgerInterceptor; import org.apache.bookkeeper.test.MockedBookKeeperTestCase; import org.apache.pulsar.broker.intercept.ManagedLedgerInterceptorImpl; -import org.apache.pulsar.broker.intercept.MangedLedgerInterceptorImplTest; +import org.apache.pulsar.broker.intercept.ManagedLedgerInterceptorImplTest; import org.apache.pulsar.common.intercept.ManagedLedgerPayloadProcessor; import org.awaitility.Awaitility; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; /*** - * Differ to {@link MangedLedgerInterceptorImplTest}, this test can call {@link ManagedLedgerImpl}'s methods modified + * Differ to {@link ManagedLedgerInterceptorImplTest}, this test can call {@link ManagedLedgerImpl}'s methods modified * by "default". */ @Slf4j @Test(groups = "broker") -public class MangedLedgerInterceptorImplTest2 extends MockedBookKeeperTestCase { +public class ManagedLedgerInterceptorImplTest2 extends MockedBookKeeperTestCase { - public static void switchLedgerManually(ManagedLedgerImpl ledger){ + private ManagedLedgerImpl ledger; + + + @BeforeMethod + public void setup() throws Exception { + final String mlName = "ml1"; + + // Registry interceptor. + ManagedLedgerConfig config = new ManagedLedgerConfig(); + Set processors = new HashSet<>(); + processors.add(new TestPayloadProcessor()); + ManagedLedgerInterceptor interceptor = new ManagedLedgerInterceptorImpl(new HashSet<>(), processors); + config.setManagedLedgerInterceptor(interceptor); + config.setMaxEntriesPerLedger(100); + + // Open the ledger. + ledger = (ManagedLedgerImpl) factory.open(mlName, config); + } + + public void switchLedgerManually() { LedgerHandle originalLedgerHandle = ledger.currentLedger; ledger.ledgerClosed(ledger.currentLedger); ledger.createLedgerAfterClosed(); @@ -52,34 +72,23 @@ public static void switchLedgerManually(ManagedLedgerImpl ledger){ @Test public void testCurrentLedgerSizeCorrectIfHasInterceptor() throws Exception { - final String mlName = "ml1"; final String cursorName = "cursor1"; - // Registry interceptor. - ManagedLedgerConfig config = new ManagedLedgerConfig(); - Set processors = new HashSet(); - processors.add(new TestPayloadProcessor()); - ManagedLedgerInterceptor interceptor = new ManagedLedgerInterceptorImpl(new HashSet(), processors); - config.setManagedLedgerInterceptor(interceptor); - config.setMaxEntriesPerLedger(100); - // Add one entry. - ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open(mlName, config); ManagedCursorImpl cursor = (ManagedCursorImpl) ledger.openCursor(cursorName); ledger.addEntry(new byte[1]); // Mark "currentLedgerSize" and switch ledger. long currentLedgerSize = ledger.getCurrentLedgerSize(); - switchLedgerManually(ledger); + switchLedgerManually(); // verify. - assertEquals(currentLedgerSize, MangedLedgerInterceptorImplTest.calculatePreciseSize(ledger)); + assertEquals(currentLedgerSize, ManagedLedgerInterceptorImplTest.calculatePreciseSize(ledger)); // cleanup. cursor.close(); ledger.close(); factory.getEntryCacheManager().clear(); factory.shutdown(); - config.setManagedLedgerInterceptor(null); } } diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/v1/V1_AdminApiTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/v1/V1_AdminApiTest.java index 43ec01f47f614..c3e40a191ddec 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/v1/V1_AdminApiTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/v1/V1_AdminApiTest.java @@ -148,6 +148,7 @@ public void setup() throws Exception { conf.setTlsCertificateFilePath(BROKER_CERT_FILE_PATH); conf.setTlsKeyFilePath(BROKER_KEY_FILE_PATH); conf.setNumExecutorThreadPoolSize(5); + conf.setLoadBalancerOverrideBrokerNicSpeedGbps(Optional.of(1.0d)); super.internalSetup(); diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/intercept/MangedLedgerInterceptorImplTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/intercept/ManagedLedgerInterceptorImplTest.java similarity index 99% rename from pulsar-broker/src/test/java/org/apache/pulsar/broker/intercept/MangedLedgerInterceptorImplTest.java rename to pulsar-broker/src/test/java/org/apache/pulsar/broker/intercept/ManagedLedgerInterceptorImplTest.java index 7d164b68147ab..9b3de199da219 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/intercept/MangedLedgerInterceptorImplTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/intercept/ManagedLedgerInterceptorImplTest.java @@ -59,8 +59,8 @@ import static org.testng.Assert.assertNotNull; @Test(groups = "broker") -public class MangedLedgerInterceptorImplTest extends MockedBookKeeperTestCase { - private static final Logger log = LoggerFactory.getLogger(MangedLedgerInterceptorImplTest.class); +public class ManagedLedgerInterceptorImplTest extends MockedBookKeeperTestCase { + private static final Logger log = LoggerFactory.getLogger(ManagedLedgerInterceptorImplTest.class); public static class TestPayloadProcessor implements ManagedLedgerPayloadProcessor { @Override diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerCloseTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerCloseTest.java index 41413f3e3a913..2ea1d96f992fd 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerCloseTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerCloseTest.java @@ -79,6 +79,7 @@ private ServiceConfiguration brokerConfig() { config.setLoadManagerClassName(ExtensibleLoadManagerImpl.class.getName()); config.setLoadBalancerDebugModeEnabled(true); config.setBrokerShutdownTimeoutMs(100); + config.setLoadBalancerOverrideBrokerNicSpeedGbps(Optional.of(1.0d)); return config; } diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/LoadManagerFailFastTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/LoadManagerFailFastTest.java index a400bf733e557..c514567420059 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/LoadManagerFailFastTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/LoadManagerFailFastTest.java @@ -50,6 +50,7 @@ protected void setup() throws Exception { config.setBrokerServicePort(Optional.of(0)); config.setWebServicePort(Optional.of(0)); config.setMetadataStoreUrl("zk:localhost:" + zkPort); + config.setLoadBalancerOverrideBrokerNicSpeedGbps(Optional.of(1.0d)); } @AfterClass