[ 
https://issues.apache.org/jira/browse/HADOOP-20048?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated HADOOP-20048:
------------------------------------
    Labels: pull-request-available  (was: )

> Fix race in TestHttpServer#testHttpServer2Metrics
> -------------------------------------------------
>
>                 Key: HADOOP-20048
>                 URL: https://issues.apache.org/jira/browse/HADOOP-20048
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: test
>            Reporter: Jose Luis López
>            Priority: Minor
>              Labels: pull-request-available
>
> {{TestHttpServer#testHttpServer2Metrics}} is intermittently flaky. It was 
> observed failing once and passing on retry (surefire {{flakyFailure}}) with:
> {noformat}
> java.lang.AssertionError:
> Expecting:
>  <104>
> to be greater than:
>  <104>
> {noformat}
> The test reads {{HttpServer2Metrics#responses2xx()}} immediately after 
> {{conn.getResponseCode()}} returns 200. That counter comes from Jetty's 
> {{StatisticsHandler}}, which records a response when the request completes on 
> the server side. This can happen after the client has already read the status 
> line, so the second read can still return the old value.
> Proposed fix (test-only):
> * read and close the response body, then {{disconnect()}}, so the exchange 
> completes;
> * wait for the counter with {{GenericTestUtils.waitFor(() -> 
> metrics.responses2xx() > before, 10, 10000, ...)}} instead of reading it once.
> The test still checks the same thing: the 2xx counter increases after a 
> successful request. With the fix, the test passed 50/50 runs in separate JVMs 
> with {{-Dsurefire.rerunFailingTestsCount=0}}, and checkstyle reports no new 
> warnings.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

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

Reply via email to