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+ .build ();
38+
39+ @ ClassRule
40+ public static RuleChain ruleChain = RuleChain .outerRule (configDir ).around (cluster );
3241
3342 public void test () throws Exception {
3443 String body = """
@@ -51,7 +60,7 @@ public void test() throws Exception {
5160 assertThat (stats , nullValue ());
5261 }
5362
54- Path configPath = PathUtils . get ( System . getProperty ( "tests.config.dir" ) );
63+ Path configPath = configDir . getRoot (). toPath ( );
5564 assertThat (Files .exists (configPath ), is (true ));
5665 Path ingestGeoipDatabaseDir = configPath .resolve ("ingest-geoip" );
5766 Files .createDirectory (ingestGeoipDatabaseDir );
@@ -82,9 +91,7 @@ public void test() throws Exception {
8291 }
8392
8493 @ 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 ();
94+ protected String getTestRestCluster () {
95+ return cluster .getHttpAddresses ();
8896 }
89-
9097}
0 commit comments