2121import java .io .IOException ;
2222import java .util .List ;
2323
24+ import org .junit .jupiter .api .BeforeAll ;
25+ import org .junit .jupiter .api .Test ;
26+
2427import org .apache .hadoop .conf .Configuration ;
2528import org .apache .hadoop .yarn .api .protocolrecords .GetApplicationAttemptReportRequest ;
2629import org .apache .hadoop .yarn .api .protocolrecords .GetApplicationAttemptReportResponse ;
4952import org .apache .hadoop .yarn .server .timeline .TimelineDataManager ;
5053import org .apache .hadoop .yarn .server .timeline .TimelineStore ;
5154import org .apache .hadoop .yarn .server .timeline .security .TimelineACLsManager ;
52- import org .junit .Assert ;
53- import org .junit .BeforeClass ;
54- import org .junit .Test ;
55+
56+ import static org .junit .jupiter .api .Assertions .assertEquals ;
57+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
58+ import static org .junit .jupiter .api .Assertions .assertTrue ;
59+ import static org .junit .jupiter .api .Assertions .fail ;
5560
5661public class TestApplicationHistoryClientService {
5762
5863 private static ApplicationHistoryClientService clientService ;
5964 private static TimelineDataManager dataManager ;
6065 private final static int MAX_APPS = 2 ;
6166
62- @ BeforeClass
67+ @ BeforeAll
6368 public static void setup () throws Exception {
6469 Configuration conf = new YarnConfiguration ();
6570 TimelineStore store =
@@ -78,7 +83,7 @@ public static void setup() throws Exception {
7883 }
7984
8085 @ Test
81- public void testApplicationNotFound () throws IOException , YarnException {
86+ void testApplicationNotFound () throws IOException , YarnException {
8287 ApplicationId appId = null ;
8388 appId = ApplicationId .newInstance (0 , MAX_APPS + 1 );
8489 GetApplicationReportRequest request =
@@ -87,18 +92,18 @@ public void testApplicationNotFound() throws IOException, YarnException {
8792 @ SuppressWarnings ("unused" )
8893 GetApplicationReportResponse response =
8994 clientService .getApplicationReport (request );
90- Assert . fail ("Exception should have been thrown before we reach here." );
95+ fail ("Exception should have been thrown before we reach here." );
9196 } catch (ApplicationNotFoundException e ) {
9297 //This exception is expected.
93- Assert . assertTrue (e .getMessage ().contains (
98+ assertTrue (e .getMessage ().contains (
9499 "doesn't exist in the timeline store" ));
95100 } catch (Exception e ) {
96- Assert . fail ("Undesired exception caught" );
101+ fail ("Undesired exception caught" );
97102 }
98103 }
99104
100105 @ Test
101- public void testApplicationAttemptNotFound () throws IOException , YarnException {
106+ void testApplicationAttemptNotFound () throws IOException , YarnException {
102107 ApplicationId appId = ApplicationId .newInstance (0 , 1 );
103108 ApplicationAttemptId appAttemptId =
104109 ApplicationAttemptId .newInstance (appId , MAX_APPS + 1 );
@@ -108,95 +113,95 @@ public void testApplicationAttemptNotFound() throws IOException, YarnException {
108113 @ SuppressWarnings ("unused" )
109114 GetApplicationAttemptReportResponse response =
110115 clientService .getApplicationAttemptReport (request );
111- Assert . fail ("Exception should have been thrown before we reach here." );
116+ fail ("Exception should have been thrown before we reach here." );
112117 } catch (ApplicationAttemptNotFoundException e ) {
113118 //This Exception is expected
114119 System .out .println (e .getMessage ());
115- Assert . assertTrue (e .getMessage ().contains (
120+ assertTrue (e .getMessage ().contains (
116121 "doesn't exist in the timeline store" ));
117122 } catch (Exception e ) {
118- Assert . fail ("Undesired exception caught" );
123+ fail ("Undesired exception caught" );
119124 }
120125 }
121126
122127 @ Test
123- public void testContainerNotFound () throws IOException , YarnException {
124- ApplicationId appId = ApplicationId .newInstance (0 , 1 );
125- ApplicationAttemptId appAttemptId =
126- ApplicationAttemptId .newInstance (appId , 1 );
127- ContainerId containerId = ContainerId .newContainerId (appAttemptId ,
128- MAX_APPS + 1 );
129- GetContainerReportRequest request =
130- GetContainerReportRequest .newInstance (containerId );
131- try {
132- @ SuppressWarnings ("unused" )
133- GetContainerReportResponse response =
134- clientService .getContainerReport (request );
135- } catch (ContainerNotFoundException e ) {
136- //This exception is expected
137- Assert . assertTrue (e .getMessage ().contains (
138- "doesn't exist in the timeline store" ));
139- } catch (Exception e ) {
140- Assert . fail ("Undesired exception caught" );
141- }
142- }
128+ void testContainerNotFound () throws IOException , YarnException {
129+ ApplicationId appId = ApplicationId .newInstance (0 , 1 );
130+ ApplicationAttemptId appAttemptId =
131+ ApplicationAttemptId .newInstance (appId , 1 );
132+ ContainerId containerId = ContainerId .newContainerId (appAttemptId ,
133+ MAX_APPS + 1 );
134+ GetContainerReportRequest request =
135+ GetContainerReportRequest .newInstance (containerId );
136+ try {
137+ @ SuppressWarnings ("unused" )
138+ GetContainerReportResponse response =
139+ clientService .getContainerReport (request );
140+ } catch (ContainerNotFoundException e ) {
141+ //This exception is expected
142+ assertTrue (e .getMessage ().contains (
143+ "doesn't exist in the timeline store" ));
144+ } catch (Exception e ) {
145+ fail ("Undesired exception caught" );
146+ }
147+ }
143148
144149 @ Test
145- public void testApplicationReport () throws IOException , YarnException {
150+ void testApplicationReport () throws IOException , YarnException {
146151 ApplicationId appId = null ;
147152 appId = ApplicationId .newInstance (0 , 1 );
148153 GetApplicationReportRequest request =
149154 GetApplicationReportRequest .newInstance (appId );
150155 GetApplicationReportResponse response =
151156 clientService .getApplicationReport (request );
152157 ApplicationReport appReport = response .getApplicationReport ();
153- Assert . assertNotNull (appReport );
154- Assert . assertEquals (123 , appReport .getApplicationResourceUsageReport ()
158+ assertNotNull (appReport );
159+ assertEquals (123 , appReport .getApplicationResourceUsageReport ()
155160 .getMemorySeconds ());
156- Assert . assertEquals (345 , appReport .getApplicationResourceUsageReport ()
161+ assertEquals (345 , appReport .getApplicationResourceUsageReport ()
157162 .getVcoreSeconds ());
158- Assert . assertEquals ("application_0_0001" , appReport .getApplicationId ()
159- .toString ());
160- Assert . assertEquals ("test app type" ,
163+ assertEquals ("application_0_0001" , appReport .getApplicationId ()
164+ .toString ());
165+ assertEquals ("test app type" ,
161166 appReport .getApplicationType ().toString ());
162- Assert . assertEquals ("test queue" , appReport .getQueue ().toString ());
167+ assertEquals ("test queue" , appReport .getQueue ().toString ());
163168 }
164169
165170 @ Test
166- public void testApplications () throws IOException , YarnException {
171+ void testApplications () throws IOException , YarnException {
167172 ApplicationId appId = null ;
168173 appId = ApplicationId .newInstance (0 , 1 );
169174 ApplicationId appId1 = ApplicationId .newInstance (0 , 2 );
170175 GetApplicationsRequest request = GetApplicationsRequest .newInstance ();
171176 GetApplicationsResponse response =
172177 clientService .getApplications (request );
173178 List <ApplicationReport > appReport = response .getApplicationList ();
174- Assert . assertNotNull (appReport );
175- Assert . assertEquals (appId , appReport .get (1 ).getApplicationId ());
176- Assert . assertEquals (appId1 , appReport .get (0 ).getApplicationId ());
179+ assertNotNull (appReport );
180+ assertEquals (appId , appReport .get (1 ).getApplicationId ());
181+ assertEquals (appId1 , appReport .get (0 ).getApplicationId ());
177182
178183 // Create a historyManager, and set the max_apps can be loaded
179184 // as 1.
180185 Configuration conf = new YarnConfiguration ();
181186 conf .setLong (YarnConfiguration .APPLICATION_HISTORY_MAX_APPS , 1 );
182187 ApplicationHistoryManagerOnTimelineStore historyManager2 =
183188 new ApplicationHistoryManagerOnTimelineStore (dataManager ,
184- new ApplicationACLsManager (conf ));
189+ new ApplicationACLsManager (conf ));
185190 historyManager2 .init (conf );
186191 historyManager2 .start ();
187192 @ SuppressWarnings ("resource" )
188193 ApplicationHistoryClientService clientService2 =
189194 new ApplicationHistoryClientService (historyManager2 );
190195 response = clientService2 .getApplications (request );
191196 appReport = response .getApplicationList ();
192- Assert . assertNotNull (appReport );
193- Assert . assertTrue (appReport .size () == 1 );
197+ assertNotNull (appReport );
198+ assertTrue (appReport .size () == 1 );
194199 // Expected to get the appReport for application with appId1
195- Assert . assertEquals (appId1 , appReport .get (0 ).getApplicationId ());
200+ assertEquals (appId1 , appReport .get (0 ).getApplicationId ());
196201 }
197202
198203 @ Test
199- public void testApplicationAttemptReport () throws IOException , YarnException {
204+ void testApplicationAttemptReport () throws IOException , YarnException {
200205 ApplicationId appId = ApplicationId .newInstance (0 , 1 );
201206 ApplicationAttemptId appAttemptId =
202207 ApplicationAttemptId .newInstance (appId , 1 );
@@ -206,13 +211,13 @@ public void testApplicationAttemptReport() throws IOException, YarnException {
206211 clientService .getApplicationAttemptReport (request );
207212 ApplicationAttemptReport attemptReport =
208213 response .getApplicationAttemptReport ();
209- Assert . assertNotNull (attemptReport );
210- Assert . assertEquals ("appattempt_0_0001_000001" , attemptReport
211- .getApplicationAttemptId ().toString ());
214+ assertNotNull (attemptReport );
215+ assertEquals ("appattempt_0_0001_000001" , attemptReport
216+ .getApplicationAttemptId ().toString ());
212217 }
213218
214219 @ Test
215- public void testApplicationAttempts () throws IOException , YarnException {
220+ void testApplicationAttempts () throws IOException , YarnException {
216221 ApplicationId appId = ApplicationId .newInstance (0 , 1 );
217222 ApplicationAttemptId appAttemptId =
218223 ApplicationAttemptId .newInstance (appId , 1 );
@@ -224,15 +229,15 @@ public void testApplicationAttempts() throws IOException, YarnException {
224229 clientService .getApplicationAttempts (request );
225230 List <ApplicationAttemptReport > attemptReports =
226231 response .getApplicationAttemptList ();
227- Assert . assertNotNull (attemptReports );
228- Assert . assertEquals (appAttemptId , attemptReports .get (0 )
229- .getApplicationAttemptId ());
230- Assert . assertEquals (appAttemptId1 , attemptReports .get (1 )
231- .getApplicationAttemptId ());
232+ assertNotNull (attemptReports );
233+ assertEquals (appAttemptId , attemptReports .get (0 )
234+ .getApplicationAttemptId ());
235+ assertEquals (appAttemptId1 , attemptReports .get (1 )
236+ .getApplicationAttemptId ());
232237 }
233238
234239 @ Test
235- public void testContainerReport () throws IOException , YarnException {
240+ void testContainerReport () throws IOException , YarnException {
236241 ApplicationId appId = ApplicationId .newInstance (0 , 1 );
237242 ApplicationAttemptId appAttemptId =
238243 ApplicationAttemptId .newInstance (appId , 1 );
@@ -242,15 +247,15 @@ public void testContainerReport() throws IOException, YarnException {
242247 GetContainerReportResponse response =
243248 clientService .getContainerReport (request );
244249 ContainerReport container = response .getContainerReport ();
245- Assert . assertNotNull (container );
246- Assert . assertEquals (containerId , container .getContainerId ());
247- Assert . assertEquals ("http://0.0.0.0:8188/applicationhistory/logs/" +
250+ assertNotNull (container );
251+ assertEquals (containerId , container .getContainerId ());
252+ assertEquals ("http://0.0.0.0:8188/applicationhistory/logs/" +
248253 "test host:100/container_0_0001_01_000001/" +
249254 "container_0_0001_01_000001/user1" , container .getLogUrl ());
250255 }
251256
252257 @ Test
253- public void testContainers () throws IOException , YarnException {
258+ void testContainers () throws IOException , YarnException {
254259 ApplicationId appId = ApplicationId .newInstance (0 , 1 );
255260 ApplicationAttemptId appAttemptId =
256261 ApplicationAttemptId .newInstance (appId , 1 );
@@ -261,8 +266,8 @@ public void testContainers() throws IOException, YarnException {
261266 GetContainersResponse response =
262267 clientService .getContainers (request );
263268 List <ContainerReport > containers = response .getContainerList ();
264- Assert . assertNotNull (containers );
265- Assert . assertEquals (containerId , containers .get (0 ).getContainerId ());
266- Assert . assertEquals (containerId1 , containers .get (1 ).getContainerId ());
269+ assertNotNull (containers );
270+ assertEquals (containerId , containers .get (0 ).getContainerId ());
271+ assertEquals (containerId1 , containers .get (1 ).getContainerId ());
267272 }
268273}
0 commit comments