Prechádzať zdrojové kódy

Merge pull request #12091 from clintongormley/plugin_rest_tests

Plugin rest tests for analysis-phonetic, cloud-*, and lang-*
Clinton Gormley 10 rokov pred
rodič
commit
50ec1b1f8e
21 zmenil súbory, kde vykonal 451 pridanie a 2 odobranie
  1. 3 2
      plugins/analysis-phonetic/pom.xml
  2. 33 0
      plugins/analysis-phonetic/rest-api-spec/test/analysis_phonetic/10_metaphone.yaml
  3. 30 0
      plugins/analysis-phonetic/rest-api-spec/test/analysis_phonetic/20_double_metaphone.yaml
  4. 32 0
      plugins/analysis-phonetic/rest-api-spec/test/analysis_phonetic/30_beider_morse.yaml
  5. 41 0
      plugins/analysis-phonetic/src/test/java/org/elasticsearch/index/analysis/AnalysisPhoneticRestIT.java
  6. 2 0
      plugins/cloud-aws/pom.xml
  7. 14 0
      plugins/cloud-aws/rest-api-spec/test/cloud_aws/10_basic.yaml
  8. 41 0
      plugins/cloud-aws/src/test/java/org/elasticsearch/cloud/aws/CloudAWSRestIT.java
  9. 2 0
      plugins/cloud-azure/pom.xml
  10. 14 0
      plugins/cloud-azure/rest-api-spec/test/cloud_azure/10_basic.yaml
  11. 41 0
      plugins/cloud-azure/src/test/java/org/elasticsearch/cloud/azure/CloudAzureRestIT.java
  12. 2 0
      plugins/cloud-gce/pom.xml
  13. 14 0
      plugins/cloud-gce/rest-api-spec/test/cloud_gce/10_basic.yaml
  14. 41 0
      plugins/cloud-gce/src/test/java/org/elasticsearch/cloud/gce/CloudGCERestIT.java
  15. 2 0
      plugins/lang-javascript/pom.xml
  16. 26 0
      plugins/lang-javascript/rest-api-spec/test/lang_javascript/10_basic.yaml
  17. 41 0
      plugins/lang-javascript/src/test/java/org/elasticsearch/script/javascript/LangJavaScriptRestIT.java
  18. 2 0
      plugins/lang-python/pom.xml
  19. 26 0
      plugins/lang-python/rest-api-spec/test/lang_python/10_basic.yaml
  20. 41 0
      plugins/lang-python/src/test/java/org/elasticsearch/script/python/LangPythonScriptRestIT.java
  21. 3 0
      plugins/pom.xml

+ 3 - 2
plugins/analysis-phonetic/pom.xml

@@ -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>

+ 33 - 0
plugins/analysis-phonetic/rest-api-spec/test/analysis_phonetic/10_metaphone.yaml

@@ -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  }
+

+ 30 - 0
plugins/analysis-phonetic/rest-api-spec/test/analysis_phonetic/20_double_metaphone.yaml

@@ -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 }
+

+ 32 - 0
plugins/analysis-phonetic/rest-api-spec/test/analysis_phonetic/30_beider_morse.yaml

@@ -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 }
+

+ 41 - 0
plugins/analysis-phonetic/src/test/java/org/elasticsearch/index/analysis/AnalysisPhoneticRestIT.java

@@ -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);
+    }
+}
+

+ 2 - 0
plugins/cloud-aws/pom.xml

@@ -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>

+ 14 - 0
plugins/cloud-aws/rest-api-spec/test/cloud_aws/10_basic.yaml

@@ -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  }

+ 41 - 0
plugins/cloud-aws/src/test/java/org/elasticsearch/cloud/aws/CloudAWSRestIT.java

@@ -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);
+    }
+}
+

+ 2 - 0
plugins/cloud-azure/pom.xml

@@ -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>

+ 14 - 0
plugins/cloud-azure/rest-api-spec/test/cloud_azure/10_basic.yaml

@@ -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  }

+ 41 - 0
plugins/cloud-azure/src/test/java/org/elasticsearch/cloud/azure/CloudAzureRestIT.java

@@ -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);
+    }
+}
+

+ 2 - 0
plugins/cloud-gce/pom.xml

@@ -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>

+ 14 - 0
plugins/cloud-gce/rest-api-spec/test/cloud_gce/10_basic.yaml

@@ -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  }

+ 41 - 0
plugins/cloud-gce/src/test/java/org/elasticsearch/cloud/gce/CloudGCERestIT.java

@@ -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);
+    }
+}
+

+ 2 - 0
plugins/lang-javascript/pom.xml

@@ -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>

+ 26 - 0
plugins/lang-javascript/rest-api-spec/test/lang_javascript/10_basic.yaml

@@ -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"}

+ 41 - 0
plugins/lang-javascript/src/test/java/org/elasticsearch/script/javascript/LangJavaScriptRestIT.java

@@ -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);
+    }
+}
+

+ 2 - 0
plugins/lang-python/pom.xml

@@ -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>

+ 26 - 0
plugins/lang-python/rest-api-spec/test/lang_python/10_basic.yaml

@@ -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"}

+ 41 - 0
plugins/lang-python/src/test/java/org/elasticsearch/script/python/LangPythonScriptRestIT.java

@@ -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);
+    }
+}
+

+ 3 - 0
plugins/pom.xml

@@ -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 -->