       (Thread/sleep 1000)
       (recur (- tries 1)))))
 
-(defn- init-docker-elastic []
+(defn- start-elasticsearch []
   (let [port (find-free-local-port)
         elastic-ip (str "http://127.0.0.1:" port)
         elastic-docker-ip (str "127.0.0.1:" port ":9200")]

    [robert.hooke :refer [add-hook]]
    [clojure.java.shell :refer [sh]]))

(defn- stop-docker-elastic []
  (sh "docker" "kill" "kouta-elastic"))

(defn- elastic-has-started? [elastic-ip]

  (defn- run-tests-hook
    [f & nss]
    (let [embedded-elasticsearch? (find-ns 'clj-elasticsearch.elastic-utils)]
      (when embedded-elasticsearch? (start-elasticsearch))
      (let [result (apply f nss)]
        (when embedded-elasticsearch? (stop-elasticsearch))
        result)))
  (add-hook #'clojure.test/run-tests #'run-tests-hook))