Skip to content
This repository was archived by the owner on Oct 29, 2023. It is now read-only.

Commit 26caa8e

Browse files
committed
Update to Elasticsearch 7.14.0
1 parent ed9dbb7 commit 26caa8e

File tree

4 files changed

+117
-17
lines changed

4 files changed

+117
-17
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Note that Elasticsearch has native support for langdetection nowadays using the
1010

1111
| ES | Command |
1212
| ----- | ------- |
13+
| 7.14.0 | `bin/elasticsearch-plugin install https://github.com/spinscale/elasticsearch-ingest-langdetect/releases/download/7.14.0.1/ingest-langdetect-7.14.0.1.zip` |
1314
| 7.13.4 | `bin/elasticsearch-plugin install https://github.com/spinscale/elasticsearch-ingest-langdetect/releases/download/7.13.4.1/ingest-langdetect-7.13.4.1.zip` |
1415
| 7.13.3 | `bin/elasticsearch-plugin install https://github.com/spinscale/elasticsearch-ingest-langdetect/releases/download/7.13.3.1/ingest-langdetect-7.13.3.1.zip` |
1516
| 7.13.2 | `bin/elasticsearch-plugin install https://github.com/spinscale/elasticsearch-ingest-langdetect/releases/download/7.13.2.1/ingest-langdetect-7.13.2.1.zip` |

build.gradle

Lines changed: 109 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
import java.nio.file.Files
2+
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
3+
import org.gradle.api.tasks.Input;
4+
import org.gradle.process.CommandLineArgumentProvider;
5+
6+
import java.util.LinkedHashMap;
7+
import java.util.Map;
8+
import java.util.function.Supplier;
9+
import java.util.stream.Collectors;
210

