99package org .elasticsearch .ingest .geoip ;
1010
1111import org .elasticsearch .client .Request ;
12- import org .elasticsearch .common .settings .SecureString ;
13- import org .elasticsearch .common .settings .Settings ;
14- import org .elasticsearch .common .util .concurrent .ThreadContext ;
15- import org .elasticsearch .core .PathUtils ;
12+ import org .elasticsearch .test .cluster .ElasticsearchCluster ;
1613import org .elasticsearch .test .rest .ESRestTestCase ;
1714import org .elasticsearch .xcontent .ObjectPath ;
15+ import org .junit .ClassRule ;
16+ import org .junit .rules .RuleChain ;
17+ import org .junit .rules .TemporaryFolder ;
1818
1919import java .io .IOException ;
2020import java .nio .file .Files ;
2929import static org .hamcrest .Matchers .nullValue ;
3030
3131public class UpdateDatabasesIT extends ESRestTestCase {
32+ public static TemporaryFolder configDir = new TemporaryFolder ();
33+
34+ public static ElasticsearchCluster cluster = ElasticsearchCluster .local ()
35+ .module ("ingest-geoip" )
36+ .withConfigDir (() -> configDir .getRoot ().toPath ())
37+ .setting ("resource.reload.interval.high" , "100ms" )
38+ .build ();
39+
40+ @ ClassRule
41+ public static RuleChain ruleChain = RuleChain .outerRule (configDir ).around (cluster );
3242
3343 public void test () throws Exception {
3444 String body = """
@@ -51,7 +61,7 @@ public void test() throws Exception {
5161 assertThat (stats , nullValue ());
5262 }
5363
54- Path configPath = PathUtils . get ( System . getProperty ( "tests.config.dir" ) );
64+ Path configPath = configDir . getRoot (). toPath ( );
5565 assertThat (Files .exists (configPath ), is (true ));
5666 Path ingestGeoipDatabaseDir = configPath .resolve ("ingest-geoip" );
5767 Files .createDirectory (ingestGeoipDatabaseDir );
@@ -82,9 +92,7 @@ public void test() throws Exception {
8292 }
8393
8494 @ Override
85- protected Settings restClientSettings () {
86- String token = basicAuthHeaderValue ("admin" , new SecureString ("admin-password" .toCharArray ()));
87- return Settings .builder ().put (ThreadContext .PREFIX + ".Authorization" , token ).build ();
95+ protected String getTestRestCluster () {
96+ return cluster .getHttpAddresses ();
8897 }
89-
9098}
0 commit comments