Browse Source

YARN-11266. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-yarn-server-timelineservice-hbase-tests. (#7538)

Co-authored-by: Chris Nauroth <cnauroth@apache.org>
Co-authored-by: Hualong Zhang <hualong.z@hotmail.com>
Reviewed-by: Chris Nauroth <cnauroth@apache.org>
Reviewed-by: Hualong Zhang <hualong.z@hotmail.com>
Signed-off-by: Shilun Fan <slfan1989@apache.org>
slfan1989 3 months ago
parent
commit
cc9e548572
11 changed files with 226 additions and 203 deletions
  1. 7 7
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/AbstractTimelineReaderHBaseTestBase.java
  2. 48 35
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServicesHBaseStorage.java
  3. 47 47
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/TestHBaseTimelineStorageApps.java
  4. 8 8
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/TestHBaseTimelineStorageDomain.java
  5. 50 49
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/TestHBaseTimelineStorageEntities.java
  6. 7 7
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/TestHBaseTimelineStorageSchema.java
  7. 16 9
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/TestTimelineReaderHBaseDown.java
  8. 9 7
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/TestTimelineWriterHBaseDown.java
  9. 9 9
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/flow/TestHBaseStorageFlowActivity.java
  10. 9 9
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/flow/TestHBaseStorageFlowRun.java
  11. 16 16
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/flow/TestHBaseStorageFlowRunCompaction.java

+ 7 - 7
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/AbstractTimelineReaderHBaseTestBase.java

@@ -18,9 +18,10 @@
 
 package org.apache.hadoop.yarn.server.timelineservice.reader;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import javax.ws.rs.client.Client;
 import javax.ws.rs.client.ClientBuilder;
@@ -43,7 +44,6 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.server.timelineservice.storage.DataGeneratorForTest;
 import org.glassfish.jersey.client.ClientConfig;
 import org.glassfish.jersey.client.HttpUrlConnectorProvider;
-import org.junit.Assert;
 
 /**
  * Test Base for TimelineReaderServer HBase tests.
@@ -101,7 +101,7 @@ public abstract class AbstractTimelineReaderHBaseTestBase {
       server.start();
       serverPort = server.getWebServerPort();
     } catch (Exception e) {
-      Assert.fail("Web server failed to start");
+      fail("Web server failed to start");
     }
   }
 
@@ -138,8 +138,8 @@ public abstract class AbstractTimelineReaderHBaseTestBase {
   protected void verifyHttpResponse(Client client, URI uri, Response.Status status) {
     Response resp = client.target(uri).request(MediaType.APPLICATION_JSON).get();
     assertNotNull(resp);
-    assertTrue("Response from server should have been " + status,
-        resp.getStatusInfo().getStatusCode() == status.getStatusCode());
+    assertTrue(resp.getStatusInfo().getStatusCode() == status.getStatusCode(),
+        "Response from server should have been " + status);
     System.out.println("Response is: " + resp.readEntity(String.class));
   }
 

+ 48 - 35
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServicesHBaseStorage.java

@@ -18,10 +18,10 @@
 
 package org.apache.hadoop.yarn.server.timelineservice.reader;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import javax.ws.rs.client.Client;
 
@@ -59,9 +59,9 @@ import org.apache.hadoop.yarn.server.timelineservice.collector.TimelineCollector
 import org.apache.hadoop.yarn.server.timelineservice.storage.HBaseTimelineWriterImpl;
 import org.apache.hadoop.yarn.server.timelineservice.storage.common.HBaseTimelineSchemaUtils;
 import org.apache.hadoop.yarn.server.utils.BuilderUtils;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 
@@ -75,14 +75,14 @@ public class TestTimelineReaderWebServicesHBaseStorage
       HBaseTimelineSchemaUtils.getTopOfTheDayTimestamp(ts);
   private static String doAsUser = "remoteuser";
 
-  @BeforeClass
+  @BeforeAll
   public static void setupBeforeClass() throws Exception {
     setup();
     loadData();
     initialize();
   }
 
-  @AfterClass
+  @AfterAll
   public static void tearDownAfterClass() throws Exception {
     tearDown();
   }
@@ -505,13 +505,14 @@ public class TestTimelineReaderWebServicesHBaseStorage
       assertNotNull(entities);
       assertEquals(2, entities.size());
       for (FlowRunEntity entity : entities) {
-        assertTrue("Id, run id or start time does not match.",
+        assertTrue(
             ((entity.getId().equals("user1@flow_name/1002345678919")) &&
             (entity.getRunId() == 1002345678919L) &&
             (entity.getStartTime() == 1425016501000L)) ||
             ((entity.getId().equals("user1@flow_name/1002345678920")) &&
             (entity.getRunId() == 1002345678920L) &&
-            (entity.getStartTime() == 1425016501034L)));
+            (entity.getStartTime() == 1425016501034L)),
+            "Id, run id or start time does not match.");
         assertEquals(0, entity.getMetrics().size());
       }
 
@@ -525,10 +526,11 @@ public class TestTimelineReaderWebServicesHBaseStorage
       assertNotNull(entities);
       assertEquals(1, entities.size());
       for (FlowRunEntity entity : entities) {
-        assertTrue("Id, run id or start time does not match.",
+        assertTrue(
             entity.getId().equals("user1@flow_name/1002345678920") &&
             entity.getRunId() == 1002345678920L &&
-            entity.getStartTime() == 1425016501034L);
+            entity.getStartTime() == 1425016501034L,
+            "Id, run id or start time does not match.");
         assertEquals(0, entity.getMetrics().size());
       }
 
@@ -542,10 +544,11 @@ public class TestTimelineReaderWebServicesHBaseStorage
       assertNotNull(entities);
       assertEquals(1, entities.size());
       for (FlowRunEntity entity : entities) {
-        assertTrue("Id, run id or start time does not match.",
+        assertTrue(
             entity.getId().equals("user1@flow_name/1002345678920") &&
             entity.getRunId() == 1002345678920L &&
-            entity.getStartTime() == 1425016501034L);
+            entity.getStartTime() == 1425016501034L,
+            "Id, run id or start time does not match.");
         assertEquals(0, entity.getMetrics().size());
       }
 
@@ -559,13 +562,14 @@ public class TestTimelineReaderWebServicesHBaseStorage
       assertNotNull(entities);
       assertEquals(2, entities.size());
       for (FlowRunEntity entity : entities) {
-        assertTrue("Id, run id or start time does not match.",
+        assertTrue(
             ((entity.getId().equals("user1@flow_name/1002345678919")) &&
             (entity.getRunId() == 1002345678919L) &&
             (entity.getStartTime() == 1425016501000L)) ||
             ((entity.getId().equals("user1@flow_name/1002345678920")) &&
             (entity.getRunId() == 1002345678920L) &&
-            (entity.getStartTime() == 1425016501034L)));
+            (entity.getStartTime() == 1425016501034L)),
+            "Id, run id or start time does not match.");
         assertEquals(0, entity.getMetrics().size());
       }
 
@@ -579,10 +583,11 @@ public class TestTimelineReaderWebServicesHBaseStorage
       assertNotNull(entities);
       assertEquals(1, entities.size());
       for (FlowRunEntity entity : entities) {
-        assertTrue("Id, run id or start time does not match.",
+        assertTrue(
              entity.getId().equals("user1@flow_name/1002345678919") &&
              entity.getRunId() == 1002345678919L &&
-             entity.getStartTime() == 1425016501000L);
+             entity.getStartTime() == 1425016501000L,
+             "Id, run id or start time does not match.");
         assertEquals(0, entity.getMetrics().size());
       }
 
@@ -596,7 +601,7 @@ public class TestTimelineReaderWebServicesHBaseStorage
       assertNotNull(entities);
       assertEquals(2, entities.size());
       for (FlowRunEntity entity : entities) {
-        assertTrue("Id, run id or start time does not match.",
+        assertTrue(
             ((entity.getId().equals("user1@flow_name/1002345678919")) &&
             (entity.getRunId() == 1002345678919L) &&
             (entity.getStartTime() == 1425016501000L) &&
@@ -604,7 +609,8 @@ public class TestTimelineReaderWebServicesHBaseStorage
             ((entity.getId().equals("user1@flow_name/1002345678920")) &&
             (entity.getRunId() == 1002345678920L) &&
             (entity.getStartTime() == 1425016501034L) &&
-            (entity.getMetrics().size() == 1)));
+            (entity.getMetrics().size() == 1)),
+            "Id, run id or start time does not match.");
       }
 
       // fields as CONFIGS will lead to a HTTP 400 as it makes no sense for
@@ -1999,11 +2005,12 @@ public class TestTimelineReaderWebServicesHBaseStorage
       assertNotNull(entities);
       assertEquals(2, entities.size());
       for (TimelineEntity entity : entities) {
-        assertTrue("Unexpected app in result",
+        assertTrue(
             (entity.getId().equals("application_1111111111_1111") &&
             entity.getMetrics().size() == 3) ||
             (entity.getId().equals("application_1111111111_2222") &&
-            entity.getMetrics().size() == 1));
+            entity.getMetrics().size() == 1),
+            "Unexpected app in result");
         for (TimelineMetric metric : entity.getMetrics()) {
           assertEquals(TimelineMetric.Type.SINGLE_VALUE, metric.getType());
           assertEquals(1, metric.getValues().size());
@@ -2018,11 +2025,12 @@ public class TestTimelineReaderWebServicesHBaseStorage
       assertNotNull(entities);
       assertEquals(2, entities.size());
       for (TimelineEntity entity : entities) {
-        assertTrue("Unexpected app in result",
+        assertTrue(
             (entity.getId().equals("application_1111111111_1111") &&
             entity.getMetrics().size() == 3) ||
             (entity.getId().equals("application_1111111111_2222") &&
-            entity.getMetrics().size() == 1));
+            entity.getMetrics().size() == 1),
+            "Unexpected app in result");
         for (TimelineMetric metric : entity.getMetrics()) {
           assertTrue(metric.getValues().size() <= 2);
           assertEquals(TimelineMetric.Type.TIME_SERIES, metric.getType());
@@ -2062,7 +2070,7 @@ public class TestTimelineReaderWebServicesHBaseStorage
       assertNotNull(entities);
       assertEquals(3, entities.size());
       for (TimelineEntity entity : entities) {
-        assertTrue("Unexpected app in result",
+        assertTrue(
             (entity.getId().equals("application_1111111111_1111") &&
             entity.getConfigs().size() == 1 &&
             entity.getConfigs().equals(ImmutableMap.of("cfg2", "value1"))) ||
@@ -2070,7 +2078,8 @@ public class TestTimelineReaderWebServicesHBaseStorage
             entity.getConfigs().size() == 1 &&
             entity.getConfigs().equals(ImmutableMap.of("cfg1", "value1"))) ||
             (entity.getId().equals("application_1111111111_2224") &&
-            entity.getConfigs().size() == 0));
+            entity.getConfigs().size() == 0),
+            "Unexpected app in result");
         for (TimelineMetric metric : entity.getMetrics()) {
           if (entity.getId().equals("application_1111111111_1111")) {
             TimelineMetric m1 = newMetric(TimelineMetric.Type.SINGLE_VALUE,
@@ -2100,7 +2109,7 @@ public class TestTimelineReaderWebServicesHBaseStorage
       assertNotNull(entities);
       assertEquals(3, entities.size());
       for (TimelineEntity entity : entities) {
-        assertTrue("Unexpected app in result",
+        assertTrue(
             (entity.getId().equals("application_1111111111_1111") &&
             entity.getConfigs().size() == 1 &&
             entity.getConfigs().equals(ImmutableMap.of("cfg2", "value1"))) ||
@@ -2108,7 +2117,8 @@ public class TestTimelineReaderWebServicesHBaseStorage
             entity.getConfigs().size() == 1 &&
             entity.getConfigs().equals(ImmutableMap.of("cfg1", "value1"))) ||
             (entity.getId().equals("application_1111111111_2224") &&
-            entity.getConfigs().size() == 0));
+            entity.getConfigs().size() == 0),
+            "Unexpected app in result");
         for (TimelineMetric metric : entity.getMetrics()) {
           if (entity.getId().equals("application_1111111111_1111")) {
             TimelineMetric m1 = newMetric(TimelineMetric.Type.TIME_SERIES,
@@ -2167,8 +2177,9 @@ public class TestTimelineReaderWebServicesHBaseStorage
           resp.readEntity(new GenericType<Set<TimelineEntity>>(){});
       assertNotNull(entities);
       assertEquals(1, entities.size());
-      assertTrue("Unexpected app in result", entities.contains(
-          newEntity(entityType, "application_1111111111_1111")));
+      assertTrue(entities.contains(
+          newEntity(entityType, "application_1111111111_1111")),
+          "Unexpected app in result");
 
       uri = URI.create("http://localhost:" + getServerPort() + "/ws/v2/" +
           "timeline/clusters/cluster1/users/user1/flows/flow_name/apps?" +
@@ -2177,8 +2188,9 @@ public class TestTimelineReaderWebServicesHBaseStorage
       entities = resp.readEntity(new GenericType<Set<TimelineEntity>>(){});
       assertNotNull(entities);
       assertEquals(1, entities.size());
-      assertTrue("Unexpected app in result", entities.contains(
-          newEntity(entityType, "application_1111111111_1111")));
+      assertTrue(entities.contains(
+          newEntity(entityType, "application_1111111111_1111")),
+          "Unexpected app in result");
 
       uri = URI.create("http://localhost:" + getServerPort() + "/ws/v2/" +
           "timeline/clusters/cluster1/users/user1/flows/flow_name/apps?" +
@@ -2187,8 +2199,9 @@ public class TestTimelineReaderWebServicesHBaseStorage
       entities = resp.readEntity(new GenericType<Set<TimelineEntity>>(){});
       assertNotNull(entities);
       assertEquals(1, entities.size());
-      assertTrue("Unexpected app in result", entities.contains(
-          newEntity(entityType, "application_1111111111_2222")));
+      assertTrue(entities.contains(
+          newEntity(entityType, "application_1111111111_2222")),
+          "Unexpected app in result");
     } finally {
       client.close();
     }

+ 47 - 47
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/TestHBaseTimelineStorageApps.java

@@ -18,9 +18,10 @@
 
 package org.apache.hadoop.yarn.server.timelineservice.storage;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 import java.util.Arrays;
@@ -76,12 +77,11 @@ import org.apache.hadoop.yarn.server.timelineservice.storage.common.HBaseTimelin
 import org.apache.hadoop.yarn.server.timelineservice.storage.common.KeyConverter;
 import org.apache.hadoop.yarn.server.timelineservice.storage.common.Separator;
 import org.apache.hadoop.yarn.server.timelineservice.storage.common.StringKeyConverter;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for apps stored in TimelineStorage.
@@ -92,7 +92,7 @@ public class TestHBaseTimelineStorageApps {
   private HBaseTimelineReaderImpl reader;
   private static final long CURRENT_TIME = System.currentTimeMillis();
 
-  @BeforeClass
+  @BeforeAll
   public static void setupBeforeClass() throws Exception {
     util = new HBaseTestingUtility();
     util.startMiniCluster();
@@ -100,14 +100,14 @@ public class TestHBaseTimelineStorageApps {
     DataGeneratorForTest.loadApps(util, CURRENT_TIME);
   }
 
-  @Before
+  @BeforeEach
   public void init() throws Exception {
     reader = new HBaseTimelineReaderImpl();
     reader.init(util.getConfiguration());
     reader.start();
   }
 
-  @After
+  @AfterEach
   public void stop() throws Exception {
     if (reader != null) {
       reader.stop();
@@ -641,13 +641,13 @@ public class TestHBaseTimelineStorageApps {
       UserGroupInformation user = UserGroupInformation.createRemoteUser("u1");
       try {
         hbi.write(context, teApp, user);
-        Assert.fail("Expected an exception as metric values are non integral");
+        fail("Expected an exception as metric values are non integral");
       } catch (IOException e) {}
 
       // Writing generic entity.
       try {
         hbi.write(context, teEntity, user);
-        Assert.fail("Expected an exception as metric values are non integral");
+        fail("Expected an exception as metric values are non integral");
       } catch (IOException e) {}
       hbi.stop();
     } finally {
@@ -719,7 +719,7 @@ public class TestHBaseTimelineStorageApps {
       if (!entity.getId().equals("application_1111111111_2222") &&
           !entity.getId().equals("application_1111111111_3333") &&
           !entity.getId().equals("application_1111111111_4444")) {
-        Assert.fail("Entities with ids' application_1111111111_2222, " +
+        fail("Entities with ids' application_1111111111_2222, " +
             "application_1111111111_3333 and application_1111111111_4444" +
             " should be present");
       }
@@ -735,7 +735,7 @@ public class TestHBaseTimelineStorageApps {
     for (TimelineEntity entity : entities) {
       if (!entity.getId().equals("application_1111111111_3333") &&
           !entity.getId().equals("application_1111111111_4444")) {
-        Assert.fail("Apps with ids' application_1111111111_3333 and" +
+        fail("Apps with ids' application_1111111111_3333 and" +
             " application_1111111111_4444 should be present");
       }
     }
@@ -749,7 +749,7 @@ public class TestHBaseTimelineStorageApps {
     assertEquals(1, entities.size());
     for (TimelineEntity entity : entities) {
       if (!entity.getId().equals("application_1111111111_2222")) {
-        Assert.fail("App with id application_1111111111_2222 should" +
+        fail("App with id application_1111111111_2222 should" +
             " be present");
       }
     }
@@ -836,7 +836,7 @@ public class TestHBaseTimelineStorageApps {
       isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size();
       if (!timelineEntity.getId().equals("application_1111111111_2222") &&
           !timelineEntity.getId().equals("application_1111111111_3333")) {
-        Assert.fail("Entity ids' should have been application_1111111111_2222"
+        fail("Entity ids' should have been application_1111111111_2222"
             + " and application_1111111111_3333");
       }
     }
@@ -860,7 +860,7 @@ public class TestHBaseTimelineStorageApps {
     for (TimelineEntity timelineEntity : entities) {
       isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size();
       if (!timelineEntity.getId().equals("application_1111111111_4444")) {
-        Assert.fail("Entity id should have been application_1111111111_4444");
+        fail("Entity id should have been application_1111111111_4444");
       }
     }
     assertEquals(0, isRelatedToCnt);
@@ -884,7 +884,7 @@ public class TestHBaseTimelineStorageApps {
       isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size();
       if (!timelineEntity.getId().equals("application_1111111111_2222") &&
           !timelineEntity.getId().equals("application_1111111111_3333")) {
-        Assert.fail("Entity ids' should have been application_1111111111_2222"
+        fail("Entity ids' should have been application_1111111111_2222"
             + " and application_1111111111_3333");
       }
     }
@@ -905,7 +905,7 @@ public class TestHBaseTimelineStorageApps {
     for (TimelineEntity timelineEntity : entities) {
       isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size();
       if (!timelineEntity.getId().equals("application_1111111111_3333")) {
-        Assert.fail("Entity id should have been application_1111111111_3333");
+        fail("Entity id should have been application_1111111111_3333");
       }
     }
     assertEquals(0, isRelatedToCnt);
@@ -960,7 +960,7 @@ public class TestHBaseTimelineStorageApps {
     for (TimelineEntity timelineEntity : entities) {
       isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size();
       if (!timelineEntity.getId().equals("application_1111111111_3333")) {
-        Assert.fail("Entity id should have been application_1111111111_3333");
+        fail("Entity id should have been application_1111111111_3333");
       }
     }
     assertEquals(0, isRelatedToCnt);
@@ -989,7 +989,7 @@ public class TestHBaseTimelineStorageApps {
       relatesToCnt += timelineEntity.getRelatesToEntities().size();
       if (!timelineEntity.getId().equals("application_1111111111_2222") &&
           !timelineEntity.getId().equals("application_1111111111_4444")) {
-        Assert.fail("Entity ids' should have been application_1111111111_2222"
+        fail("Entity ids' should have been application_1111111111_2222"
             + " and application_1111111111_4444");
       }
     }
@@ -1013,7 +1013,7 @@ public class TestHBaseTimelineStorageApps {
     for (TimelineEntity timelineEntity : entities) {
       relatesToCnt += timelineEntity.getRelatesToEntities().size();
       if (!timelineEntity.getId().equals("application_1111111111_3333")) {
-        Assert.fail("Entity id should have been application_1111111111_3333");
+        fail("Entity id should have been application_1111111111_3333");
       }
     }
     assertEquals(0, relatesToCnt);
@@ -1037,7 +1037,7 @@ public class TestHBaseTimelineStorageApps {
       relatesToCnt += timelineEntity.getRelatesToEntities().size();
       if (!timelineEntity.getId().equals("application_1111111111_2222") &&
           !timelineEntity.getId().equals("application_1111111111_4444")) {
-        Assert.fail("Entity ids' should have been application_1111111111_2222"
+        fail("Entity ids' should have been application_1111111111_2222"
             + " and application_1111111111_4444");
       }
     }
@@ -1058,7 +1058,7 @@ public class TestHBaseTimelineStorageApps {
     for (TimelineEntity timelineEntity : entities) {
       relatesToCnt += timelineEntity.getRelatesToEntities().size();
       if (!timelineEntity.getId().equals("application_1111111111_2222")) {
-        Assert.fail("Entity id should have been application_1111111111_2222");
+        fail("Entity id should have been application_1111111111_2222");
       }
     }
     assertEquals(0, relatesToCnt);
@@ -1113,7 +1113,7 @@ public class TestHBaseTimelineStorageApps {
     for (TimelineEntity timelineEntity : entities) {
       relatesToCnt += timelineEntity.getRelatesToEntities().size();
       if (!timelineEntity.getId().equals("application_1111111111_2222")) {
-        Assert.fail("Entity id should have been application_1111111111_2222");
+        fail("Entity id should have been application_1111111111_2222");
       }
     }
     assertEquals(0, relatesToCnt);
@@ -1149,7 +1149,7 @@ public class TestHBaseTimelineStorageApps {
     for (TimelineEntity timelineEntity : entities) {
       relatesToCnt += timelineEntity.getRelatesToEntities().size();
       if (!timelineEntity.getId().equals("application_1111111111_3333")) {
-        Assert.fail("Entity id should have been application_1111111111_3333");
+        fail("Entity id should have been application_1111111111_3333");
       }
     }
     assertEquals(0, relatesToCnt);
@@ -1191,7 +1191,7 @@ public class TestHBaseTimelineStorageApps {
       isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size();
       relatesToCnt += timelineEntity.getRelatesToEntities().size();
       if (!timelineEntity.getId().equals("application_1111111111_4444")) {
-        Assert.fail("Entity id should have been application_1111111111_4444");
+        fail("Entity id should have been application_1111111111_4444");
       }
     }
     assertEquals(0, eventCnt);
@@ -1335,7 +1335,7 @@ public class TestHBaseTimelineStorageApps {
     for (TimelineEntity timelineEntity : entities) {
       eventCnt += timelineEntity.getEvents().size();
       if (!timelineEntity.getId().equals("application_1111111111_4444")) {
-        Assert.fail("Entity id should have been application_1111111111_4444");
+        fail("Entity id should have been application_1111111111_4444");
       }
     }
     assertEquals(1, eventCnt);
@@ -1356,7 +1356,7 @@ public class TestHBaseTimelineStorageApps {
     for (TimelineEntity timelineEntity : entities) {
       eventCnt += timelineEntity.getEvents().size();
       if (!timelineEntity.getId().equals("application_1111111111_4444")) {
-        Assert.fail("Entity id should have been application_1111111111_4444");
+        fail("Entity id should have been application_1111111111_4444");
       }
     }
     assertEquals(0, eventCnt);
@@ -1376,7 +1376,7 @@ public class TestHBaseTimelineStorageApps {
       eventCnt += timelineEntity.getEvents().size();
       if (!timelineEntity.getId().equals("application_1111111111_2222") &&
           !timelineEntity.getId().equals("application_1111111111_4444")) {
-        Assert.fail("Entity ids' should have been application_1111111111_2222"
+        fail("Entity ids' should have been application_1111111111_2222"
             + " and application_1111111111_4444");
       }
     }
@@ -1415,7 +1415,7 @@ public class TestHBaseTimelineStorageApps {
     for (TimelineEntity timelineEntity : entities) {
       eventCnt += timelineEntity.getEvents().size();
       if (!timelineEntity.getId().equals("application_1111111111_2222")) {
-        Assert.fail("Entity id should have been application_1111111111_2222");
+        fail("Entity id should have been application_1111111111_2222");
       }
     }
     assertEquals(0, eventCnt);
@@ -1436,7 +1436,7 @@ public class TestHBaseTimelineStorageApps {
     for (TimelineEntity timelineEntity : entities) {
       eventCnt += timelineEntity.getEvents().size();
       if (!timelineEntity.getId().equals("application_1111111111_2222")) {
-        Assert.fail("Entity id should have been application_1111111111_2222");
+        fail("Entity id should have been application_1111111111_2222");
       }
     }
     assertEquals(0, eventCnt);
@@ -1464,8 +1464,8 @@ public class TestHBaseTimelineStorageApps {
     for (TimelineEntity entity : es1) {
       cfgCnt += entity.getConfigs().size();
       for (String confKey : entity.getConfigs().keySet()) {
-        assertTrue("Config key returned should start with cfg_",
-            confKey.startsWith("cfg_"));
+        assertTrue(confKey.startsWith("cfg_"),
+            "Config key returned should start with cfg_");
       }
     }
     assertEquals(3, cfgCnt);
@@ -1491,8 +1491,8 @@ public class TestHBaseTimelineStorageApps {
     for (TimelineEntity entity : entities) {
       cfgCnt += entity.getConfigs().size();
       for (String confKey : entity.getConfigs().keySet()) {
-        assertTrue("Config key returned should start with cfg_",
-            confKey.startsWith("cfg_"));
+        assertTrue(confKey.startsWith("cfg_"),
+            "Config key returned should start with cfg_");
       }
     }
     assertEquals(2, cfgCnt);
@@ -1525,8 +1525,8 @@ public class TestHBaseTimelineStorageApps {
     for (TimelineEntity entity : entities) {
       cfgCnt += entity.getConfigs().size();
       for (String confKey : entity.getConfigs().keySet()) {
-        assertTrue("Config key returned should start with config_",
-            confKey.startsWith("config_"));
+        assertTrue(confKey.startsWith("config_"),
+            "Config key returned should start with config_");
       }
     }
     assertEquals(2, cfgCnt);
@@ -1671,8 +1671,8 @@ public class TestHBaseTimelineStorageApps {
     for (TimelineEntity entity : es1) {
       metricCnt += entity.getMetrics().size();
       for (TimelineMetric metric : entity.getMetrics()) {
-        assertTrue("Metric Id returned should start with MAP1_",
-            metric.getId().startsWith("MAP1_"));
+        assertTrue(metric.getId().startsWith("MAP1_"),
+            "Metric Id returned should start with MAP1_");
       }
     }
     assertEquals(2, metricCnt);
@@ -1725,8 +1725,8 @@ public class TestHBaseTimelineStorageApps {
     for (TimelineEntity entity : entities) {
       metricCnt += entity.getMetrics().size();
       for (TimelineMetric metric : entity.getMetrics()) {
-        assertTrue("Metric Id returned should start with MAP1_",
-            metric.getId().startsWith("MAP1_"));
+        assertTrue(metric.getId().startsWith("MAP1_"),
+            "Metric Id returned should start with MAP1_");
       }
     }
     assertEquals(2, metricCnt);
@@ -1745,8 +1745,8 @@ public class TestHBaseTimelineStorageApps {
       metricCnt += entity.getMetrics().size();
       for (TimelineMetric metric : entity.getMetrics()) {
         metricValCnt += metric.getValues().size();
-        assertTrue("Metric Id returned should start with MAP1_",
-            metric.getId().startsWith("MAP1_"));
+        assertTrue(metric.getId().startsWith("MAP1_"),
+            "Metric Id returned should start with MAP1_");
       }
     }
     assertEquals(2, metricCnt);
@@ -1934,7 +1934,7 @@ public class TestHBaseTimelineStorageApps {
     assertEquals(3, entities.size());
   }
 
-  @AfterClass
+  @AfterAll
   public static void tearDownAfterClass() throws Exception {
     if (util != null) {
       util.shutdownMiniCluster();

+ 8 - 8
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/TestHBaseTimelineStorageDomain.java

@@ -32,13 +32,13 @@ import org.apache.hadoop.yarn.server.timelineservice.storage.common.ColumnRWHelp
 import org.apache.hadoop.yarn.server.timelineservice.storage.domain.DomainColumn;
 import org.apache.hadoop.yarn.server.timelineservice.storage.domain.DomainRowKey;
 import org.apache.hadoop.yarn.server.timelineservice.storage.domain.DomainTableRW;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
  * Test for timeline domain.
@@ -47,7 +47,7 @@ public class TestHBaseTimelineStorageDomain {
 
   private static HBaseTestingUtility util;
 
-  @BeforeClass
+  @BeforeAll
   public static void setupBeforeClass() throws Exception {
     util = new HBaseTestingUtility();
     Configuration conf = util.getConfiguration();
@@ -125,7 +125,7 @@ public class TestHBaseTimelineStorageDomain {
     assertEquals("writer1,writer2", writers);
   }
 
-  @AfterClass
+  @AfterAll
   public static void tearDownAfterClass() throws Exception {
     if (util != null) {
       util.shutdownMiniCluster();

+ 50 - 49
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/TestHBaseTimelineStorageEntities.java

@@ -18,10 +18,11 @@
 
 package org.apache.hadoop.yarn.server.timelineservice.storage;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 import java.util.Arrays;
@@ -81,12 +82,12 @@ import org.apache.hadoop.yarn.server.timelineservice.storage.subapplication.SubA
 import org.apache.hadoop.yarn.server.timelineservice.storage.subapplication.SubApplicationRowKey;
 import org.apache.hadoop.yarn.server.timelineservice.storage.subapplication.SubApplicationRowKeyPrefix;
 import org.apache.hadoop.yarn.server.timelineservice.storage.subapplication.SubApplicationTableRW;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 /**
  * Various tests to test writing entities to HBase and reading them back from
@@ -105,7 +106,7 @@ public class TestHBaseTimelineStorageEntities {
   private HBaseTimelineReaderImpl reader;
   private static final long CURRENT_TIME = System.currentTimeMillis();
 
-  @BeforeClass
+  @BeforeAll
   public static void setupBeforeClass() throws Exception {
     util = new HBaseTestingUtility();
     util.startMiniCluster();
@@ -113,14 +114,14 @@ public class TestHBaseTimelineStorageEntities {
     DataGeneratorForTest.loadEntities(util, CURRENT_TIME);
   }
 
-  @Before
+  @BeforeEach
   public void init() throws Exception {
     reader = new HBaseTimelineReaderImpl();
     reader.init(util.getConfiguration());
     reader.start();
   }
 
-  @After
+  @AfterEach
   public void stop() throws Exception {
     if (reader != null) {
       reader.stop();
@@ -722,7 +723,7 @@ public class TestHBaseTimelineStorageEntities {
     for (TimelineEntity entity : entities) {
       if (!entity.getId().equals("hello") && !entity.getId().equals("hello1") &&
           !entity.getId().equals("hello2")) {
-        Assert.fail("Entities with ids' hello, hello1 and hello2 should be" +
+        fail("Entities with ids' hello, hello1 and hello2 should be" +
             " present");
       }
     }
@@ -736,7 +737,7 @@ public class TestHBaseTimelineStorageEntities {
     for (TimelineEntity entity : entities) {
       if (!entity.getId().equals("hello1") &&
           !entity.getId().equals("hello2")) {
-        Assert.fail("Entities with ids' hello1 and hello2 should be present");
+        fail("Entities with ids' hello1 and hello2 should be present");
       }
     }
     entities = reader.getEntities(
@@ -748,7 +749,7 @@ public class TestHBaseTimelineStorageEntities {
     assertEquals(1, entities.size());
     for (TimelineEntity entity : entities) {
       if (!entity.getId().equals("hello")) {
-        Assert.fail("Entity with id hello should be present");
+        fail("Entity with id hello should be present");
       }
     }
   }
@@ -788,7 +789,7 @@ public class TestHBaseTimelineStorageEntities {
       isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size();
       relatesToCnt += timelineEntity.getRelatesToEntities().size();
       if (!timelineEntity.getId().equals("hello2")) {
-        Assert.fail("Entity id should have been hello2");
+        fail("Entity id should have been hello2");
       }
     }
     assertEquals(0, eventCnt);
@@ -814,7 +815,7 @@ public class TestHBaseTimelineStorageEntities {
     for (TimelineEntity timelineEntity : entities) {
       eventCnt += timelineEntity.getEvents().size();
       if (!timelineEntity.getId().equals("hello2")) {
-        Assert.fail("Entity id should have been hello2");
+        fail("Entity id should have been hello2");
       }
     }
     assertEquals(1, eventCnt);
@@ -834,7 +835,7 @@ public class TestHBaseTimelineStorageEntities {
     for (TimelineEntity timelineEntity : entities) {
       eventCnt += timelineEntity.getEvents().size();
       if (!timelineEntity.getId().equals("hello2")) {
-        Assert.fail("Entity id should have been hello2");
+        fail("Entity id should have been hello2");
       }
     }
     assertEquals(0, eventCnt);
@@ -853,7 +854,7 @@ public class TestHBaseTimelineStorageEntities {
       eventCnt += timelineEntity.getEvents().size();
       if (!timelineEntity.getId().equals("hello") &&
           !timelineEntity.getId().equals("hello2")) {
-        Assert.fail("Entity ids' should have been hello and hello2");
+        fail("Entity ids' should have been hello and hello2");
       }
     }
     assertEquals(0, eventCnt);
@@ -889,7 +890,7 @@ public class TestHBaseTimelineStorageEntities {
     for (TimelineEntity timelineEntity : entities) {
       eventCnt += timelineEntity.getEvents().size();
       if (!timelineEntity.getId().equals("hello")) {
-        Assert.fail("Entity id should have been hello");
+        fail("Entity id should have been hello");
       }
     }
     assertEquals(0, eventCnt);
@@ -909,7 +910,7 @@ public class TestHBaseTimelineStorageEntities {
     for (TimelineEntity timelineEntity : entities) {
       eventCnt += timelineEntity.getEvents().size();
       if (!timelineEntity.getId().equals("hello")) {
-        Assert.fail("Entity id should have been hello");
+        fail("Entity id should have been hello");
       }
     }
     assertEquals(0, eventCnt);
@@ -936,7 +937,7 @@ public class TestHBaseTimelineStorageEntities {
       isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size();
       if (!timelineEntity.getId().equals("hello") &&
           !timelineEntity.getId().equals("hello1")) {
-        Assert.fail("Entity ids' should have been hello and hello1");
+        fail("Entity ids' should have been hello and hello1");
       }
     }
     assertEquals(3, isRelatedToCnt);
@@ -958,7 +959,7 @@ public class TestHBaseTimelineStorageEntities {
     for (TimelineEntity timelineEntity : entities) {
       isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size();
       if (!timelineEntity.getId().equals("hello2")) {
-        Assert.fail("Entity id should have been hello2");
+        fail("Entity id should have been hello2");
       }
     }
     assertEquals(0, isRelatedToCnt);
@@ -981,7 +982,7 @@ public class TestHBaseTimelineStorageEntities {
       isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size();
       if (!timelineEntity.getId().equals("hello") &&
           !timelineEntity.getId().equals("hello1")) {
-        Assert.fail("Entity ids' should have been hello and hello1");
+        fail("Entity ids' should have been hello and hello1");
       }
     }
     assertEquals(0, isRelatedToCnt);
@@ -1000,7 +1001,7 @@ public class TestHBaseTimelineStorageEntities {
     for (TimelineEntity timelineEntity : entities) {
       isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size();
       if (!timelineEntity.getId().equals("hello1")) {
-        Assert.fail("Entity id should have been hello1");
+        fail("Entity id should have been hello1");
       }
     }
     assertEquals(0, isRelatedToCnt);
@@ -1052,7 +1053,7 @@ public class TestHBaseTimelineStorageEntities {
     for (TimelineEntity timelineEntity : entities) {
       isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size();
       if (!timelineEntity.getId().equals("hello1")) {
-        Assert.fail("Entity id should have been hello1");
+        fail("Entity id should have been hello1");
       }
     }
     assertEquals(0, isRelatedToCnt);
@@ -1079,7 +1080,7 @@ public class TestHBaseTimelineStorageEntities {
       relatesToCnt += timelineEntity.getRelatesToEntities().size();
       if (!timelineEntity.getId().equals("hello") &&
           !timelineEntity.getId().equals("hello2")) {
-        Assert.fail("Entity ids' should have been hello and hello2");
+        fail("Entity ids' should have been hello and hello2");
       }
     }
     assertEquals(3, relatesToCnt);
@@ -1101,7 +1102,7 @@ public class TestHBaseTimelineStorageEntities {
     for (TimelineEntity timelineEntity : entities) {
       relatesToCnt += timelineEntity.getRelatesToEntities().size();
       if (!timelineEntity.getId().equals("hello1")) {
-        Assert.fail("Entity id should have been hello1");
+        fail("Entity id should have been hello1");
       }
     }
     assertEquals(0, relatesToCnt);
@@ -1124,7 +1125,7 @@ public class TestHBaseTimelineStorageEntities {
       relatesToCnt += timelineEntity.getRelatesToEntities().size();
       if (!timelineEntity.getId().equals("hello") &&
           !timelineEntity.getId().equals("hello2")) {
-        Assert.fail("Entity ids' should have been hello and hello2");
+        fail("Entity ids' should have been hello and hello2");
       }
     }
     assertEquals(0, relatesToCnt);
@@ -1143,7 +1144,7 @@ public class TestHBaseTimelineStorageEntities {
     for (TimelineEntity timelineEntity : entities) {
       relatesToCnt += timelineEntity.getRelatesToEntities().size();
       if (!timelineEntity.getId().equals("hello")) {
-        Assert.fail("Entity id should have been hello");
+        fail("Entity id should have been hello");
       }
     }
     assertEquals(0, relatesToCnt);
@@ -1195,7 +1196,7 @@ public class TestHBaseTimelineStorageEntities {
     for (TimelineEntity timelineEntity : entities) {
       relatesToCnt += timelineEntity.getRelatesToEntities().size();
       if (!timelineEntity.getId().equals("hello")) {
-        Assert.fail("Entity id should have been hello");
+        fail("Entity id should have been hello");
       }
     }
     assertEquals(0, relatesToCnt);
@@ -1230,7 +1231,7 @@ public class TestHBaseTimelineStorageEntities {
     for (TimelineEntity timelineEntity : entities) {
       relatesToCnt += timelineEntity.getRelatesToEntities().size();
       if (!timelineEntity.getId().equals("hello1")) {
-        Assert.fail("Entity id should have been hello1");
+        fail("Entity id should have been hello1");
       }
     }
     assertEquals(0, relatesToCnt);
@@ -1311,8 +1312,7 @@ public class TestHBaseTimelineStorageEntities {
     for (TimelineEntity entity : es1) {
       cfgCnt += entity.getConfigs().size();
       for (String confKey : entity.getConfigs().keySet()) {
-        assertTrue("Config key returned should start with cfg_",
-            confKey.startsWith("cfg_"));
+        assertTrue(confKey.startsWith("cfg_"), "Config key returned should start with cfg_");
       }
     }
     assertEquals(3, cfgCnt);
@@ -1447,8 +1447,8 @@ public class TestHBaseTimelineStorageEntities {
     for (TimelineEntity entity : entities) {
       cfgCnt += entity.getConfigs().size();
       for (String confKey : entity.getConfigs().keySet()) {
-        assertTrue("Config key returned should start with cfg_",
-            confKey.startsWith("cfg_"));
+        assertTrue(
+            confKey.startsWith("cfg_"), "Config key returned should start with cfg_");
       }
     }
     assertEquals(2, cfgCnt);
@@ -1479,8 +1479,8 @@ public class TestHBaseTimelineStorageEntities {
     for (TimelineEntity entity : entities) {
       cfgCnt += entity.getConfigs().size();
       for (String confKey : entity.getConfigs().keySet()) {
-        assertTrue("Config key returned should start with config_",
-            confKey.startsWith("config_"));
+        assertTrue(
+            confKey.startsWith("config_"), "Config key returned should start with config_");
       }
     }
     assertEquals(2, cfgCnt);
@@ -1506,8 +1506,8 @@ public class TestHBaseTimelineStorageEntities {
     for (TimelineEntity entity : es1) {
       metricCnt += entity.getMetrics().size();
       for (TimelineMetric metric : entity.getMetrics()) {
-        assertTrue("Metric Id returned should start with MAP1_",
-            metric.getId().startsWith("MAP1_"));
+        assertTrue(
+            metric.getId().startsWith("MAP1_"), "Metric Id returned should start with MAP1_");
       }
     }
     assertEquals(2, metricCnt);
@@ -1699,8 +1699,8 @@ public class TestHBaseTimelineStorageEntities {
     for (TimelineEntity entity : entities) {
       metricCnt += entity.getMetrics().size();
       for (TimelineMetric metric : entity.getMetrics()) {
-        assertTrue("Metric Id returned should start with MAP1_",
-            metric.getId().startsWith("MAP1_"));
+        assertTrue(
+            metric.getId().startsWith("MAP1_"), "Metric Id returned should start with MAP1_");
       }
     }
     assertEquals(1, metricCnt);
@@ -1731,8 +1731,8 @@ public class TestHBaseTimelineStorageEntities {
       for (TimelineMetric metric : entity.getMetrics()) {
         assertEquals(TimelineMetric.Type.SINGLE_VALUE, metric.getType());
         assertEquals(1, metric.getValues().size());
-        assertTrue("Metric Id returned should start with MAP1_",
-            metric.getId().startsWith("MAP1_"));
+        assertTrue(
+            metric.getId().startsWith("MAP1_"), "Metric Id returned should start with MAP1_");
       }
     }
     assertEquals(2, metricCnt);
@@ -1751,8 +1751,8 @@ public class TestHBaseTimelineStorageEntities {
       metricCnt += entity.getMetrics().size();
       for (TimelineMetric metric : entity.getMetrics()) {
         metricValCnt += metric.getValues().size();
-        assertTrue("Metric Id returned should start with MAP1_",
-            metric.getId().startsWith("MAP1_"));
+        assertTrue(
+            metric.getId().startsWith("MAP1_"), "Metric Id returned should start with MAP1_");
       }
     }
     assertEquals(2, metricCnt);
@@ -1854,7 +1854,8 @@ public class TestHBaseTimelineStorageEntities {
     assertEquals(3, entities.size());
   }
 
-  @Test(timeout = 90000)
+  @Test
+  @Timeout(value = 90)
   public void testListTypesInApp() throws Exception {
     Set<String> types = reader.getEntityTypes(
         new TimelineReaderContext("cluster1", "user1", "some_flow_name",
@@ -1877,7 +1878,7 @@ public class TestHBaseTimelineStorageEntities {
     assertEquals(0, types.size());
   }
 
-  @AfterClass
+  @AfterAll
   public static void tearDownAfterClass() throws Exception {
     if (util != null) {
       util.shutdownMiniCluster();

+ 7 - 7
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/TestHBaseTimelineStorageSchema.java

@@ -18,15 +18,15 @@
 
 package org.apache.hadoop.yarn.server.timelineservice.storage;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import org.apache.hadoop.yarn.server.timelineservice.storage.common.BaseTableRW;
 import org.apache.hadoop.yarn.server.timelineservice.storage.entity.EntityTableRW;
 import org.apache.hadoop.yarn.server.timelineservice.storage.flow.FlowRunTableRW;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 import java.io.IOException;
 
@@ -45,7 +45,7 @@ import org.apache.hadoop.hbase.client.Table;
 public class TestHBaseTimelineStorageSchema {
   private static HBaseTestingUtility util;
 
-  @BeforeClass
+  @BeforeAll
   public static void setupBeforeClass() throws Exception {
     util = new HBaseTestingUtility();
     Configuration conf = util.getConfiguration();
@@ -139,7 +139,7 @@ public class TestHBaseTimelineStorageSchema {
     .unset(YarnConfiguration.TIMELINE_SERVICE_HBASE_SCHEMA_PREFIX_NAME);
   }
 
-  @AfterClass
+  @AfterAll
   public static void tearDownAfterClass() throws Exception {
     if (util != null) {
       util.shutdownMiniCluster();

+ 16 - 9
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/TestTimelineReaderHBaseDown.java

@@ -28,8 +28,8 @@ import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntityType;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.server.timelineservice.reader.TimelineReaderContext;
 import org.apache.hadoop.yarn.server.timelineservice.reader.TimelineReaderServer;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 import java.io.IOException;
 import java.util.Set;
@@ -38,10 +38,13 @@ import java.util.concurrent.TimeoutException;
 import static org.apache.hadoop.yarn.conf.YarnConfiguration.TIMELINE_SERVICE_READER_STORAGE_MONITOR_INTERVAL_MS;
 import static org.apache.hadoop.yarn.server.timelineservice.storage.HBaseStorageMonitor.DATA_TO_RETRIEVE;
 import static org.apache.hadoop.yarn.server.timelineservice.storage.HBaseStorageMonitor.MONITOR_FILTERS;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
 
 public class TestTimelineReaderHBaseDown {
 
-  @Test(timeout=300000)
+  @Test
+  @Timeout(value = 300)
   public void testTimelineReaderHBaseUp() throws Exception {
     HBaseTestingUtility util = new HBaseTestingUtility();
     configure(util);
@@ -60,7 +63,8 @@ public class TestTimelineReaderHBaseDown {
     }
   }
 
-  @Test(timeout=300000)
+  @Test
+  @Timeout(value = 300)
   public void testTimelineReaderInitWhenHBaseIsDown() throws
       TimeoutException, InterruptedException {
     HBaseTestingUtility util = new HBaseTestingUtility();
@@ -74,7 +78,8 @@ public class TestTimelineReaderHBaseDown {
     waitForHBaseDown(htr);
   }
 
-  @Test(timeout=300000)
+  @Test
+  @Timeout(value = 300)
   public void testTimelineReaderDetectsHBaseDown() throws Exception {
     HBaseTestingUtility util = new HBaseTestingUtility();
     configure(util);
@@ -101,7 +106,8 @@ public class TestTimelineReaderHBaseDown {
     }
   }
 
-  @Test(timeout=300000)
+  @Test
+  @Timeout(value = 300)
   public void testTimelineReaderDetectsZooKeeperDown() throws Exception {
     HBaseTestingUtility util = new HBaseTestingUtility();
     configure(util);
@@ -128,7 +134,8 @@ public class TestTimelineReaderHBaseDown {
     }
   }
 
-  @Test(timeout=300000)
+  @Test
+  @Timeout(value = 300)
   public void testTimelineReaderRecoversAfterHBaseReturns() throws Exception {
     HBaseTestingUtility util = new HBaseTestingUtility();
     configure(util);
@@ -177,9 +184,9 @@ public class TestTimelineReaderHBaseDown {
         }
       }, 1000, 150000);
       checkQuery(htr);
-      Assert.fail("Query should fail when HBase is down");
+      fail("Query should fail when HBase is down");
     } catch (IOException e) {
-      Assert.assertEquals("HBase is down", e.getMessage());
+      assertEquals("HBase is down", e.getMessage());
     }
   }
 

+ 9 - 7
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/TestTimelineWriterHBaseDown.java

@@ -19,8 +19,8 @@ package org.apache.hadoop.yarn.server.timelineservice.storage;
 
 import java.io.IOException;
 
-import org.junit.Test;
-import org.junit.Assert;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
@@ -31,14 +31,16 @@ import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntities;
 import org.apache.hadoop.yarn.api.records.timelineservice.ApplicationEntity;
 
 import static org.apache.hadoop.yarn.conf.YarnConfiguration.TIMELINE_SERVICE_READER_STORAGE_MONITOR_INTERVAL_MS;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 /**
  * This class tests HbaseTimelineWriter with Hbase Down.
  */
 public class TestTimelineWriterHBaseDown {
 
-  @Test(timeout=300000)
+  @Test
+  @Timeout(value = 300)
   public void testTimelineWriterHBaseDown() throws Exception {
     HBaseTestingUtility util = new HBaseTestingUtility();
     HBaseTimelineWriterImpl writer = new HBaseTimelineWriterImpl();
@@ -58,7 +60,7 @@ public class TestTimelineWriterHBaseDown {
       try {
         storageMonitor.checkStorageIsUp();
       } catch(IOException e) {
-        Assert.fail("HBaseStorageMonitor failed to detect HBase Up");
+        fail("HBaseStorageMonitor failed to detect HBase Up");
       }
 
       util.shutdownMiniHBaseCluster();
@@ -82,8 +84,8 @@ public class TestTimelineWriterHBaseDown {
           exceptionCaught = true;
         }
       }
-      assertTrue("HBaseStorageMonitor failed to detect HBase Down",
-          exceptionCaught);
+      assertTrue(
+          exceptionCaught, "HBaseStorageMonitor failed to detect HBase Down");
     } finally {
       writer.stop();
       util.shutdownMiniCluster();

+ 9 - 9
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/flow/TestHBaseStorageFlowActivity.java

@@ -18,10 +18,10 @@
 
 package org.apache.hadoop.yarn.server.timelineservice.storage.flow;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 import java.util.Map;
@@ -55,9 +55,9 @@ import org.apache.hadoop.yarn.server.timelineservice.storage.HBaseTimelineWriter
 import org.apache.hadoop.yarn.server.timelineservice.storage.common.BaseTableRW;
 import org.apache.hadoop.yarn.server.timelineservice.storage.common.ColumnHelper;
 import org.apache.hadoop.yarn.server.timelineservice.storage.common.HBaseTimelineSchemaUtils;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests the FlowRun and FlowActivity Tables.
@@ -66,7 +66,7 @@ public class TestHBaseStorageFlowActivity {
 
   private static HBaseTestingUtility util;
 
-  @BeforeClass
+  @BeforeAll
   public static void setupBeforeClass() throws Exception {
     util = new HBaseTestingUtility();
     Configuration conf = util.getConfiguration();
@@ -490,7 +490,7 @@ public class TestHBaseStorageFlowActivity {
     }
   }
 
-  @AfterClass
+  @AfterAll
   public static void tearDownAfterClass() throws Exception {
     if (util != null) {
       util.shutdownMiniCluster();

+ 9 - 9
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/flow/TestHBaseStorageFlowRun.java

@@ -18,10 +18,10 @@
 
 package org.apache.hadoop.yarn.server.timelineservice.storage.flow;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 import java.util.EnumSet;
@@ -64,9 +64,9 @@ import org.apache.hadoop.yarn.server.timelineservice.storage.common.BaseTableRW;
 import org.apache.hadoop.yarn.server.timelineservice.storage.common.ColumnHelper;
 import org.apache.hadoop.yarn.server.timelineservice.storage.common.HBaseTimelineServerUtils;
 import org.apache.hadoop.yarn.server.timelineservice.storage.entity.EntityTableRW;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests the FlowRun and FlowActivity Tables.
@@ -78,7 +78,7 @@ public class TestHBaseStorageFlowRun {
   private static final String METRIC1 = "MAP_SLOT_MILLIS";
   private static final String METRIC2 = "HDFS_BYTES_READ";
 
-  @BeforeClass
+  @BeforeAll
   public static void setupBeforeClass() throws Exception {
     util = new HBaseTestingUtility();
     Configuration conf = util.getConfiguration();
@@ -1073,7 +1073,7 @@ public class TestHBaseStorageFlowRun {
     }
   }
 
-  @AfterClass
+  @AfterAll
   public static void tearDownAfterClass() throws Exception {
     if (util != null) {
       util.shutdownMiniCluster();

+ 16 - 16
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/flow/TestHBaseStorageFlowRunCompaction.java

@@ -19,10 +19,11 @@
 package org.apache.hadoop.yarn.server.timelineservice.storage.flow;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -59,10 +60,9 @@ import org.apache.hadoop.yarn.server.timelineservice.storage.common.ColumnHelper
 import org.apache.hadoop.yarn.server.timelineservice.storage.common.HBaseTimelineServerUtils;
 import org.apache.hadoop.yarn.server.timelineservice.storage.common.LongConverter;
 import org.apache.hadoop.yarn.server.timelineservice.storage.common.TimestampGenerator;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests the FlowRun and FlowActivity Tables.
@@ -78,7 +78,7 @@ public class TestHBaseStorageFlowRunCompaction {
   private final byte[] aFamily = Bytes.toBytes("family");
   private final byte[] aQualifier = Bytes.toBytes("qualifier");
 
-  @BeforeClass
+  @BeforeAll
   public static void setupBeforeClass() throws Exception {
     util = new HBaseTestingUtility();
     Configuration conf = util.getConfiguration();
@@ -335,8 +335,8 @@ public class TestHBaseStorageFlowRunCompaction {
     // flush and compact all the regions of the primary table
     int regionNum = HBaseTimelineServerUtils.flushCompactTableRegions(
         server, flowRunTable);
-    assertTrue("Didn't find any regions for primary table!",
-        regionNum > 0);
+    assertTrue(regionNum > 0,
+        "Didn't find any regions for primary table!");
 
     // check flow run for one flow many apps
     checkFlowRunTable(cluster, user, flow, runid, c1, 4);
@@ -490,7 +490,7 @@ public class TestHBaseStorageFlowRunCompaction {
         assertTrue(returnTs >= currentTimestamp);
       } else {
         // raise a failure since we expect only these two values back
-        Assert.fail();
+        fail();
       }
     }
   }
@@ -576,7 +576,7 @@ public class TestHBaseStorageFlowRunCompaction {
         assertTrue(returnTs <= cellTsNotFinalStart * count);
       } else {
         // raise a failure since we expect only these values back
-        Assert.fail();
+        fail();
       }
     }
   }
@@ -691,7 +691,7 @@ public class TestHBaseStorageFlowRunCompaction {
         assertTrue(returnTs <= cellTsFinalStartNotExpire + countFinalNotExpire);
       } else {
         // raise a failure since we expect only these values back
-        Assert.fail();
+        fail();
       }
     }
   }
@@ -755,7 +755,7 @@ public class TestHBaseStorageFlowRunCompaction {
       assertTrue(returnTs != inputTs1);
     } else {
       // raise a failure since we expect only these two values back
-      Assert.fail();
+      fail();
     }
   }
 
@@ -850,7 +850,7 @@ public class TestHBaseStorageFlowRunCompaction {
     assertEquals(0, cells.size());
   }
 
-  @AfterClass
+  @AfterAll
   public static void tearDownAfterClass() throws Exception {
     if (util != null) {
       util.shutdownMiniCluster();