3131import org .elasticsearch .persistent .PersistentTasksCustomMetadata ;
3232import org .elasticsearch .search .SearchHit ;
3333import org .elasticsearch .search .sort .SortOrder ;
34- import org .elasticsearch .test .ESIntegTestCase .ClusterScope ;
35- import org .elasticsearch .test .ESIntegTestCase .Scope ;
3634import org .elasticsearch .test .junit .annotations .TestLogging ;
3735import org .junit .After ;
3836
4139import java .io .IOException ;
4240import java .io .InputStream ;
4341import java .io .OutputStream ;
44- import java .io .UncheckedIOException ;
4542import java .nio .file .Files ;
4643import java .nio .file .Path ;
4744import java .util .ArrayList ;
6360import static org .hamcrest .Matchers .equalTo ;
6461import static org .hamcrest .Matchers .is ;
6562
66- @ ClusterScope (scope = Scope .TEST , maxNumDataNodes = 1 )
6763public class GeoIpDownloaderIT extends AbstractGeoIpIT {
6864
6965 private static final String ENDPOINT = System .getProperty ("geoip_endpoint" );
@@ -81,7 +77,7 @@ protected Settings nodeSettings(int nodeOrdinal) {
8177 public void disableDownloader () {
8278 ClusterUpdateSettingsResponse settingsResponse = client ().admin ().cluster ()
8379 .prepareUpdateSettings ()
84- .setPersistentSettings (Settings .builder ().put (GeoIpDownloaderTaskExecutor .ENABLED_SETTING .getKey (), false ))
80+ .setPersistentSettings (Settings .builder ().put (GeoIpDownloaderTaskExecutor .ENABLED_SETTING .getKey (), ( String ) null ))
8581 .get ();
8682 assertTrue (settingsResponse .isAcknowledged ());
8783 }
@@ -233,19 +229,13 @@ public void testUseGeoIpProcessorWithDownloadedDBs() throws Exception {
233229 final java .util .Set <String > ids = StreamSupport .stream (nodes .getDataNodes ().values ().spliterator (), false )
234230 .map (c -> c .value .getId ())
235231 .collect (Collectors .toSet ());
236- final List <Path > geoipTmpDirs = StreamSupport .stream (internalCluster ().getDataNodeInstances (Environment .class ).spliterator (), false )
237- .map (env -> {
238- Path geoipTmpDir = env .tmpFile ().resolve ("geoip-databases" );
239- assertThat (Files .exists (geoipTmpDir ), is (true ));
240- return geoipTmpDir ;
241- }).flatMap (path -> {
242- try {
243- return Files .list (path );
244- } catch (IOException e ) {
245- throw new UncheckedIOException (e );
246- }
247- }).filter (path -> ids .contains (path .getFileName ().toString ()))
248- .collect (Collectors .toList ());
232+ // All nodes share the same geoip base dir in the shared tmp dir:
233+ Path geoipBaseTmpDir = internalCluster ().getDataNodeInstance (Environment .class ).tmpFile ().resolve ("geoip-databases" );
234+ assertThat (Files .exists (geoipBaseTmpDir ), is (true ));
235+ final List <Path > geoipTmpDirs ;
236+ try (Stream <Path > files = Files .list (geoipBaseTmpDir )) {
237+ geoipTmpDirs = files .filter (path -> ids .contains (path .getFileName ().toString ())).collect (Collectors .toList ());
238+ }
249239 assertThat (geoipTmpDirs .size (), equalTo (internalCluster ().numDataNodes ()));
250240 assertBusy (() -> {
251241 for (Path geoipTmpDir : geoipTmpDirs ) {
0 commit comments