Merge pull request #12091 from clintongormley/plugin_rest_tests

Plugin rest tests for analysis-phonetic, cloud-*, and lang-*
This commit is contained in:
Clinton Gormley 2015-07-07 19:27:17 +02:00
commit 50ec1b1f8e
21 changed files with 451 additions and 2 deletions

View File

@ -15,8 +15,9 @@
<description>The Phonetic Analysis plugin integrates phonetic token filter analysis with elasticsearch.</description>
<properties>
<!-- You can add any specific project property here -->
</properties>
<tests.rest.suite>analysis_phonetic</tests.rest.suite>
<tests.rest.load_packaged>false</tests.rest.load_packaged>
</properties>
<dependencies>
<dependency>

View File

@ -0,0 +1,33 @@
# Integration tests for Phonetic analysis components
#
"Metaphone":
- do:
indices.create:
index: phonetic_sample
body:
settings:
index:
analysis:
analyzer:
my_analyzer:
tokenizer: standard
filter: ["standard", "lowercase", "my_metaphone"]
filter:
my_metaphone:
type: phonetic
encoder: metaphone
replace: false
- do:
indices.analyze:
index: phonetic_sample
analyzer: my_analyzer
text: Joe Bloggs
- length: { tokens: 4 }
- match: { tokens.0.token: J }
- match: { tokens.1.token: joe }
- match: { tokens.2.token: BLKS }
- match: { tokens.3.token: bloggs }

View File

@ -0,0 +1,30 @@
# Integration tests for Phonetic analysis components
#
"Double Metaphone":
- do:
indices.create:
index: phonetic_sample
body:
settings:
index:
analysis:
analyzer:
my_analyzer:
tokenizer: standard
filter: ["standard", "lowercase", "my_metaphone"]
filter:
my_metaphone:
type: phonetic
encoder: double_metaphone
max_code_len: 6
- do:
indices.analyze:
index: phonetic_sample
analyzer: my_analyzer
text: supercalifragilisticexpialidocious
- length: { tokens: 1 }
- match: { tokens.0.token: SPRKLF }

View File

@ -0,0 +1,32 @@
# Integration tests for Phonetic analysis components
#
"Double Metaphone":
- do:
indices.create:
index: phonetic_sample
body:
settings:
index:
analysis:
analyzer:
my_analyzer:
tokenizer: standard
filter: ["standard", "lowercase", "beider_morse"]
filter:
beider_morse:
type: phonetic
encoder: beider_morse
rule_type: exact
name_type: ashkenazi
languageset: polish
- do:
indices.analyze:
index: phonetic_sample
analyzer: my_analyzer
text: Szwarc
- length: { tokens: 1 }
- match: { tokens.0.token: Svarts }

View File

@ -0,0 +1,41 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.index.analysis;
import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.elasticsearch.test.rest.ElasticsearchRestTestCase;
import org.elasticsearch.test.rest.RestTestCandidate;
import org.elasticsearch.test.rest.parser.RestTestParseException;
import java.io.IOException;
public class AnalysisPhoneticRestIT extends ElasticsearchRestTestCase {
public AnalysisPhoneticRestIT(@Name("yaml") RestTestCandidate testCandidate) {
super(testCandidate);
}
@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, RestTestParseException {
return ElasticsearchRestTestCase.createParameters(0, 1);
}
}

View File

@ -17,6 +17,8 @@
<properties>
<amazonaws.version>1.10.0</amazonaws.version>
<tests.jvms>1</tests.jvms>
<tests.rest.suite>cloud_aws</tests.rest.suite>
<tests.rest.load_packaged>false</tests.rest.load_packaged>
</properties>
<dependencies>

View File

@ -0,0 +1,14 @@
# Integration tests for Cloud AWS components
#
"Cloud AWS loaded":
- do:
cluster.state: {}
# Get master node id
- set: { master_node: master }
- do:
nodes.info: {}
- match: { nodes.$master.plugins.0.name: cloud-aws }
- match: { nodes.$master.plugins.0.jvm: true }

View File

@ -0,0 +1,41 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.cloud.aws;
import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.elasticsearch.test.rest.ElasticsearchRestTestCase;
import org.elasticsearch.test.rest.RestTestCandidate;
import org.elasticsearch.test.rest.parser.RestTestParseException;
import java.io.IOException;
public class CloudAWSRestIT extends ElasticsearchRestTestCase {
public CloudAWSRestIT(@Name("yaml") RestTestCandidate testCandidate) {
super(testCandidate);
}
@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, RestTestParseException {
return ElasticsearchRestTestCase.createParameters(0, 1);
}
}

View File

@ -28,6 +28,8 @@ governing permissions and limitations under the License. -->
<properties>
<!-- You can add any specific project property here -->
<tests.jvms>1</tests.jvms>
<tests.rest.suite>cloud_azure</tests.rest.suite>
<tests.rest.load_packaged>false</tests.rest.load_packaged>
</properties>
<dependencies>

View File

@ -0,0 +1,14 @@
# Integration tests for Cloud Azure components
#
"Cloud Azure loaded":
- do:
cluster.state: {}
# Get master node id
- set: { master_node: master }
- do:
nodes.info: {}
- match: { nodes.$master.plugins.0.name: cloud-azure }
- match: { nodes.$master.plugins.0.jvm: true }

