Skip to content

Commit

Permalink
[fix][test] Fix TransactionTest failure due to clean up after class (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
liangyepianzhou authored Oct 17, 2022
1 parent 9c8a6ad commit a990822
Showing 1 changed file with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.pulsar.broker.transaction;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.pulsar.common.naming.SystemTopicNames.PENDING_ACK_STORE_CURSOR_NAME;
import static org.apache.pulsar.common.naming.SystemTopicNames.PENDING_ACK_STORE_SUFFIX;
import static org.apache.pulsar.transaction.coordinator.impl.MLTransactionLogImpl.TRANSACTION_LOG_PREFIX;
import static org.apache.pulsar.transaction.coordinator.impl.DisabledTxnLogBufferedWriterMetricsStats.DISABLED_BUFFERED_WRITER_METRICS;
Expand Down Expand Up @@ -406,20 +407,19 @@ public void testGetTxnID() throws Exception {
Transaction transaction = pulsarClient.newTransaction()
.build().get();
TxnID txnID = transaction.getTxnID();
Assert.assertEquals(txnID.getLeastSigBits(), 0);
Assert.assertEquals(txnID.getMostSigBits(), 0);

transaction.abort();
transaction = pulsarClient.newTransaction()
.build().get();
txnID = transaction.getTxnID();
Assert.assertEquals(txnID.getLeastSigBits(), 1);
Assert.assertEquals(txnID.getMostSigBits(), 0);
TxnID txnID1 = transaction.getTxnID();
Assert.assertEquals(txnID1.getLeastSigBits(), txnID.getLeastSigBits() + 1);
Assert.assertEquals(txnID1.getMostSigBits(), 0);
}

@Test
public void testSubscriptionRecreateTopic()
throws PulsarAdminException, NoSuchFieldException, IllegalAccessException, PulsarClientException {
String topic = "persistent://pulsar/system/testReCreateTopic";
String topic = "persistent://pulsar/system/testSubscriptionRecreateTopic";
String subName = "sub_testReCreateTopic";
int retentionSizeInMbSetTo = 5;
int retentionSizeInMbSetTopic = 6;
Expand Down Expand Up @@ -481,11 +481,7 @@ public void testSubscriptionRecreateTopic()
}
);
});


});


}

@Test
Expand Down Expand Up @@ -782,6 +778,8 @@ public void testEndTPRecoveringWhenManagerLedgerDisReadable() throws Exception{
Class<PulsarService> pulsarServiceClass = PulsarService.class;
Field field = pulsarServiceClass.getDeclaredField("transactionPendingAckStoreProvider");
field.setAccessible(true);
TransactionPendingAckStoreProvider originPendingAckStoreProvider =
(TransactionPendingAckStoreProvider) field.get(getPulsarServiceList().get(0));
field.set(getPulsarServiceList().get(0), pendingAckStoreProvider);

PendingAckHandleImpl pendingAckHandle1 = new PendingAckHandleImpl(persistentSubscription);
Expand Down Expand Up @@ -811,6 +809,7 @@ public void testEndTPRecoveringWhenManagerLedgerDisReadable() throws Exception{

// cleanup
transactionTimer.stop();
field.set(getPulsarServiceList().get(0), originPendingAckStoreProvider);
}

@Test
Expand Down Expand Up @@ -1075,7 +1074,7 @@ public void testAutoCreateSchemaForTransactionSnapshot() throws Exception {
public void testPendingAckMarkDeletePosition() throws Exception {
getPulsarServiceList().get(0).getConfig().setTransactionPendingAckLogIndexMinLag(1);
getPulsarServiceList().get(0).getConfiguration().setManagedLedgerDefaultMarkDeleteRateLimit(5);
String topic = NAMESPACE1 + "/test1";
String topic = NAMESPACE1 + "/testPendingAckMarkDeletePosition";

@Cleanup
Producer<byte[]> producer = pulsarClient
Expand Down Expand Up @@ -1136,7 +1135,7 @@ public void testPendingAckMarkDeletePosition() throws Exception {
.getPendingAckInternalStats(topic, "sub", false)
.pendingAckLogStats
.managedLedgerInternalStats;
String [] markDeletePosition = managedLedgerInternalStats.cursors.get("__pending_ack_state")
String [] markDeletePosition = managedLedgerInternalStats.cursors.get(PENDING_ACK_STORE_CURSOR_NAME)
.markDeletePosition.split(":");
String [] lastConfirmedEntry = managedLedgerInternalStats.lastConfirmedEntry.split(":");
Assert.assertEquals(markDeletePosition[0], lastConfirmedEntry[0]);
Expand Down

0 comments on commit a990822

Please sign in to comment.