Skip to content

Commit e8c6cdd

Browse files
committed
Add a test of the new behavior
1 parent e448ea7 commit e8c6cdd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorFactoryTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ public void testDatabaseNotReadyYet() throws Exception {
549549
Map<String, Object> config = new HashMap<>();
550550
config.put("field", "source_field");
551551
config.put("database_file", "GeoLite2-City.mmdb");
552+
config.put("ignore_missing", true);
552553

553554
GeoIpProcessor.DatabaseUnavailableProcessor processor = (GeoIpProcessor.DatabaseUnavailableProcessor) factory.create(
554555
null,
@@ -565,6 +566,13 @@ public void testDatabaseNotReadyYet() throws Exception {
565566
assertThat(document.getSourceAndMetadata().get("geoip"), nullValue());
566567
assertThat(document.getSourceAndMetadata().get("tags"), equalTo(List.of("_geoip_database_unavailable_GeoLite2-City.mmdb")));
567568
}
569+
{
570+
// if there's no value for the source_field and ignore_missing is true, then we don't tag the document
571+
document = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); // note: no source_field
572+
processor.execute(document);
573+
assertThat(document.getSourceAndMetadata().get("geoip"), nullValue());
574+
assertThat(document.getSourceAndMetadata().get("tags"), nullValue());
575+
}
568576
}
569577

570578
copyDatabase("GeoLite2-City-Test.mmdb", geoipTmpDir);

0 commit comments

Comments
 (0)