@@ -249,38 +249,23 @@ public void testFollowIndexWithConcurrentMappingChanges() throws Exception {
249
249
final int firstBatchNumDocs = randomIntBetween (2 , 64 );
250
250
logger .info ("Indexing [{}] docs as first batch" , firstBatchNumDocs );
251
251
for (int i = 0 ; i < firstBatchNumDocs ; i ++) {
252
- final String source = String .format (Locale .ROOT , "{\" f\" :%d}" , i );
253
- leaderClient ().prepareIndex ("index1" , "doc" , Integer .toString (i )).setSource (source , XContentType .JSON ).get ();
252
+ leaderClient ().prepareIndex ("index1" , "_doc" ).setId (Integer .toString (i )).setSource ("f" , i ).get ();
254
253
}
255
254
256
255
AtomicBoolean isRunning = new AtomicBoolean (true );
257
256
258
257
// Concurrently index new docs with mapping changes
258
+ int numFields = between (10 , 20 );
259
259
Thread thread = new Thread (() -> {
260
- int docID = 10000 ;
261
- char [] chars = "abcdeghijklmnopqrstuvwxyz" .toCharArray ();
262
- for (char c : chars ) {
260
+ int numDocs = between (10 , 200 );
261
+ for (int i = 0 ; i < numDocs ; i ++) {
263
262
if (isRunning .get () == false ) {
264
263
break ;
265
264
}
266
- final String source ;
267
- long valueToPutInDoc = randomLongBetween (0 , 50000 );
268
- if (randomBoolean ()) {
269
- source = String .format (Locale .ROOT , "{\" %c\" :%d}" , c , valueToPutInDoc );
270
- } else {
271
- source = String .format (Locale .ROOT , "{\" %c\" :\" %d\" }" , c , valueToPutInDoc );
272
- }
273
- for (int i = 1 ; i < 10 ; i ++) {
274
- if (isRunning .get () == false ) {
275
- break ;
276
- }
277
- leaderClient ().prepareIndex ("index1" , "doc" , Long .toString (docID ++)).setSource (source , XContentType .JSON ).get ();
278
- if (rarely ()) {
279
- leaderClient ().admin ().indices ().prepareFlush ("index1" ).setForce (true ).get ();
280
- }
281
- }
282
- if (between (0 , 100 ) < 20 ) {
283
- leaderClient ().admin ().indices ().prepareFlush ("index1" ).setForce (false ).setWaitIfOngoing (false ).get ();
265
+ final String field = "f-" + between (1 , numFields );
266
+ leaderClient ().prepareIndex ("index1" , "_doc" ).setSource (field , between (0 , 1000 )).get ();
267
+ if (rarely ()) {
268
+ leaderClient ().admin ().indices ().prepareFlush ("index1" ).setWaitIfOngoing (false ).setForce (false ).get ();
284
269
}
285
270
}
286
271
});
@@ -298,16 +283,14 @@ public void testFollowIndexWithConcurrentMappingChanges() throws Exception {
298
283
final int secondBatchNumDocs = randomIntBetween (2 , 64 );
299
284
logger .info ("Indexing [{}] docs as second batch" , secondBatchNumDocs );
300
285
for (int i = firstBatchNumDocs ; i < firstBatchNumDocs + secondBatchNumDocs ; i ++) {
301
- final String source = String .format (Locale .ROOT , "{\" f\" :%d}" , i );
302
- leaderClient ().prepareIndex ("index1" , "doc" , Integer .toString (i )).setSource (source , XContentType .JSON ).get ();
286
+ leaderClient ().prepareIndex ("index1" , "_doc" ).setId (Integer .toString (i )).setSource ("f" , i ).get ();
303
287
}
304
-
305
- for (int i = firstBatchNumDocs ; i < firstBatchNumDocs + secondBatchNumDocs ; i ++) {
288
+ for (int i = 0 ; i < firstBatchNumDocs + secondBatchNumDocs ; i ++) {
306
289
assertBusy (assertExpectedDocumentRunnable (i ), 1 , TimeUnit .MINUTES );
307
290
}
308
-
309
291
isRunning .set (false );
310
292
thread .join ();
293
+ assertIndexFullyReplicatedToFollower ("index1" , "index2" );
311
294
}
312
295
313
296
public void testFollowIndexWithoutWaitForComplete () throws Exception {
0 commit comments