Github user revans2 commented on a diff in the pull request:
https://github.com/apache/incubator-storm/pull/38#discussion_r13931874
--- Diff: storm-core/test/clj/backtype/storm/metrics_test.clj ---
@@ -143,6 +153,62 @@
(advance-cluster-time cluster 5)
(assert-buckets! "2" "my-custom-metric" [1 0 0 0 0 0 2]))))
+(defn mk-shell-bolt-with-metrics-spec
+ [inputs command & kwargs]
+ (let [command (into-array String command)]
+ (apply thrift/mk-bolt-spec inputs
+ (PythonShellMetricsBolt. command) kwargs)))
+
+(deftest test-custom-metric-with-multilang-py
+ (with-local-cluster
+ [cluster :daemon-conf {TOPOLOGY-METRICS-CONSUMER-REGISTER
+ [{"class"
"clojure.storm.metric.testing.FakeMetricConsumer"}]
+ "storm.zookeeper.connection.timeout" 30000
+ "storm.zookeeper.session.timeout" 60000
+ }]
+ (let [feeder (feeder-spout ["field1"])
+ topology (thrift/mk-topology
+ {"1" (thrift/mk-spout-spec feeder)}
+ {"2" (mk-shell-bolt-with-metrics-spec {"1" :global}
["python" "tester_bolt_metrics.py"])})]
+ (submit-local-topology (:nimbus cluster) "shell-metrics-tester" {}
topology)
+
+ (.feed feeder ["a"] 1)
+ (Thread/sleep 6000)
+ (assert-buckets! "2" "my-custom-shell-metric" [1])
+
+ (Thread/sleep 5000)
+ (assert-buckets! "2" "my-custom-shell-metric" [1 0])
+
+ (Thread/sleep 20000)
+ (assert-buckets! "2" "my-custom-shell-metric" [1 0 0 0 0 0])
+
+ (.feed feeder ["b"] 2)
+ (.feed feeder ["c"] 3)
+ (Thread/sleep 5000)
--- End diff --
Sleep in a test to get the timing right is not Ideal. I can see in the
other multi-lang tests they mostly just verify that the topology ran, nothing
about the metrics being consumed. I would prefer to see you use
with-simulated-time-local-cluster instead. I don't see any reason why they
should not work with shell bolts and spouts.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---