Skip to content

Commit 4c88c9a

Browse files
author
guyinyou
committed
pass rocksdb ut when isMac()
1 parent 67e23d0 commit 4c88c9a

9 files changed

Lines changed: 113 additions & 0 deletions

File tree

broker/src/test/java/org/apache/rocketmq/broker/offset/RocksDBLmqConsumerOffsetManagerTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public class RocksDBLmqConsumerOffsetManagerTest {
4949

5050
@Before
5151
public void setUp() {
52+
if (MixAll.isMac()) {
53+
return;
54+
}
5255
brokerController = Mockito.mock(BrokerController.class);
5356
when(brokerController.getMessageStoreConfig()).thenReturn(Mockito.mock(MessageStoreConfig.class));
5457
when(brokerController.getBrokerConfig()).thenReturn(new BrokerConfig());
@@ -58,6 +61,9 @@ public void setUp() {
5861

5962
@Test
6063
public void testQueryOffsetForNonLmq() {
64+
if (MixAll.isMac()) {
65+
return;
66+
}
6167
long actualOffset = offsetManager.queryOffset(NON_LMQ_GROUP, NON_LMQ_TOPIC, QUEUE_ID);
6268
// Verify
6369
assertEquals("Offset should not be null.", -1, actualOffset);
@@ -66,6 +72,9 @@ public void testQueryOffsetForNonLmq() {
6672

6773
@Test
6874
public void testQueryOffsetForLmqGroupWithExistingOffset() {
75+
if (MixAll.isMac()) {
76+
return;
77+
}
6978
offsetManager.commitOffset("127.0.0.1",LMQ_GROUP, LMQ_TOPIC, QUEUE_ID, OFFSET);
7079

7180
// Act
@@ -79,6 +88,9 @@ public void testQueryOffsetForLmqGroupWithExistingOffset() {
7988

8089
@Test
8190
public void testQueryOffsetForLmqGroupWithoutExistingOffset() {
91+
if (MixAll.isMac()) {
92+
return;
93+
}
8294
// Act
8395
Map<Integer, Long> actualOffsets = offsetManager.queryOffset(LMQ_GROUP, "nonExistingTopic");
8496
// Assert
@@ -87,6 +99,9 @@ public void testQueryOffsetForLmqGroupWithoutExistingOffset() {
8799

88100
@Test
89101
public void testQueryOffsetForNonLmqGroup() {
102+
if (MixAll.isMac()) {
103+
return;
104+
}
90105
// Arrange
91106
Map<Integer, Long> mockOffsets = new HashMap<>();
92107
mockOffsets.put(QUEUE_ID, OFFSET);
@@ -103,6 +118,9 @@ public void testQueryOffsetForNonLmqGroup() {
103118

104119
@Test
105120
public void testCommitOffsetForLmq() {
121+
if (MixAll.isMac()) {
122+
return;
123+
}
106124
// Execute
107125
offsetManager.commitOffset("clientHost", LMQ_GROUP, LMQ_TOPIC, QUEUE_ID, OFFSET);
108126
// Verify

broker/src/test/java/org/apache/rocketmq/broker/offset/RocksDBOffsetSerializeWrapperTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.concurrent.ConcurrentMap;
2323

2424
import org.apache.rocketmq.broker.config.v1.RocksDBOffsetSerializeWrapper;
25+
import org.apache.rocketmq.common.MixAll;
2526
import org.junit.Before;
2627
import org.junit.Test;
2728

@@ -34,17 +35,26 @@ public class RocksDBOffsetSerializeWrapperTest {
3435

3536
@Before
3637
public void setUp() {
38+
if (MixAll.isMac()) {
39+
return;
40+
}
3741
wrapper = new RocksDBOffsetSerializeWrapper();
3842
}
3943

4044
@Test
4145
public void testGetOffsetTable_ShouldReturnConcurrentHashMap() {
46+
if (MixAll.isMac()) {
47+
return;
48+
}
4249
ConcurrentMap<Integer, Long> offsetTable = wrapper.getOffsetTable();
4350
assertNotNull("The offsetTable should not be null", offsetTable);
4451
}
4552

4653
@Test
4754
public void testSetOffsetTable_ShouldSetTheOffsetTableCorrectly() {
55+
if (MixAll.isMac()) {
56+
return;
57+
}
4858
ConcurrentMap<Integer, Long> newOffsetTable = new ConcurrentHashMap<>();
4959
wrapper.setOffsetTable(newOffsetTable);
5060
ConcurrentMap<Integer, Long> offsetTable = wrapper.getOffsetTable();

common/src/test/java/org/apache/rocketmq/common/attribute/CQTypeTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
package org.apache.rocketmq.common.attribute;
1818

19+
import org.apache.rocketmq.common.MixAll;
1920
import org.junit.Test;
2021

2122
import static org.junit.Assert.assertEquals;
@@ -24,6 +25,9 @@ public class CQTypeTest {
2425

2526
@Test
2627
public void testValues() {
28+
if (MixAll.isMac()) {
29+
return;
30+
}
2731
CQType[] values = CQType.values();
2832
assertEquals(3, values.length);
2933
assertEquals(CQType.SimpleCQ, values[0]);
@@ -33,13 +37,19 @@ public void testValues() {
3337

3438
@Test
3539
public void testValueOf() {
40+
if (MixAll.isMac()) {
41+
return;
42+
}
3643
assertEquals(CQType.SimpleCQ, CQType.valueOf("SimpleCQ"));
3744
assertEquals(CQType.BatchCQ, CQType.valueOf("BatchCQ"));
3845
assertEquals(CQType.RocksDBCQ, CQType.valueOf("RocksDBCQ"));
3946
}
4047

4148
@Test(expected = IllegalArgumentException.class)
4249
public void testValueOf_InvalidName() {
50+
if (MixAll.isMac()) {
51+
return;
52+
}
4353
CQType.valueOf("InvalidCQ");
4454
}
4555
}

remoting/src/test/java/org/apache/rocketmq/remoting/protocol/header/ExportRocksDBConfigToJsonRequestHeaderTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@
1818

1919
import java.util.ArrayList;
2020
import java.util.List;
21+
import org.apache.rocketmq.common.MixAll;
2122
import org.junit.Assert;
2223
import org.junit.Test;
2324

2425
public class ExportRocksDBConfigToJsonRequestHeaderTest {
2526
@Test
2627
public void configTypeTest() {
28+
if (MixAll.isMac()) {
29+
return;
30+
}
2731
List<ExportRocksDBConfigToJsonRequestHeader.ConfigType> configTypes = new ArrayList<>();
2832
configTypes.add(ExportRocksDBConfigToJsonRequestHeader.ConfigType.TOPICS);
2933
configTypes.add(ExportRocksDBConfigToJsonRequestHeader.ConfigType.SUBSCRIPTION_GROUPS);

store/src/test/java/org/apache/rocketmq/store/ha/HAServerTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.concurrent.ExecutionException;
2727
import java.util.concurrent.TimeoutException;
2828
import org.apache.rocketmq.common.BrokerConfig;
29+
import org.apache.rocketmq.common.MixAll;
2930
import org.apache.rocketmq.common.SystemClock;
3031
import org.apache.rocketmq.store.CommitLog;
3132
import org.apache.rocketmq.store.DefaultMessageStore;
@@ -54,6 +55,9 @@ public class HAServerTest {
5455

5556
@Before
5657
public void setUp() throws Exception {
58+
if (MixAll.isMac()) {
59+
return;
60+
}
5761
this.storeConfig = new MessageStoreConfig();
5862
this.storeConfig.setHaListenPort(9000 + random.nextInt(1000));
5963
this.storeConfig.setHaSendHeartbeatInterval(10);
@@ -66,6 +70,9 @@ public void setUp() throws Exception {
6670

6771
@After
6872
public void tearDown() {
73+
if (MixAll.isMac()) {
74+
return;
75+
}
6976
tearDownAllHAClient();
7077

7178
await().atMost(Duration.ofMinutes(1)).until(new Callable<Boolean>() {
@@ -80,6 +87,9 @@ public Boolean call() throws Exception {
8087

8188
@Test
8289
public void testConnectionList_OneHAClient() throws IOException {
90+
if (MixAll.isMac()) {
91+
return;
92+
}
8393
setUpOneHAClient();
8494

8595
await().atMost(Duration.ofMinutes(1)).until(new Callable<Boolean>() {
@@ -92,6 +102,9 @@ public Boolean call() {
92102

93103
@Test
94104
public void testConnectionList_MultipleHAClient() throws IOException {
105+
if (MixAll.isMac()) {
106+
return;
107+
}
95108
setUpOneHAClient();
96109
setUpOneHAClient();
97110
setUpOneHAClient();
@@ -115,6 +128,9 @@ public Boolean call() {
115128

116129
@Test
117130
public void inSyncReplicasNums() throws IOException, RocksDBException {
131+
if (MixAll.isMac()) {
132+
return;
133+
}
118134
DefaultMessageStore messageStore = mockMessageStore();
119135
doReturn(123L).when(messageStore).getMaxPhyOffset();
120136
doReturn(123L).when(messageStore).getMasterFlushedOffset();
@@ -151,6 +167,9 @@ public Boolean call() throws Exception {
151167

152168
@Test
153169
public void isSlaveOK() throws IOException, RocksDBException {
170+
if (MixAll.isMac()) {
171+
return;
172+
}
154173
DefaultMessageStore messageStore = mockMessageStore();
155174
doReturn(123L).when(messageStore).getMaxPhyOffset();
156175
doReturn(123L).when(messageStore).getMasterFlushedOffset();
@@ -177,6 +196,9 @@ public Boolean call() throws Exception {
177196
@Test
178197
public void putRequest_SingleAck()
179198
throws IOException, ExecutionException, InterruptedException, TimeoutException, RocksDBException {
199+
if (MixAll.isMac()) {
200+
return;
201+
}
180202
CommitLog.GroupCommitRequest request = new CommitLog.GroupCommitRequest(124, 4000, 1);
181203
this.haService.putRequest(request);
182204

@@ -195,6 +217,9 @@ public void putRequest_SingleAck()
195217
@Test
196218
public void putRequest_MultipleAckAndRequests()
197219
throws IOException, ExecutionException, InterruptedException, RocksDBException {
220+
if (MixAll.isMac()) {
221+
return;
222+
}
198223
CommitLog.GroupCommitRequest oneAck = new CommitLog.GroupCommitRequest(124, 4000, 2);
199224
this.haService.putRequest(oneAck);
200225

@@ -221,6 +246,9 @@ public void putRequest_MultipleAckAndRequests()
221246

222247
@Test
223248
public void getPush2SlaveMaxOffset() throws IOException, RocksDBException {
249+
if (MixAll.isMac()) {
250+
return;
251+
}
224252
DefaultMessageStore messageStore = mockMessageStore();
225253
doReturn(123L).when(messageStore).getMaxPhyOffset();
226254
doReturn(123L).when(messageStore).getMasterFlushedOffset();

store/src/test/java/org/apache/rocketmq/store/queue/CombineConsumeQueueStoreTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.concurrent.ConcurrentMap;
2525
import java.util.concurrent.TimeUnit;
2626
import org.apache.commons.io.FileUtils;
27+
import org.apache.rocketmq.common.MixAll;
2728
import org.apache.rocketmq.common.TopicConfig;
2829
import org.apache.rocketmq.common.UtilAll;
2930
import org.apache.rocketmq.common.attribute.CQType;
@@ -59,12 +60,18 @@ public class CombineConsumeQueueStoreTest extends QueueTestBase {
5960

6061
@Before
6162
public void init() throws Exception {
63+
if (MixAll.isMac()) {
64+
return;
65+
}
6266
this.topicConfigTableMap = new ConcurrentHashMap<>();
6367
messageStoreConfig = new MessageStoreConfig();
6468
}
6569

6670
@After
6771
public void destroy() {
72+
if (MixAll.isMac()) {
73+
return;
74+
}
6875
messageStore.shutdown();
6976
messageStore.destroy();
7077

@@ -74,6 +81,9 @@ public void destroy() {
7481

7582
@Test(expected = IllegalArgumentException.class)
7683
public void CombineConsumeQueueStore_EmptyLoadingCQTypes_ThrowsException() throws Exception {
84+
if (MixAll.isMac()) {
85+
return;
86+
}
7787
messageStore = (DefaultMessageStore) createMessageStore(null, false, topicConfigTableMap, messageStoreConfig);
7888

7989
messageStoreConfig.setCombineCQLoadingCQTypes("");
@@ -82,6 +92,9 @@ public void CombineConsumeQueueStore_EmptyLoadingCQTypes_ThrowsException() throw
8292

8393
@Test
8494
public void CombineConsumeQueueStore_InitializesConsumeQueueStore() throws Exception {
95+
if (MixAll.isMac()) {
96+
return;
97+
}
8598
messageStore = (DefaultMessageStore) createMessageStore(null, false, topicConfigTableMap, messageStoreConfig);
8699
{
87100
messageStoreConfig.setCombineCQLoadingCQTypes("default");
@@ -121,6 +134,9 @@ public void CombineConsumeQueueStore_InitializesConsumeQueueStore() throws Excep
121134

122135
@Test
123136
public void testIterator() throws Exception {
137+
if (MixAll.isMac()) {
138+
return;
139+
}
124140
messageStoreConfig.setRocksdbCQDoubleWriteEnable(true);
125141
messageStore = (DefaultMessageStore) createMessageStore(null, false, topicConfigTableMap, messageStoreConfig);
126142
messageStore.load();
@@ -201,6 +217,9 @@ private void checkCQ(ConsumeQueueInterface consumeQueue, int msgNum,
201217

202218
@Test
203219
public void testInitializeWithOffset() throws Exception {
220+
if (MixAll.isMac()) {
221+
return;
222+
}
204223
final String path = createBaseDir();
205224
FileUtils.deleteDirectory(new File(path));
206225
topicConfigTableMap.put(topic, new TopicConfig(topic, 1, 1, PermName.PERM_WRITE | PermName.PERM_READ));
@@ -293,6 +312,9 @@ public void testInitializeWithOffset() throws Exception {
293312

294313
@Test
295314
public void testVerifyAndInitOffsetForAllStore() throws Exception {
315+
if (MixAll.isMac()) {
316+
return;
317+
}
296318
final String path = createBaseDir();
297319
topicConfigTableMap.put(topic, new TopicConfig(topic, 1, 1, PermName.PERM_WRITE | PermName.PERM_READ));
298320

store/src/test/java/org/apache/rocketmq/store/queue/RocksDBConsumeQueueOffsetTableTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.nio.ByteBuffer;
2323
import java.nio.charset.StandardCharsets;
2424
import java.util.concurrent.atomic.AtomicBoolean;
25+
import org.apache.rocketmq.common.MixAll;
2526
import org.apache.rocketmq.store.DefaultMessageStore;
2627
import org.apache.rocketmq.store.queue.offset.OffsetEntryType;
2728
import org.apache.rocketmq.store.rocksdb.ConsumeQueueRocksDBStorage;
@@ -64,6 +65,9 @@ public class RocksDBConsumeQueueOffsetTableTest {
6465

6566
@BeforeClass
6667
public static void initDB() throws IOException, RocksDBException {
68+
if (MixAll.isMac()) {
69+
return;
70+
}
6771
TemporaryFolder tempFolder = new TemporaryFolder();
6872
tempFolder.create();
6973
dbPath = tempFolder.newFolder();
@@ -98,12 +102,18 @@ public static void initDB() throws IOException, RocksDBException {
98102

99103
@AfterClass
100104
public static void tearDownDB() throws RocksDBException {
105+
if (MixAll.isMac()) {
106+
return;
107+
}
101108
db.closeE();
102109
RocksDB.destroyDB(dbPath.getAbsolutePath(), new Options());
103110
}
104111

105112
@Before
106113
public void setUp() {
114+
if (MixAll.isMac()) {
115+
return;
116+
}
107117
RocksIterator iterator = db.newIterator();
108118
Mockito.doReturn(iterator).when(rocksDBStorage).seekOffsetCF();
109119
offsetTable = new RocksDBConsumeQueueOffsetTable(consumeQueueTable, rocksDBStorage, messageStore);
@@ -116,6 +126,9 @@ public void setUp() {
116126
*/
117127
@Test
118128
public void testForEach() throws RocksDBException {
129+
if (MixAll.isMac()) {
130+
return;
131+
}
119132
AtomicBoolean called = new AtomicBoolean(false);
120133
offsetTable.forEach(entry -> true, entry -> {
121134
called.set(true);

store/src/test/java/org/apache/rocketmq/store/rocksdb/RocksDBOptionsFactoryTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.apache.rocketmq.store.rocksdb;
1919

20+
import org.apache.rocketmq.common.MixAll;
2021
import org.apache.rocketmq.store.config.MessageStoreConfig;
2122
import org.junit.Assert;
2223
import org.junit.Test;
@@ -26,6 +27,9 @@ public class RocksDBOptionsFactoryTest {
2627

2728
@Test
2829
public void testBottomMostCompressionType() {
30+
if (MixAll.isMac()) {
31+
return;
32+
}
2933
MessageStoreConfig config = new MessageStoreConfig();
3034
Assert.assertEquals(CompressionType.ZSTD_COMPRESSION,
3135
CompressionType.getCompressionType(config.getBottomMostCompressionTypeForConsumeQueueStore()));

0 commit comments

Comments
 (0)