From 35a22f7ecd12376c0a3c90a58b79e55cba8e44b7 Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Wed, 26 Mar 2025 07:30:21 +0800 Subject: [PATCH 1/3] YARN-11266. Upgrade JUnit from 4 to 5 in hadoop-yarn-server-timelineservice-hbase-tests. --- .../AbstractTimelineReaderHBaseTestBase.java | 14 +-- ...TimelineReaderWebServicesHBaseStorage.java | 90 ++++++++-------- .../storage/TestHBaseTimelineStorageApps.java | 94 ++++++++-------- .../TestHBaseTimelineStorageDomain.java | 16 +-- .../TestHBaseTimelineStorageEntities.java | 100 +++++++++--------- .../TestHBaseTimelineStorageSchema.java | 14 +-- .../storage/TestTimelineReaderHBaseDown.java | 24 +++-- .../storage/TestTimelineWriterHBaseDown.java | 16 +-- .../flow/TestHBaseStorageFlowActivity.java | 18 ++-- .../storage/flow/TestHBaseStorageFlowRun.java | 18 ++-- .../TestHBaseStorageFlowRunCompaction.java | 32 +++--- 11 files changed, 223 insertions(+), 213 deletions(-) diff --git a/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 b/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 index dbe9546d0f4e1..6950f3c474983 100644 --- a/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 +++ b/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,9 @@ 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 javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; @@ -43,7 +43,7 @@ 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; +import org.junit.jupiter.api.Assertions; /** * Test Base for TimelineReaderServer HBase tests. @@ -101,7 +101,7 @@ protected void addFilters(Configuration conf) { server.start(); serverPort = server.getWebServerPort(); } catch (Exception e) { - Assert.fail("Web server failed to start"); + Assertions.fail("Web server failed to start"); } } @@ -138,8 +138,8 @@ protected Response getResponse(Client client, URI uri) 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)); } diff --git a/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 b/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 index e54885369a706..291dc4f96bf7c 100644 --- a/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 +++ b/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.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,13 @@ public void testGetFlowRuns() throws Exception { assertNotNull(entities); assertEquals(2, entities.size()); for (FlowRunEntity entity : entities) { - assertTrue("Id, run id or start time does not match.", - ((entity.getId().equals("user1@flow_name/1002345678919")) && + 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 +525,10 @@ public void testGetFlowRuns() throws Exception { assertNotNull(entities); assertEquals(1, entities.size()); for (FlowRunEntity entity : entities) { - assertTrue("Id, run id or start time does not match.", - entity.getId().equals("user1@flow_name/1002345678920") && + 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 +542,10 @@ public void testGetFlowRuns() throws Exception { assertNotNull(entities); assertEquals(1, entities.size()); for (FlowRunEntity entity : entities) { - assertTrue("Id, run id or start time does not match.", - entity.getId().equals("user1@flow_name/1002345678920") && + 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 +559,13 @@ public void testGetFlowRuns() throws Exception { assertNotNull(entities); assertEquals(2, entities.size()); for (FlowRunEntity entity : entities) { - assertTrue("Id, run id or start time does not match.", - ((entity.getId().equals("user1@flow_name/1002345678919")) && + 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 +579,10 @@ public void testGetFlowRuns() throws Exception { assertNotNull(entities); assertEquals(1, entities.size()); for (FlowRunEntity entity : entities) { - assertTrue("Id, run id or start time does not match.", - entity.getId().equals("user1@flow_name/1002345678919") && + 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,15 +596,15 @@ public void testGetFlowRuns() throws Exception { assertNotNull(entities); assertEquals(2, entities.size()); for (FlowRunEntity entity : entities) { - assertTrue("Id, run id or start time does not match.", - ((entity.getId().equals("user1@flow_name/1002345678919")) && + assertTrue( + ((entity.getId().equals("user1@flow_name/1002345678919")) && (entity.getRunId() == 1002345678919L) && (entity.getStartTime() == 1425016501000L) && (entity.getMetrics().size() == 3)) || ((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 +1999,11 @@ public void testGetFlowRunApps() throws Exception { assertNotNull(entities); assertEquals(2, entities.size()); for (TimelineEntity entity : entities) { - assertTrue("Unexpected app in result", - (entity.getId().equals("application_1111111111_1111") && + 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 +2018,11 @@ public void testGetFlowRunApps() throws Exception { assertNotNull(entities); assertEquals(2, entities.size()); for (TimelineEntity entity : entities) { - assertTrue("Unexpected app in result", - (entity.getId().equals("application_1111111111_1111") && + 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,15 +2062,15 @@ public void testGetFlowApps() throws Exception { assertNotNull(entities); assertEquals(3, entities.size()); for (TimelineEntity entity : entities) { - assertTrue("Unexpected app in result", - (entity.getId().equals("application_1111111111_1111") && + assertTrue( + (entity.getId().equals("application_1111111111_1111") && entity.getConfigs().size() == 1 && entity.getConfigs().equals(ImmutableMap.of("cfg2", "value1"))) || (entity.getId().equals("application_1111111111_2222") && 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,15 +2100,15 @@ public void testGetFlowApps() throws Exception { assertNotNull(entities); assertEquals(3, entities.size()); for (TimelineEntity entity : entities) { - assertTrue("Unexpected app in result", - (entity.getId().equals("application_1111111111_1111") && + assertTrue( + (entity.getId().equals("application_1111111111_1111") && entity.getConfigs().size() == 1 && entity.getConfigs().equals(ImmutableMap.of("cfg2", "value1"))) || (entity.getId().equals("application_1111111111_2222") && 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 +2167,8 @@ public void testGetFlowAppsFilters() throws Exception { resp.readEntity(new GenericType>(){}); 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 +2177,8 @@ public void testGetFlowAppsFilters() throws Exception { entities = resp.readEntity(new GenericType>(){}); 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 +2187,8 @@ public void testGetFlowAppsFilters() throws Exception { entities = resp.readEntity(new GenericType>(){}); 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(); } diff --git a/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 b/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 index 0dee442264efd..59cdde5b435a4 100644 --- a/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 +++ b/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,9 @@ 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 java.io.IOException; import java.util.Arrays; @@ -76,12 +76,12 @@ 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.Assertions; +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 static void setupBeforeClass() throws Exception { 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 void testNonIntegralMetricValues() throws IOException { UserGroupInformation user = UserGroupInformation.createRemoteUser("u1"); try { hbi.write(context, teApp, user); - Assert.fail("Expected an exception as metric values are non integral"); + Assertions.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"); + Assertions.fail("Expected an exception as metric values are non integral"); } catch (IOException e) {} hbi.stop(); } finally { @@ -719,7 +719,7 @@ public void testFilterAppsByCreatedTime() throws Exception { 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, " + + Assertions.fail("Entities with ids' application_1111111111_2222, " + "application_1111111111_3333 and application_1111111111_4444" + " should be present"); } @@ -735,7 +735,7 @@ public void testFilterAppsByCreatedTime() throws Exception { 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" + + Assertions.fail("Apps with ids' application_1111111111_3333 and" + " application_1111111111_4444 should be present"); } } @@ -749,7 +749,7 @@ public void testFilterAppsByCreatedTime() throws Exception { assertEquals(1, entities.size()); for (TimelineEntity entity : entities) { if (!entity.getId().equals("application_1111111111_2222")) { - Assert.fail("App with id application_1111111111_2222 should" + + Assertions.fail("App with id application_1111111111_2222 should" + " be present"); } } @@ -836,7 +836,7 @@ public void testReadAppsIsRelatedTo() throws Exception { 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" + Assertions.fail("Entity ids' should have been application_1111111111_2222" + " and application_1111111111_3333"); } } @@ -860,7 +860,7 @@ public void testReadAppsIsRelatedTo() throws Exception { 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"); + Assertions.fail("Entity id should have been application_1111111111_4444"); } } assertEquals(0, isRelatedToCnt); @@ -884,7 +884,7 @@ public void testReadAppsIsRelatedTo() throws Exception { 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" + Assertions.fail("Entity ids' should have been application_1111111111_2222" + " and application_1111111111_3333"); } } @@ -905,7 +905,7 @@ public void testReadAppsIsRelatedTo() throws Exception { 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"); + Assertions.fail("Entity id should have been application_1111111111_3333"); } } assertEquals(0, isRelatedToCnt); @@ -960,7 +960,7 @@ public void testReadAppsIsRelatedTo() throws Exception { 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"); + Assertions.fail("Entity id should have been application_1111111111_3333"); } } assertEquals(0, isRelatedToCnt); @@ -989,7 +989,7 @@ public void testReadAppsRelatesTo() throws Exception { 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" + Assertions.fail("Entity ids' should have been application_1111111111_2222" + " and application_1111111111_4444"); } } @@ -1013,7 +1013,7 @@ public void testReadAppsRelatesTo() throws Exception { 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"); + Assertions.fail("Entity id should have been application_1111111111_3333"); } } assertEquals(0, relatesToCnt); @@ -1037,7 +1037,7 @@ public void testReadAppsRelatesTo() throws Exception { 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" + Assertions.fail("Entity ids' should have been application_1111111111_2222" + " and application_1111111111_4444"); } } @@ -1058,7 +1058,7 @@ public void testReadAppsRelatesTo() throws Exception { 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"); + Assertions.fail("Entity id should have been application_1111111111_2222"); } } assertEquals(0, relatesToCnt); @@ -1113,7 +1113,7 @@ public void testReadAppsRelatesTo() throws Exception { 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"); + Assertions.fail("Entity id should have been application_1111111111_2222"); } } assertEquals(0, relatesToCnt); @@ -1149,7 +1149,7 @@ public void testReadAppsRelatesTo() throws Exception { 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"); + Assertions.fail("Entity id should have been application_1111111111_3333"); } } assertEquals(0, relatesToCnt); @@ -1191,7 +1191,7 @@ public void testReadAppsRelationsAndEventFiltersDefaultView() 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"); + Assertions.fail("Entity id should have been application_1111111111_4444"); } } assertEquals(0, eventCnt); @@ -1335,7 +1335,7 @@ public void testReadAppsEventFilters() throws Exception { 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"); + Assertions.fail("Entity id should have been application_1111111111_4444"); } } assertEquals(1, eventCnt); @@ -1356,7 +1356,7 @@ public void testReadAppsEventFilters() throws Exception { 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"); + Assertions.fail("Entity id should have been application_1111111111_4444"); } } assertEquals(0, eventCnt); @@ -1376,7 +1376,7 @@ public void testReadAppsEventFilters() throws Exception { 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" + Assertions.fail("Entity ids' should have been application_1111111111_2222" + " and application_1111111111_4444"); } } @@ -1415,7 +1415,7 @@ public void testReadAppsEventFilters() throws Exception { 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"); + Assertions.fail("Entity id should have been application_1111111111_2222"); } } assertEquals(0, eventCnt); @@ -1436,7 +1436,7 @@ public void testReadAppsEventFilters() throws Exception { 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"); + Assertions.fail("Entity id should have been application_1111111111_2222"); } } assertEquals(0, eventCnt); @@ -1464,8 +1464,8 @@ public void testReadAppsConfigPrefix() throws Exception { 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 void testReadAppsConfigFilterPrefix() throws Exception { 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 void testReadAppsConfigFilterPrefix() throws Exception { 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 void testReadAppsMetricPrefix() throws Exception { 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 void testReadAppsMetricFilterPrefix() throws Exception { 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 void testReadAppsMetricFilterPrefix() throws Exception { 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 void testReadAppsInfoFilters() throws Exception { assertEquals(3, entities.size()); } - @AfterClass + @AfterAll public static void tearDownAfterClass() throws Exception { if (util != null) { util.shutdownMiniCluster(); diff --git a/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 b/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 index 1f59088435e5b..ed00242d8647e 100644 --- a/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 +++ b/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.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 void testDomainIdTable() throws Exception { assertEquals("writer1,writer2", writers); } - @AfterClass + @AfterAll public static void tearDownAfterClass() throws Exception { if (util != null) { util.shutdownMiniCluster(); diff --git a/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 b/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 index 116285c23fa5b..689d165686820 100644 --- a/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 +++ b/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,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.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 java.io.IOException; import java.util.Arrays; @@ -81,12 +81,13 @@ 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.Assertions; +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 static void setupBeforeClass() throws Exception { 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 void testFilterEntitiesByCreatedTime() throws Exception { 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" + + Assertions.fail("Entities with ids' hello, hello1 and hello2 should be" + " present"); } } @@ -736,7 +737,7 @@ public void testFilterEntitiesByCreatedTime() throws Exception { for (TimelineEntity entity : entities) { if (!entity.getId().equals("hello1") && !entity.getId().equals("hello2")) { - Assert.fail("Entities with ids' hello1 and hello2 should be present"); + Assertions.fail("Entities with ids' hello1 and hello2 should be present"); } } entities = reader.getEntities( @@ -748,7 +749,7 @@ public void testFilterEntitiesByCreatedTime() throws Exception { assertEquals(1, entities.size()); for (TimelineEntity entity : entities) { if (!entity.getId().equals("hello")) { - Assert.fail("Entity with id hello should be present"); + Assertions.fail("Entity with id hello should be present"); } } } @@ -788,7 +789,7 @@ public void testReadEntitiesRelationsAndEventFiltersDefaultView() isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size(); relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("hello2")) { - Assert.fail("Entity id should have been hello2"); + Assertions.fail("Entity id should have been hello2"); } } assertEquals(0, eventCnt); @@ -814,7 +815,7 @@ public void testReadEntitiesEventFilters() throws Exception { for (TimelineEntity timelineEntity : entities) { eventCnt += timelineEntity.getEvents().size(); if (!timelineEntity.getId().equals("hello2")) { - Assert.fail("Entity id should have been hello2"); + Assertions.fail("Entity id should have been hello2"); } } assertEquals(1, eventCnt); @@ -834,7 +835,7 @@ public void testReadEntitiesEventFilters() throws Exception { for (TimelineEntity timelineEntity : entities) { eventCnt += timelineEntity.getEvents().size(); if (!timelineEntity.getId().equals("hello2")) { - Assert.fail("Entity id should have been hello2"); + Assertions.fail("Entity id should have been hello2"); } } assertEquals(0, eventCnt); @@ -853,7 +854,7 @@ public void testReadEntitiesEventFilters() throws Exception { eventCnt += timelineEntity.getEvents().size(); if (!timelineEntity.getId().equals("hello") && !timelineEntity.getId().equals("hello2")) { - Assert.fail("Entity ids' should have been hello and hello2"); + Assertions.fail("Entity ids' should have been hello and hello2"); } } assertEquals(0, eventCnt); @@ -889,7 +890,7 @@ public void testReadEntitiesEventFilters() throws Exception { for (TimelineEntity timelineEntity : entities) { eventCnt += timelineEntity.getEvents().size(); if (!timelineEntity.getId().equals("hello")) { - Assert.fail("Entity id should have been hello"); + Assertions.fail("Entity id should have been hello"); } } assertEquals(0, eventCnt); @@ -909,7 +910,7 @@ public void testReadEntitiesEventFilters() throws Exception { for (TimelineEntity timelineEntity : entities) { eventCnt += timelineEntity.getEvents().size(); if (!timelineEntity.getId().equals("hello")) { - Assert.fail("Entity id should have been hello"); + Assertions.fail("Entity id should have been hello"); } } assertEquals(0, eventCnt); @@ -936,7 +937,7 @@ public void testReadEntitiesIsRelatedTo() throws Exception { isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size(); if (!timelineEntity.getId().equals("hello") && !timelineEntity.getId().equals("hello1")) { - Assert.fail("Entity ids' should have been hello and hello1"); + Assertions.fail("Entity ids' should have been hello and hello1"); } } assertEquals(3, isRelatedToCnt); @@ -958,7 +959,7 @@ public void testReadEntitiesIsRelatedTo() throws Exception { for (TimelineEntity timelineEntity : entities) { isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size(); if (!timelineEntity.getId().equals("hello2")) { - Assert.fail("Entity id should have been hello2"); + Assertions.fail("Entity id should have been hello2"); } } assertEquals(0, isRelatedToCnt); @@ -981,7 +982,7 @@ public void testReadEntitiesIsRelatedTo() throws Exception { isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size(); if (!timelineEntity.getId().equals("hello") && !timelineEntity.getId().equals("hello1")) { - Assert.fail("Entity ids' should have been hello and hello1"); + Assertions.fail("Entity ids' should have been hello and hello1"); } } assertEquals(0, isRelatedToCnt); @@ -1000,7 +1001,7 @@ public void testReadEntitiesIsRelatedTo() throws Exception { for (TimelineEntity timelineEntity : entities) { isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size(); if (!timelineEntity.getId().equals("hello1")) { - Assert.fail("Entity id should have been hello1"); + Assertions.fail("Entity id should have been hello1"); } } assertEquals(0, isRelatedToCnt); @@ -1052,7 +1053,7 @@ public void testReadEntitiesIsRelatedTo() throws Exception { for (TimelineEntity timelineEntity : entities) { isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size(); if (!timelineEntity.getId().equals("hello1")) { - Assert.fail("Entity id should have been hello1"); + Assertions.fail("Entity id should have been hello1"); } } assertEquals(0, isRelatedToCnt); @@ -1079,7 +1080,7 @@ public void testReadEntitiesRelatesTo() throws Exception { relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("hello") && !timelineEntity.getId().equals("hello2")) { - Assert.fail("Entity ids' should have been hello and hello2"); + Assertions.fail("Entity ids' should have been hello and hello2"); } } assertEquals(3, relatesToCnt); @@ -1101,7 +1102,7 @@ public void testReadEntitiesRelatesTo() throws Exception { for (TimelineEntity timelineEntity : entities) { relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("hello1")) { - Assert.fail("Entity id should have been hello1"); + Assertions.fail("Entity id should have been hello1"); } } assertEquals(0, relatesToCnt); @@ -1124,7 +1125,7 @@ public void testReadEntitiesRelatesTo() throws Exception { relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("hello") && !timelineEntity.getId().equals("hello2")) { - Assert.fail("Entity ids' should have been hello and hello2"); + Assertions.fail("Entity ids' should have been hello and hello2"); } } assertEquals(0, relatesToCnt); @@ -1143,7 +1144,7 @@ public void testReadEntitiesRelatesTo() throws Exception { for (TimelineEntity timelineEntity : entities) { relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("hello")) { - Assert.fail("Entity id should have been hello"); + Assertions.fail("Entity id should have been hello"); } } assertEquals(0, relatesToCnt); @@ -1195,7 +1196,7 @@ public void testReadEntitiesRelatesTo() throws Exception { for (TimelineEntity timelineEntity : entities) { relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("hello")) { - Assert.fail("Entity id should have been hello"); + Assertions.fail("Entity id should have been hello"); } } assertEquals(0, relatesToCnt); @@ -1230,7 +1231,7 @@ public void testReadEntitiesRelatesTo() throws Exception { for (TimelineEntity timelineEntity : entities) { relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("hello1")) { - Assert.fail("Entity id should have been hello1"); + Assertions.fail("Entity id should have been hello1"); } } assertEquals(0, relatesToCnt); @@ -1311,8 +1312,8 @@ public void testReadEntitiesConfigPrefix() throws Exception { 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 +1448,8 @@ public void testReadEntitiesConfigFilterPrefix() throws Exception { 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 +1480,8 @@ public void testReadEntitiesConfigFilterPrefix() throws Exception { 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 +1507,8 @@ public void testReadEntitiesMetricPrefix() throws Exception { 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 +1700,8 @@ public void testReadEntitiesMetricFilterPrefix() throws Exception { 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 +1732,8 @@ public void testReadEntitiesMetricFilterPrefix() throws Exception { 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 +1752,8 @@ public void testReadEntitiesMetricFilterPrefix() throws Exception { 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 +1855,8 @@ public void testReadEntitiesInfoFilters() throws Exception { assertEquals(3, entities.size()); } - @Test(timeout = 90000) + @Test + @Timeout(value = 90) public void testListTypesInApp() throws Exception { Set types = reader.getEntityTypes( new TimelineReaderContext("cluster1", "user1", "some_flow_name", @@ -1877,7 +1879,7 @@ public void testListTypesInApp() throws Exception { assertEquals(0, types.size()); } - @AfterClass + @AfterAll public static void tearDownAfterClass() throws Exception { if (util != null) { util.shutdownMiniCluster(); diff --git a/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 b/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 index 950ce62be59c0..3880ba266ef22 100644 --- a/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 +++ b/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 @@ 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 void createWithSetPrefix() throws IOException { .unset(YarnConfiguration.TIMELINE_SERVICE_HBASE_SCHEMA_PREFIX_NAME); } - @AfterClass + @AfterAll public static void tearDownAfterClass() throws Exception { if (util != null) { util.shutdownMiniCluster(); diff --git a/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 b/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 index 7d7e6b24498d2..1e8594ae1a1c5 100644 --- a/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 +++ b/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,9 @@ 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.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import java.io.IOException; import java.util.Set; @@ -41,7 +42,8 @@ public class TestTimelineReaderHBaseDown { - @Test(timeout=300000) + @Test + @Timeout(value = 300) public void testTimelineReaderHBaseUp() throws Exception { HBaseTestingUtility util = new HBaseTestingUtility(); configure(util); @@ -60,7 +62,8 @@ public void testTimelineReaderHBaseUp() throws Exception { } } - @Test(timeout=300000) + @Test + @Timeout(value = 300) public void testTimelineReaderInitWhenHBaseIsDown() throws TimeoutException, InterruptedException { HBaseTestingUtility util = new HBaseTestingUtility(); @@ -74,7 +77,8 @@ public void testTimelineReaderInitWhenHBaseIsDown() throws waitForHBaseDown(htr); } - @Test(timeout=300000) + @Test + @Timeout(value = 300) public void testTimelineReaderDetectsHBaseDown() throws Exception { HBaseTestingUtility util = new HBaseTestingUtility(); configure(util); @@ -101,7 +105,8 @@ public void testTimelineReaderDetectsHBaseDown() throws Exception { } } - @Test(timeout=300000) + @Test + @Timeout(value = 300) public void testTimelineReaderDetectsZooKeeperDown() throws Exception { HBaseTestingUtility util = new HBaseTestingUtility(); configure(util); @@ -128,7 +133,8 @@ public void testTimelineReaderDetectsZooKeeperDown() throws Exception { } } - @Test(timeout=300000) + @Test + @Timeout(value = 300) public void testTimelineReaderRecoversAfterHBaseReturns() throws Exception { HBaseTestingUtility util = new HBaseTestingUtility(); configure(util); @@ -177,9 +183,9 @@ private static void waitForHBaseDown(HBaseTimelineReaderImpl htr) throws } }, 1000, 150000); checkQuery(htr); - Assert.fail("Query should fail when HBase is down"); + Assertions.fail("Query should fail when HBase is down"); } catch (IOException e) { - Assert.assertEquals("HBase is down", e.getMessage()); + Assertions.assertEquals("HBase is down", e.getMessage()); } } diff --git a/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 b/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 index 5d658b96c5b1c..59c03e71a24dd 100644 --- a/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 +++ b/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,9 @@ 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.junit.jupiter.api.Assertions; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseTestingUtility; @@ -31,14 +32,15 @@ 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; /** * 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 void testTimelineWriterHBaseDown() throws Exception { try { storageMonitor.checkStorageIsUp(); } catch(IOException e) { - Assert.fail("HBaseStorageMonitor failed to detect HBase Up"); + Assertions.fail("HBaseStorageMonitor failed to detect HBase Up"); } util.shutdownMiniHBaseCluster(); @@ -82,8 +84,8 @@ public void testTimelineWriterHBaseDown() throws Exception { exceptionCaught = true; } } - assertTrue("HBaseStorageMonitor failed to detect HBase Down", - exceptionCaught); + assertTrue( + exceptionCaught, "HBaseStorageMonitor failed to detect HBase Down"); } finally { writer.stop(); util.shutdownMiniCluster(); diff --git a/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 b/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 index 31434633b4a57..9c5f27d83f7c0 100644 --- a/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 +++ b/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.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 @@ private void checkFlowActivityRunId(long runid, String flowVersion, } } - @AfterClass + @AfterAll public static void tearDownAfterClass() throws Exception { if (util != null) { util.shutdownMiniCluster(); diff --git a/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 b/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 index f34a6dcacf43b..eba05cd9f2cb6 100644 --- a/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 +++ b/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.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 void testMetricFilters() throws Exception { } } - @AfterClass + @AfterAll public static void tearDownAfterClass() throws Exception { if (util != null) { util.shutdownMiniCluster(); diff --git a/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 b/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 index 475cb7a306ffd..309fa66dc2f94 100644 --- a/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 +++ b/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,10 @@ 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.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.util.ArrayList; @@ -59,10 +59,10 @@ 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.Assertions; +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 void testWriteFlowRunCompaction() throws Exception { // 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 void checkProcessSummationMoreCellsSumFinal2() assertTrue(returnTs >= currentTimestamp); } else { // raise a failure since we expect only these two values back - Assert.fail(); + Assertions.fail(); } } } @@ -576,7 +576,7 @@ public void checkProcessSummationMoreCellsSumFinalMany() throws IOException { assertTrue(returnTs <= cellTsNotFinalStart * count); } else { // raise a failure since we expect only these values back - Assert.fail(); + Assertions.fail(); } } } @@ -691,7 +691,7 @@ public void checkProcessSummationMoreCellsSumFinalVariedTags() assertTrue(returnTs <= cellTsFinalStartNotExpire + countFinalNotExpire); } else { // raise a failure since we expect only these values back - Assert.fail(); + Assertions.fail(); } } } @@ -755,7 +755,7 @@ public void testProcessSummationMoreCellsSumFinal() throws IOException { assertTrue(returnTs != inputTs1); } else { // raise a failure since we expect only these two values back - Assert.fail(); + Assertions.fail(); } } @@ -850,7 +850,7 @@ public void testProcessSummationEmpty() throws IOException { assertEquals(0, cells.size()); } - @AfterClass + @AfterAll public static void tearDownAfterClass() throws Exception { if (util != null) { util.shutdownMiniCluster(); From df8e854155a9d81ad6886e32081346c3804e50be Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Wed, 26 Mar 2025 13:35:35 +0800 Subject: [PATCH 2/3] YARN-11266. Fix CheckStyle. --- .../AbstractTimelineReaderHBaseTestBase.java | 4 +- ...TimelineReaderWebServicesHBaseStorage.java | 59 ++++++++++------ .../storage/TestHBaseTimelineStorageApps.java | 70 +++++++++---------- .../TestHBaseTimelineStorageEntities.java | 42 +++++------ .../storage/TestTimelineReaderHBaseDown.java | 7 +- .../storage/TestTimelineWriterHBaseDown.java | 4 +- .../TestHBaseStorageFlowRunCompaction.java | 12 ++-- 7 files changed, 106 insertions(+), 92 deletions(-) diff --git a/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 b/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 index 6950f3c474983..227d4a73f7e18 100644 --- a/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 +++ b/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 @@ -21,6 +21,7 @@ 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.server.timelineservice.storage.DataGeneratorForTest; import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.client.HttpUrlConnectorProvider; -import org.junit.jupiter.api.Assertions; /** * Test Base for TimelineReaderServer HBase tests. @@ -101,7 +101,7 @@ protected void addFilters(Configuration conf) { server.start(); serverPort = server.getWebServerPort(); } catch (Exception e) { - Assertions.fail("Web server failed to start"); + fail("Web server failed to start"); } } diff --git a/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 b/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 index 291dc4f96bf7c..6b189256d3675 100644 --- a/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 +++ b/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 @@ -506,12 +506,13 @@ public void testGetFlowRuns() throws Exception { assertEquals(2, entities.size()); for (FlowRunEntity entity : entities) { assertTrue( - ((entity.getId().equals("user1@flow_name/1002345678919")) && + ((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)), "Id, run id or start time does not match."); + (entity.getStartTime() == 1425016501034L)), + "Id, run id or start time does not match."); assertEquals(0, entity.getMetrics().size()); } @@ -526,9 +527,10 @@ public void testGetFlowRuns() throws Exception { assertEquals(1, entities.size()); for (FlowRunEntity entity : entities) { assertTrue( - entity.getId().equals("user1@flow_name/1002345678920") && + entity.getId().equals("user1@flow_name/1002345678920") && entity.getRunId() == 1002345678920L && - entity.getStartTime() == 1425016501034L, "Id, run id or start time does not match."); + entity.getStartTime() == 1425016501034L, + "Id, run id or start time does not match."); assertEquals(0, entity.getMetrics().size()); } @@ -543,9 +545,10 @@ public void testGetFlowRuns() throws Exception { assertEquals(1, entities.size()); for (FlowRunEntity entity : entities) { assertTrue( - entity.getId().equals("user1@flow_name/1002345678920") && + entity.getId().equals("user1@flow_name/1002345678920") && entity.getRunId() == 1002345678920L && - entity.getStartTime() == 1425016501034L, "Id, run id or start time does not match."); + entity.getStartTime() == 1425016501034L, + "Id, run id or start time does not match."); assertEquals(0, entity.getMetrics().size()); } @@ -560,12 +563,13 @@ public void testGetFlowRuns() throws Exception { assertEquals(2, entities.size()); for (FlowRunEntity entity : entities) { assertTrue( - ((entity.getId().equals("user1@flow_name/1002345678919")) && + ((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)), "Id, run id or start time does not match."); + (entity.getStartTime() == 1425016501034L)), + "Id, run id or start time does not match."); assertEquals(0, entity.getMetrics().size()); } @@ -580,9 +584,10 @@ public void testGetFlowRuns() throws Exception { assertEquals(1, entities.size()); for (FlowRunEntity entity : entities) { assertTrue( - entity.getId().equals("user1@flow_name/1002345678919") && + entity.getId().equals("user1@flow_name/1002345678919") && entity.getRunId() == 1002345678919L && - entity.getStartTime() == 1425016501000L, "Id, run id or start time does not match."); + entity.getStartTime() == 1425016501000L, + "Id, run id or start time does not match."); assertEquals(0, entity.getMetrics().size()); } @@ -597,14 +602,15 @@ public void testGetFlowRuns() throws Exception { assertEquals(2, entities.size()); for (FlowRunEntity entity : entities) { assertTrue( - ((entity.getId().equals("user1@flow_name/1002345678919")) && + ((entity.getId().equals("user1@flow_name/1002345678919")) && (entity.getRunId() == 1002345678919L) && (entity.getStartTime() == 1425016501000L) && (entity.getMetrics().size() == 3)) || ((entity.getId().equals("user1@flow_name/1002345678920")) && (entity.getRunId() == 1002345678920L) && (entity.getStartTime() == 1425016501034L) && - (entity.getMetrics().size() == 1)), "Id, run id or start time does not match."); + (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 @@ -2000,10 +2006,11 @@ public void testGetFlowRunApps() throws Exception { assertEquals(2, entities.size()); for (TimelineEntity entity : entities) { assertTrue( - (entity.getId().equals("application_1111111111_1111") && + (entity.getId().equals("application_1111111111_1111") && entity.getMetrics().size() == 3) || (entity.getId().equals("application_1111111111_2222") && - entity.getMetrics().size() == 1), "Unexpected app in result"); + 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()); @@ -2019,10 +2026,11 @@ public void testGetFlowRunApps() throws Exception { assertEquals(2, entities.size()); for (TimelineEntity entity : entities) { assertTrue( - (entity.getId().equals("application_1111111111_1111") && + (entity.getId().equals("application_1111111111_1111") && entity.getMetrics().size() == 3) || (entity.getId().equals("application_1111111111_2222") && - entity.getMetrics().size() == 1), "Unexpected app in result"); + 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()); @@ -2063,14 +2071,15 @@ public void testGetFlowApps() throws Exception { assertEquals(3, entities.size()); for (TimelineEntity entity : entities) { assertTrue( - (entity.getId().equals("application_1111111111_1111") && + (entity.getId().equals("application_1111111111_1111") && entity.getConfigs().size() == 1 && entity.getConfigs().equals(ImmutableMap.of("cfg2", "value1"))) || (entity.getId().equals("application_1111111111_2222") && entity.getConfigs().size() == 1 && entity.getConfigs().equals(ImmutableMap.of("cfg1", "value1"))) || (entity.getId().equals("application_1111111111_2224") && - entity.getConfigs().size() == 0), "Unexpected app in result"); + 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, @@ -2101,14 +2110,15 @@ public void testGetFlowApps() throws Exception { assertEquals(3, entities.size()); for (TimelineEntity entity : entities) { assertTrue( - (entity.getId().equals("application_1111111111_1111") && + (entity.getId().equals("application_1111111111_1111") && entity.getConfigs().size() == 1 && entity.getConfigs().equals(ImmutableMap.of("cfg2", "value1"))) || (entity.getId().equals("application_1111111111_2222") && entity.getConfigs().size() == 1 && entity.getConfigs().equals(ImmutableMap.of("cfg1", "value1"))) || (entity.getId().equals("application_1111111111_2224") && - entity.getConfigs().size() == 0), "Unexpected app in result"); + 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, @@ -2168,7 +2178,8 @@ public void testGetFlowAppsFilters() throws Exception { assertNotNull(entities); assertEquals(1, entities.size()); assertTrue(entities.contains( - newEntity(entityType, "application_1111111111_1111")), "Unexpected app in result"); + 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?" + @@ -2178,7 +2189,8 @@ public void testGetFlowAppsFilters() throws Exception { assertNotNull(entities); assertEquals(1, entities.size()); assertTrue(entities.contains( - newEntity(entityType, "application_1111111111_1111")), "Unexpected app in result"); + 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?" + @@ -2188,7 +2200,8 @@ public void testGetFlowAppsFilters() throws Exception { assertNotNull(entities); assertEquals(1, entities.size()); assertTrue(entities.contains( - newEntity(entityType, "application_1111111111_2222")), "Unexpected app in result"); + newEntity(entityType, "application_1111111111_2222")), + "Unexpected app in result"); } finally { client.close(); } diff --git a/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 b/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 index 59cdde5b435a4..1545ccdef0f2d 100644 --- a/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 +++ b/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 @@ -21,6 +21,7 @@ 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; @@ -78,7 +79,6 @@ import org.apache.hadoop.yarn.server.timelineservice.storage.common.StringKeyConverter; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -641,13 +641,13 @@ public void testNonIntegralMetricValues() throws IOException { UserGroupInformation user = UserGroupInformation.createRemoteUser("u1"); try { hbi.write(context, teApp, user); - Assertions.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); - Assertions.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 void testFilterAppsByCreatedTime() throws Exception { if (!entity.getId().equals("application_1111111111_2222") && !entity.getId().equals("application_1111111111_3333") && !entity.getId().equals("application_1111111111_4444")) { - Assertions.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 void testFilterAppsByCreatedTime() throws Exception { for (TimelineEntity entity : entities) { if (!entity.getId().equals("application_1111111111_3333") && !entity.getId().equals("application_1111111111_4444")) { - Assertions.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 void testFilterAppsByCreatedTime() throws Exception { assertEquals(1, entities.size()); for (TimelineEntity entity : entities) { if (!entity.getId().equals("application_1111111111_2222")) { - Assertions.fail("App with id application_1111111111_2222 should" + + fail("App with id application_1111111111_2222 should" + " be present"); } } @@ -836,7 +836,7 @@ public void testReadAppsIsRelatedTo() throws Exception { isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size(); if (!timelineEntity.getId().equals("application_1111111111_2222") && !timelineEntity.getId().equals("application_1111111111_3333")) { - Assertions.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 void testReadAppsIsRelatedTo() throws Exception { for (TimelineEntity timelineEntity : entities) { isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size(); if (!timelineEntity.getId().equals("application_1111111111_4444")) { - Assertions.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 void testReadAppsIsRelatedTo() throws Exception { isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size(); if (!timelineEntity.getId().equals("application_1111111111_2222") && !timelineEntity.getId().equals("application_1111111111_3333")) { - Assertions.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 void testReadAppsIsRelatedTo() throws Exception { for (TimelineEntity timelineEntity : entities) { isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size(); if (!timelineEntity.getId().equals("application_1111111111_3333")) { - Assertions.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 void testReadAppsIsRelatedTo() throws Exception { for (TimelineEntity timelineEntity : entities) { isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size(); if (!timelineEntity.getId().equals("application_1111111111_3333")) { - Assertions.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 void testReadAppsRelatesTo() throws Exception { relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("application_1111111111_2222") && !timelineEntity.getId().equals("application_1111111111_4444")) { - Assertions.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 void testReadAppsRelatesTo() throws Exception { for (TimelineEntity timelineEntity : entities) { relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("application_1111111111_3333")) { - Assertions.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 void testReadAppsRelatesTo() throws Exception { relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("application_1111111111_2222") && !timelineEntity.getId().equals("application_1111111111_4444")) { - Assertions.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 void testReadAppsRelatesTo() throws Exception { for (TimelineEntity timelineEntity : entities) { relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("application_1111111111_2222")) { - Assertions.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 void testReadAppsRelatesTo() throws Exception { for (TimelineEntity timelineEntity : entities) { relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("application_1111111111_2222")) { - Assertions.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 void testReadAppsRelatesTo() throws Exception { for (TimelineEntity timelineEntity : entities) { relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("application_1111111111_3333")) { - Assertions.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 void testReadAppsRelationsAndEventFiltersDefaultView() isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size(); relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("application_1111111111_4444")) { - Assertions.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 void testReadAppsEventFilters() throws Exception { for (TimelineEntity timelineEntity : entities) { eventCnt += timelineEntity.getEvents().size(); if (!timelineEntity.getId().equals("application_1111111111_4444")) { - Assertions.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 void testReadAppsEventFilters() throws Exception { for (TimelineEntity timelineEntity : entities) { eventCnt += timelineEntity.getEvents().size(); if (!timelineEntity.getId().equals("application_1111111111_4444")) { - Assertions.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 void testReadAppsEventFilters() throws Exception { eventCnt += timelineEntity.getEvents().size(); if (!timelineEntity.getId().equals("application_1111111111_2222") && !timelineEntity.getId().equals("application_1111111111_4444")) { - Assertions.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 void testReadAppsEventFilters() throws Exception { for (TimelineEntity timelineEntity : entities) { eventCnt += timelineEntity.getEvents().size(); if (!timelineEntity.getId().equals("application_1111111111_2222")) { - Assertions.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 void testReadAppsEventFilters() throws Exception { for (TimelineEntity timelineEntity : entities) { eventCnt += timelineEntity.getEvents().size(); if (!timelineEntity.getId().equals("application_1111111111_2222")) { - Assertions.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 void testReadAppsConfigPrefix() throws Exception { for (TimelineEntity entity : es1) { cfgCnt += entity.getConfigs().size(); for (String confKey : entity.getConfigs().keySet()) { - assertTrue( - confKey.startsWith("cfg_"), "Config key returned should start with cfg_"); + assertTrue(confKey.startsWith("cfg_"), + "Config key returned should start with cfg_"); } } assertEquals(3, cfgCnt); @@ -1491,8 +1491,8 @@ public void testReadAppsConfigFilterPrefix() throws Exception { for (TimelineEntity entity : entities) { cfgCnt += entity.getConfigs().size(); for (String confKey : entity.getConfigs().keySet()) { - assertTrue( - confKey.startsWith("cfg_"), "Config key returned should start with cfg_"); + assertTrue(confKey.startsWith("cfg_"), + "Config key returned should start with cfg_"); } } assertEquals(2, cfgCnt); @@ -1525,8 +1525,8 @@ public void testReadAppsConfigFilterPrefix() throws Exception { for (TimelineEntity entity : entities) { cfgCnt += entity.getConfigs().size(); for (String confKey : entity.getConfigs().keySet()) { - assertTrue( - confKey.startsWith("config_"), "Config key returned should start with config_"); + assertTrue(confKey.startsWith("config_"), + "Config key returned should start with config_"); } } assertEquals(2, cfgCnt); @@ -1671,8 +1671,8 @@ public void testReadAppsMetricPrefix() throws Exception { for (TimelineEntity entity : es1) { metricCnt += entity.getMetrics().size(); for (TimelineMetric metric : entity.getMetrics()) { - assertTrue( - metric.getId().startsWith("MAP1_"), "Metric Id returned should start with MAP1_"); + assertTrue(metric.getId().startsWith("MAP1_"), + "Metric Id returned should start with MAP1_"); } } assertEquals(2, metricCnt); @@ -1725,8 +1725,8 @@ public void testReadAppsMetricFilterPrefix() throws Exception { for (TimelineEntity entity : entities) { metricCnt += entity.getMetrics().size(); for (TimelineMetric metric : entity.getMetrics()) { - assertTrue( - metric.getId().startsWith("MAP1_"), "Metric Id returned should start with MAP1_"); + assertTrue(metric.getId().startsWith("MAP1_"), + "Metric Id returned should start with MAP1_"); } } assertEquals(2, metricCnt); @@ -1745,8 +1745,8 @@ public void testReadAppsMetricFilterPrefix() throws Exception { metricCnt += entity.getMetrics().size(); for (TimelineMetric metric : entity.getMetrics()) { metricValCnt += metric.getValues().size(); - assertTrue( - metric.getId().startsWith("MAP1_"), "Metric Id returned should start with MAP1_"); + assertTrue(metric.getId().startsWith("MAP1_"), + "Metric Id returned should start with MAP1_"); } } assertEquals(2, metricCnt); diff --git a/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 b/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 index 689d165686820..46a7891eda87b 100644 --- a/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 +++ b/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 @@ -22,6 +22,7 @@ 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; @@ -83,7 +84,6 @@ import org.apache.hadoop.yarn.server.timelineservice.storage.subapplication.SubApplicationTableRW; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -723,7 +723,7 @@ public void testFilterEntitiesByCreatedTime() throws Exception { for (TimelineEntity entity : entities) { if (!entity.getId().equals("hello") && !entity.getId().equals("hello1") && !entity.getId().equals("hello2")) { - Assertions.fail("Entities with ids' hello, hello1 and hello2 should be" + + fail("Entities with ids' hello, hello1 and hello2 should be" + " present"); } } @@ -737,7 +737,7 @@ public void testFilterEntitiesByCreatedTime() throws Exception { for (TimelineEntity entity : entities) { if (!entity.getId().equals("hello1") && !entity.getId().equals("hello2")) { - Assertions.fail("Entities with ids' hello1 and hello2 should be present"); + fail("Entities with ids' hello1 and hello2 should be present"); } } entities = reader.getEntities( @@ -749,7 +749,7 @@ public void testFilterEntitiesByCreatedTime() throws Exception { assertEquals(1, entities.size()); for (TimelineEntity entity : entities) { if (!entity.getId().equals("hello")) { - Assertions.fail("Entity with id hello should be present"); + fail("Entity with id hello should be present"); } } } @@ -789,7 +789,7 @@ public void testReadEntitiesRelationsAndEventFiltersDefaultView() isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size(); relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("hello2")) { - Assertions.fail("Entity id should have been hello2"); + fail("Entity id should have been hello2"); } } assertEquals(0, eventCnt); @@ -815,7 +815,7 @@ public void testReadEntitiesEventFilters() throws Exception { for (TimelineEntity timelineEntity : entities) { eventCnt += timelineEntity.getEvents().size(); if (!timelineEntity.getId().equals("hello2")) { - Assertions.fail("Entity id should have been hello2"); + fail("Entity id should have been hello2"); } } assertEquals(1, eventCnt); @@ -835,7 +835,7 @@ public void testReadEntitiesEventFilters() throws Exception { for (TimelineEntity timelineEntity : entities) { eventCnt += timelineEntity.getEvents().size(); if (!timelineEntity.getId().equals("hello2")) { - Assertions.fail("Entity id should have been hello2"); + fail("Entity id should have been hello2"); } } assertEquals(0, eventCnt); @@ -854,7 +854,7 @@ public void testReadEntitiesEventFilters() throws Exception { eventCnt += timelineEntity.getEvents().size(); if (!timelineEntity.getId().equals("hello") && !timelineEntity.getId().equals("hello2")) { - Assertions.fail("Entity ids' should have been hello and hello2"); + fail("Entity ids' should have been hello and hello2"); } } assertEquals(0, eventCnt); @@ -890,7 +890,7 @@ public void testReadEntitiesEventFilters() throws Exception { for (TimelineEntity timelineEntity : entities) { eventCnt += timelineEntity.getEvents().size(); if (!timelineEntity.getId().equals("hello")) { - Assertions.fail("Entity id should have been hello"); + fail("Entity id should have been hello"); } } assertEquals(0, eventCnt); @@ -910,7 +910,7 @@ public void testReadEntitiesEventFilters() throws Exception { for (TimelineEntity timelineEntity : entities) { eventCnt += timelineEntity.getEvents().size(); if (!timelineEntity.getId().equals("hello")) { - Assertions.fail("Entity id should have been hello"); + fail("Entity id should have been hello"); } } assertEquals(0, eventCnt); @@ -937,7 +937,7 @@ public void testReadEntitiesIsRelatedTo() throws Exception { isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size(); if (!timelineEntity.getId().equals("hello") && !timelineEntity.getId().equals("hello1")) { - Assertions.fail("Entity ids' should have been hello and hello1"); + fail("Entity ids' should have been hello and hello1"); } } assertEquals(3, isRelatedToCnt); @@ -959,7 +959,7 @@ public void testReadEntitiesIsRelatedTo() throws Exception { for (TimelineEntity timelineEntity : entities) { isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size(); if (!timelineEntity.getId().equals("hello2")) { - Assertions.fail("Entity id should have been hello2"); + fail("Entity id should have been hello2"); } } assertEquals(0, isRelatedToCnt); @@ -982,7 +982,7 @@ public void testReadEntitiesIsRelatedTo() throws Exception { isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size(); if (!timelineEntity.getId().equals("hello") && !timelineEntity.getId().equals("hello1")) { - Assertions.fail("Entity ids' should have been hello and hello1"); + fail("Entity ids' should have been hello and hello1"); } } assertEquals(0, isRelatedToCnt); @@ -1001,7 +1001,7 @@ public void testReadEntitiesIsRelatedTo() throws Exception { for (TimelineEntity timelineEntity : entities) { isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size(); if (!timelineEntity.getId().equals("hello1")) { - Assertions.fail("Entity id should have been hello1"); + fail("Entity id should have been hello1"); } } assertEquals(0, isRelatedToCnt); @@ -1053,7 +1053,7 @@ public void testReadEntitiesIsRelatedTo() throws Exception { for (TimelineEntity timelineEntity : entities) { isRelatedToCnt += timelineEntity.getIsRelatedToEntities().size(); if (!timelineEntity.getId().equals("hello1")) { - Assertions.fail("Entity id should have been hello1"); + fail("Entity id should have been hello1"); } } assertEquals(0, isRelatedToCnt); @@ -1080,7 +1080,7 @@ public void testReadEntitiesRelatesTo() throws Exception { relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("hello") && !timelineEntity.getId().equals("hello2")) { - Assertions.fail("Entity ids' should have been hello and hello2"); + fail("Entity ids' should have been hello and hello2"); } } assertEquals(3, relatesToCnt); @@ -1102,7 +1102,7 @@ public void testReadEntitiesRelatesTo() throws Exception { for (TimelineEntity timelineEntity : entities) { relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("hello1")) { - Assertions.fail("Entity id should have been hello1"); + fail("Entity id should have been hello1"); } } assertEquals(0, relatesToCnt); @@ -1125,7 +1125,7 @@ public void testReadEntitiesRelatesTo() throws Exception { relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("hello") && !timelineEntity.getId().equals("hello2")) { - Assertions.fail("Entity ids' should have been hello and hello2"); + fail("Entity ids' should have been hello and hello2"); } } assertEquals(0, relatesToCnt); @@ -1144,7 +1144,7 @@ public void testReadEntitiesRelatesTo() throws Exception { for (TimelineEntity timelineEntity : entities) { relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("hello")) { - Assertions.fail("Entity id should have been hello"); + fail("Entity id should have been hello"); } } assertEquals(0, relatesToCnt); @@ -1196,7 +1196,7 @@ public void testReadEntitiesRelatesTo() throws Exception { for (TimelineEntity timelineEntity : entities) { relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("hello")) { - Assertions.fail("Entity id should have been hello"); + fail("Entity id should have been hello"); } } assertEquals(0, relatesToCnt); @@ -1231,7 +1231,7 @@ public void testReadEntitiesRelatesTo() throws Exception { for (TimelineEntity timelineEntity : entities) { relatesToCnt += timelineEntity.getRelatesToEntities().size(); if (!timelineEntity.getId().equals("hello1")) { - Assertions.fail("Entity id should have been hello1"); + fail("Entity id should have been hello1"); } } assertEquals(0, relatesToCnt); diff --git a/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 b/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 index 1e8594ae1a1c5..6d795507b8dd5 100644 --- a/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 +++ b/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,7 +28,6 @@ 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.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; @@ -39,6 +38,8 @@ 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 { @@ -183,9 +184,9 @@ private static void waitForHBaseDown(HBaseTimelineReaderImpl htr) throws } }, 1000, 150000); checkQuery(htr); - Assertions.fail("Query should fail when HBase is down"); + fail("Query should fail when HBase is down"); } catch (IOException e) { - Assertions.assertEquals("HBase is down", e.getMessage()); + assertEquals("HBase is down", e.getMessage()); } } diff --git a/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 b/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 index 59c03e71a24dd..8897e3caf871f 100644 --- a/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 +++ b/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 @@ -21,7 +21,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; -import org.junit.jupiter.api.Assertions; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseTestingUtility; @@ -33,6 +32,7 @@ import static org.apache.hadoop.yarn.conf.YarnConfiguration.TIMELINE_SERVICE_READER_STORAGE_MONITOR_INTERVAL_MS; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * This class tests HbaseTimelineWriter with Hbase Down. @@ -60,7 +60,7 @@ public void testTimelineWriterHBaseDown() throws Exception { try { storageMonitor.checkStorageIsUp(); } catch(IOException e) { - Assertions.fail("HBaseStorageMonitor failed to detect HBase Up"); + fail("HBaseStorageMonitor failed to detect HBase Up"); } util.shutdownMiniHBaseCluster(); diff --git a/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 b/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 index 309fa66dc2f94..da70cba71c8b5 100644 --- a/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 +++ b/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 @@ -20,9 +20,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; 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; @@ -60,7 +61,6 @@ import org.apache.hadoop.yarn.server.timelineservice.storage.common.LongConverter; import org.apache.hadoop.yarn.server.timelineservice.storage.common.TimestampGenerator; import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -490,7 +490,7 @@ public void checkProcessSummationMoreCellsSumFinal2() assertTrue(returnTs >= currentTimestamp); } else { // raise a failure since we expect only these two values back - Assertions.fail(); + fail(); } } } @@ -576,7 +576,7 @@ public void checkProcessSummationMoreCellsSumFinalMany() throws IOException { assertTrue(returnTs <= cellTsNotFinalStart * count); } else { // raise a failure since we expect only these values back - Assertions.fail(); + fail(); } } } @@ -691,7 +691,7 @@ public void checkProcessSummationMoreCellsSumFinalVariedTags() assertTrue(returnTs <= cellTsFinalStartNotExpire + countFinalNotExpire); } else { // raise a failure since we expect only these values back - Assertions.fail(); + fail(); } } } @@ -755,7 +755,7 @@ public void testProcessSummationMoreCellsSumFinal() throws IOException { assertTrue(returnTs != inputTs1); } else { // raise a failure since we expect only these two values back - Assertions.fail(); + fail(); } } From 3356205d8d2b9cba0db775eb3869e8c9e533a886 Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Wed, 26 Mar 2025 23:23:17 +0800 Subject: [PATCH 3/3] YARN-11266. Fix CheckStyle. --- .../storage/TestHBaseTimelineStorageEntities.java | 15 +++++++-------- .../storage/TestTimelineWriterHBaseDown.java | 2 +- .../flow/TestHBaseStorageFlowRunCompaction.java | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/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 b/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 index 46a7891eda87b..bcdbc6caa9c9c 100644 --- a/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 +++ b/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 @@ -1312,8 +1312,7 @@ public void testReadEntitiesConfigPrefix() throws Exception { for (TimelineEntity entity : es1) { cfgCnt += entity.getConfigs().size(); for (String confKey : entity.getConfigs().keySet()) { - assertTrue( - confKey.startsWith("cfg_"), "Config key returned should start with cfg_"); + assertTrue(confKey.startsWith("cfg_"), "Config key returned should start with cfg_"); } } assertEquals(3, cfgCnt); @@ -1449,7 +1448,7 @@ public void testReadEntitiesConfigFilterPrefix() throws Exception { cfgCnt += entity.getConfigs().size(); for (String confKey : entity.getConfigs().keySet()) { assertTrue( - confKey.startsWith("cfg_"), "Config key returned should start with cfg_"); + confKey.startsWith("cfg_"), "Config key returned should start with cfg_"); } } assertEquals(2, cfgCnt); @@ -1481,7 +1480,7 @@ public void testReadEntitiesConfigFilterPrefix() throws Exception { cfgCnt += entity.getConfigs().size(); for (String confKey : entity.getConfigs().keySet()) { assertTrue( - confKey.startsWith("config_"), "Config key returned should start with config_"); + confKey.startsWith("config_"), "Config key returned should start with config_"); } } assertEquals(2, cfgCnt); @@ -1508,7 +1507,7 @@ public void testReadEntitiesMetricPrefix() throws Exception { metricCnt += entity.getMetrics().size(); for (TimelineMetric metric : entity.getMetrics()) { assertTrue( - metric.getId().startsWith("MAP1_"), "Metric Id returned should start with MAP1_"); + metric.getId().startsWith("MAP1_"), "Metric Id returned should start with MAP1_"); } } assertEquals(2, metricCnt); @@ -1701,7 +1700,7 @@ public void testReadEntitiesMetricFilterPrefix() throws Exception { metricCnt += entity.getMetrics().size(); for (TimelineMetric metric : entity.getMetrics()) { assertTrue( - metric.getId().startsWith("MAP1_"), "Metric Id returned should start with MAP1_"); + metric.getId().startsWith("MAP1_"), "Metric Id returned should start with MAP1_"); } } assertEquals(1, metricCnt); @@ -1733,7 +1732,7 @@ public void testReadEntitiesMetricFilterPrefix() throws Exception { assertEquals(TimelineMetric.Type.SINGLE_VALUE, metric.getType()); assertEquals(1, metric.getValues().size()); assertTrue( - metric.getId().startsWith("MAP1_"), "Metric Id returned should start with MAP1_"); + metric.getId().startsWith("MAP1_"), "Metric Id returned should start with MAP1_"); } } assertEquals(2, metricCnt); @@ -1753,7 +1752,7 @@ public void testReadEntitiesMetricFilterPrefix() throws Exception { for (TimelineMetric metric : entity.getMetrics()) { metricValCnt += metric.getValues().size(); assertTrue( - metric.getId().startsWith("MAP1_"), "Metric Id returned should start with MAP1_"); + metric.getId().startsWith("MAP1_"), "Metric Id returned should start with MAP1_"); } } assertEquals(2, metricCnt); diff --git a/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 b/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 index 8897e3caf871f..f0028ae162962 100644 --- a/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 +++ b/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 @@ -85,7 +85,7 @@ public void testTimelineWriterHBaseDown() throws Exception { } } assertTrue( - exceptionCaught, "HBaseStorageMonitor failed to detect HBase Down"); + exceptionCaught, "HBaseStorageMonitor failed to detect HBase Down"); } finally { writer.stop(); util.shutdownMiniCluster(); diff --git a/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 b/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 index da70cba71c8b5..0e5cecb5e5a38 100644 --- a/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 +++ b/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 @@ -335,8 +335,8 @@ public void testWriteFlowRunCompaction() throws Exception { // flush and compact all the regions of the primary table int regionNum = HBaseTimelineServerUtils.flushCompactTableRegions( server, flowRunTable); - assertTrue( - regionNum > 0, "Didn't find any regions for primary table!"); + 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);