Skip to content

Commit 5f651a3

Browse files
committed
share yaml test code WIP
1 parent 20955aa commit 5f651a3

File tree

4 files changed

+47
-33
lines changed

4 files changed

+47
-33
lines changed

modules/ingest-geoip/build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,16 @@ tasks.named("dependencyLicenses").configure {
8585
ignoreFile 'elastic-geoip-database-service-agreement-LICENSE.txt'
8686
}
8787

88+
configurations {
89+
yamlRestImplementation {
90+
attributes {
91+
attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.JVM_CLASS_DIRECTORY)
92+
}
93+
}
94+
}
95+
8896
artifacts {
97+
yamlRestImplementation(new File(projectDir, "src/yamlRestTest/java"))
8998
restTests(new File(projectDir, "src/yamlRestTest/resources/rest-api-spec/test"))
9099
}
91100

modules/ingest-geoip/qa/multi-project/build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@
99

1010
apply plugin: 'elasticsearch.internal-java-rest-test'
1111
apply plugin: 'elasticsearch.internal-yaml-rest-test'
12-
apply plugin: 'elasticsearch.yaml-rest-compat-test'
12+
//apply plugin: 'elasticsearch.yaml-rest-compat-test'
1313

1414
dependencies {
15+
yamlRestTestImplementation project(path: ':modules:ingest-geoip', configuration: 'yamlRestImplementation')
1516
javaRestTestImplementation project(':modules:ingest-geoip')
1617
javaRestTestImplementation project(':test:external-modules:test-multi-project')
1718
javaRestTestImplementation project(':test:fixtures:geoip-fixture')
1819

20+
// testImplementation project(':modules:ingest-geoip')
1921
yamlRestTestImplementation project(':modules:ingest-geoip')
22+
23+
// yamlRestTestImplementation(testArtifact(project(":modules:ingest-geoip")))
2024
yamlRestTestImplementation project(':test:external-modules:test-multi-project')
2125
yamlRestTestImplementation project(':test:fixtures:geoip-fixture')
2226
yamlRestTestImplementation project(':x-pack:qa:multi-project:yaml-test-framework')

modules/ingest-geoip/qa/multi-project/src/yamlRestTest/java/org/elasticsearch/ingest/geoip/IngestGeoIpClientMultiProjectYamlTestSuiteIT.java

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import static org.hamcrest.Matchers.containsInAnyOrder;
3939
import static org.hamcrest.Matchers.equalTo;
4040
import static org.hamcrest.Matchers.notNullValue;
41+
import static org.elasticsearch.ingest.geoip.IngestGeoIpClientYamlTestSuiteIT.putGeoipPipeline;
4142

4243
public class IngestGeoIpClientMultiProjectYamlTestSuiteIT extends MultipleProjectsClientYamlSuiteTestCase {
4344

@@ -79,7 +80,7 @@ public static Iterable<Object[]> parameters() throws Exception {
7980

8081
@Before
8182
public void waitForDatabases() throws Exception {
82-
putGeoipPipeline();
83+
putGeoIpPipeline();
8384
assertBusy(() -> {
8485
Request request = new Request("GET", "/_ingest/geoip/stats");
8586
Map<String, Object> response = entityAsMap(client().performRequest(request));
@@ -104,33 +105,33 @@ public void waitForDatabases() throws Exception {
104105
* This creates a pipeline with a geoip processor so that the GeoipDownloader will download its databases.
105106
* @throws IOException
106107
*/
107-
private void putGeoipPipeline() throws IOException {
108-
final BytesReference bytes;
109-
try (XContentBuilder builder = JsonXContent.contentBuilder()) {
110-
builder.startObject();
111-
{
112-
builder.startArray("processors");
113-
{
114-
builder.startObject();
115-
{
116-
builder.startObject("geoip");
117-
{
118-
builder.field("field", "ip");
119-
builder.field("target_field", "ip-city");
120-
builder.field("database_file", "GeoLite2-City.mmdb");
121-
}
122-
builder.endObject();
123-
}
124-
builder.endObject();
125-
}
126-
builder.endArray();
127-
}
128-
builder.endObject();
129-
bytes = BytesReference.bytes(builder);
130-
}
131-
Request putPipelineRequest = new Request("PUT", "/_ingest/pipeline/pipeline-with-geoip");
132-
putPipelineRequest.setEntity(new ByteArrayEntity(bytes.array(), ContentType.APPLICATION_JSON));
133-
client().performRequest(putPipelineRequest);
134-
}
108+
// private void putGeoipPipeline() throws IOException {
109+
// final BytesReference bytes;
110+
// try (XContentBuilder builder = JsonXContent.contentBuilder()) {
111+
// builder.startObject();
112+
// {
113+
// builder.startArray("processors");
114+
// {
115+
// builder.startObject();
116+
// {
117+
// builder.startObject("geoip");
118+
// {
119+
// builder.field("field", "ip");
120+
// builder.field("target_field", "ip-city");
121+
// builder.field("database_file", "GeoLite2-City.mmdb");
122+
// }
123+
// builder.endObject();
124+
// }
125+
// builder.endObject();
126+
// }
127+
// builder.endArray();
128+
// }
129+
// builder.endObject();
130+
// bytes = BytesReference.bytes(builder);
131+
// }
132+
// Request putPipelineRequest = new Request("PUT", "/_ingest/pipeline/pipeline-with-geoip");
133+
// putPipelineRequest.setEntity(new ByteArrayEntity(bytes.array(), ContentType.APPLICATION_JSON));
134+
// client().performRequest(putPipelineRequest);
135+
// }
135136

136137
}

modules/ingest-geoip/src/yamlRestTest/java/org/elasticsearch/ingest/geoip/IngestGeoIpClientYamlTestSuiteIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ public void waitForDatabases() throws Exception {
7878
assertBusy(() -> {
7979
Request request = new Request("GET", "/_ingest/geoip/stats");
8080
Map<String, Object> response = entityAsMap(client().performRequest(request));
81-
81+
// assert databases are downloaded
8282
Map<?, ?> downloadStats = (Map<?, ?>) response.get("stats");
8383
assertThat(downloadStats.get("databases_count"), equalTo(4));
84-
84+
// assert databases are loaded to node
8585
Map<?, ?> nodes = (Map<?, ?>) response.get("nodes");
8686
assertThat(nodes.size(), equalTo(1));
8787
Map<?, ?> node = (Map<?, ?>) nodes.values().iterator().next();
@@ -99,7 +99,7 @@ public void waitForDatabases() throws Exception {
9999
* This creates a pipeline with a geoip processor so that the GeoipDownloader will download its databases.
100100
* @throws IOException
101101
*/
102-
private void putGeoipPipeline() throws IOException {
102+
public static void putGeoipPipeline() throws IOException {
103103
final BytesReference bytes;
104104
try (XContentBuilder builder = JsonXContent.contentBuilder()) {
105105
builder.startObject();

0 commit comments

Comments
 (0)