Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.

Commit

Permalink
fail in-parallel only after no other step is running (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
flosell committed Nov 29, 2015
1 parent 9f632fd commit 115a761
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ The official release will have a defined and more stable API. If you are already
* UI: Adding feature to collapse/expand all or active steps (#59)
* Bugs:
* `either` no longer aggregates to failure if only some children failed (#67)
* `in-parallel` no longer aggregates to failure while other children are still running (#68)
* Breaking Changes:
* `successful-when-one-successful` status aggregation only fails if all statuses are `:failure` (#64)
* `successful-when-one-successful` status aggregation only fails if all statuses are `:failure` (#67)
* `successful-when-all-successful-sequential` status aggregation doesn't fail while other steps are still running (#68)

## 0.5.7
* Improvements:
Expand Down
2 changes: 1 addition & 1 deletion src/clj/lambdacd/steps/status.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

(defn successful-when-all-successful [statuses]
(cond
(one-in statuses :failure) :failure
(one-in statuses :running) :running
(one-in statuses :waiting) :waiting
(one-in statuses :failure) :failure
(all statuses :success) :success
:else :unknown))
14 changes: 14 additions & 0 deletions test/clj/lambdacd/steps/control_flow_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,16 @@

(defn some-successful-step [arg & _]
{:status :success})

(defn some-failing-step [arg & _]
{:status :failure})

(defn some-step-sending-failure-but-returning-success [_ {ch :result-channel}]
(async/>!! ch [:status :running])
(async/>!! ch [:status :failure])
(Thread/sleep 20)
{:status :success})

(defn some-step-sending-waiting-on-channel [_ {ch :result-channel}]
(async/>!! ch [:status :running])
(Thread/sleep 20)
Expand Down Expand Up @@ -106,6 +113,13 @@
(is (= [[:status :running]
[:status :waiting]
[:status :success]] (slurp-chan result-ch)))))
(testing "that it doesnt immediately inherit failures on the result channel so it doesn't look like the step has failed just because a child failed"
(let [result-ch (async/chan 100)
ctx (some-ctx-with :result-channel result-ch :step-id [333])]
((in-parallel some-step-sending-failure-but-returning-success some-step-sending-running-then-waiting-then-finished-on-channel) {} ctx)
(is (= [[:status :running]
[:status :waiting]
[:status :success]] (slurp-chan result-ch)))))
(testing "that it kills all children if it is killed"
(let [is-killed (atom true)
ctx (some-ctx-with :is-killed is-killed
Expand Down
7 changes: 3 additions & 4 deletions test/clj/lambdacd/steps/status_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
(testing "undefined otherwise"
(is (= :unknown (successful-when-one-successful [:foo :bar])))))


(deftest successful-when-all-successful-test
(testing "that that all successful steps make a successful unified view"
(is (= :success (successful-when-all-successful [:success])))
(is (= :success (successful-when-all-successful [:success :success]))))
(testing "that one failed step fails the unified view"
(testing "it doesnt fail as long as something is running"
(is (= :failure (successful-when-all-successful [:failure])))
(is (= :failure (successful-when-all-successful [:failure :running])))
(is (= :failure (successful-when-all-successful [:failure :waiting])))
(is (= :running (successful-when-all-successful [:failure :running])))
(is (= :waiting (successful-when-all-successful [:failure :waiting])))
(is (= :failure (successful-when-all-successful [:success :failure]))))
(testing "that one waiting makes the unified view waiting when nothing's running"
(is (= :waiting (successful-when-all-successful [:success :waiting]))))
Expand Down

0 comments on commit 115a761

Please sign in to comment.