This is an automated email from the ASF dual-hosted git repository.
ShannonDing pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git
The following commit(s) were added to refs/heads/develop by this push:
new d4ef859054 Close RocksDB before deleting the topic transfer test store
(#11569)
d4ef859054 is described below
commit d4ef859054995569d450ac18632a6995e6ee22b7
Author: Hilarious12138 <[email protected]>
AuthorDate: Mon Nov 23 19:03:42 2026 +0800
Close RocksDB before deleting the topic transfer test store (#11569)
Let JUnit remove the per-test store after the manager has stopped. Compare
the reopened topic configuration with the JSON source to verify the migration
survives a restart.
---
.../topic/RocksdbTopicConfigTransferTest.java | 33 ++++------------------
1 file changed, 6 insertions(+), 27 deletions(-)
diff --git
a/broker/src/test/java/org/apache/rocketmq/broker/topic/RocksdbTopicConfigTransferTest.java
b/broker/src/test/java/org/apache/rocketmq/broker/topic/RocksdbTopicConfigTransferTest.java
index e925ed4bd8..01fae68596 100644
---
a/broker/src/test/java/org/apache/rocketmq/broker/topic/RocksdbTopicConfigTransferTest.java
+++
b/broker/src/test/java/org/apache/rocketmq/broker/topic/RocksdbTopicConfigTransferTest.java
@@ -28,28 +28,24 @@ import org.apache.rocketmq.store.config.MessageStoreConfig;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
-import java.util.UUID;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class RocksdbTopicConfigTransferTest {
- private final String basePath = Paths.get(System.getProperty("user.home"),
- "unit-test-store", UUID.randomUUID().toString().substring(0,
16).toUpperCase()).toString();
+ @Rule
+ public final TemporaryFolder storeDirectory =
TemporaryFolder.builder().assureDeletion().build();
private RocksDBTopicConfigManager rocksdbTopicConfigManager;
@@ -68,7 +64,7 @@ public class RocksdbTopicConfigTransferTest {
BrokerConfig brokerConfig = new BrokerConfig();
when(brokerController.getBrokerConfig()).thenReturn(brokerConfig);
MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
- messageStoreConfig.setStorePathRootDir(basePath);
+
messageStoreConfig.setStorePathRootDir(storeDirectory.getRoot().getAbsolutePath());
Mockito.lenient().when(brokerController.getMessageStoreConfig()).thenReturn(messageStoreConfig);
when(brokerController.getMessageStore()).thenReturn(defaultMessageStore);
when(defaultMessageStore.getStateMachineVersion()).thenReturn(0L);
@@ -76,23 +72,6 @@ public class RocksdbTopicConfigTransferTest {
@After
public void destroy() {
- if (notToBeExecuted()) {
- return;
- }
- Path pathToBeDeleted = Paths.get(basePath);
- try {
- Files.walk(pathToBeDeleted)
- .sorted(Comparator.reverseOrder())
- .forEach(path -> {
- try {
- Files.delete(path);
- } catch (IOException e) {
- // ignore
- }
- });
- } catch (IOException e) {
- // ignore
- }
if (rocksdbTopicConfigManager != null) {
rocksdbTopicConfigManager.stop();
}
@@ -248,7 +227,7 @@ public class RocksdbTopicConfigTransferTest {
Assert.assertEquals(2L, dataVersion.getCounter().get());
Assert.assertEquals(0L, dataVersion.getStateVersion());
Assert.assertNotEquals(0,
rocksdbTopicConfigManager.getTopicConfigTable().size());
-
Assert.assertEquals(rocksdbTopicConfigManager.getTopicConfigTable().size(),
rocksdbTopicConfigManager.getTopicConfigTable().size());
+ Assert.assertEquals(jsonTopicConfigManager.getTopicConfigTable(),
rocksdbTopicConfigManager.getTopicConfigTable());
}