Skip to content

Commit cc9e548

Browse files
slfan1989cnaurothzhtttylz
authored
YARN-11266. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-yarn-server-timelineservice-hbase-tests. (#7538)
Co-authored-by: Chris Nauroth <cnauroth@apache.org> Co-authored-by: Hualong Zhang <hualong.z@hotmail.com> Reviewed-by: Chris Nauroth <cnauroth@apache.org> Reviewed-by: Hualong Zhang <hualong.z@hotmail.com> Signed-off-by: Shilun Fan <slfan1989@apache.org>
1 parent 18f7617 commit cc9e548

File tree

11 files changed

+226
-203
lines changed

11 files changed

+226
-203
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818

1919
package org.apache.hadoop.yarn.server.timelineservice.reader;
2020

21-
import static org.junit.Assert.assertEquals;
22-
import static org.junit.Assert.assertNotNull;
23-
import static org.junit.Assert.assertTrue;
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
22+
import static org.junit.jupiter.api.Assertions.assertNotNull;
23+
import static org.junit.jupiter.api.Assertions.assertTrue;
24+
import static org.junit.jupiter.api.Assertions.fail;
2425

2526
import javax.ws.rs.client.Client;
2627
import javax.ws.rs.client.ClientBuilder;
@@ -43,7 +44,6 @@
4344
import org.apache.hadoop.yarn.server.timelineservice.storage.DataGeneratorForTest;
4445
import org.glassfish.jersey.client.ClientConfig;
4546
import org.glassfish.jersey.client.HttpUrlConnectorProvider;
46-
import org.junit.Assert;
4747

4848
/**
4949
* Test Base for TimelineReaderServer HBase tests.
@@ -101,7 +101,7 @@ protected void addFilters(Configuration conf) {
101101
server.start();
102102
serverPort = server.getWebServerPort();
103103
} catch (Exception e) {
104-
Assert.fail("Web server failed to start");
104+
fail("Web server failed to start");
105105
}
106106
}
107107

@@ -138,8 +138,8 @@ protected Response getResponse(Client client, URI uri)
138138
protected void verifyHttpResponse(Client client, URI uri, Response.Status status) {
139139
Response resp = client.target(uri).request(MediaType.APPLICATION_JSON).get();
140140
assertNotNull(resp);
141-
assertTrue("Response from server should have been " + status,
142-
resp.getStatusInfo().getStatusCode() == status.getStatusCode());
141+
assertTrue(resp.getStatusInfo().getStatusCode() == status.getStatusCode(),
142+
"Response from server should have been " + status);
143143
System.out.println("Response is: " + resp.readEntity(String.class));
144144
}
145145

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

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
package org.apache.hadoop.yarn.server.timelineservice.reader;
2020

21-
import static org.junit.Assert.assertEquals;
22-
import static org.junit.Assert.assertNotNull;
23-
import static org.junit.Assert.assertTrue;
24-
import static org.junit.Assert.fail;
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
22+
import static org.junit.jupiter.api.Assertions.assertNotNull;
23+
import static org.junit.jupiter.api.Assertions.assertTrue;
24+
import static org.junit.jupiter.api.Assertions.fail;
2525

2626
import javax.ws.rs.client.Client;
2727

@@ -59,9 +59,9 @@
5959
import org.apache.hadoop.yarn.server.timelineservice.storage.HBaseTimelineWriterImpl;
6060
import org.apache.hadoop.yarn.server.timelineservice.storage.common.HBaseTimelineSchemaUtils;
6161
import org.apache.hadoop.yarn.server.utils.BuilderUtils;
62-
import org.junit.AfterClass;
63-
import org.junit.BeforeClass;
64-
import org.junit.Test;
62+
import org.junit.jupiter.api.AfterAll;
63+
import org.junit.jupiter.api.BeforeAll;
64+
import org.junit.jupiter.api.Test;
6565

6666
import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
6767

@@ -75,14 +75,14 @@ public class TestTimelineReaderWebServicesHBaseStorage
7575
HBaseTimelineSchemaUtils.getTopOfTheDayTimestamp(ts);
7676
private static String doAsUser = "remoteuser";
7777

78-
@BeforeClass
78+
@BeforeAll
7979
public static void setupBeforeClass() throws Exception {
8080
setup();
8181
loadData();
8282
initialize();
8383
}
8484

85-
@AfterClass
85+
@AfterAll
8686
public static void tearDownAfterClass() throws Exception {
8787
tearDown();
8888
}
@@ -505,13 +505,14 @@ public void testGetFlowRuns() throws Exception {
505505
assertNotNull(entities);
506506
assertEquals(2, entities.size());
507507
for (FlowRunEntity entity : entities) {
508-
assertTrue("Id, run id or start time does not match.",
508+
assertTrue(
509509
((entity.getId().equals("user1@flow_name/1002345678919")) &&
510510
(entity.getRunId() == 1002345678919L) &&
511511
(entity.getStartTime() == 1425016501000L)) ||
512512
((entity.getId().equals("user1@flow_name/1002345678920")) &&
513513
(entity.getRunId() == 1002345678920L) &&
514-
(entity.getStartTime() == 1425016501034L)));
514+
(entity.getStartTime() == 1425016501034L)),
515+
"Id, run id or start time does not match.");
515516
assertEquals(0, entity.getMetrics().size());
516517
}
517518

@@ -525,10 +526,11 @@ public void testGetFlowRuns() throws Exception {
525526
assertNotNull(entities);
526527
assertEquals(1, entities.size());
527528
for (FlowRunEntity entity : entities) {
528-
assertTrue("Id, run id or start time does not match.",
529+
assertTrue(
529530
entity.getId().equals("user1@flow_name/1002345678920") &&
530531
entity.getRunId() == 1002345678920L &&
531-
entity.getStartTime() == 1425016501034L);
532+
entity.getStartTime() == 1425016501034L,
533+
"Id, run id or start time does not match.");
532534
assertEquals(0, entity.getMetrics().size());
533535
}
534536

@@ -542,10 +544,11 @@ public void testGetFlowRuns() throws Exception {
542544
assertNotNull(entities);
543545
assertEquals(1, entities.size());
544546
for (FlowRunEntity entity : entities) {
545-
assertTrue("Id, run id or start time does not match.",
547+
assertTrue(
546548
entity.getId().equals("user1@flow_name/1002345678920") &&
547549
entity.getRunId() == 1002345678920L &&
548-
entity.getStartTime() == 1425016501034L);
550+
entity.getStartTime() == 1425016501034L,
551+
"Id, run id or start time does not match.");
549552
assertEquals(0, entity.getMetrics().size());
550553
}
551554

@@ -559,13 +562,14 @@ public void testGetFlowRuns() throws Exception {
559562
assertNotNull(entities);
560563
assertEquals(2, entities.size());
561564
for (FlowRunEntity entity : entities) {
562-
assertTrue("Id, run id or start time does not match.",
565+
assertTrue(
563566
((entity.getId().equals("user1@flow_name/1002345678919")) &&
564567
(entity.getRunId() == 1002345678919L) &&
565568
(entity.getStartTime() == 1425016501000L)) ||
566569
((entity.getId().equals("user1@flow_name/1002345678920")) &&
567570
(entity.getRunId() == 1002345678920L) &&
568-
(entity.getStartTime() == 1425016501034L)));
571+
(entity.getStartTime() == 1425016501034L)),
572+
"Id, run id or start time does not match.");
569573
assertEquals(0, entity.getMetrics().size());
570574
}
571575

@@ -579,10 +583,11 @@ public void testGetFlowRuns() throws Exception {
579583
assertNotNull(entities);
580584
assertEquals(1, entities.size());
581585
for (FlowRunEntity entity : entities) {
582-
assertTrue("Id, run id or start time does not match.",
586+
assertTrue(
583587
entity.getId().equals("user1@flow_name/1002345678919") &&
584588
entity.getRunId() == 1002345678919L &&
585-
entity.getStartTime() == 1425016501000L);
589+
entity.getStartTime() == 1425016501000L,
590+
"Id, run id or start time does not match.");
586591
assertEquals(0, entity.getMetrics().size());
587592
}
588593

@@ -596,15 +601,16 @@ public void testGetFlowRuns() throws Exception {
596601
assertNotNull(entities);
597602
assertEquals(2, entities.size());
598603
for (FlowRunEntity entity : entities) {
599-
assertTrue("Id, run id or start time does not match.",
604+
assertTrue(
600605
((entity.getId().equals("user1@flow_name/1002345678919")) &&
601606
(entity.getRunId() == 1002345678919L) &&
602607
(entity.getStartTime() == 1425016501000L) &&
603608
(entity.getMetrics().size() == 3)) ||
604609
((entity.getId().equals("user1@flow_name/1002345678920")) &&
605610
(entity.getRunId() == 1002345678920L) &&
606611
(entity.getStartTime() == 1425016501034L) &&
607-
(entity.getMetrics().size() == 1)));
612+
(entity.getMetrics().size() == 1)),
613+
"Id, run id or start time does not match.");
608614
}
609615

610616
// fields as CONFIGS will lead to a HTTP 400 as it makes no sense for
@@ -1999,11 +2005,12 @@ public void testGetFlowRunApps() throws Exception {
19992005
assertNotNull(entities);
20002006
assertEquals(2, entities.size());
20012007
for (TimelineEntity entity : entities) {
2002-
assertTrue("Unexpected app in result",
2008+
assertTrue(
20032009
(entity.getId().equals("application_1111111111_1111") &&
20042010
entity.getMetrics().size() == 3) ||
20052011
(entity.getId().equals("application_1111111111_2222") &&
2006-
entity.getMetrics().size() == 1));
2012+
entity.getMetrics().size() == 1),
2013+
"Unexpected app in result");
20072014
for (TimelineMetric metric : entity.getMetrics()) {
20082015
assertEquals(TimelineMetric.Type.SINGLE_VALUE, metric.getType());
20092016
assertEquals(1, metric.getValues().size());
@@ -2018,11 +2025,12 @@ public void testGetFlowRunApps() throws Exception {
20182025
assertNotNull(entities);
20192026
assertEquals(2, entities.size());
20202027
for (TimelineEntity entity : entities) {
2021-
assertTrue("Unexpected app in result",
2028+
assertTrue(
20222029
(entity.getId().equals("application_1111111111_1111") &&
20232030
entity.getMetrics().size() == 3) ||
20242031
(entity.getId().equals("application_1111111111_2222") &&
2025-
entity.getMetrics().size() == 1));
2032+
entity.getMetrics().size() == 1),
2033+
"Unexpected app in result");
20262034
for (TimelineMetric metric : entity.getMetrics()) {
20272035
assertTrue(metric.getValues().size() <= 2);
20282036
assertEquals(TimelineMetric.Type.TIME_SERIES, metric.getType());
@@ -2062,15 +2070,16 @@ public void testGetFlowApps() throws Exception {
20622070
assertNotNull(entities);
20632071
assertEquals(3, entities.size());
20642072
for (TimelineEntity entity : entities) {
2065-
assertTrue("Unexpected app in result",
2073+
assertTrue(
20662074
(entity.getId().equals("application_1111111111_1111") &&
20672075
entity.getConfigs().size() == 1 &&
20682076
entity.getConfigs().equals(ImmutableMap.of("cfg2", "value1"))) ||
20692077
(entity.getId().equals("application_1111111111_2222") &&
20702078
entity.getConfigs().size() == 1 &&
20712079
entity.getConfigs().equals(ImmutableMap.of("cfg1", "value1"))) ||
20722080
(entity.getId().equals("application_1111111111_2224") &&
2073-
entity.getConfigs().size() == 0));
2081+
entity.getConfigs().size() == 0),
2082+
"Unexpected app in result");
20742083
for (TimelineMetric metric : entity.getMetrics()) {
20752084
if (entity.getId().equals("application_1111111111_1111")) {
20762085
TimelineMetric m1 = newMetric(TimelineMetric.Type.SINGLE_VALUE,
@@ -2100,15 +2109,16 @@ public void testGetFlowApps() throws Exception {
21002109
assertNotNull(entities);
21012110
assertEquals(3, entities.size());
21022111
for (TimelineEntity entity : entities) {
2103-
assertTrue("Unexpected app in result",
2112+
assertTrue(
21042113
(entity.getId().equals("application_1111111111_1111") &&
21052114
entity.getConfigs().size() == 1 &&
21062115
entity.getConfigs().equals(ImmutableMap.of("cfg2", "value1"))) ||
21072116
(entity.getId().equals("application_1111111111_2222") &&
21082117
entity.getConfigs().size() == 1 &&
21092118
entity.getConfigs().equals(ImmutableMap.of("cfg1", "value1"))) ||
21102119
(entity.getId().equals("application_1111111111_2224") &&
2111-
entity.getConfigs().size() == 0));
2120+
entity.getConfigs().size() == 0),
2121+
"Unexpected app in result");
21122122
for (TimelineMetric metric : entity.getMetrics()) {
21132123
if (entity.getId().equals("application_1111111111_1111")) {
21142124
TimelineMetric m1 = newMetric(TimelineMetric.Type.TIME_SERIES,
@@ -2167,8 +2177,9 @@ public void testGetFlowAppsFilters() throws Exception {
21672177
resp.readEntity(new GenericType<Set<TimelineEntity>>(){});
21682178
assertNotNull(entities);
21692179
assertEquals(1, entities.size());
2170-
assertTrue("Unexpected app in result", entities.contains(
2171-
newEntity(entityType, "application_1111111111_1111")));
2180+
assertTrue(entities.contains(
2181+
newEntity(entityType, "application_1111111111_1111")),
2182+
"Unexpected app in result");
21722183

21732184
uri = URI.create("http://localhost:" + getServerPort() + "/ws/v2/" +
21742185
"timeline/clusters/cluster1/users/user1/flows/flow_name/apps?" +
@@ -2177,8 +2188,9 @@ public void testGetFlowAppsFilters() throws Exception {
21772188
entities = resp.readEntity(new GenericType<Set<TimelineEntity>>(){});
21782189
assertNotNull(entities);
21792190
assertEquals(1, entities.size());
2180-
assertTrue("Unexpected app in result", entities.contains(
2181-
newEntity(entityType, "application_1111111111_1111")));
2191+
assertTrue(entities.contains(
2192+
newEntity(entityType, "application_1111111111_1111")),
2193+
"Unexpected app in result");
21822194

21832195
uri = URI.create("http://localhost:" + getServerPort() + "/ws/v2/" +
21842196
"timeline/clusters/cluster1/users/user1/flows/flow_name/apps?" +
@@ -2187,8 +2199,9 @@ public void testGetFlowAppsFilters() throws Exception {
21872199
entities = resp.readEntity(new GenericType<Set<TimelineEntity>>(){});
21882200
assertNotNull(entities);
21892201
assertEquals(1, entities.size());
2190-
assertTrue("Unexpected app in result", entities.contains(
2191-
newEntity(entityType, "application_1111111111_2222")));
2202+
assertTrue(entities.contains(
2203+
newEntity(entityType, "application_1111111111_2222")),
2204+
"Unexpected app in result");
21922205
} finally {
21932206
client.close();
21942207
}

0 commit comments

Comments
 (0)