@@ -294,31 +294,30 @@ public void testDoNotDownloadDatabaseOnPipelineCreation() throws Exception {
294294
295295 // Enabling the downloader.
296296 updateClusterSettings (Settings .builder ().put (GeoIpDownloaderTaskExecutor .ENABLED_SETTING .getKey (), true ));
297+ assertBusy (() -> assertNotNull (getTask ()));
297298
298299 // Creating a pipeline containing a geo processor with lazy download enable.
299300 // Download should not be triggered and task state should stay null.
300301 putGeoIpPipeline (pipelineId , false );
301302 assertNull (getTask ().getState ());
302303
303- // Create an index that use the newly created geo pipeline as default pipeline or final pipeline.
304- // This should trigger the database download.
305- Setting <String > pipelineSetting = randomFrom (IndexSettings .FINAL_PIPELINE , IndexSettings .DEFAULT_PIPELINE );
304+ // Creating an index which does not reference the pipeline should not trigger the database download.
306305 String indexIdentifier = randomIdentifier ();
307- assertAcked (
308- client ().admin ()
309- .indices ()
310- .prepareCreate (indexIdentifier )
311- .setSettings (Settings .builder ().put (pipelineSetting .getKey (), pipelineId ))
312- .get ()
313- );
306+ assertAcked (client ().admin ().indices ().prepareCreate (indexIdentifier ).get ());
307+ assertNull (getTask ().getState ());
314308
309+ // Set the pipeline as default_pipeline or final_pipeline for the index.
310+ // This should trigger the database download.
311+ Setting <String > pipelineSetting = randomFrom (IndexSettings .FINAL_PIPELINE , IndexSettings .DEFAULT_PIPELINE );
312+ Settings indexSettings = Settings .builder ().put (pipelineSetting .getKey (), pipelineId ).build ();
313+ assertAcked (client ().admin ().indices ().prepareUpdateSettings (indexIdentifier ).setSettings (indexSettings ).get ());
315314 assertBusy (() -> {
316315 GeoIpTaskState state = getGeoIpTaskState ();
317316 assertEquals (Set .of ("GeoLite2-ASN.mmdb" , "GeoLite2-City.mmdb" , "GeoLite2-Country.mmdb" ), state .getDatabases ().keySet ());
318317 }, 2 , TimeUnit .MINUTES );
319318
320319 // Remove the created index.
321- assertAcked (client ().admin ().indices ().prepareDelete (indexIdentifier ).get ());
320+ // assertAcked(client().admin().indices().prepareDelete(indexIdentifier).get());
322321 }
323322
324323 @ TestLogging (value = "org.elasticsearch.ingest.geoip:TRACE" , reason = "https://github.com/elastic/elasticsearch/issues/69972" )
@@ -512,8 +511,8 @@ private void putGeoIpPipeline(String pipelineId, boolean downloadDatabaseOnPipel
512511 builder .field ("field" , "ip" );
513512 builder .field ("target_field" , "ip-city" );
514513 builder .field ("database_file" , "GeoLite2-City.mmdb" );
515- if (downloadDatabaseOnPipelineCreation ) {
516- builder .field ("download_database_on_pipeline_creation" , true );
514+ if (downloadDatabaseOnPipelineCreation == false || randomBoolean () ) {
515+ builder .field ("download_database_on_pipeline_creation" , downloadDatabaseOnPipelineCreation );
517516 }
518517 }
519518 builder .endObject ();
@@ -526,8 +525,8 @@ private void putGeoIpPipeline(String pipelineId, boolean downloadDatabaseOnPipel
526525 builder .field ("field" , "ip" );
527526 builder .field ("target_field" , "ip-country" );
528527 builder .field ("database_file" , "GeoLite2-Country.mmdb" );
529- if (downloadDatabaseOnPipelineCreation ) {
530- builder .field ("download_database_on_pipeline_creation" , true );
528+ if (downloadDatabaseOnPipelineCreation == false || randomBoolean () ) {
529+ builder .field ("download_database_on_pipeline_creation" , downloadDatabaseOnPipelineCreation );
531530 }
532531 }
533532 builder .endObject ();
0 commit comments