Skip to content

Commit

Permalink
[fix][flaky-test] fix flaky test PerformanceTransactionTest (#18296)
Browse files Browse the repository at this point in the history
<!--
### 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 #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: labuladong#6
  • Loading branch information
labuladong authored Nov 3, 2022
1 parent fe47d2d commit 3cb9d4d
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void testTxnPerf() throws Exception {

@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);
Expand All @@ -174,14 +174,20 @@ public void testProduceTxnMessage() throws InterruptedException, PulsarClientExc
.subscribe();
Thread thread = new Thread(() -> {
try {
log.info("");
PerformanceProducer.main(args.split(" "));
} catch (Exception e) {
e.printStackTrace();
}
});
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)
Expand All @@ -198,7 +204,7 @@ public void testProduceTxnMessage() throws InterruptedException, PulsarClientExc

@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,
Expand Down

0 comments on commit 3cb9d4d

Please sign in to comment.