You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/06/25 14:33:27 UTC

[7/7] incubator-ignite git commit: #ignite-965: add tests for incorrect function map/reduce.

#ignite-965: add tests for incorrect function map/reduce.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/d603238c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/d603238c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/d603238c

Branch: refs/heads/ignite-965
Commit: d603238c6840361801ab5dbc5c9651ecbf91a29a
Parents: 4bf86c9
Author: ivasilinets <iv...@gridgain.com>
Authored: Thu Jun 25 15:33:01 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Thu Jun 25 15:33:01 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/NodeJsComputeSelfTest.java  | 18 +++++-
 modules/nodejs/src/test/js/test-compute.js      | 62 ++++++++++++++++----
 2 files changed, 65 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d603238c/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsComputeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsComputeSelfTest.java b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsComputeSelfTest.java
index 2ba5e63..3a00231 100644
--- a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsComputeSelfTest.java
+++ b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsComputeSelfTest.java
@@ -62,8 +62,22 @@ public class NodeJsComputeSelfTest extends NodeJsAbstractTest {
     /**
      * @throws Exception If failed.
      */
-    public void testComputeErrorExecute() throws Exception {
-        runJsScript("testComputeErrorExecute");
+    public void testComputeFuncWithErrorExecute() throws Exception {
+        runJsScript("testComputeFuncWithErrorExecute");
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testComputeIncorrectFuncExecute() throws Exception {
+        runJsScript("testComputeIncorrectFuncExecute");
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testComputeIncorrectMapExecute() throws Exception {
+        runJsScript("testComputeIncorrectMapExecute");
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d603238c/modules/nodejs/src/test/js/test-compute.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-compute.js b/modules/nodejs/src/test/js/test-compute.js
index 187e54c..c069d97 100644
--- a/modules/nodejs/src/test/js/test-compute.js
+++ b/modules/nodejs/src/test/js/test-compute.js
@@ -27,10 +27,6 @@ testComputeExecute = function() {
     TestUtils.startIgniteNode(computeExecute);
 }
 
-testComputeErrorExecute = function() {
-    TestUtils.startIgniteNode(computeErrorExecute);
-}
-
 testComputeAllNodeExecute = function() {
     TestUtils.startIgniteNode(computeAllNodeExecute);
 }
@@ -123,22 +119,62 @@ function computeAllNodeExecute(error, ignite) {
     ignite.compute().execute(map, reduce, "", callback);
 }
 
-function computeErrorExecute(error, ignite) {
+testComputeFuncWithErrorExecute = function() {
     var map = function(nodes, arg) {
-        var f = [function (args) {}, function(args){throw "Bad function";}];
+        var f = function(args){throw "Bad function";};
+
         for (var i = 0; i < nodes.length; i++) {
-            emit(f[i % f.length], "", nodes[i %  nodes.length]);
+            emit(f, "", nodes[i %  nodes.length]);
         }
     };
 
-    var callback = function(err, res) {
-        assert(err != null, "Do not get error on compute task.");
+    testComputeWithErrors(map);
+}
+
+testComputeIncorrectFuncExecute = function() {
+    var map = function(nodes, arg) {
+        var f = function() {
+            prin("hi");
+        };
 
-        assert(err.indexOf("Function evaluation failed") > -1, "Incorrect error "+
-            "[expected=function evaluation failed, value=" + err + "]");
+        for (var i = 0; i < nodes.length; i++) {
+            emit(f, "", nodes[i %  nodes.length]);
+        }
+    };
 
-        TestUtils.testDone();
+    testComputeWithErrors(map);
+}
+
+testComputeIncorrectMapExecute = function() {
+    var map = function(nodes, arg) {
+        var f = function() {
+            print("hi");
+        };
+
+        for (i = 0; i < nodes.length; i++) {
+            emit(f, "", nodes[a %  nodes.length]);
+        }
+    };
+
+    testComputeWithErrors(map);
+}
+
+function testComputeWithErrors(map) {
+    function computeErrorExecute(error, ignite) {
+        var callback = function(err, res) {
+            assert(err != null, "Do not get error on compute task.");
+
+            console.log("ERROR on Compute: "  + err);
+            console.log("End of ERROR.");
+
+            assert(err.indexOf("Function evaluation failed") > -1, "Incorrect error "+
+                "[expected=function evaluation failed, value=" + err + "]");
+
+            TestUtils.testDone();
+        }
+
+        ignite.compute().execute(map, function (args) {}, "Hi Alice", callback);
     }
 
-    ignite.compute().execute(map, function (args) {}, "Hi Alice", callback);
+    TestUtils.startIgniteNode(computeErrorExecute);
 }