@@ -295,31 +295,35 @@ private Response concat(int evals) throws IOException {
295295 * Returns many moderately long strings.
296296 */
297297 public void testManyConcat () throws IOException {
298+ int strings = 300 ;
298299 initManyLongs ();
299- Response resp = manyConcat (300 );
300- Map <?, ?> map = responseAsMap (resp );
301- ListMatcher columns = matchesList ();
302- for (int s = 0 ; s < 300 ; s ++) {
303- columns = columns .item (matchesMap ().entry ("name" , "str" + s ).entry ("type" , "keyword" ));
304- }
305- MapMatcher mapMatcher = matchesMap ();
306- assertMap (map , mapMatcher .entry ("columns" , columns ).entry ("values" , any (List .class )).entry ("took" , greaterThanOrEqualTo (0 )));
300+ Response resp = manyConcat ("FROM manylongs" , strings );
301+ assertManyStrings (resp , strings );
307302 }
308303
309304 /**
310305 * Hits a circuit breaker by building many moderately long strings.
311306 */
312307 public void testHugeManyConcat () throws IOException {
313308 initManyLongs ();
314- assertCircuitBreaks (() -> manyConcat (2000 ));
309+ assertCircuitBreaks (() -> manyConcat ("FROM manylongs" , 2000 ));
310+ }
311+
312+ /**
313+ * Returns many moderately long strings.
314+ */
315+ public void testManyConcatFromRow () throws IOException {
316+ int strings = 2000 ;
317+ Response resp = manyConcat ("ROW a=9999, b=9999, c=9999, d=9999, e=9999" , strings );
318+ assertManyStrings (resp , strings );
315319 }
316320
317321 /**
318322 * Tests that generate many moderately long strings.
319323 */
320- private Response manyConcat (int strings ) throws IOException {
324+ private Response manyConcat (String init , int strings ) throws IOException {
321325 StringBuilder query = startQuery ();
322- query .append ("FROM manylongs | EVAL str = CONCAT(" );
326+ query .append (init ). append ( " | EVAL str = CONCAT(" );
323327 query .append (
324328 Arrays .stream (new String [] { "a" , "b" , "c" , "d" , "e" })
325329 .map (f -> "TO_STRING(" + f + ")" )
@@ -344,7 +348,64 @@ private Response manyConcat(int strings) throws IOException {
344348 query .append ("str" ).append (s );
345349 }
346350 query .append ("\" }" );
347- return query (query .toString (), null );
351+ return query (query .toString (), "columns" );
352+ }
353+
354+ /**
355+ * Returns many moderately long strings.
356+ */
357+ public void testManyRepeat () throws IOException {
358+ int strings = 30 ;
359+ initManyLongs ();
360+ Response resp = manyRepeat ("FROM manylongs" , strings );
361+ assertManyStrings (resp , 30 );
362+ }
363+
364+ /**
365+ * Hits a circuit breaker by building many moderately long strings.
366+ */
367+ public void testHugeManyRepeat () throws IOException {
368+ initManyLongs ();
369+ assertCircuitBreaks (() -> manyRepeat ("FROM manylongs" , 75 ));
370+ }
371+
372+ /**
373+ * Returns many moderately long strings.
374+ */
375+ public void testManyRepeatFromRow () throws IOException {
376+ int strings = 10000 ;
377+ Response resp = manyRepeat ("ROW a = 99" , strings );
378+ assertManyStrings (resp , strings );
379+ }
380+
381+ /**
382+ * Tests that generate many moderately long strings.
383+ */
384+ private Response manyRepeat (String init , int strings ) throws IOException {
385+ StringBuilder query = startQuery ();
386+ query .append (init ).append (" | EVAL str = TO_STRING(a)" );
387+ for (int s = 0 ; s < strings ; s ++) {
388+ query .append (",\n str" ).append (s ).append ("=REPEAT(str, 10000)" );
389+ }
390+ query .append ("\n |KEEP " );
391+ for (int s = 0 ; s < strings ; s ++) {
392+ if (s != 0 ) {
393+ query .append (", " );
394+ }
395+ query .append ("str" ).append (s );
396+ }
397+ query .append ("\" }" );
398+ return query (query .toString (), "columns" );
399+ }
400+
401+ private void assertManyStrings (Response resp , int strings ) throws IOException {
402+ Map <?, ?> map = responseAsMap (resp );
403+ ListMatcher columns = matchesList ();
404+ for (int s = 0 ; s < strings ; s ++) {
405+ columns = columns .item (matchesMap ().entry ("name" , "str" + s ).entry ("type" , "keyword" ));
406+ }
407+ MapMatcher mapMatcher = matchesMap ();
408+ assertMap (map , mapMatcher .entry ("columns" , columns ));
348409 }
349410
350411 public void testManyEval () throws IOException {
0 commit comments