Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.rocketmq.common.BrokerConfig;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.store.config.MessageStoreConfig;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
Expand Down Expand Up @@ -53,8 +54,15 @@ public void setUp() {
when(brokerController.getMessageStoreConfig()).thenReturn(new MessageStoreConfig());
when(brokerController.getBrokerConfig()).thenReturn(new BrokerConfig());
offsetManager = new RocksDBConsumerOffsetManager(brokerController);
offsetManager.load();
}

@After
public void tearDown() {
if (offsetManager != null) {
offsetManager.stop();
}
}

@Test
public void testQueryOffsetForNonLmq() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.rocketmq.broker.offset;

import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.HashMap;
Expand All @@ -31,6 +32,7 @@
import org.apache.rocketmq.common.CheckRocksdbCqWriteResult;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.Pair;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.store.DefaultMessageStore;
import org.apache.rocketmq.store.DispatchRequest;
import org.apache.rocketmq.store.StoreType;
Expand All @@ -43,6 +45,7 @@
import org.apache.rocketmq.store.queue.RocksDBConsumeQueueStore;
import org.apache.rocketmq.store.stats.BrokerStatsManager;
import org.awaitility.Awaitility;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -95,6 +98,32 @@ public void init() throws IOException {
rocksdbConsumerOffsetManager = new RocksDBConsumerOffsetManager(brokerController);
}

@After
public void tearDown() {
if (notToBeExecuted()) {
return;
}

if (rocksdbConsumerOffsetManager != null) {
rocksdbConsumerOffsetManager.stop();
}

if (consumerOffsetManager != null) {
consumerOffsetManager.stop();
}

if (defaultMessageStore != null) {
ConsumeQueueStoreInterface cqStore = defaultMessageStore.getQueueStore();
cqStore.shutdown();
cqStore.destroy(false);

defaultMessageStore.shutdown();
defaultMessageStore.destroy();
}

UtilAll.deleteFile(new File(basePath));
}

@Test
public void testTransferOffset() {
if (notToBeExecuted()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ public void init() throws IOException {

@After
public void shutdown() throws IOException {
if (consumerService != null) {
consumerService.shutdown();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用例里面已经 shutdown 过了

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}
FileUtils.deleteDirectory(new File(filePath));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ public void destroy() {
if (notToBeExecuted()) {
return;
}

if (rocksDBSubscriptionGroupManager != null) {
rocksDBSubscriptionGroupManager.stop();
}

if (jsonSubscriptionGroupManager != null) {
jsonSubscriptionGroupManager.stop();
}

Path pathToBeDeleted = Paths.get(basePath);

try {
Expand All @@ -93,9 +102,6 @@ public void destroy() {
} catch (IOException e) {
// ignore
}
if (rocksDBSubscriptionGroupManager != null) {
rocksDBSubscriptionGroupManager.stop();
}
}


Expand Down Expand Up @@ -282,7 +288,7 @@ public void theSecondTimeLoadJsonSubscriptionGroupManager() {
}

@Test
public void theSecondTimeLoadRocksdbTopicConfigManager() {
public void theSecondTimeLoadRocksdbSubscriptionGroupManager() {
if (notToBeExecuted()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.rocketmq.broker.topic;

import java.io.File;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.List;
Expand All @@ -29,6 +30,7 @@
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.TopicAttributes;
import org.apache.rocketmq.common.TopicConfig;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.attribute.Attribute;
import org.apache.rocketmq.common.attribute.BooleanAttribute;
import org.apache.rocketmq.common.attribute.CQType;
Expand Down Expand Up @@ -87,6 +89,8 @@ public void destroy() {
if (topicConfigManager != null) {
topicConfigManager.stop();
}

UtilAll.deleteFile(new File(basePath));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ public void destroy() {
if (notToBeExecuted()) {
return;
}

if (rocksdbTopicConfigManager != null) {
rocksdbTopicConfigManager.stop();
}

if (jsonTopicConfigManager != null) {
jsonTopicConfigManager.stop();
}

Path pathToBeDeleted = Paths.get(basePath);
try {
Files.walk(pathToBeDeleted)
Expand All @@ -93,9 +102,6 @@ public void destroy() {
} catch (IOException e) {
// ignore
}
if (rocksdbTopicConfigManager != null) {
rocksdbTopicConfigManager.stop();
}
}

public void initRocksdbTopicConfigManager() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.atomic.AtomicBoolean;

import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.store.DefaultMessageStore;
import org.apache.rocketmq.store.queue.offset.OffsetEntryType;
import org.apache.rocketmq.store.rocksdb.ConsumeQueueRocksDBStorage;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
Expand Down Expand Up @@ -62,6 +65,8 @@ public class RocksDBConsumeQueueOffsetTableTest {

private static String topicName;

private RocksIterator iterator;

@BeforeClass
public static void initDB() throws IOException, RocksDBException {
TemporaryFolder tempFolder = new TemporaryFolder();
Expand Down Expand Up @@ -98,17 +103,30 @@ public static void initDB() throws IOException, RocksDBException {

@AfterClass
public static void tearDownDB() throws RocksDBException {
db.closeE();
RocksDB.destroyDB(dbPath.getAbsolutePath(), new Options());
if (db != null) {
db.closeE();
}

if (dbPath != null) {
RocksDB.destroyDB(dbPath.getAbsolutePath(), new Options());
UtilAll.deleteFile(dbPath);
}
}

@Before
public void setUp() {
RocksIterator iterator = db.newIterator();
iterator = db.newIterator();
Mockito.doReturn(iterator).when(rocksDBStorage).seekOffsetCF();
offsetTable = new RocksDBConsumeQueueOffsetTable(consumeQueueTable, rocksDBStorage, messageStore);
}

@After
public void tearDown() {
if (iterator != null) {
iterator.close();
}
}

/**
* Verify forEach can expand key-buffer properly and works well for long topic names.
*
Expand Down
Loading