Skip to content

Commit

Permalink
Make GeoIpDownloaderIT.testInvalidTimestamp more robust (elastic#75330)
Browse files Browse the repository at this point in the history
This change adds additional assertion in GeoIpDownloaderIT.testInvalidTimestamp which makes sure that validity checks work both ways (so going out of validity and back) and it should fix race in cleanUp method leading to occasional failures.

Closes elastic#75221
Closes elastic#74358
  • Loading branch information
probakowski authored and elasticsearchmachine committed Jul 14, 2021
1 parent 4e182b9 commit 046ef17
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
Expand All @@ -78,9 +79,9 @@ public void cleanUp() {
ClusterUpdateSettingsResponse settingsResponse = client().admin().cluster()
.prepareUpdateSettings()
.setPersistentSettings(Settings.builder()
.put(GeoIpDownloaderTaskExecutor.ENABLED_SETTING.getKey(), (String) null)
.put(GeoIpDownloader.POLL_INTERVAL_SETTING.getKey(), (String) null)
.put("ingest.geoip.database_validity", (String) null))
.putNull(GeoIpDownloaderTaskExecutor.ENABLED_SETTING.getKey())
.putNull(GeoIpDownloader.POLL_INTERVAL_SETTING.getKey())
.putNull("ingest.geoip.database_validity"))
.get();
assertTrue(settingsResponse.isAcknowledged());
}
Expand Down Expand Up @@ -138,6 +139,21 @@ public void testInvalidTimestamp() throws Exception {
assertFalse(result.getIngestDocument().hasField("ip-asn"));
assertFalse(result.getIngestDocument().hasField("ip-country"));
});
settingsResponse =
client().admin().cluster()
.prepareUpdateSettings()
.setPersistentSettings(Settings.builder()
.putNull("ingest.geoip.database_validity"))
.get();
assertTrue(settingsResponse.isAcknowledged());
assertBusy(() -> {
for (Path geoIpTmpDir : geoIpTmpDirs) {
try (Stream<Path> files = Files.list(geoIpTmpDir)) {
Set<String> names = files.map(f -> f.getFileName().toString()).collect(Collectors.toSet());
assertThat(names, hasItems("GeoLite2-ASN.mmdb","GeoLite2-City.mmdb","GeoLite2-Country.mmdb"));
}
}
});
}

public void testUpdatedTimestamp() throws Exception {
Expand Down

0 comments on commit 046ef17

Please sign in to comment.