From b9cad008634ebd07ee181a5d033523cf52ab2236 Mon Sep 17 00:00:00 2001 From: Florian Sellmayr Date: Sun, 16 Oct 2016 13:10:32 +0200 Subject: [PATCH] reproduce #135 --- example/clj/todopipeline/pipeline.clj | 1 + example/clj/todopipeline/steps.clj | 24 ++++++++++++++++++++++- test/clj/lambdacd/example/steps_test.clj | 25 +++++++++++++++++++++++- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/example/clj/todopipeline/pipeline.clj b/example/clj/todopipeline/pipeline.clj index d432589e..9b903976 100644 --- a/example/clj/todopipeline/pipeline.clj +++ b/example/clj/todopipeline/pipeline.clj @@ -43,6 +43,7 @@ ; wait-for-frontend-repo ; do-stuff + log-lots-of-output-in-chaining compare-screenshots ;; this step executes his child-steps (the arguments after the in-parallel) in parallel and waits ;; until all of them are done. if one of them fails, the whole step fails. diff --git a/example/clj/todopipeline/steps.clj b/example/clj/todopipeline/steps.clj index 0600adcc..3b80afa7 100644 --- a/example/clj/todopipeline/steps.clj +++ b/example/clj/todopipeline/steps.clj @@ -6,7 +6,9 @@ (:require [lambdacd.steps.shell :as shell] [lambdacd.steps.git :as git] [lambdacd.steps.manualtrigger :as manualtrigger] - [lambdacd.steps.support :as support])) + [lambdacd.steps.support :as support] + [clojure.core.async :as async] + [clojure.tools.logging :as log])) ;; Let's define some constants (def backend-repo "git@github.com:flosell/todo-backend-compojure.git") @@ -42,6 +44,26 @@ (defn wait-for-greeting [args ctx] (manualtrigger/parameterized-trigger {:greeting { :desc "some greeting"}} ctx)) +(defn log-lots-of-output [args ctx] + (support/capture-output ctx + (doall (for [i (range 800)] + (support/if-not-killed ctx + (do + (log/info (str "trying write to " (:result-channel ctx) " " i)) + (async/>!! (:result-channel ctx) [:xyz i]) + (log/info (str "tried write to " (:result-channel ctx) " " i))) + ))) + {:status :success})) + +(defn log-lots-of-output-in-chaining [args ctx] + (support/chaining args ctx + (log-lots-of-output support/injected-args support/injected-ctx))) + +(defn log-lots-of-output-in-more-chaining [args ctx] + (support/chaining args ctx + (log-lots-of-output-in-chaining support/injected-args support/injected-ctx))) + + (defn demonstrate-ansi [args ctx] (shell/bash ctx "/" "printf \"\\033[0mAll attributes off\\033[0m\\n\"" diff --git a/test/clj/lambdacd/example/steps_test.clj b/test/clj/lambdacd/example/steps_test.clj index b64280a3..9ab0adb5 100644 --- a/test/clj/lambdacd/example/steps_test.clj +++ b/test/clj/lambdacd/example/steps_test.clj @@ -1,7 +1,10 @@ (ns lambdacd.example.steps-test (:require [clojure.test :refer [deftest testing is]] [conjure.core :as c] + [lambdacd.internal.execution :as execution] + [lambdacd.testsupport.data :as data] [lambdacd.steps.git :as git] + [lambdacd.testsupport.noop-pipeline-state :as noop-pipeline-state] [todopipeline.steps :as steps])) ; testing a simple build step @@ -13,4 +16,24 @@ :frontend-revision "some-revision" :backend-revision "HEAD" :revision "some-revision"} - (steps/wait-for-frontend-repo nil nil)))))) \ No newline at end of file + (steps/wait-for-frontend-repo nil nil)))))) + +(defmacro with-timeout [millis & body] + `(let [future# (future ~@body)] + (try + (.get future# ~millis java.util.concurrent.TimeUnit/MILLISECONDS) + (catch java.util.concurrent.TimeoutException x# + (do + (future-cancel future#) + "timeout"))))) + +(defn output-load-test-ctx [] + (data/some-ctx-with :pipeline-state-component (noop-pipeline-state/new-no-op-pipeline-state))) + +(deftest output-load-test + ;(testing "that we don't fail if we come across lots of output for just in general" + ; (is (not= "timeout" (with-timeout 10000 + ; (execution/execute-step {} [(output-load-test-ctx) steps/log-lots-of-output]))))) + (testing "that we don't fail if we come across lots of output for chaining" + (is (not= "timeout" (with-timeout 5000 + (execution/execute-step {} [(output-load-test-ctx) steps/log-lots-of-output-in-chaining]))))))