You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ma...@apache.org on 2022/07/15 10:33:41 UTC
[pulsar] branch branch-2.9 updated: [fix][test][branch-2.10] Fix test TransactionEndToEndTest#testSendTxnMessageTimeout (only release branches) (#16570)
This is an automated email from the ASF dual-hosted git repository.
mattisonchao pushed a commit to branch branch-2.9
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/branch-2.9 by this push:
new 8ca3941c00e [fix][test][branch-2.10] Fix test TransactionEndToEndTest#testSendTxnMessageTimeout (only release branches) (#16570)
8ca3941c00e is described below
commit 8ca3941c00e30f4c9de25c2fb02da7cfe9d94828
Author: Nicolò Boschi <bo...@gmail.com>
AuthorDate: Thu Jul 14 10:17:11 2022 +0200
[fix][test][branch-2.10] Fix test TransactionEndToEndTest#testSendTxnMessageTimeout (only release branches) (#16570)
### Motivation
`TransactionEndToEndTest#testSendTxnMessageTimeout` fails on releases branch after https://github.com/apache/pulsar/pull/16519 has been cherry-picked.
```
java.lang.AssertionError: expected [true] but found [false]
at org.testng.Assert.fail(Assert.java:99)
at org.testng.Assert.failNotEquals(Assert.java:1037)
at org.testng.Assert.assertTrue(Assert.java:45)
at org.testng.Assert.assertTrue(Assert.java:55)
at org.apache.pulsar.client.impl.TransactionEndToEndTest.testSendTxnMessageTimeout(TransactionEndToEndTest.java:1099)
```
The reason is that the mock setup must be slightly different since the `ProducerImpl` is not exactly the same between master and branch-2.10.
---
.../java/org/apache/pulsar/client/impl/TransactionEndToEndTest.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/TransactionEndToEndTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/TransactionEndToEndTest.java
index d3e8674925c..3c0fe8f8e52 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/TransactionEndToEndTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/TransactionEndToEndTest.java
@@ -23,6 +23,7 @@ import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
@@ -37,7 +38,9 @@ import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
+import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.DefaultEventLoop;
import io.netty.util.concurrent.EventExecutor;
import lombok.Cleanup;
import lombok.extern.slf4j.Slf4j;
@@ -1080,7 +1083,10 @@ public class TransactionEndToEndTest extends TransactionTestBase {
// mock cnx, send message can't receive response
ClientCnx cnx = mock(ClientCnx.class);
+ Channel channel = mock(Channel.class);
+ doReturn(spy(DefaultEventLoop.class)).when(channel).eventLoop();
ChannelHandlerContext channelHandlerContext = mock(ChannelHandlerContext.class);
+ doReturn(channel).when(channelHandlerContext).channel();
doReturn(channelHandlerContext).when(cnx).ctx();
EventExecutor eventExecutor = mock(EventExecutor.class);
doReturn(eventExecutor).when(channelHandlerContext).executor();