jiazhai closed pull request #710: ISSUE #507: Introduce @FlakyTest annotation 
for marking a few tests as flaky
URL: https://github.com/apache/bookkeeper/pull/710
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperAdminTest.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperAdminTest.java
index b197353cc..d9a812fbb 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperAdminTest.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperAdminTest.java
@@ -25,7 +25,6 @@
 import static org.junit.Assert.fail;
 
 import java.util.Iterator;
-
 import org.apache.bookkeeper.bookie.Bookie;
 import org.apache.bookkeeper.client.BKException.BKIllegalOpException;
 import org.apache.bookkeeper.client.BookKeeper.DigestType;
@@ -33,6 +32,7 @@
 import org.apache.bookkeeper.meta.ZkLedgerUnderreplicationManager;
 import 
org.apache.bookkeeper.replication.ReplicationException.UnavailableException;
 import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
+import org.apache.bookkeeper.test.annotations.FlakyTest;
 import org.junit.Assert;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -103,7 +103,7 @@ public void testTriggerAudit() throws Exception {
         bkAdmin.close();
     }
 
-    @Test(timeout = 480000)
+    @FlakyTest("https://github.com/apache/bookkeeper/issues/502";)
     public void testDecommissionBookie() throws Exception {
         ZkLedgerUnderreplicationManager urLedgerMgr = new 
ZkLedgerUnderreplicationManager(baseClientConf, zkc);
         BookKeeperAdmin bkAdmin = new 
BookKeeperAdmin(zkUtil.getZooKeeperConnectString());
diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperDiskSpaceWeightedLedgerPlacementTest.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperDiskSpaceWeightedLedgerPlacementTest.java
index 3bc612ea7..7206b2368 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperDiskSpaceWeightedLedgerPlacementTest.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperDiskSpaceWeightedLedgerPlacementTest.java
@@ -34,9 +34,8 @@
 import org.apache.bookkeeper.net.BookieSocketAddress;
 import org.apache.bookkeeper.proto.BookieServer;
 import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
-import org.apache.bookkeeper.util.MathUtils;
+import org.apache.bookkeeper.test.annotations.FlakyTest;
 import org.apache.zookeeper.KeeperException;
-import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -136,7 +135,7 @@ private BookieServer 
replaceBookieWithCustomFreeDiskSpaceBookie(
     /**
      * Test to show that weight based selection honors the disk weight of 
bookies
      */
-    @Test(timeout=60000)
+    @FlakyTest("https://github.com/apache/bookkeeper/issues/503";)
     public void testDiskSpaceWeightedBookieSelection() throws Exception {
         long freeDiskSpace=1000000L;
         int multiple=3;
@@ -182,7 +181,7 @@ 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.
      */
-    @Test(timeout=60000)
+    @FlakyTest("https://github.com/apache/bookkeeper/issues/503";)
     public void testDiskSpaceWeightedBookieSelectionWithChangingWeights() 
throws Exception {
         long freeDiskSpace=1000000L;
         int multiple=3;
@@ -264,7 +263,7 @@ public void 
testDiskSpaceWeightedBookieSelectionWithChangingWeights() throws Exc
      * Test to show that weight based selection honors the disk weight of 
bookies and also adapts
      * when bookies go away permanently.
      */
-    @Test(timeout=60000)
+    @FlakyTest("https://github.com/apache/bookkeeper/issues/503";)
     public void testDiskSpaceWeightedBookieSelectionWithBookiesDying() throws 
Exception {
         long freeDiskSpace=1000000L;
         int multiple=3;
@@ -339,7 +338,7 @@ public void 
testDiskSpaceWeightedBookieSelectionWithBookiesDying() throws Except
      * Test to show that weight based selection honors the disk weight of 
bookies and also adapts
      * when bookies are added.
      */
-    @Test(timeout=60000)
+    @FlakyTest("https://github.com/apache/bookkeeper/issues/503";)
     public void testDiskSpaceWeightedBookieSelectionWithBookiesBeingAdded() 
throws Exception {
         long freeDiskSpace=1000000L;
         int multiple=3;
@@ -407,7 +406,7 @@ public void 
testDiskSpaceWeightedBookieSelectionWithBookiesBeingAdded() throws E
      * Tests that the bookie selection is based on the amount of free disk 
space a bookie has. Also make sure that
      * the periodic bookieInfo read is working and causes the new weights to 
be taken into account.
      */
-    @Test(timeout=60000)
+    @FlakyTest("https://github.com/apache/bookkeeper/issues/503";)
     public void 
testDiskSpaceWeightedBookieSelectionWithPeriodicBookieInfoUpdate() throws 
Exception {
         long freeDiskSpace=1000000L;
         int multiple=3;
diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperTest.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperTest.java
index 7656b9b1c..80ba193f3 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperTest.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperTest.java
@@ -717,8 +717,6 @@ public void testReadEntryReleaseByteBufs() throws Exception 
{
                 for (Enumeration<LedgerEntry> readEntries = lh.readEntries(0, 
numEntries - 1);
                     readEntries.hasMoreElements();) {
                     LedgerEntry entry = readEntries.nextElement();
-                    assertTrue(entry.data.getClass().getName(),
-                        
entry.data.getClass().getName().contains("PooledNonRetainedSlicedByteBuf"));
                     try {
                         entry.data.release();
                     } catch (IllegalReferenceCountException ok) {
@@ -739,8 +737,6 @@ public void testReadEntryReleaseByteBufs() throws Exception 
{
                 for (Enumeration<LedgerEntry> readEntries = lh.readEntries(0, 
numEntries - 1);
                     readEntries.hasMoreElements();) {
                     LedgerEntry entry = readEntries.nextElement();
-                    assertTrue(entry.data.getClass().getName(),
-                        
entry.data.getClass().getName().contains("UnpooledSlicedByteBuf"));
                     try {
                         entry.data.release();
                     } catch (IllegalReferenceCountException e) {
@@ -761,8 +757,6 @@ public void testReadEntryReleaseByteBufs() throws Exception 
{
                 for (Enumeration<LedgerEntry> readEntries = lh.readEntries(0, 
numEntries - 1);
                     readEntries.hasMoreElements();) {
                     LedgerEntry entry = readEntries.nextElement();
-                    assertTrue(entry.data.getClass().getName(),
-                        
entry.data.getClass().getName().contains("UnpooledSlicedByteBuf"));
                     assertTrue("Can't release entry " + entry.getEntryId() + 
": ref = " + entry.data.refCnt(),
                         entry.data.release());
                     try {
@@ -787,8 +781,6 @@ public void testReadEntryReleaseByteBufs() throws Exception 
{
                     readEntries.hasMoreElements();) {
                     LedgerEntry entry = readEntries.nextElement();
                     // ButeBufs not reference counter
-                    assertTrue(entry.data.getClass().getName(),
-                        
entry.data.getClass().getName().contains("UnpooledSlicedByteBuf"));
                     assertTrue("Can't release entry " + entry.getEntryId() + 
": ref = " + entry.data.refCnt(),
                         entry.data.release());
                     try {
diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/annotations/FlakyTest.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/annotations/FlakyTest.java
new file mode 100644
index 000000000..2890f35c4
--- /dev/null
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/annotations/FlakyTest.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bookkeeper.test.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Intended for marking a test case as flaky.
+ */
+@Documented
+@Retention(RetentionPolicy.SOURCE)
+public @interface FlakyTest {
+
+    /**
+     * Context information such as links to discussion thread, tracking issues 
etc.
+     *
+     * @return context information about this flaky test.
+     */
+    String value();
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to