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