You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by da...@apache.org on 2014/06/23 21:42:23 UTC

[4/6] git commit: Added tests for per-topology classpath and per-topology environment-variables.

Added tests for per-topology classpath and per-topology environment-variables.


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

Branch: refs/heads/master
Commit: d00f966098eb1e422d9507334c8d1d475112c9ac
Parents: e1735d2
Author: Kyle Nusbaum <kn...@yahoo-inc.com>
Authored: Wed Jun 18 17:57:00 2014 +0000
Committer: Kyle Nusbaum <kn...@yahoo-inc.com>
Committed: Wed Jun 18 17:57:00 2014 +0000

----------------------------------------------------------------------
 .../test/clj/backtype/storm/supervisor_test.clj | 45 +++++++++++++++++---
 1 file changed, 39 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/d00f9660/storm-core/test/clj/backtype/storm/supervisor_test.clj
----------------------------------------------------------------------
diff --git a/storm-core/test/clj/backtype/storm/supervisor_test.clj b/storm-core/test/clj/backtype/storm/supervisor_test.clj
index 1d0804a..eb69f11 100644
--- a/storm-core/test/clj/backtype/storm/supervisor_test.clj
+++ b/storm-core/test/clj/backtype/storm/supervisor_test.clj
@@ -246,8 +246,8 @@
     (let [mock-port "42"
           mock-storm-id "fake-storm-id"
           mock-worker-id "fake-worker-id"
-          mock-cp "mock-classpath"
-          exp-args-fn (fn [opts topo-opts]
+          mock-cp "/base:/stormjar.jar"
+          exp-args-fn (fn [opts topo-opts classpath]
                        (concat [(supervisor/java-cmd) "-server"]
                                opts
                                topo-opts
@@ -258,7 +258,7 @@
                                 (str "-Dstorm.id=" mock-storm-id)
                                 (str "-Dworker.id=" mock-worker-id)
                                 (str "-Dworker.port=" mock-port)
-                                "-cp" mock-cp
+                                "-cp" classpath
                                 "backtype.storm.daemon.worker"
                                 mock-storm-id
                                 mock-port
@@ -267,7 +267,8 @@
         (let [string-opts "-Dfoo=bar  -Xmx1024m"
               topo-string-opts "-Dkau=aux   -Xmx2048m"
               exp-args (exp-args-fn ["-Dfoo=bar" "-Xmx1024m"]
-                                    ["-Dkau=aux" "-Xmx2048m"])
+                                    ["-Dkau=aux" "-Xmx2048m"]
+                                    mock-cp)
               mock-supervisor {:conf {STORM-CLUSTER-MODE :distributed
                                       WORKER-CHILDOPTS string-opts}}]
           (stubbing [read-supervisor-storm-conf {TOPOLOGY-WORKER-CHILDOPTS
@@ -286,7 +287,7 @@
       (testing "testing *.worker.childopts as list of strings, with spaces in values"
         (let [list-opts '("-Dopt1='this has a space in it'" "-Xmx1024m")
               topo-list-opts '("-Dopt2='val with spaces'" "-Xmx2048m")
-              exp-args (exp-args-fn list-opts topo-list-opts)
+              exp-args (exp-args-fn list-opts topo-list-opts mock-cp)
               mock-supervisor {:conf {STORM-CLUSTER-MODE :distributed
                                       WORKER-CHILDOPTS list-opts}}]
           (stubbing [read-supervisor-storm-conf {TOPOLOGY-WORKER-CHILDOPTS
@@ -301,7 +302,39 @@
                                       mock-worker-id)
             (verify-first-call-args-for-indices launch-process
                                                 [0]
-                                                exp-args)))))))
+                                                exp-args))))
+      (testing "testing topology.classpath is added to classpath"
+        (let [topo-cp "/any/path"
+              exp-args (exp-args-fn [] [] (add-to-classpath mock-cp [topo-cp]))
+              mock-supervisor {:conf {STORM-CLUSTER-MODE :distributed}}]
+          (stubbing [read-supervisor-storm-conf {TOPOLOGY-CLASSPATH topo-cp}
+                     supervisor-stormdist-root nil
+                     supervisor/jlp nil
+                     launch-process nil
+                     current-classpath "/base"]
+                    (supervisor/launch-worker mock-supervisor
+                                              mock-storm-id
+                                              mock-port
+                                              mock-worker-id)
+                    (verify-first-call-args-for-indices launch-process
+                                                        [0]
+                                                        exp-args))))
+      (testing "testing topology.environment is added to environment for worker launch"
+        (let [topo-env {"THISVAR" "somevalue" "THATVAR" "someothervalue"}
+              exp-args (exp-args-fn [] [] mock-cp)
+              mock-supervisor {:conf {STORM-CLUSTER-MODE :distributed}}]
+          (stubbing [read-supervisor-storm-conf {TOPOLOGY-ENVIRONMENT topo-env}
+                     supervisor-stormdist-root nil
+                     supervisor/jlp nil
+                     launch-process nil
+                     current-classpath "/base"]
+                    (supervisor/launch-worker mock-supervisor
+                                              mock-storm-id
+                                              mock-port
+                                              mock-worker-id)
+                    (verify-first-call-args-for-indices launch-process
+                                                        [2]
+                                                        (merge topo-env {"LD_LIBRARY_PATH" nil}))))))))
 
 (deftest test-workers-go-bananas
   ;; test that multiple workers are started for a port, and test that