9
9
package org .elasticsearch .ingest .geoip ;
10
10
11
11
import 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 ;
16
13
import org .elasticsearch .test .rest .ESRestTestCase ;
17
14
import org .elasticsearch .xcontent .ObjectPath ;
15
+ import org .junit .ClassRule ;
16
+ import org .junit .rules .RuleChain ;
17
+ import org .junit .rules .TemporaryFolder ;
18
18
19
19
import java .io .IOException ;
20
20
import java .nio .file .Files ;
29
29
import static org .hamcrest .Matchers .nullValue ;
30
30
31
31
public 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 );
32
42
33
43
public void test () throws Exception {
34
44
String body = """
@@ -51,7 +61,7 @@ public void test() throws Exception {
51
61
assertThat (stats , nullValue ());
52
62
}
53
63
54
- Path configPath = PathUtils . get ( System . getProperty ( "tests.config.dir" ) );
64
+ Path configPath = configDir . getRoot (). toPath ( );
55
65
assertThat (Files .exists (configPath ), is (true ));
56
66
Path ingestGeoipDatabaseDir = configPath .resolve ("ingest-geoip" );
57
67
Files .createDirectory (ingestGeoipDatabaseDir );
@@ -82,9 +92,7 @@ public void test() throws Exception {
82
92
}
83
93
84
94
@ 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 ();
88
97
}
89
-
90
98
}
0 commit comments