Github user d2r commented on a diff in the pull request:
https://github.com/apache/incubator-storm/pull/36#discussion_r16192380
--- Diff: storm-core/test/clj/backtype/storm/scheduler_test.clj ---
@@ -259,3 +260,27 @@
(is (= false (.isSlotOccupied cluster (WorkerSlot. "supervisor1" (int
3)))))
(is (= false (.isSlotOccupied cluster (WorkerSlot. "supervisor1" (int
5)))))
))
+
+(deftest test-sort-slots
+ ;; test supervisor1 and supervisor2 has the same free slot
+ (is (= '(["supervisor1" 6700] ["supervisor2" 6700]
+ ["supervisor1" 6701] ["supervisor2" 6701])
+ (sort-slots [["supervisor1" 6700] ["supervisor1" 6701]
["supervisor2" 6700] ["supervisor2" 6701]])))
+ ;; test supervisor2 has more free slots
+ (is (= '(["supervisor2" 6700] ["supervisor1" 6700]
+ ["supervisor2" 6701] ["supervisor1" 6701]
+ ["supervisor2" 6702])
+ (sort-slots [["supervisor1" 6700] ["supervisor1" 6701]
+ ["supervisor2" 6700] ["supervisor2" 6701]
["supervisor2" 6702]
+ ])))
+ ;; test supervisor3 has more free slots
+ (is (= '(["supervisor3" 6700] ["supervisor2" 6700] ["supervisor1" 6700]
+ ["supervisor3" 6701] ["supervisor2" 6701] ["supervisor1" 6701]
+ ["supervisor3" 6702] ["supervisor2" 6702]
+ ["supervisor3" 6703])
+ (sort-slots [["supervisor1" 6700] ["supervisor1" 6701]
+ ["supervisor2" 6700] ["supervisor2" 6701]
["supervisor2" 6702]
+ ["supervisor3" 6700] ["supervisor3" 6701]
["supervisor3" 6702] ["supervisor3" 6703]
+ ])))
+ )
--- End diff --
For the above tests, are we sure the ports will always be returned in
ascending order (e.g., 6700...6701...6702...)?
If not, maybe we should just check the supervisor names and not compare the
actual port numbers.
If we are sure the port numbers will be in order, then these tests should
be OK.
---
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.
---