2727import java .util .Collections ;
2828import java .util .HashMap ;
2929import java .util .concurrent .TimeUnit ;
30+ import java .util .stream .Collectors ;
31+ import java .util .stream .IntStream ;
32+ import org .apache .lucene .tests .util .LuceneTestCase ;
3033import org .apache .solr .client .api .util .SolrVersion ;
3134import org .apache .solr .client .solrj .ResponseParser ;
3235import org .apache .solr .client .solrj .SolrClient ;
3942import org .apache .solr .common .params .CommonParams ;
4043import org .apache .solr .common .params .MapSolrParams ;
4144import org .apache .solr .common .params .ModifiableSolrParams ;
45+ import org .apache .solr .common .params .SolrParams ;
4246import org .apache .solr .common .util .NamedList ;
4347import org .eclipse .jetty .client .WWWAuthenticationProtocolHandler ;
4448import org .eclipse .jetty .http .HttpStatus ;
@@ -707,11 +711,13 @@ public void testIdleTimeoutWithHttpClient() throws Exception {
707711 }
708712
709713 // too little time to succeed
710- QueryRequest req = new QueryRequest ();
714+ int packets = LuceneTestCase .RANDOM_MULTIPLIER == 1 ? 10 : 80 ; // 60 crosses a default timeout
715+ long timeToSendMs = packets * BasicHttpSolrClientTest .SlowStreamServlet .PACKET_MS ;
716+ QueryRequest req = new QueryRequest (SolrParams .of ("count" , "" + packets ));
711717 req .setResponseParser (new InputStreamResponseParser (FILE_STREAM ));
712718 assertIsTimeout (expectThrows (SolrServerException .class , () -> oldClient .request (req )));
713719
714- int newIdleTimeoutMs = 10 * 1000 ; // enough time to succeed
720+ long newIdleTimeoutMs = timeToSendMs + 1000 ; // enough time to succeed
715721 try (Http2SolrClient idleTimeoutChangedClient =
716722 new Http2SolrClient .Builder (url )
717723 .withHttpClient (oldClient )
@@ -721,7 +727,9 @@ public void testIdleTimeoutWithHttpClient() throws Exception {
721727 assertEquals (newIdleTimeoutMs , idleTimeoutChangedClient .getIdleTimeout ());
722728 NamedList <Object > response = idleTimeoutChangedClient .request (req );
723729 try (InputStream is = (InputStream ) response .get ("stream" )) {
724- assertEquals ("0123456789" , new String (is .readAllBytes (), StandardCharsets .UTF_8 ));
730+ String expect =
731+ IntStream .range (0 , packets ).mapToObj (String ::valueOf ).collect (Collectors .joining ());
732+ assertEquals (expect , new String (is .readAllBytes (), StandardCharsets .UTF_8 ));
725733 }
726734 }
727735 }
0 commit comments