提交 4d760164 编写于 作者: V vongosling

Polish parts slow UT

上级 788c757a
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.apache.rocketmq.broker; package org.apache.rocketmq.broker;
import java.io.File;
import org.apache.rocketmq.common.BrokerConfig; import org.apache.rocketmq.common.BrokerConfig;
import org.apache.rocketmq.common.UtilAll; import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.remoting.netty.NettyClientConfig; import org.apache.rocketmq.remoting.netty.NettyClientConfig;
...@@ -25,16 +26,10 @@ import org.apache.rocketmq.store.config.MessageStoreConfig; ...@@ -25,16 +26,10 @@ import org.apache.rocketmq.store.config.MessageStoreConfig;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
import java.io.File;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
public class BrokerControllerTest { public class BrokerControllerTest {
/**
* Tests if the controller can be properly stopped and started.
*
* @throws Exception If fails.
*/
@Test @Test
public void testBrokerRestart() throws Exception { public void testBrokerRestart() throws Exception {
BrokerController brokerController = new BrokerController( BrokerController brokerController = new BrokerController(
...@@ -48,7 +43,7 @@ public class BrokerControllerTest { ...@@ -48,7 +43,7 @@ public class BrokerControllerTest {
} }
@After @After
public void destory() { public void destroy() {
UtilAll.deleteFile(new File(new MessageStoreConfig().getStorePathRootDir())); UtilAll.deleteFile(new File(new MessageStoreConfig().getStorePathRootDir()));
} }
} }
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
package org.apache.rocketmq.logappender; package org.apache.rocketmq.logappender;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.rocketmq.client.exception.MQClientException;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
...@@ -30,7 +29,7 @@ public abstract class Log4jTest extends AbstractTestCase { ...@@ -30,7 +29,7 @@ public abstract class Log4jTest extends AbstractTestCase {
public abstract String getType(); public abstract String getType();
@Test @Test
public void testLog4j() throws InterruptedException, MQClientException { public void testLog4j() {
clear(); clear();
Logger logger = Logger.getLogger("testLogger"); Logger logger = Logger.getLogger("testLogger");
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
......
...@@ -20,15 +20,13 @@ import ch.qos.logback.classic.LoggerContext; ...@@ -20,15 +20,13 @@ import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator; import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException; import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.util.StatusPrinter; import ch.qos.logback.core.util.StatusPrinter;
import org.apache.rocketmq.client.exception.MQClientException; import java.io.File;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File;
public class LogbackTest extends AbstractTestCase { public class LogbackTest extends AbstractTestCase {
@Before @Before
...@@ -42,7 +40,7 @@ public class LogbackTest extends AbstractTestCase { ...@@ -42,7 +40,7 @@ public class LogbackTest extends AbstractTestCase {
} }
@Test @Test
public void testLogback() throws InterruptedException, MQClientException { public void testLogback() {
clear(); clear();
Logger logger = LoggerFactory.getLogger("testLogger"); Logger logger = LoggerFactory.getLogger("testLogger");
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
......
...@@ -35,7 +35,7 @@ import static org.mockito.Mockito.spy; ...@@ -35,7 +35,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class DefaultMessageStoreShuwDownTest { public class DefaultMessageStoreShutdownTest {
private DefaultMessageStore messageStore; private DefaultMessageStore messageStore;
@Before @Before
...@@ -48,7 +48,7 @@ public class DefaultMessageStoreShuwDownTest { ...@@ -48,7 +48,7 @@ public class DefaultMessageStoreShuwDownTest {
} }
@Test @Test
public void testDispatchBehindWhenShutDown() { public void testDispatchBehindWhenShutdown() {
messageStore.shutdown(); messageStore.shutdown();
assertTrue(!messageStore.shutDownNormal); assertTrue(!messageStore.shutDownNormal);
File file = new File(StorePathConfigHelper.getAbortFile(messageStore.getMessageStoreConfig().getStorePathRootDir())); File file = new File(StorePathConfigHelper.getAbortFile(messageStore.getMessageStoreConfig().getStorePathRootDir()));
...@@ -56,7 +56,7 @@ public class DefaultMessageStoreShuwDownTest { ...@@ -56,7 +56,7 @@ public class DefaultMessageStoreShuwDownTest {
} }
@After @After
public void destory() { public void destroy() {
messageStore.destroy(); messageStore.destroy();
File file = new File(messageStore.getMessageStoreConfig().getStorePathRootDir()); File file = new File(messageStore.getMessageStoreConfig().getStorePathRootDir());
UtilAll.deleteFile(file); UtilAll.deleteFile(file);
......
...@@ -59,7 +59,6 @@ public class DefaultMessageStoreTest { ...@@ -59,7 +59,6 @@ public class DefaultMessageStoreTest {
@Test(expected = OverlappingFileLockException.class) @Test(expected = OverlappingFileLockException.class)
public void test_repate_restart() throws Exception { public void test_repate_restart() throws Exception {
long totalMsgs = 100;
QUEUE_TOTAL = 1; QUEUE_TOTAL = 1;
MessageBody = StoreMessage.getBytes(); MessageBody = StoreMessage.getBytes();
...@@ -92,7 +91,7 @@ public class DefaultMessageStoreTest { ...@@ -92,7 +91,7 @@ public class DefaultMessageStoreTest {
UtilAll.deleteFile(file); UtilAll.deleteFile(file);
} }
public MessageStore buildMessageStore() throws Exception { private MessageStore buildMessageStore() throws Exception {
MessageStoreConfig messageStoreConfig = new MessageStoreConfig(); MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
messageStoreConfig.setMapedFileSizeCommitLog(1024 * 1024 * 10); messageStoreConfig.setMapedFileSizeCommitLog(1024 * 1024 * 10);
messageStoreConfig.setMapedFileSizeConsumeQueue(1024 * 1024 * 10); messageStoreConfig.setMapedFileSizeConsumeQueue(1024 * 1024 * 10);
...@@ -103,8 +102,8 @@ public class DefaultMessageStoreTest { ...@@ -103,8 +102,8 @@ public class DefaultMessageStoreTest {
} }
@Test @Test
public void testWriteAndRead() throws Exception { public void testWriteAndRead() {
long totalMsgs = 100; long totalMsgs = 10;
QUEUE_TOTAL = 1; QUEUE_TOTAL = 1;
MessageBody = StoreMessage.getBytes(); MessageBody = StoreMessage.getBytes();
for (long i = 0; i < totalMsgs; i++) { for (long i = 0; i < totalMsgs; i++) {
...@@ -119,7 +118,7 @@ public class DefaultMessageStoreTest { ...@@ -119,7 +118,7 @@ public class DefaultMessageStoreTest {
verifyThatMasterIsFunctional(totalMsgs, messageStore); verifyThatMasterIsFunctional(totalMsgs, messageStore);
} }
public MessageExtBrokerInner buildMessage() { private MessageExtBrokerInner buildMessage() {
MessageExtBrokerInner msg = new MessageExtBrokerInner(); MessageExtBrokerInner msg = new MessageExtBrokerInner();
msg.setTopic("FooBar"); msg.setTopic("FooBar");
msg.setTags("TAG1"); msg.setTags("TAG1");
...@@ -134,23 +133,6 @@ public class DefaultMessageStoreTest { ...@@ -134,23 +133,6 @@ public class DefaultMessageStoreTest {
return msg; return msg;
} }
@Test
public void testGroupCommit() throws Exception {
long totalMsgs = 10;
QUEUE_TOTAL = 1;
MessageBody = StoreMessage.getBytes();
for (long i = 0; i < totalMsgs; i++) {
messageStore.putMessage(buildMessage());
}
for (long i = 0; i < totalMsgs; i++) {
GetMessageResult result = messageStore.getMessage("GROUP_A", "TOPIC_A", 0, i, 1024 * 1024, null);
assertThat(result).isNotNull();
result.release();
}
verifyThatMasterIsFunctional(totalMsgs, messageStore);
}
private void verifyThatMasterIsFunctional(long totalMsgs, MessageStore master) { private void verifyThatMasterIsFunctional(long totalMsgs, MessageStore master) {
for (long i = 0; i < totalMsgs; i++) { for (long i = 0; i < totalMsgs; i++) {
master.putMessage(buildMessage()); master.putMessage(buildMessage());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册