|
146 | 146 | (is (not-nil? ((:executor->start-time-secs assignment) e))))
|
147 | 147 | ))
|
148 | 148 |
|
149 |
| -(deftest test-file-bogus-bogus-download |
150 |
| - (with-local-cluster [cluster :daemon-conf {SUPERVISOR-ENABLE false TOPOLOGY-ACKER-EXECUTORS 0}] |
151 |
| - (let [nimbus (:nimbus cluster)] |
152 |
| - (is (thrown? AuthorizationException (.beginFileDownload nimbus nil))) |
153 |
| - (is (thrown? AuthorizationException (.beginFileDownload nimbus ""))) |
154 |
| - (is (thrown? AuthorizationException (.beginFileDownload nimbus "/bogus-path/foo"))) |
155 |
| - ))) |
| 149 | + |
156 | 150 |
|
157 | 151 | (deftest test-bogusId
|
158 | 152 | (with-local-cluster [cluster :supervisors 4 :ports-per-supervisor 3 :daemon-conf {SUPERVISOR-ENABLE false TOPOLOGY-ACKER-EXECUTORS 0}]
|
|
234 | 228 | {"1" (thrift/mk-spout-spec (TestPlannerSpout. false) :parallelism-hint 3)}
|
235 | 229 | {"2" (thrift/mk-bolt-spec {"1" :none} (TestPlannerBolt.) :parallelism-hint 5)
|
236 | 230 | "3" (thrift/mk-bolt-spec {"2" :none} (TestPlannerBolt.))}))
|
237 |
| - |
| 231 | + |
238 | 232 | (submit-local-topology nimbus "noniso" {TOPOLOGY-OPTIMIZE false TOPOLOGY-WORKERS 4} topology)
|
239 | 233 | (advance-cluster-time cluster 1)
|
240 | 234 | (is (= 4 (topology-num-nodes state "noniso")))
|
|
243 | 237 | (submit-local-topology nimbus "tester1" {TOPOLOGY-OPTIMIZE false TOPOLOGY-WORKERS 6} topology)
|
244 | 238 | (submit-local-topology nimbus "tester2" {TOPOLOGY-OPTIMIZE false TOPOLOGY-WORKERS 6} topology)
|
245 | 239 | (advance-cluster-time cluster 1)
|
246 |
| - |
| 240 | + |
247 | 241 | (bind task-info-tester1 (storm-component->task-info cluster "tester1"))
|
248 | 242 | (bind task-info-tester2 (storm-component->task-info cluster "tester2"))
|
249 |
| - |
| 243 | + |
250 | 244 |
|
251 | 245 | (is (= 1 (topology-num-nodes state "noniso")))
|
252 | 246 | (is (= 3 (storm-num-workers state "noniso")))
|
253 | 247 |
|
254 | 248 | (is (= {2 3} (topology-node-distribution state "tester1")))
|
255 | 249 | (is (= {3 2} (topology-node-distribution state "tester2")))
|
256 |
| - |
| 250 | + |
257 | 251 | (is (apply disjoint? (map (partial topology-nodes state) ["noniso" "tester1" "tester2"])))
|
258 |
| - |
| 252 | + |
259 | 253 | (check-consistency cluster "tester1")
|
260 | 254 | (check-consistency cluster "tester2")
|
261 | 255 | (check-consistency cluster "noniso")
|
262 | 256 |
|
263 | 257 | ;;check that nothing gets reassigned
|
264 | 258 | (bind tester1-slots (topology-slots state "tester1"))
|
265 | 259 | (bind tester2-slots (topology-slots state "tester2"))
|
266 |
| - (bind noniso-slots (topology-slots state "noniso")) |
| 260 | + (bind noniso-slots (topology-slots state "noniso")) |
267 | 261 | (advance-cluster-time cluster 20)
|
268 | 262 | (is (= tester1-slots (topology-slots state "tester1")))
|
269 | 263 | (is (= tester2-slots (topology-slots state "tester2")))
|
270 | 264 | (is (= noniso-slots (topology-slots state "noniso")))
|
271 |
| - |
| 265 | + |
272 | 266 | )))
|
273 | 267 |
|
274 | 268 | (deftest test-zero-executor-or-tasks
|
|
302 | 296 | (check-consistency cluster "mystorm")
|
303 | 297 | (is (= 5 (count (task-info "1"))))
|
304 | 298 | (check-distribution (executor-info "1") [2 2 1])
|
305 |
| - |
| 299 | + |
306 | 300 | (is (= 2 (count (task-info "2"))))
|
307 | 301 | (check-distribution (executor-info "2") [1 1])
|
308 | 302 |
|
|
375 | 369 | (is (thrown? AlreadyAliveException (submit-local-topology (:nimbus cluster) "2test" {} topology)))
|
376 | 370 | (advance-cluster-time cluster 5)
|
377 | 371 | (is (= 1 (count (.heartbeat-storms state))))
|
378 |
| - |
| 372 | + |
379 | 373 | (advance-cluster-time cluster 6)
|
380 | 374 | (is (nil? (.storm-base state storm-id nil)))
|
381 | 375 | (is (nil? (.assignment-info state storm-id nil)))
|
382 | 376 | (advance-cluster-time cluster 11)
|
383 | 377 | (is (= 0 (count (.heartbeat-storms state))))
|
384 |
| - |
| 378 | + |
385 | 379 | (submit-local-topology (:nimbus cluster) "test3" {TOPOLOGY-MESSAGE-TIMEOUT-SECS 5} topology)
|
386 | 380 | (bind storm-id3 (get-storm-id state "test3"))
|
387 | 381 | (advance-cluster-time cluster 1)
|
|
395 | 389 | ;; this guarantees that monitor thread won't trigger for 10 more seconds
|
396 | 390 | (advance-time-secs! 11)
|
397 | 391 | (wait-until-cluster-waiting cluster)
|
398 |
| - |
| 392 | + |
399 | 393 | (submit-local-topology (:nimbus cluster) "test3" {TOPOLOGY-MESSAGE-TIMEOUT-SECS 5} topology)
|
400 | 394 | (bind storm-id3 (get-storm-id state "test3"))
|
401 | 395 |
|
402 | 396 | (bind executor-id (first (topology-executors cluster storm-id3)))
|
403 |
| - |
| 397 | + |
404 | 398 | (do-executor-heartbeat cluster storm-id3 executor-id)
|
405 | 399 |
|
406 | 400 | (.killTopology (:nimbus cluster) "test3")
|
|
416 | 410 | (advance-cluster-time cluster 9)
|
417 | 411 | (is (not-nil? (.assignment-info state storm-id4 nil)))
|
418 | 412 | (advance-cluster-time cluster 2)
|
419 |
| - (is (nil? (.assignment-info state storm-id4 nil))) |
| 413 | + (is (nil? (.assignment-info state storm-id4 nil))) |
420 | 414 | )))
|
421 | 415 |
|
422 | 416 | (deftest test-reassignment
|
|
440 | 434 | (bind [executor-id1 executor-id2] (topology-executors cluster storm-id))
|
441 | 435 | (bind ass1 (executor-assignment cluster storm-id executor-id1))
|
442 | 436 | (bind ass2 (executor-assignment cluster storm-id executor-id2))
|
443 |
| - |
| 437 | + |
444 | 438 | (advance-cluster-time cluster 59)
|
445 | 439 | (do-executor-heartbeat cluster storm-id executor-id1)
|
446 | 440 | (do-executor-heartbeat cluster storm-id executor-id2)
|
|
461 | 455 | (do-executor-heartbeat cluster storm-id executor-id1)
|
462 | 456 | (is (= ass1 (executor-assignment cluster storm-id executor-id1)))
|
463 | 457 | (check-consistency cluster "test")
|
464 |
| - |
| 458 | + |
465 | 459 | (advance-cluster-time cluster 11)
|
466 | 460 | (is (= ass1 (executor-assignment cluster storm-id executor-id1)))
|
467 | 461 | (is (not= ass2 (executor-assignment cluster storm-id executor-id2)))
|
|
537 | 531 | (bind [executor-id1 executor-id2] (topology-executors cluster storm-id))
|
538 | 532 | (bind ass1 (executor-assignment cluster storm-id executor-id1))
|
539 | 533 | (bind ass2 (executor-assignment cluster storm-id executor-id2))
|
540 |
| - |
| 534 | + |
541 | 535 | (advance-cluster-time cluster 59)
|
542 | 536 | (do-executor-heartbeat cluster storm-id executor-id1)
|
543 | 537 | (do-executor-heartbeat cluster storm-id executor-id2)
|
|
609 | 603 | (bind common (first (find-first (fn [[k v]] (= 3 (count v))) slot-executors2)))
|
610 | 604 | (is (not-nil? common))
|
611 | 605 | (is (= (slot-executors2 common) (slot-executors common)))
|
612 |
| - |
| 606 | + |
613 | 607 | ;; check that start times are changed for everything but the common one
|
614 | 608 | (bind same-executors (slot-executors2 common))
|
615 | 609 | (bind changed-executors (apply concat (vals (dissoc slot-executors2 common))))
|
|
655 | 649 | (bind slot-executors (slot-assignments cluster storm-id))
|
656 | 650 | (check-executor-distribution slot-executors [1 1 1])
|
657 | 651 | (check-num-nodes slot-executors 3)
|
658 |
| - |
| 652 | + |
659 | 653 | (is (thrown? InvalidTopologyException
|
660 | 654 | (.rebalance (:nimbus cluster) "test"
|
661 | 655 | (doto (RebalanceOptions.)
|
|
685 | 679 | (slot-assignments cluster storm-id)
|
686 | 680 | distribution)))
|
687 | 681 | (checker [2 2 2])
|
688 |
| - |
| 682 | + |
689 | 683 | (.rebalance (:nimbus cluster) "test"
|
690 | 684 | (doto (RebalanceOptions.)
|
691 | 685 | (.set_num_workers 6)
|
|
694 | 688 | (checker [2 2 2])
|
695 | 689 | (advance-cluster-time cluster 3)
|
696 | 690 | (checker [1 1 1 1 1 1])
|
697 |
| - |
| 691 | + |
698 | 692 | (.rebalance (:nimbus cluster) "test"
|
699 | 693 | (doto (RebalanceOptions.)
|
700 | 694 | (.set_num_executors {"1" 1})
|
|
712 | 706 | (advance-cluster-time cluster 32)
|
713 | 707 | (checker [2 2 2 2])
|
714 | 708 | (check-consistency cluster "test")
|
715 |
| - |
| 709 | + |
716 | 710 | (bind executor-info (->> (storm-component->executor-info cluster "test")
|
717 | 711 | (map-val #(map executor-id->tasks %))))
|
718 | 712 | (check-distribution (executor-info "1") [2 2 2 2 1 1 1 1])
|
719 |
| - |
| 713 | + |
720 | 714 | )))
|
721 | 715 |
|
722 | 716 | (deftest test-submit-invalid
|
|
729 | 723 | (bind topology (thrift/mk-topology
|
730 | 724 | {"1" (thrift/mk-spout-spec (TestPlannerSpout. true) :parallelism-hint 0 :conf {TOPOLOGY-TASKS 1})}
|
731 | 725 | {}))
|
732 |
| - |
| 726 | + |
733 | 727 | (is (thrown? InvalidTopologyException
|
734 | 728 | (submit-local-topology (:nimbus cluster)
|
735 | 729 | "test"
|
736 | 730 | {}
|
737 | 731 | topology)))
|
738 |
| - |
| 732 | + |
739 | 733 | (bind topology (thrift/mk-topology
|
740 | 734 | {"1" (thrift/mk-spout-spec (TestPlannerSpout. true) :parallelism-hint 1 :conf {TOPOLOGY-TASKS 1})}
|
741 | 735 | {}))
|
|
753 | 747 | (is (thrown? InvalidTopologyException
|
754 | 748 | (submit-local-topology (:nimbus cluster)
|
755 | 749 | "test"
|
756 |
| - {TOPOLOGY-WORKERS 3} |
| 750 | + {TOPOLOGY-WORKERS 3} |
757 | 751 | topology)))
|
758 | 752 | (bind topology (thrift/mk-topology
|
759 | 753 | {"1" (thrift/mk-spout-spec (TestPlannerSpout. true)
|
|
838 | 832 | ))))
|
839 | 833 |
|
840 | 834 | (deftest test-nimbus-iface-submitTopologyWithOpts-checks-authorization
|
841 |
| - (with-local-cluster [cluster |
842 |
| - :daemon-conf {NIMBUS-AUTHORIZER |
| 835 | + (with-local-cluster [cluster |
| 836 | + :daemon-conf {NIMBUS-AUTHORIZER |
843 | 837 | "backtype.storm.security.auth.authorizer.DenyAuthorizer"}]
|
844 | 838 | (let [
|
845 | 839 | nimbus (:nimbus cluster)
|
846 | 840 | topology (thrift/mk-topology {} {})
|
847 | 841 | ]
|
848 | 842 | (is (thrown? AuthorizationException
|
849 |
| - (submit-local-topology-with-opts nimbus "mystorm" {} topology |
| 843 | + (submit-local-topology-with-opts nimbus "mystorm" {} topology |
850 | 844 | (SubmitOptions. TopologyInitialStatus/INACTIVE))
|
851 | 845 | ))
|
852 | 846 | )
|
853 | 847 | )
|
854 | 848 | )
|
855 | 849 |
|
856 | 850 | (deftest test-nimbus-iface-methods-check-authorization
|
857 |
| - (with-local-cluster [cluster |
858 |
| - :daemon-conf {NIMBUS-AUTHORIZER |
| 851 | + (with-local-cluster [cluster |
| 852 | + :daemon-conf {NIMBUS-AUTHORIZER |
859 | 853 | "backtype.storm.security.auth.authorizer.DenyAuthorizer"}]
|
860 | 854 | (let [
|
861 | 855 | nimbus (:nimbus cluster)
|
862 | 856 | topology (thrift/mk-topology {} {})
|
863 | 857 | ]
|
864 | 858 | ; Fake good authorization as part of setup.
|
865 | 859 | (mocking [nimbus/check-authorization!]
|
866 |
| - (submit-local-topology-with-opts nimbus "test" {} topology |
| 860 | + (submit-local-topology-with-opts nimbus "test" {} topology |
867 | 861 | (SubmitOptions. TopologyInitialStatus/INACTIVE))
|
868 | 862 | )
|
869 | 863 | (stubbing [nimbus/storm-active? true]
|
|
939 | 933 | (stubbing [topology-bases bogus-bases]
|
940 | 934 | (let [topos (.get_topologies (.getClusterInfo nimbus))]
|
941 | 935 | ; The number of topologies in the summary is correct.
|
942 |
| - (is (= (count |
| 936 | + (is (= (count |
943 | 937 | (filter (fn [b] (second b)) bogus-bases)) (count topos)))
|
944 | 938 | ; Each topology present has a valid name.
|
945 | 939 | (is (empty?
|
946 | 940 | (filter (fn [t] (or (nil? t) (nil? (.get_name t)))) topos)))
|
947 | 941 | ; The topologies are those with valid bases.
|
948 | 942 | (is (empty?
|
949 |
| - (filter (fn [t] |
950 |
| - (or |
951 |
| - (nil? t) |
| 943 | + (filter (fn [t] |
| 944 | + (or |
| 945 | + (nil? t) |
952 | 946 | (not (number? (read-string (.get_id t))))
|
953 | 947 | (odd? (read-string (.get_id t)))
|
954 | 948 | )) topos)))
|
|
0 commit comments