View File

@ -0,0 +1,41 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.cloud.azure;
import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.elasticsearch.test.rest.ElasticsearchRestTestCase;
import org.elasticsearch.test.rest.RestTestCandidate;
import org.elasticsearch.test.rest.parser.RestTestParseException;
import java.io.IOException;
public class CloudAzureRestIT extends ElasticsearchRestTestCase {
public CloudAzureRestIT(@Name("yaml") RestTestCandidate testCandidate) {
super(testCandidate);
}
@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, RestTestParseException {
return ElasticsearchRestTestCase.createParameters(0, 1);
}
}

View File

@ -31,6 +31,8 @@ governing permissions and limitations under the License. -->
<!-- currently has no unit tests -->
<tests.ifNoTests>warn</tests.ifNoTests>
<tests.jvms>1</tests.jvms>
<tests.rest.suite>cloud_gce</tests.rest.suite>
<tests.rest.load_packaged>false</tests.rest.load_packaged>
</properties>
<dependencies>

View File

@ -0,0 +1,14 @@
# Integration tests for Cloud GCE components
#
"Cloud GCE loaded":
- do:
cluster.state: {}
# Get master node id
- set: { master_node: master }
- do:
nodes.info: {}
- match: { nodes.$master.plugins.0.name: cloud-gce }
- match: { nodes.$master.plugins.0.jvm: true }

View File

@ -0,0 +1,41 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.cloud.gce;
import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.elasticsearch.test.rest.ElasticsearchRestTestCase;
import org.elasticsearch.test.rest.RestTestCandidate;
import org.elasticsearch.test.rest.parser.RestTestParseException;
import java.io.IOException;
public class CloudGCERestIT extends ElasticsearchRestTestCase {
public CloudGCERestIT(@Name("yaml") RestTestCandidate testCandidate) {
super(testCandidate);
}
@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, RestTestParseException {
return ElasticsearchRestTestCase.createParameters(0, 1);
}
}

View File

@ -16,6 +16,8 @@
<properties>
<!-- You can add any specific project property here -->
<tests.rest.suite>lang_javascript</tests.rest.suite>
<tests.rest.load_packaged>false</tests.rest.load_packaged>
</properties>
<dependencies>

View File

@ -0,0 +1,26 @@
# Integration tests for Lang JavaScript components
#
setup:
- do:
index:
index: test
type: test
id: 1
body: { "foo": "aaa" }
- do:
indices.refresh: {}
---
"Lang JavaScript":
- do:
search:
body:
script_fields:
bar:
lang: javascript
script: "doc['foo'].value + x"
params:
x: "bbb"
- match: { hits.hits.0.fields.bar.0: "aaabbb"}

View File

@ -0,0 +1,41 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.script.javascript;
import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.elasticsearch.test.rest.ElasticsearchRestTestCase;
import org.elasticsearch.test.rest.RestTestCandidate;
import org.elasticsearch.test.rest.parser.RestTestParseException;
import java.io.IOException;
public class LangJavaScriptRestIT extends ElasticsearchRestTestCase {
public LangJavaScriptRestIT(@Name("yaml") RestTestCandidate testCandidate) {
super(testCandidate);
}
@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, RestTestParseException {
return ElasticsearchRestTestCase.createParameters(0, 1);
}
}

View File

@ -16,6 +16,8 @@
<properties>
<!-- You can add any specific project property here -->
<tests.rest.suite>lang_python</tests.rest.suite>
<tests.rest.load_packaged>false</tests.rest.load_packaged>
</properties>
<dependencies>

View File

@ -0,0 +1,26 @@
# Integration tests for Lang Python components
#
setup:
- do:
index:
index: test
type: test
id: 1
body: { "foo": "aaa" }
- do:
indices.refresh: {}
---
"Lang Python":
- do:
search:
body:
script_fields:
bar:
lang: python
script: "doc['foo'].value + x"
params:
x: "bbb"
- match: { hits.hits.0.fields.bar.0: "aaabbb"}

View File

@ -0,0 +1,41 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.script.python;
import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.elasticsearch.test.rest.ElasticsearchRestTestCase;
import org.elasticsearch.test.rest.RestTestCandidate;
import org.elasticsearch.test.rest.parser.RestTestParseException;
import java.io.IOException;
public class LangPythonScriptRestIT extends ElasticsearchRestTestCase {
public LangPythonScriptRestIT(@Name("yaml") RestTestCandidate testCandidate) {
super(testCandidate);
}
@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, RestTestParseException {
return ElasticsearchRestTestCase.createParameters(0, 1);
}
}

View File

@ -275,13 +275,16 @@
<!-- required by the test framework -->
<include>api/info.json</include>
<include>api/cluster.health.json</include>
<include>api/cluster.state.json</include>
<!-- used in plugin REST tests -->
<include>api/index.json</include>
<include>api/search.json</include>
<include>api/indices.analyze.json</include>
<include>api/indices.create.json</include>
<include>api/indices.refresh.json</include>
<include>api/nodes.info.json</include>
<include>api/count.json</include>
<include>api/search.json</include>
</includes>
</testResource>
<!-- shared test resources like log4j.properties -->