Skip to content

Commit eeea3d7

Browse files
authored
Convert ingest-geoip file based update tests to new testing framework (#125632) (#125700)
1 parent 3dc0f25 commit eeea3d7

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

modules/ingest-geoip/qa/file-based-update/build.gradle

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,8 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
apply plugin: 'elasticsearch.legacy-java-rest-test'
10+
apply plugin: 'elasticsearch.internal-java-rest-test'
1111

12-
testClusters.configureEach {
13-
testDistribution = 'DEFAULT'
14-
setting 'resource.reload.interval.high', '100ms'
15-
setting 'xpack.security.enabled', 'true'
16-
user username: 'admin', password: 'admin-password', role: 'superuser'
17-
}
18-
19-
tasks.named("javaRestTest").configure {
20-
systemProperty 'tests.security.manager', 'false' // Allows the test the add databases to config directory.
21-
nonInputProperties.systemProperty 'tests.config.dir', testClusters.named("javaRestTest").map(c -> c.singleNode().getConfigDir())
22-
}
23-
24-
tasks.named("forbiddenPatterns").configure {
25-
exclude '**/*.mmdb'
12+
dependencies {
13+
clusterModules project(':modules:ingest-geoip')
2614
}

modules/ingest-geoip/qa/file-based-update/src/javaRestTest/java/org/elasticsearch/ingest/geoip/UpdateDatabasesIT.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
package org.elasticsearch.ingest.geoip;
1010

1111
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;
1613
import org.elasticsearch.test.rest.ESRestTestCase;
1714
import org.elasticsearch.xcontent.ObjectPath;
15+
import org.junit.ClassRule;
16+
import org.junit.rules.RuleChain;
17+
import org.junit.rules.TemporaryFolder;
1818

1919
import java.io.IOException;
2020
import java.nio.file.Files;
@@ -29,6 +29,16 @@
2929
import static org.hamcrest.Matchers.nullValue;
3030

3131
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);
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

Comments
 (0)