Skip to content

Commit

Permalink
improve: allow flaky tests run with specify parameters
Browse files Browse the repository at this point in the history
Signed-off-by: ZhangJian He <[email protected]>
  • Loading branch information
hezhangjian committed May 31, 2024
1 parent 15a5b49 commit 8eb82b8
Show file tree
Hide file tree
Showing 10 changed files with 417 additions and 349 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
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 @@ -141,6 +143,8 @@ 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();
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
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 @@ -134,6 +136,8 @@ 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 @@ -182,6 +186,8 @@ public void testDiskSpaceWeightedBookieSelection() throws Exception {
* when the bookies's 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 @@ -269,6 +275,8 @@ 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 @@ -347,6 +355,8 @@ 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 @@ -419,6 +429,8 @@ 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,6 +37,7 @@
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 @@ -128,6 +129,8 @@ 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
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<excludedGroups>flaky</excludedGroups>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInfo;
import org.junit.rules.TestName;
import org.junit.rules.Timeout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -72,6 +78,9 @@
public class TestDistributedLogBase {
static final Logger LOG = LoggerFactory.getLogger(TestDistributedLogBase.class);

@Rule
public final TestName runtime = new TestName();

@Rule
public Timeout globalTimeout = Timeout.seconds(120);

Expand Down Expand Up @@ -105,7 +114,20 @@ public class TestDistributedLogBase {
protected static int zkPort;
protected static final List<File> TMP_DIRS = new ArrayList<File>();

protected String testName;

@Before
public void setTestNameJunit4() {
testName = runtime.getMethodName();
}

@BeforeEach
void setTestNameJunit5(TestInfo testInfo) {
testName = testInfo.getDisplayName();
}

@BeforeClass
@BeforeAll
public static void setupCluster() throws Exception {
setupCluster(numBookies);
}
Expand Down Expand Up @@ -134,6 +156,7 @@ public void uncaughtException(Thread t, Throwable e) {
}

@AfterClass
@AfterAll
public static void teardownCluster() throws Exception {
bkutil.teardown();
zks.stop();
Expand All @@ -143,6 +166,7 @@ public static void teardownCluster() throws Exception {
}

@Before
@BeforeEach
public void setup() throws Exception {
try {
zkc = LocalDLMEmulator.connectZooKeeper("127.0.0.1", zkPort);
Expand All @@ -153,6 +177,7 @@ public void setup() throws Exception {
}

@After
@AfterEach
public void teardown() throws Exception {
if (null != zkc) {
zkc.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
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 @@ -71,6 +73,8 @@ 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
Loading

0 comments on commit 8eb82b8

Please sign in to comment.