               (jruby-protocol/return-instance jruby-service instance1 :max-requests-flush-while-pool-flush-in-progress-test)
 
               ;; wait until the flush is complete
-              @flush-complete)
+              (is (true? (timed-deref flush-complete))
+                  "timed out waiting for the flush to complete"))
 
             ;; we should have three instances with the constant and one without.
             (is (true? (check-jrubies-for-constant-counts pool-context 3 1)))))))))

  (testing "instance borrowed from old pool before pool flush begins and returned *after* new pool is available"
    (bootstrap/with-puppetserver-running
      app
      {:jruby-puppet {:max-active-instances 4}}
      (let [jruby-service (tk-app/get-service app :JRubyPuppetService)
            context (tk-services/service-context jruby-service)
            pool-context (:pool-context context)]

  (testing "file handle opened from old pool instance is held open across pool flush"
    (bootstrap/with-puppetserver-running
      app
      {:jruby-puppet {:max-active-instances 2
                      :borrow-timeout default-borrow-timeout}}
      (let [jruby-service (tk-app/get-service app :JRubyPuppetService)
            context (tk-services/service-context jruby-service)
            pool-context (:pool-context context)]