311
buildscript {
412
dependencies {
@@ -22,31 +30,22 @@ version = "${elasticsearchVersion}.1-SNAPSHOT"
2230
apply plugin: 'java'
2331
apply plugin: 'idea'
2432
apply plugin: 'elasticsearch.esplugin'
25-
apply plugin: 'elasticsearch.yaml-rest-test'
26-
27-
// license of this project
28-
licenseFile = rootProject.file('LICENSE.txt')
29-
// copyright notices
30-
noticeFile = rootProject.file('NOTICE.txt')
33+
apply plugin: 'elasticsearch.testclusters'
3134

3235
esplugin {
33-
name 'ingest-langdetect'
34-
description 'Ingest processor doing language detection for fields'
35-
classname 'org.elasticsearch.plugin.ingest.langdetect.IngestLangDetectPlugin'
36-
// license of the plugin, may be different than the above license
37-
licenseFile rootProject.file('LICENSE.txt')
38-
// copyright notices, may be different than the above notice
39-
noticeFile rootProject.file('NOTICE.txt')
36+
name = 'ingest-langdetect'
37+
description = 'Ingest processor doing language detection for fields'
38+
classname = 'org.elasticsearch.plugin.ingest.langdetect.IngestLangDetectPlugin'
39+
licenseFile = rootProject.file('LICENSE.txt')
40+
noticeFile = rootProject.file('NOTICE.txt')
4041
}
4142

42-
validateElasticPom.enabled = false
43-
4443
// In this section you declare the dependencies for your production and test code
4544
dependencies {
4645
implementation 'com.youcruit.com.cybozu.labs:langdetect:1.1.2-20151117'
4746
implementation 'net.arnx:jsonic:1.3.10'
4847
// the yaml tests require a log4j2 dependency, otherwise a dependency is thrown on startup
49-
yamlRestTestImplementation 'org.apache.logging.log4j:log4j-core:2.11.1'
48+
runtimeOnly 'org.apache.logging.log4j:log4j-core:2.11.1'
5049
}
5150

5251
// ignore javadoc warnings for now
@@ -76,3 +75,97 @@ githubRelease.doFirst {
7675
assets = [ filename ]
7776
}
7877
}
78+
79+
80+
// setup yaml rest tests
81+
testClusters {
82+
yamlRestTest
83+
}
84+
85+
sourceSets {
86+
yamlRestTest
87+
}
88+
89+
configurations {
90+
yamlRestTestImplementation.extendsFrom testImplementation
91+
yamlRestTestRuntimeOnly.extendsFrom testRuntimeOnly
92+
restTestSpecs
93+
}
94+
95+
tasks.register('copyRestTestSpecs', Copy) {
96+
from zipTree(configurations.restTestSpecs.singleFile)
97+
into "$buildDir/restResources/restspec"
98+
}
99+
100+
TaskProvider<Zip> bundle = project.getTasks().withType(Zip.class).named("bundlePlugin");
101+
102+
// Register rest resources with source set
103+
sourceSets.yamlRestTest.getOutput().dir("$buildDir/restResources/restspec");
104+
105+
tasks.register('yamlRestTest', StandaloneRestIntegTestTask) { testTask ->
106+
testTask.dependsOn(bundle, 'copyRestTestSpecs')
107+
108+
def cluster = testClusters.yamlRestTest
109+
cluster.plugin(bundle.flatMap(AbstractArchiveTask::getArchiveFile))
110+
testTask.useCluster(testClusters.yamlRestTest)
111+
112+
testTask.mustRunAfter(project.getTasks().named("test"))
113+
testTask.setTestClassesDirs(sourceSets.yamlRestTest.getOutput().getClassesDirs())
114+
testTask.setClasspath(sourceSets.yamlRestTest.getRuntimeClasspath())
115+
116+
117+
SystemPropertyCommandLineArgumentProvider nonInputProperties = new SystemPropertyCommandLineArgumentProvider()
118+
nonInputProperties.systemProperty("tests.rest.cluster", "${-> String.join(",", cluster.getAllHttpSocketURI())}")
119+
nonInputProperties.systemProperty("tests.cluster", "${-> String.join(",", cluster.getAllTransportPortURI())}")
120+
nonInputProperties.systemProperty("tests.clustername", "${-> cluster.getName()}")
121+
testTask.getJvmArgumentProviders().add(nonInputProperties)
122+
testTask.systemProperty("tests.rest.load_packaged", Boolean.FALSE.toString())
123+
}
124+
125+
// this is a bit of a hack to make sure we run the test tests when releasing...
126+
check.dependsOn 'yamlRestTest'
127+
128+
dependencies {
129+
yamlRestTestImplementation "org.elasticsearch.test:framework:$elasticsearchVersion"
130+
restTestSpecs "org.elasticsearch:rest-api-spec:$elasticsearchVersion"
131+
}
132+
133+
// remove when 7.14.1 is released
134+
tasks.withType(Test).configureEach { testTask ->
135+
testTask.systemProperties 'gradle.dist.lib': "${gradle.gradleHomeDir}/lib",
136+
'gradle.worker.jar': "${gradle.gradleUserHomeDir}/caches/${gradle.gradleVersion}/workerMain/gradle-worker.jar",
137+
'tests.gradle': 'true',
138+
'tests.task': testTask.path
139+
}
140+
141+
// This will be available in 7.15 in build tools and not manually declared.
142+
public class SystemPropertyCommandLineArgumentProvider implements CommandLineArgumentProvider {
143+
private final Map<String, Object> systemProperties = new LinkedHashMap<>();
144+
145+
public void systemProperty(String key, Supplier<String> value) {
146+
systemProperties.put(key, value);
147+
}
148+
149+
public void systemProperty(String key, Object value) {
150+
systemProperties.put(key, value);
151+
}
152+
153+
@Override
154+
public Iterable<String> asArguments() {
155+
return systemProperties.entrySet()
156+
.stream()
157+
.map(
158+
entry -> "-D"
159+
+ entry.getKey()
160+
+ "="
161+
+ (entry.getValue() instanceof Supplier ? ((Supplier) entry.getValue()).get() : entry.getValue())
162+
)
163+
.collect(Collectors.toList());
164+
}
165+
166+
// Track system property keys as an input so our build cache key will change if we add properties but values are still ignored
167+
@Input
168+
public Iterable<String> getPropertyNames() {
169+
return systemProperties.keySet();
170+
}
171+
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
elasticsearchVersion = 7.13.4
1+
elasticsearchVersion = 7.14.0

src/test/java/org/elasticsearch/plugin/ingest/langdetect/LangDetectProcessorTests.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.elasticsearch.ingest.Processor;
2626
import org.elasticsearch.ingest.RandomDocumentPicks;
2727
import org.elasticsearch.test.ESTestCase;
28+
import org.junit.AfterClass;
2829
import org.junit.BeforeClass;
2930

3031
import java.util.Collections;
@@ -44,6 +45,11 @@ public static void loadProfiles() throws Exception {
4445
SecureDetectorFactory.loadProfileFromClassPath(environment);
4546
}
4647

48+
@AfterClass
49+
public static void done() {
50+
System.out.println("DONE");
51+
}
52+
4753
public void testThatProcessorWorks() throws Exception {
4854
Map<String, Object> data = ingestDocument(config("source_field", "language", false),
4955
"source_field", "This is hopefully an english text, that will be detected.");

0 commit comments

Comments
 (0)