@@ -70,31 +70,38 @@ private void testSearchAndRelocateConcurrently(int numberOfReplicas) throws Exce
70
70
}
71
71
indexRandom (true , indexBuilders .toArray (new IndexRequestBuilder [indexBuilders .size ()]));
72
72
assertHitCount (client ().prepareSearch ().get (), (long ) (numDocs ));
73
- final int numIters = atLeast (3 );
73
+ final int numIters = atLeast (10 );
74
74
for (int i = 0 ; i < numIters ; i ++) {
75
- allowNodes ("test" , between (1 , 3 ));
76
- client ().admin ().cluster ().prepareReroute ().get ();
77
75
final AtomicBoolean stop = new AtomicBoolean (false );
78
76
final List <Throwable > thrownExceptions = new CopyOnWriteArrayList <Throwable >();
79
- final Thread t = new Thread () {
80
- public void run () {
81
- try {
82
- while (!stop .get ()) {
83
- SearchResponse sr = client ().prepareSearch ().setSize (numDocs ).get ();
84
- assertHitCount (sr , (long ) (numDocs ));
85
- final SearchHits sh = sr .getHits ();
86
- assertThat ("Expected hits to be the same size the actual hits array" , sh .getTotalHits (),
87
- equalTo ((long ) (sh .getHits ().length )));
77
+ Thread [] threads = new Thread [atLeast (1 )];
78
+ for (int j = 0 ; j < threads .length ; j ++) {
79
+ threads [j ] = new Thread () {
80
+ public void run () {
81
+ try {
82
+ while (!stop .get ()) {
83
+ SearchResponse sr = client ().prepareSearch ().setSize (numDocs ).get ();
84
+ assertHitCount (sr , (long ) (numDocs ));
85
+ final SearchHits sh = sr .getHits ();
86
+ assertThat ("Expected hits to be the same size the actual hits array" , sh .getTotalHits (),
87
+ equalTo ((long ) (sh .getHits ().length )));
88
+ }
89
+ } catch (Throwable t ) {
90
+ thrownExceptions .add (t );
88
91
}
89
- } catch (Throwable t ) {
90
- thrownExceptions .add (t );
91
92
}
92
- }
93
- };
94
- t .start ();
93
+ };
94
+ }
95
+ for (int j = 0 ; j < threads .length ; j ++) {
96
+ threads [j ].start ();
97
+ }
98
+ allowNodes ("test" , between (1 , 3 ));
99
+ client ().admin ().cluster ().prepareReroute ().get ();
95
100
ClusterHealthResponse resp = client ().admin ().cluster ().prepareHealth ().setWaitForRelocatingShards (0 ).execute ().actionGet ();
96
101
stop .set (true );
97
- t .join ();
102
+ for (int j = 0 ; j < threads .length ; j ++) {
103
+ threads [j ].join ();
104
+ }
98
105
assertThat (resp .isTimedOut (), equalTo (false ));
99
106
100
107
if (!thrownExceptions .isEmpty ()) {
0 commit comments