Skip to content

Commit 5a3271c

Browse files
author
qifanwang
committed
fix bug for unit test
1 parent 568983b commit 5a3271c

File tree

7 files changed

+12
-7
lines changed

7 files changed

+12
-7
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
sh install.sh
3636
3737
- name: Cache Maven packages
38-
uses: actions/cache@v2
38+
uses: actions/cache@v4
3939
with:
4040
path: ~/.m2
4141
key: ${{ runner.os }}-m2-2022-11-30-${{ hashFiles('**/pom.xml') }}

core/src/test/java/com/ctrip/xpipe/AbstractTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ protected boolean assertSuccess(Runnable assertion) {
194194

195195
protected void waitConditionUntilTimeOut(BooleanSupplier booleanSupplier) throws TimeoutException {
196196

197-
waitConditionUntilTimeOut(booleanSupplier, 5000, 2);
197+
waitConditionUntilTimeOut(booleanSupplier, 10000, 2);
198198
}
199199

200200
protected void waitConditionUntilTimeOut(BooleanSupplier booleanSupplier, int waitTimeMilli) throws TimeoutException {

redis/redis-keeper/src/test/java/com/ctrip/xpipe/redis/keeper/impl/DefaultRedisMasterReplicationTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
import com.ctrip.xpipe.redis.keeper.AbstractRedisKeeperTest;
1111
import com.ctrip.xpipe.redis.keeper.RedisKeeperServer;
1212
import com.ctrip.xpipe.redis.keeper.RedisMaster;
13+
import com.ctrip.xpipe.redis.keeper.config.DefaultKeeperConfig;
1314
import com.ctrip.xpipe.redis.keeper.config.DefaultKeeperResourceManager;
1415
import com.ctrip.xpipe.redis.keeper.config.KeeperResourceManager;
16+
import com.ctrip.xpipe.redis.keeper.config.TestKeeperConfig;
1517
import com.ctrip.xpipe.redis.keeper.monitor.KeeperMonitor;
1618
import com.ctrip.xpipe.simpleserver.Server;
1719
import com.ctrip.xpipe.utils.DefaultLeakyBucket;
@@ -80,6 +82,7 @@ public void beforeDefaultRedisMasterReplicationTest() throws Exception {
8082
defaultRedisMasterReplication = new DefaultRedisMasterReplication(redisMaster, redisKeeperServer, nioEventLoopGroup,
8183
scheduled, proxyResourceManager);
8284
when(redisKeeperServer.getRedisKeeperServerState()).thenReturn(new RedisKeeperServerStateActive(redisKeeperServer));
85+
when(redisKeeperServer.getKeeperConfig()).thenReturn(new TestKeeperConfig());
8386

8487
when(redisMaster.getCurrentReplicationStore()).thenReturn(replicationStore);
8588
when(replicationStore.getMetaStore()).thenReturn(metaStore);

redis/redis-keeper/src/test/java/com/ctrip/xpipe/redis/keeper/impl/fakeredis/DefaultRedisKeeperServerConnectToFakeRedisTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private void startKeeperServerAndTestReFullSync(int fileToKeep, int maxTransferC
5555

5656
RedisKeeperServer redisKeeperServer = startRedisKeeperServerAndConnectToFakeRedis(fileToKeep, maxTransferCommnadsSize, 1000);
5757
int keeperPort = redisKeeperServer.getListeningPort();
58-
sleep(3000);
58+
sleep(5000);
5959
logger.info(remarkableMessage("send psync to redump rdb"));
6060

6161
int rdbDumpCount1 = ((DefaultReplicationStore)redisKeeperServer.getReplicationStore()).getRdbUpdateCount();

redis/redis-keeper/src/test/java/com/ctrip/xpipe/redis/keeper/impl/fakeredis/FakeRedisHalfRdbServerFail.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void redisFailWhileSendingRdb() throws Exception {
4444
logger.info(remarkableMessage("[redisFailWhileSendingRdb]"));
4545
InMemoryPsync inMemoryPsync = sendInmemoryPsync("localhost", redisKeeperServer.getListeningPort());
4646

47-
sleep(1500);
47+
sleep(3000);
4848
assertPsyncResultEquals(inMemoryPsync);
4949

5050
}
@@ -67,7 +67,7 @@ public void redisFailKeeperRestartDumpNewRdb() throws Exception {
6767
SimplePsyncObserver simplePsyncObserver = new SimplePsyncObserver();
6868
InMemoryPsync inMemoryPsync = sendInmemoryPsync("localhost", redisKeeperServer.getListeningPort(), simplePsyncObserver);
6969
//wait
70-
simplePsyncObserver.getOnline().get(5000, TimeUnit.MILLISECONDS);
70+
simplePsyncObserver.getOnline().get(6000, TimeUnit.MILLISECONDS);
7171
//wait for commands
7272
sleep(1000);
7373

redis/redis-proxy/src/test/java/com/ctrip/xpipe/redis/proxy/handler/BackendSessionHandlerTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.junit.Before;
1313
import org.junit.Test;
1414
import org.mockito.Mock;
15+
import org.mockito.Mockito;
1516
import org.mockito.MockitoAnnotations;
1617
import org.mockito.invocation.InvocationOnMock;
1718
import org.mockito.stubbing.Answer;
@@ -76,7 +77,7 @@ public void testByteBufReleasedAfterPipelineBroken() {
7677
ByteBuf byteBuf = Unpooled.copiedBuffer("test".getBytes());
7778
channel.writeInbound(byteBuf);
7879
Assert.assertEquals(0, byteBuf.refCnt());
79-
Assert.assertFalse(channel.isOpen());
80+
Mockito.verify(session).release();
8081
}
8182

8283
}

redis/redis-proxy/src/test/java/com/ctrip/xpipe/redis/proxy/handler/FrontendSessionNettyHandlerTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.junit.Before;
1616
import org.junit.Test;
1717
import org.mockito.Mock;
18+
import org.mockito.Mockito;
1819
import org.mockito.MockitoAnnotations;
1920
import org.mockito.invocation.InvocationOnMock;
2021
import org.mockito.stubbing.Answer;
@@ -114,7 +115,7 @@ public void testByteBufReleasedAfterPipelineBroken() {
114115
ByteBuf byteBuf = Unpooled.copiedBuffer("test".getBytes());
115116
channel.writeInbound(byteBuf);
116117
Assert.assertEquals(0, byteBuf.refCnt());
117-
Assert.assertFalse(channel.isOpen());
118+
Mockito.verify(session).release();
118119
}
119120

120121
}

0 commit comments

Comments
 (0)