Browse Source

Added rest tests for language plugins

Clinton Gormley 10 years ago
parent
commit
956123157b

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

+ 1 - 0
plugins/pom.xml

@@ -284,6 +284,7 @@
                     <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 -->