This is an automated email from the ASF dual-hosted git repository.

bogong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 3cb9d4dfc00 [fix][flaky-test] fix flaky test 
`PerformanceTransactionTest` (#18296)
3cb9d4dfc00 is described below

commit 3cb9d4dfc0058819c79ee73490b96d705374f950
Author: labuladong <[email protected]>
AuthorDate: Thu Nov 3 22:34:58 2022 +0800

    [fix][flaky-test] fix flaky test `PerformanceTransactionTest` (#18296)
    
    <!--
    ### Contribution Checklist
    
      - PR title format should be *[type][component] summary*. For details, see 
*[Guideline - Pulsar PR Naming 
Convention](https://docs.google.com/document/d/1d8Pw6ZbWk-_pCKdOmdvx9rnhPiyuxwq60_TrD68d7BA/edit#heading=h.trs9rsex3xom)*.
    
      - Fill out the template below to describe the changes contributed by the 
pull request. That will give reviewers the context they need to do the review.
    
      - Each pull request should address only one issue, not mix up code from 
multiple issues.
    
      - Each commit in the pull request has a meaningful commit message
    
      - Once all items of the checklist are addressed, remove the above text 
and this checklist, leaving only the filled out template below.
    -->
    
    <!-- Either this PR fixes an issue, -->
    
    Fixes #18282
    
    
    ### Modifications
    
    We start 10 transactions and consume 50 messages in every transaction by 
default.
    
    But notice `-r 10` set the consumption rate limit to be 10 msg per second, 
so every transaction is about 5 seconds.
    
    In https://github.com/apache/pulsar/pull/17837 we set the transaction TTL 
to be 5 seconds, so transactions may be timeout randomly, which causes the test 
to fail.
    
    To prove this, you can try to set `-r 9` or `-tto 4`, which will cause 
failure 100%.
    
    So remove the `-r` option can fix this issue.
    
    ### Verifying this change
    
    - [x] Make sure that the change passes the CI checks.
    
    ### Documentation
    
    <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
    
    - [ ] `doc` <!-- Your PR contains doc changes. Please attach the local 
preview screenshots (run `sh start.sh` at `pulsar/site2/website`) to your PR 
description, or else your PR might not get merged. -->
    - [ ] `doc-required` <!-- Your PR changes impact docs and you will update 
later -->
    - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
    - [ ] `doc-complete` <!-- Docs have been already added -->
    
    ### Matching PR in forked repository
    
    PR in forked repository: https://github.com/labuladong/pulsar/pull/6
---
 .../apache/pulsar/testclient/PerformanceTransactionTest.java | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git 
a/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceTransactionTest.java
 
b/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceTransactionTest.java
index bcc0e5e0cb0..d477797aab6 100644
--- 
a/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceTransactionTest.java
+++ 
b/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceTransactionTest.java
@@ -163,7 +163,7 @@ public class PerformanceTransactionTest extends 
MockedPulsarServiceBaseTest {
 
     @Test
     public void testProduceTxnMessage() throws InterruptedException, 
PulsarClientException {
-        String argString = "%s -r 10 -u %s -m %d -txn";
+        String argString = "%s -r 50 -u %s -m %d -txn";
         String topic = testTopic + UUID.randomUUID();
         int totalMessage = 100;
         String args = String.format(argString, topic, 
pulsar.getBrokerServiceUrl(), totalMessage);
@@ -174,7 +174,6 @@ public class PerformanceTransactionTest extends 
MockedPulsarServiceBaseTest {
                 .subscribe();
         Thread thread = new Thread(() -> {
             try {
-                log.info("");
                 PerformanceProducer.main(args.split(" "));
             } catch (Exception e) {
                 e.printStackTrace();
@@ -182,6 +181,13 @@ public class PerformanceTransactionTest extends 
MockedPulsarServiceBaseTest {
         });
         thread.start();
         thread.join();
+
+        Awaitility.await().untilAsserted(() -> {
+            admin.transactions().getCoordinatorStats().forEach((integer, 
transactionCoordinatorStats) -> {
+                
Assert.assertEquals(transactionCoordinatorStats.ongoingTxnSize, 0);
+            });
+        });
+
         Consumer<byte[]> consumer = 
pulsarClient.newConsumer().subscriptionName("subName").topic(topic)
                 
.subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
                 .subscriptionType(SubscriptionType.Exclusive)
@@ -198,7 +204,7 @@ public class PerformanceTransactionTest extends 
MockedPulsarServiceBaseTest {
 
     @Test
     public void testConsumeTxnMessage() throws Exception {
-        String argString = "%s -r 10 -u %s -txn -ss %s -st %s -sp %s -ntxn %d 
-tto 5";
+        String argString = "%s -r 50 -u %s -txn -ss %s -st %s -sp %s -ntxn %d 
-tto 5";
         String subName = "sub";
         String topic = testTopic + UUID.randomUUID();
         String args = String.format(argString, topic, 
pulsar.getBrokerServiceUrl(), subName,

Reply via email to