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