Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-965 fbe541306 -> 86723ffaf


#ignite-965:  add tests.


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

Branch: refs/heads/ignite-965
Commit: 86723ffaff530dbfdc77cb8fa316151fdc5c3e38
Parents: fbe5413
Author: ivasilinets <[email protected]>
Authored: Wed Jun 24 16:35:01 2015 +0300
Committer: ivasilinets <[email protected]>
Committed: Wed Jun 24 16:35:01 2015 +0300

----------------------------------------------------------------------
 .../scripting/IgniteScriptProcessor.java        |  4 +-
 .../ignite/internal/NodeJsComputeSelfTest.java  | 50 ++++++++++++++++++++
 modules/nodejs/src/test/js/test-compute.js      | 24 ++++++++++
 3 files changed, 76 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/86723ffa/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java
index 2c2d5c5..0bd7233 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java
@@ -138,10 +138,10 @@ public class IgniteScriptProcessor extends 
GridProcessorAdapter {
             return invocable.invokeFunction(nameFunc, args);
         }
         catch (ScriptException e) {
-            throw new IgniteCheckedException("Function evaluation failed 
[funcName=" + nameFunc + "].", e);
+            throw new IgniteCheckedException("Function evaluation failed 
[funcName=" + nameFunc + "].");
         }
         catch (NoSuchMethodException e) {
-            throw new IgniteCheckedException("Cannot find function [funcName=" 
+ nameFunc + "].", e);
+            throw new IgniteCheckedException("Cannot find function [funcName=" 
+ nameFunc + "].");
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/86723ffa/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 82afe9b..0015025 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
@@ -17,6 +17,13 @@
 
 package org.apache.ignite.internal;
 
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.testframework.*;
+
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+
 /**
  * Test compute node js.
  */
@@ -51,4 +58,47 @@ public class NodeJsComputeSelfTest extends 
NodeJsAbstractTest {
     public void testComputeExecute() throws Exception {
         runJsScript("testComputeExecute");
     }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testComputeErrorExecute() throws Exception {
+        runJsScript("testComputeErrorExecute");
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRestartGrid() throws Exception {
+        final AtomicInteger id = new AtomicInteger(2);
+        IgniteInternalFuture<Long> fut = 
GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                ArrayList<Integer> ids = new ArrayList<Integer>();
+
+                for (int i = 0 ; i < 3; ++i) {
+                    int cur = id.getAndIncrement();
+
+                    startGrid(cur);
+
+                    ids.add(cur);
+                }
+
+                for (int i = 0; i < ids.size(); ++i)
+                    stopGrid(ids.get(i));
+
+                return null;
+            }
+        }, 2, "runIgnite");
+
+        while (!fut.isDone())
+            runJsScript("testComputeExecute");
+
+        stopGrid(1);
+
+        U.sleep(500);
+
+        startGrid(1);
+
+        U.sleep(3000);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/86723ffa/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 6aad0c6..d883e18 100644
--- a/modules/nodejs/src/test/js/test-compute.js
+++ b/modules/nodejs/src/test/js/test-compute.js
@@ -27,6 +27,10 @@ testComputeExecute = function() {
     TestUtils.startIgniteNode(computeExecute);
 }
 
+testComputeErrorExecute = function() {
+    TestUtils.startIgniteNode(computeErrorExecute);
+}
+
 function onStart(onPut, error, ignite) {
     var cache = ignite.cache("mycache");
 
@@ -90,3 +94,23 @@ function computeExecute(error, ignite) {
 
     ignite.compute().execute(map, reduce, "Hi Alice", callback);
 }
+
+function computeErrorExecute(error, ignite) {
+    var map = function(nodes, arg) {
+        var f = [function (args) {}, function(args){throw "Bad function";}];
+        for (var i = 0; i < nodes.length; i++) {
+            emit(f[i % f.length], "", nodes[i %  nodes.length]);
+        }
+    };
+
+    var callback = function(err, res) {
+        assert(err != null, "Do not get error on compute task.");
+
+        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);
+}

Reply via email to