Skip to content

Commit

Permalink
[Test] migrate-junit5-client-module
Browse files Browse the repository at this point in the history
  • Loading branch information
sherlock-lin committed Oct 25, 2024
1 parent f148f63 commit 7968110
Show file tree
Hide file tree
Showing 18 changed files with 972 additions and 761 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*/
package org.apache.bookkeeper.client;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
Expand All @@ -33,8 +35,7 @@
import org.apache.bookkeeper.conf.ClientConfiguration;
import org.apache.bookkeeper.meta.HierarchicalLedgerManagerFactory;
import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -51,7 +52,7 @@ public ConcurrentV2RecoveryTest() {
}

@Test
public void testConcurrentOpen() throws Exception {
void concurrentOpen() throws Exception {
ClientConfiguration conf = new ClientConfiguration();
conf.setMetadataServiceUri(zkUtil.getMetadataServiceUri())
.setNumChannelsPerBookie(16)
Expand Down Expand Up @@ -101,7 +102,7 @@ public void testConcurrentOpen() throws Exception {
// also fine, recovery can currently fail because of metadata conflicts.
// We should fix this at some point by making the metadata immutable,
// and restarting the entire operation
Assert.assertEquals(ee.getCause().getClass(), BKException.BKLedgerRecoveryException.class);
assertEquals(BKException.BKLedgerRecoveryException.class, ee.getCause().getClass());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
package org.apache.bookkeeper.client;

import static org.apache.bookkeeper.common.concurrent.FutureUtils.result;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
Expand All @@ -30,7 +31,7 @@
import org.apache.bookkeeper.client.api.WriteFlag;
import org.apache.bookkeeper.client.api.WriteHandle;
import org.apache.bookkeeper.net.BookieId;
import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* Client side tests on deferred sync write flag.
Expand All @@ -42,7 +43,7 @@ public class DeferredSyncTest extends MockBookKeeperTestCase {
static final int NUM_ENTRIES = 100;

@Test
public void testAddEntryLastAddConfirmedDoesNotAdvance() throws Exception {
void addEntryLastAddConfirmedDoesNotAdvance() throws Exception {
try (WriteHandle wh = result(newCreateLedgerOp()
.withEnsembleSize(3)
.withWriteQuorumSize(3)
Expand All @@ -61,7 +62,7 @@ public void testAddEntryLastAddConfirmedDoesNotAdvance() throws Exception {
}

@Test
public void testAddEntryLastAddConfirmedAdvanceWithForce() throws Exception {
void addEntryLastAddConfirmedAdvanceWithForce() throws Exception {
try (WriteHandle wh = result(newCreateLedgerOp()
.withEnsembleSize(3)
.withWriteQuorumSize(3)
Expand All @@ -82,7 +83,7 @@ public void testAddEntryLastAddConfirmedAdvanceWithForce() throws Exception {
}

@Test
public void testForceOnWriteAdvHandle() throws Exception {
void forceOnWriteAdvHandle() throws Exception {
try (WriteAdvHandle wh = result(newCreateLedgerOp()
.withEnsembleSize(3)
.withWriteQuorumSize(3)
Expand Down Expand Up @@ -112,7 +113,7 @@ public void testForceOnWriteAdvHandle() throws Exception {
}

@Test
public void testForceRequiresFullEnsemble() throws Exception {
void forceRequiresFullEnsemble() throws Exception {
try (WriteHandle wh = result(newCreateLedgerOp()
.withEnsembleSize(3)
.withWriteQuorumSize(2)
Expand Down Expand Up @@ -146,7 +147,7 @@ public void testForceRequiresFullEnsemble() throws Exception {
}

@Test
public void testForceWillAdvanceLacOnlyUpToLastAcknowledgedWrite() throws Exception {
void forceWillAdvanceLacOnlyUpToLastAcknowledgedWrite() throws Exception {
try (WriteHandle wh = result(newCreateLedgerOp()
.withEnsembleSize(3)
.withWriteQuorumSize(3)
Expand Down Expand Up @@ -187,7 +188,7 @@ public void testForceWillAdvanceLacOnlyUpToLastAcknowledgedWrite() throws Except
}

@Test
public void testForbiddenEnsembleChange() throws Exception {
void forbiddenEnsembleChange() throws Exception {
try (WriteHandle wh = result(newCreateLedgerOp()
.withEnsembleSize(1)
.withWriteQuorumSize(1)
Expand Down Expand Up @@ -218,8 +219,8 @@ public void testForbiddenEnsembleChange() throws Exception {
}
}

@Test(expected = BKException.BKLedgerClosedException.class)
public void testCannotIssueForceOnClosedLedgerHandle() throws Exception {
@Test
void cannotIssueForceOnClosedLedgerHandle() throws Exception {
WriteHandle wh = result(newCreateLedgerOp()
.withEnsembleSize(1)
.withWriteQuorumSize(1)
Expand All @@ -228,7 +229,8 @@ public void testCannotIssueForceOnClosedLedgerHandle() throws Exception {
.withWriteFlags(WriteFlag.DEFERRED_SYNC)
.execute());
wh.close();
result(wh.force());
assertThrows(BKException.BKLedgerClosedException.class, () ->
result(wh.force()));
}

}
Loading

0 comments on commit 7968110

Please sign in to comment.