Skip to content

Commit 16f3db6

Browse files
committed
Update unit test
1 parent f65ec96 commit 16f3db6

File tree

1 file changed

+7
-3
lines changed
  • kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/client

1 file changed

+7
-3
lines changed

kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/client/MySQLBinlogClientTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import io.netty.channel.nio.NioEventLoopGroup;
2424
import io.netty.util.Attribute;
2525
import io.netty.util.concurrent.Promise;
26+
import lombok.SneakyThrows;
2627
import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLConstants;
2728
import org.apache.shardingsphere.db.protocol.mysql.packet.command.binlog.MySQLComBinlogDumpCommandPacket;
2829
import org.apache.shardingsphere.db.protocol.mysql.packet.command.binlog.MySQLComRegisterSlaveCommandPacket;
@@ -40,6 +41,7 @@
4041

4142
import java.net.InetSocketAddress;
4243
import java.util.Collections;
44+
import java.util.concurrent.TimeUnit;
4345
import java.util.concurrent.atomic.AtomicInteger;
4446

4547
import static org.hamcrest.CoreMatchers.is;
@@ -131,9 +133,11 @@ private void mockChannelResponse(final Object response) {
131133
new Thread(() -> mockChannelResponseInThread(response)).start();
132134
}
133135

136+
@SneakyThrows(InterruptedException.class)
134137
@SuppressWarnings("unchecked")
135138
private void mockChannelResponseInThread(final Object response) {
136-
while (true) {
139+
long t1 = System.currentTimeMillis();
140+
do {
137141
Promise<Object> responseCallback;
138142
try {
139143
responseCallback = (Promise<Object>) Plugins.getMemberAccessor().get(MySQLBinlogClient.class.getDeclaredField("responseCallback"), client);
@@ -142,9 +146,9 @@ private void mockChannelResponseInThread(final Object response) {
142146
}
143147
if (null != responseCallback) {
144148
responseCallback.setSuccess(response);
145-
break;
146149
}
147-
}
150+
TimeUnit.SECONDS.sleep(1L);
151+
} while (System.currentTimeMillis() - t1 <= TimeUnit.SECONDS.toMillis(20L));
148152
}
149153

150154
@Test

0 commit comments

Comments
 (0)