3131import org .elasticsearch .plugins .Plugin ;
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 ;
6663import static org .hamcrest .Matchers .equalTo ;
6764import static org .hamcrest .Matchers .is ;
6865
69- @ ClusterScope (scope = Scope .TEST , maxNumDataNodes = 1 )
7066public class GeoIpDownloaderIT extends AbstractGeoIpIT {
7167
7268 private static final String ENDPOINT = System .getProperty ("geoip_endpoint" );
@@ -89,7 +85,7 @@ protected Settings nodeSettings(int nodeOrdinal) {
8985 public void disableDownloader () {
9086 ClusterUpdateSettingsResponse settingsResponse = client ().admin ().cluster ()
9187 .prepareUpdateSettings ()
92- .setPersistentSettings (Settings .builder ().put (GeoIpDownloaderTaskExecutor .ENABLED_SETTING .getKey (), false ))
88+ .setPersistentSettings (Settings .builder ().put (GeoIpDownloaderTaskExecutor .ENABLED_SETTING .getKey (), ( String ) null ))
9389 .get ();
9490 assertTrue (settingsResponse .isAcknowledged ());
9591 }
@@ -236,19 +232,13 @@ public void testUseGeoIpProcessorWithDownloadedDBs() throws Exception {
236232 final Set <String > ids = StreamSupport .stream (clusterService ().state ().nodes ().getDataNodes ().values ().spliterator (), false )
237233 .map (c -> c .value .getId ())
238234 .collect (Collectors .toSet ());
239- final List <Path > geoipTmpDirs = StreamSupport .stream (internalCluster ().getDataNodeInstances (Environment .class ).spliterator (), false )
240- .map (env -> {
241- Path geoipTmpDir = env .tmpFile ().resolve ("geoip-databases" );
242- assertThat (Files .exists (geoipTmpDir ), is (true ));
243- return geoipTmpDir ;
244- }).flatMap (path -> {
245- try {
246- return Files .list (path );
247- } catch (IOException e ) {
248- throw new UncheckedIOException (e );
249- }
250- }).filter (path -> ids .contains (path .getFileName ().toString ()))
251- .collect (Collectors .toList ());
235+ // All nodes share the same geoip base dir in the shared tmp dir:
236+ Path geoipBaseTmpDir = internalCluster ().getDataNodeInstance (Environment .class ).tmpFile ().resolve ("geoip-databases" );
237+ assertThat (Files .exists (geoipBaseTmpDir ), is (true ));
238+ final List <Path > geoipTmpDirs ;
239+ try (Stream <Path > files = Files .list (geoipBaseTmpDir )) {
240+ geoipTmpDirs = files .filter (path -> ids .contains (path .getFileName ().toString ())).collect (Collectors .toList ());
241+ }
252242 assertThat (geoipTmpDirs .size (), equalTo (internalCluster ().numDataNodes ()));
253243 assertBusy (() -> {
254244 for (Path geoipTmpDir : geoipTmpDirs ) {
0 commit comments