Skip to content

Commit

Permalink
chore: try junit5 feature
Browse files Browse the repository at this point in the history
Signed-off-by: ZhangJian He <[email protected]>
  • Loading branch information
ZhangJian He committed Oct 9, 2024
1 parent 66eb33c commit d16dcc3
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,21 @@
package org.apache.bookkeeper.common.testing.annotations;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

/**
* Intended for marking a test case as flaky.
*/
@Documented
@Retention(RetentionPolicy.SOURCE)
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Tag("flaky")
@Test
public @interface FlakyTest {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
import org.apache.bookkeeper.util.DiskChecker;
import org.apache.bookkeeper.util.TestUtils;
import org.junit.Before;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

/**
* Test BookieStorage with a threshold.
Expand Down Expand Up @@ -143,17 +141,15 @@ public float checkDir(File dir) throws DiskErrorException, DiskOutOfSpaceExcepti
}

@FlakyTest(value = "https://github.com/apache/bookkeeper/issues/1562")
@Tag("flaky")
@Test
public void testStorageThresholdCompaction() throws Exception {
stopAllBookies();
ServerConfiguration conf = newServerConfiguration();
File ledgerDir1 = tmpDirs.createNew("ledger", "test1");
File ledgerDir2 = tmpDirs.createNew("ledger", "test2");
File journalDir = tmpDirs.createNew("journal", "test");
String[] ledgerDirNames = new String[]{
ledgerDir1.getPath(),
ledgerDir2.getPath()
ledgerDir1.getPath(),
ledgerDir2.getPath()
};
conf.setLedgerDirNames(ledgerDirNames);
conf.setJournalDirName(journalDir.getPath());
Expand Down Expand Up @@ -228,7 +224,7 @@ public void diskFull(File disk) {
// there are no writableLedgerDirs
for (File ledgerDir : bookie.getLedgerDirsManager().getAllLedgerDirs()) {
assertFalse("Found entry log file ([0,1,2].log. They should have been compacted" + ledgerDir,
TestUtils.hasLogFiles(ledgerDir.getParentFile(), true, 0, 1, 2));
TestUtils.hasLogFiles(ledgerDir.getParentFile(), true, 0, 1, 2));
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
import org.junit.Assert;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.slf4j.Logger;
Expand Down Expand Up @@ -684,8 +683,6 @@ public Boolean call() throws IOException, BookieException {
* using InterleavedLedgerStorage.
*/
@FlakyTest(value = "https://github.com/apache/bookkeeper/issues/1516")
@Tag("flaky")
@Test
public void testConcurrentWriteAndReadCallsOfInterleavedLedgerStorage() throws Exception {
testConcurrentWriteAndReadCalls(InterleavedLedgerStorage.class.getName(), false);
}
Expand All @@ -695,8 +692,6 @@ public void testConcurrentWriteAndReadCallsOfInterleavedLedgerStorage() throws E
* using InterleavedLedgerStorage with EntryLogPerLedger enabled.
*/
@FlakyTest(value = "https://github.com/apache/bookkeeper/issues/1516")
@Tag("flaky")
@Test
public void testConcurrentWriteAndReadCallsOfInterleavedLedgerStorageWithELPLEnabled() throws Exception {
testConcurrentWriteAndReadCalls(InterleavedLedgerStorage.class.getName(), true);
}
Expand All @@ -706,8 +701,6 @@ public void testConcurrentWriteAndReadCallsOfInterleavedLedgerStorageWithELPLEna
* using SortedLedgerStorage.
*/
@FlakyTest(value = "https://github.com/apache/bookkeeper/issues/1516")
@Tag("flaky")
@Test
public void testConcurrentWriteAndReadCallsOfSortedLedgerStorage() throws Exception {
testConcurrentWriteAndReadCalls(SortedLedgerStorage.class.getName(), false);
}
Expand All @@ -717,8 +710,6 @@ public void testConcurrentWriteAndReadCallsOfSortedLedgerStorage() throws Except
* using SortedLedgerStorage with EntryLogPerLedger enabled.
*/
@FlakyTest(value = "https://github.com/apache/bookkeeper/issues/1516")
@Tag("flaky")
@Test
public void testConcurrentWriteAndReadCallsOfSortedLedgerStorageWithELPLEnabled() throws Exception {
testConcurrentWriteAndReadCalls(SortedLedgerStorage.class.getName(), true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
import org.apache.bookkeeper.net.BookieId;
import org.apache.bookkeeper.proto.BookieServer;
import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -136,8 +134,6 @@ private BookieServer replaceBookieWithCustomFreeDiskSpaceBookie(
* Test to show that weight based selection honors the disk weight of bookies.
*/
@FlakyTest("https://github.com/apache/bookkeeper/issues/503")
@Tag("flaky")
@Test
public void testDiskSpaceWeightedBookieSelection() throws Exception {
long freeDiskSpace = 1000000L;
int multiple = 3;
Expand Down Expand Up @@ -183,11 +179,9 @@ public void testDiskSpaceWeightedBookieSelection() throws Exception {

/**
* Test to show that weight based selection honors the disk weight of bookies and also adapts
* when the bookies's weight changes.
* when the bookies' weight changes.
*/
@FlakyTest("https://github.com/apache/bookkeeper/issues/503")
@Tag("flaky")
@Test
public void testDiskSpaceWeightedBookieSelectionWithChangingWeights() throws Exception {
long freeDiskSpace = 1000000L;
int multiple = 3;
Expand Down Expand Up @@ -275,8 +269,6 @@ public void testDiskSpaceWeightedBookieSelectionWithChangingWeights() throws Exc
* when bookies go away permanently.
*/
@FlakyTest("https://github.com/apache/bookkeeper/issues/503")
@Tag("flaky")
@Test
public void testDiskSpaceWeightedBookieSelectionWithBookiesDying() throws Exception {
long freeDiskSpace = 1000000L;
int multiple = 3;
Expand Down Expand Up @@ -355,8 +347,6 @@ public void testDiskSpaceWeightedBookieSelectionWithBookiesDying() throws Except
* when bookies are added.
*/
@FlakyTest("https://github.com/apache/bookkeeper/issues/503")
@Tag("flaky")
@Test
public void testDiskSpaceWeightedBookieSelectionWithBookiesBeingAdded() throws Exception {
long freeDiskSpace = 1000000L;
int multiple = 3;
Expand Down Expand Up @@ -429,8 +419,6 @@ public void testDiskSpaceWeightedBookieSelectionWithBookiesBeingAdded() throws E
* the periodic bookieInfo read is working and causes the new weights to be taken into account.
*/
@FlakyTest("https://github.com/apache/bookkeeper/issues/503")
@Tag("flaky")
@Test
public void testDiskSpaceWeightedBookieSelectionWithPeriodicBookieInfoUpdate() throws Exception {
long freeDiskSpace = 1000000L;
int multiple = 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.apache.bookkeeper.proto.BookieServer;
import org.apache.bookkeeper.stats.NullStatsLogger;
import org.apache.bookkeeper.util.PortManager;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledForJreRange;
import org.junit.jupiter.api.condition.JRE;
Expand Down Expand Up @@ -129,8 +128,6 @@ will fail (even if retry it many times).
@FlakyTest(value = "https://github.com/apache/bookkeeper/issues/4142")
@SuppressWarnings("deprecation")
@EnabledForJreRange(max = JRE.JAVA_17)
@Tag("flaky")
@Test
public void testBookieServerZKSessionExpireBehaviour() throws Exception {
// 6000 is minimum due to default tick time
System.setProperty("zookeeper.request.timeout", "0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
import org.apache.zookeeper.ZooDefs;
import org.junit.After;
import org.junit.Before;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -73,8 +71,6 @@ public void teardown() throws Exception {
}

@FlakyTest("https://issues.apache.org/jira/browse/DL-44")
@Tag("flaky")
@Test
@SuppressWarnings("deprecation")
public void testChangeSequenceNumber() throws Exception {
DistributedLogConfiguration confLocal = new DistributedLogConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
import org.apache.zookeeper.data.Stat;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.slf4j.Logger;
Expand Down Expand Up @@ -133,8 +132,6 @@ private SimpleLedgerAllocator createAllocator(String allocationPath,
}

@FlakyTest("https://issues.apache.org/jira/browse/DL-43")
@Tag("flaky")
@org.junit.jupiter.api.Test
public void testAllocation() throws Exception {
String allocationPath = "/allocation1";
SimpleLedgerAllocator allocator = createAllocator(allocationPath);
Expand Down Expand Up @@ -325,8 +322,6 @@ public void testCloseAllocatorDuringObtaining() throws Exception {
}

@FlakyTest("https://issues.apache.org/jira/browse/DL-26")
@Tag("flaky")
@Test
public void testCloseAllocatorAfterConfirm() throws Exception {
String allocationPath = "/allocation2";
SimpleLedgerAllocator allocator = createAllocator(allocationPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.apache.bookkeeper.stats.NullStatsLogger;
import org.apache.distributedlog.DistributedLogConfiguration;
import org.apache.distributedlog.common.config.PropertiesWriter;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

/**
Expand Down Expand Up @@ -82,8 +81,6 @@ public void testLoadFeaturesFromBase() throws Exception {
}

@FlakyTest("https://issues.apache.org/jira/browse/DL-40")
@Tag("flaky")
@Test
public void testLoadFeaturesFromOverlay() throws Exception {
PropertiesWriter writer = new PropertiesWriter();
writer.setProperty("feature_1", "10000");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.rules.TestName;

/**
Expand Down Expand Up @@ -93,8 +91,6 @@ private static ByteBuf getValue(int i) {
}

@FlakyTest("https://github.com/apache/bookkeeper/issues/1440")
@Tag("flaky")
@Test
public void testTableSimpleAPI() throws Exception {
// Create a namespace
NamespaceConfiguration nsConf = NamespaceConfiguration.newBuilder()
Expand Down
4 changes: 4 additions & 0 deletions testtools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,9 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
</dependencies>
</project>

0 comments on commit d16dcc3

Please sign in to comment.