Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add await conditions for trans grpc test #21

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.rocketmq.util.RandomUtils;
import org.apache.rocketmq.util.TestUtils;
import org.apache.rocketmq.util.VerifyUtils;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -139,8 +140,11 @@ public void testTrans_SendCheckerCommit_PushConsume() {
producer.sendTrans(message, null);
}
//Wait for the callback to execute commit
TestUtils.waitForSeconds(60);
TestUtils.waitForSeconds(30);
Assertions.assertEquals(SEND_NUM, producer.getEnqueueMessages().getDataSize(), "send message failed");
Awaitility.await().atMost(Duration.ofSeconds(180)).until(() -> {
return pushConsumer.getListener().getDequeueMessages().getDataSize() == SEND_NUM;
});
VerifyUtils.verifyNormalMessage(producer.getEnqueueMessages(), pushConsumer.getListener().getDequeueMessages());
}

Expand Down Expand Up @@ -195,14 +199,15 @@ public TransactionResolution check(MessageView messageView) {
Message message = MessageFactory.buildMessage(topic, tag, String.valueOf(i));
producer.sendTrans(message, null);
}
await().atMost(120, SECONDS).until(new Callable<Boolean>() {
//Wait for the rollback and execute commit/rollback
TestUtils.waitForSeconds(60);
//Wait for the callback to execute commit
await().atMost(180, SECONDS).until(new Callable<Boolean>() {
@Override
public Boolean call() {
return rollbackMsgNum.get() == commitMsgNum.get() && commitMsgNum.get() == SEND_NUM / 2;
}
});
//Wait for the rollback and execute commit/rollback
TestUtils.waitForSeconds(60);
Assertions.assertEquals(SEND_NUM, producer.getEnqueueMessages().getDataSize(), "send message failed");
Assertions.assertEquals(5, pushConsumer.getListener().getDequeueMessages().getDataSize());
}
Expand Down