@@ -249,38 +249,23 @@ public void testFollowIndexWithConcurrentMappingChanges() throws Exception {
249249 final int firstBatchNumDocs = randomIntBetween (2 , 64 );
250250 logger .info ("Indexing [{}] docs as first batch" , firstBatchNumDocs );
251251 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 ();
254253 }
255254
256255 AtomicBoolean isRunning = new AtomicBoolean (true );
257256
258257 // Concurrently index new docs with mapping changes
258+ int numFields = between (10 , 20 );
259259 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 ++) {
263262 if (isRunning .get () == false ) {
264263 break ;
265264 }
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 ();
284269 }
285270 }
286271 });
@@ -298,16 +283,14 @@ public void testFollowIndexWithConcurrentMappingChanges() throws Exception {
298283 final int secondBatchNumDocs = randomIntBetween (2 , 64 );
299284 logger .info ("Indexing [{}] docs as second batch" , secondBatchNumDocs );
300285 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 ();
303287 }
304-
305- for (int i = firstBatchNumDocs ; i < firstBatchNumDocs + secondBatchNumDocs ; i ++) {
288+ for (int i = 0 ; i < firstBatchNumDocs + secondBatchNumDocs ; i ++) {
306289 assertBusy (assertExpectedDocumentRunnable (i ), 1 , TimeUnit .MINUTES );
307290 }
308-
309291 isRunning .set (false );
310292 thread .join ();
293+ assertIndexFullyReplicatedToFollower ("index1" , "index2" );
311294 }
312295
313296 public void testFollowIndexWithoutWaitForComplete () throws Exception {
0 commit comments