You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by bo...@apache.org on 2014/04/22 18:39:18 UTC
[06/10] git commit: Add test for handling *.worker.childopts in supvor
Add test for handling *.worker.childopts in supvor
Project: http://git-wip-us.apache.org/repos/asf/incubator-storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-storm/commit/2fb66fa3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-storm/tree/2fb66fa3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-storm/diff/2fb66fa3
Branch: refs/heads/master
Commit: 2fb66fa3be27f3495fbbe78831565a1edce12af1
Parents: c970225
Author: Derek Dagit <de...@yahoo-inc.com>
Authored: Wed Jan 15 03:10:35 2014 +0000
Committer: Derek Dagit <de...@yahoo-inc.com>
Committed: Wed Jan 15 03:16:54 2014 +0000
----------------------------------------------------------------------
pom.xml | 7 +++
storm-core/pom.xml | 5 ++
.../test/clj/backtype/storm/supervisor_test.clj | 64 +++++++++++++++++++-
3 files changed, 75 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/2fb66fa3/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 3bd3362..3a0c26b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -166,6 +166,7 @@
<clojure-complete.version>0.2.3</clojure-complete.version>
<mockito.version>1.9.5</mockito.version>
<reply.version>0.3.0</reply.version>
+ <conjure.version>2.1.3</conjure.version>
</properties>
@@ -411,6 +412,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.clojars.runa</groupId>
+ <artifactId>conjure</artifactId>
+ <version>${conjure.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.storm</groupId>
<artifactId>libthrift7</artifactId>
<version>${project.version}</version>
http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/2fb66fa3/storm-core/pom.xml
----------------------------------------------------------------------
diff --git a/storm-core/pom.xml b/storm-core/pom.xml
index d333b88..f1a74c6 100644
--- a/storm-core/pom.xml
+++ b/storm-core/pom.xml
@@ -145,6 +145,11 @@
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.clojars.runa</groupId>
+ <artifactId>conjure</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<sourceDirectory>src/jvm</sourceDirectory>
http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/2fb66fa3/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 9f9def9..54a3ee9 100644
--- a/storm-core/test/clj/backtype/storm/supervisor_test.clj
+++ b/storm-core/test/clj/backtype/storm/supervisor_test.clj
@@ -15,10 +15,12 @@
;; limitations under the License.
(ns backtype.storm.supervisor-test
(:use [clojure test])
+ (:require [clojure [string :as string]])
(:import [backtype.storm.testing TestWordCounter TestWordSpout TestGlobalCount TestAggregatesCounter])
- (:use [backtype.storm bootstrap testing])
+ (:use [backtype.storm bootstrap config testing])
(:use [backtype.storm.daemon common])
(:require [backtype.storm.daemon [worker :as worker] [supervisor :as supervisor]])
+ (:use [conjure core])
)
(bootstrap)
@@ -239,6 +241,66 @@
)))
+(deftest test-worker-launch-command
+ (testing "*.worker.childopts configuration"
+ (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]
+ (concat ["java" "-server"]
+ opts
+ topo-opts
+ ["-Djava.library.path="
+ (str "-Dlogfile.name=worker-" mock-port ".log")
+ "-Dstorm.home="
+ "-Dlogback.configurationFile=/logback/cluster.xml"
+ (str "-Dstorm.id=" mock-storm-id)
+ (str "-Dworker.id=" mock-worker-id)
+ (str "-Dworker.port=" mock-port)
+ "-cp" mock-cp
+ "backtype.storm.daemon.worker"
+ mock-storm-id
+ mock-port
+ mock-worker-id]))]
+ (testing "testing *.worker.childopts as strings with extra spaces"
+ (let [string-opts "-Dfoo=bar -Xmx1024m"
+ topo-string-opts "-Dkau=aux -Xmx2048m"
+ exp-args (exp-args-fn ["-Dfoo=bar" "-Xmx1024m"]
+ ["-Dkau=aux" "-Xmx2048m"])
+ mock-supervisor {:conf {STORM-CLUSTER-MODE :distributed
+ WORKER-CHILDOPTS string-opts}}]
+ (stubbing [read-supervisor-storm-conf {TOPOLOGY-WORKER-CHILDOPTS
+ topo-string-opts}
+ add-to-classpath mock-cp
+ supervisor-stormdist-root nil
+ launch-process nil]
+ (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 *.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)
+ mock-supervisor {:conf {STORM-CLUSTER-MODE :distributed
+ WORKER-CHILDOPTS list-opts}}]
+ (stubbing [read-supervisor-storm-conf {TOPOLOGY-WORKER-CHILDOPTS
+ topo-list-opts}
+ add-to-classpath mock-cp
+ supervisor-stormdist-root nil
+ launch-process nil]
+ (supervisor/launch-worker mock-supervisor
+ mock-storm-id
+ mock-port
+ mock-worker-id)
+ (verify-first-call-args-for-indices launch-process
+ [0]
+ exp-args)))))))
+
(deftest test-workers-go-bananas
;; test that multiple workers are started for a port, and test that
;; supervisor shuts down propertly (doesn't shutdown the most