slfan1989 commented on code in PR #8652:
URL: https://github.com/apache/hadoop/pull/8652#discussion_r4091891889


##########
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebApp.java:
##########
@@ -417,6 +417,36 @@ protected ClientService createClientService(AppContext 
context) {
     }
   }
 
+  @Test
+  public void testAttemptsPageRender() throws Exception {
+    MRApp app = new MRApp(2, 2, true, this.getClass().getName(), true) {
+      @Override
+      protected ClientService createClientService(AppContext context) {
+        return new MRClientService(context);
+      }
+    };
+    Configuration conf = new Configuration();
+
+    Job job = app.submit(conf);
+    String hostPort =
+        NetUtils.getHostPortString(((MRClientService) app.getClientService())
+          .getWebApp().getListenerAddress());
+    URL attemptsUrl = new URL("http://"; + hostPort + "/mapreduce/attempts/"
+        + job.getID().toString() + "/m/SUCCESSFUL");
+    app.waitForState(job, JobState.SUCCEEDED);
+
+    HttpURLConnection conn = (HttpURLConnection) attemptsUrl.openConnection();
+    assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode(),
+        attemptsUrl.toString());
+    InputStream in = conn.getInputStream();
+    ByteArrayOutputStream out = new ByteArrayOutputStream();
+    IOUtils.copyBytes(in, out, 1024);
+
+    String content = out.toString();
+    assertTrue(content.contains("attempt_"), "Attempts Page should have the 
attepmts data");
+    app.verifyCompleted();

Review Comment:
   Could we explicitly stop the client service and the MRApp in a `finally` 
block?
   
   `verifyCompleted()` only checks timestamps. The test's job-finish handler 
calls
   `MRApp.stop()`, but `MRClientService` is managed separately and is not 
stopped
   by that call. Consequently, this test leaves its HTTP and RPC servers 
running,
   including when an assertion fails.
   
   Please ensure both `app.getClientService()` and `app` are stopped during 
cleanup.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to