Skip to content

Commit 8eb82b8

Browse files
committed
improve: allow flaky tests run with specify parameters
Signed-off-by: ZhangJian He <[email protected]>
1 parent 15a5b49 commit 8eb82b8

File tree

10 files changed

+417
-349
lines changed

10 files changed

+417
-349
lines changed

bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieStorageThresholdTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
import org.apache.bookkeeper.util.DiskChecker;
4242
import org.apache.bookkeeper.util.TestUtils;
4343
import org.junit.Before;
44+
import org.junit.jupiter.api.Tag;
45+
import org.junit.jupiter.api.Test;
4446

4547
/**
4648
* Test BookieStorage with a threshold.
@@ -141,6 +143,8 @@ public float checkDir(File dir) throws DiskErrorException, DiskOutOfSpaceExcepti
141143
}
142144

143145
@FlakyTest(value = "https://github.com/apache/bookkeeper/issues/1562")
146+
@Tag("flaky")
147+
@Test
144148
public void testStorageThresholdCompaction() throws Exception {
145149
stopAllBookies();
146150
ServerConfiguration conf = newServerConfiguration();

bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/DefaultEntryLogTest.java

Lines changed: 81 additions & 98 deletions
Large diffs are not rendered by default.

bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperDiskSpaceWeightedLedgerPlacementTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
import org.apache.bookkeeper.net.BookieId;
3939
import org.apache.bookkeeper.proto.BookieServer;
4040
import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
41+
import org.junit.jupiter.api.Tag;
42+
import org.junit.jupiter.api.Test;
4143
import org.slf4j.Logger;
4244
import org.slf4j.LoggerFactory;
4345

@@ -134,6 +136,8 @@ private BookieServer replaceBookieWithCustomFreeDiskSpaceBookie(
134136
* Test to show that weight based selection honors the disk weight of bookies.
135137
*/
136138
@FlakyTest("https://github.com/apache/bookkeeper/issues/503")
139+
@Tag("flaky")
140+
@Test
137141
public void testDiskSpaceWeightedBookieSelection() throws Exception {
138142
long freeDiskSpace = 1000000L;
139143
int multiple = 3;
@@ -182,6 +186,8 @@ public void testDiskSpaceWeightedBookieSelection() throws Exception {
182186
* when the bookies's weight changes.
183187
*/
184188
@FlakyTest("https://github.com/apache/bookkeeper/issues/503")
189+
@Tag("flaky")
190+
@Test
185191
public void testDiskSpaceWeightedBookieSelectionWithChangingWeights() throws Exception {
186192
long freeDiskSpace = 1000000L;
187193
int multiple = 3;
@@ -269,6 +275,8 @@ public void testDiskSpaceWeightedBookieSelectionWithChangingWeights() throws Exc
269275
* when bookies go away permanently.
270276
*/
271277
@FlakyTest("https://github.com/apache/bookkeeper/issues/503")
278+
@Tag("flaky")
279+
@Test
272280
public void testDiskSpaceWeightedBookieSelectionWithBookiesDying() throws Exception {
273281
long freeDiskSpace = 1000000L;
274282
int multiple = 3;
@@ -347,6 +355,8 @@ public void testDiskSpaceWeightedBookieSelectionWithBookiesDying() throws Except
347355
* when bookies are added.
348356
*/
349357
@FlakyTest("https://github.com/apache/bookkeeper/issues/503")
358+
@Tag("flaky")
359+
@Test
350360
public void testDiskSpaceWeightedBookieSelectionWithBookiesBeingAdded() throws Exception {
351361
long freeDiskSpace = 1000000L;
352362
int multiple = 3;
@@ -419,6 +429,8 @@ public void testDiskSpaceWeightedBookieSelectionWithBookiesBeingAdded() throws E
419429
* the periodic bookieInfo read is working and causes the new weights to be taken into account.
420430
*/
421431
@FlakyTest("https://github.com/apache/bookkeeper/issues/503")
432+
@Tag("flaky")
433+
@Test
422434
public void testDiskSpaceWeightedBookieSelectionWithPeriodicBookieInfoUpdate() throws Exception {
423435
long freeDiskSpace = 1000000L;
424436
int multiple = 3;

bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieZKExpireTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.apache.bookkeeper.proto.BookieServer;
3838
import org.apache.bookkeeper.stats.NullStatsLogger;
3939
import org.apache.bookkeeper.util.PortManager;
40+
import org.junit.jupiter.api.Tag;
4041
import org.junit.jupiter.api.Test;
4142
import org.junit.jupiter.api.condition.EnabledForJreRange;
4243
import org.junit.jupiter.api.condition.JRE;
@@ -128,6 +129,8 @@ will fail (even if retry it many times).
128129
@FlakyTest(value = "https://github.com/apache/bookkeeper/issues/4142")
129130
@SuppressWarnings("deprecation")
130131
@EnabledForJreRange(max = JRE.JAVA_17)
132+
@Tag("flaky")
133+
@Test
131134
public void testBookieServerZKSessionExpireBehaviour() throws Exception {
132135
// 6000 is minimum due to default tick time
133136
System.setProperty("zookeeper.request.timeout", "0");

pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,9 @@
872872
<groupId>org.apache.maven.plugins</groupId>
873873
<artifactId>maven-surefire-plugin</artifactId>
874874
<version>${maven-surefire-plugin.version}</version>
875+
<configuration>
876+
<excludedGroups>flaky</excludedGroups>
877+
</configuration>
875878
</plugin>
876879
<plugin>
877880
<groupId>org.apache.maven.plugins</groupId>

stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestDistributedLogBase.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@
6161
import org.junit.Before;
6262
import org.junit.BeforeClass;
6363
import org.junit.Rule;
64+
import org.junit.jupiter.api.AfterAll;
65+
import org.junit.jupiter.api.AfterEach;
66+
import org.junit.jupiter.api.BeforeAll;
67+
import org.junit.jupiter.api.BeforeEach;
68+
import org.junit.jupiter.api.TestInfo;
69+
import org.junit.rules.TestName;
6470
import org.junit.rules.Timeout;
6571
import org.slf4j.Logger;
6672
import org.slf4j.LoggerFactory;
@@ -72,6 +78,9 @@
7278
public class TestDistributedLogBase {
7379
static final Logger LOG = LoggerFactory.getLogger(TestDistributedLogBase.class);
7480

81+
@Rule
82+
public final TestName runtime = new TestName();
83+
7584
@Rule
7685
public Timeout globalTimeout = Timeout.seconds(120);
7786

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

117+
protected String testName;
118+
119+
@Before
120+
public void setTestNameJunit4() {
121+
testName = runtime.getMethodName();
122+
}
123+
124+
@BeforeEach
125+
void setTestNameJunit5(TestInfo testInfo) {
126+
testName = testInfo.getDisplayName();
127+
}
128+
108129
@BeforeClass
130+
@BeforeAll
109131
public static void setupCluster() throws Exception {
110132
setupCluster(numBookies);
111133
}
@@ -134,6 +156,7 @@ public void uncaughtException(Thread t, Throwable e) {
134156
}
135157

136158
@AfterClass
159+
@AfterAll
137160
public static void teardownCluster() throws Exception {
138161
bkutil.teardown();
139162
zks.stop();
@@ -143,6 +166,7 @@ public static void teardownCluster() throws Exception {
143166
}
144167

145168
@Before
169+
@BeforeEach
146170
public void setup() throws Exception {
147171
try {
148172
zkc = LocalDLMEmulator.connectZooKeeper("127.0.0.1", zkPort);
@@ -153,6 +177,7 @@ public void setup() throws Exception {
153177
}
154178

155179
@After
180+
@AfterEach
156181
public void teardown() throws Exception {
157182
if (null != zkc) {
158183
zkc.close();

stream/distributedlog/core/src/test/java/org/apache/distributedlog/admin/TestDistributedLogAdmin.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
import org.apache.zookeeper.ZooDefs;
4545
import org.junit.After;
4646
import org.junit.Before;
47+
import org.junit.jupiter.api.Tag;
48+
import org.junit.jupiter.api.Test;
4749
import org.slf4j.Logger;
4850
import org.slf4j.LoggerFactory;
4951

@@ -71,6 +73,8 @@ public void teardown() throws Exception {
7173
}
7274

7375
@FlakyTest("https://issues.apache.org/jira/browse/DL-44")
76+
@Tag("flaky")
77+
@Test
7478
@SuppressWarnings("deprecation")
7579
public void testChangeSequenceNumber() throws Exception {
7680
DistributedLogConfiguration confLocal = new DistributedLogConfiguration();

0 commit comments

Comments
 (0)