Update testcontainers version to 1.19.0 (#69)
This commit is contained in:
parent
390563ac1d
commit
8c807a8750
3 changed files with 30 additions and 18 deletions
|
|
@ -7,7 +7,7 @@
|
||||||
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
||||||
|
|
||||||
:dependencies [[org.clojure/clojure "1.10.3"]
|
:dependencies [[org.clojure/clojure "1.10.3"]
|
||||||
[org.testcontainers/testcontainers "1.17.6"]]
|
[org.testcontainers/testcontainers "1.19.0"]]
|
||||||
|
|
||||||
:aliases {"test" ["run" "-m" "kaocha.runner"]
|
:aliases {"test" ["run" "-m" "kaocha.runner"]
|
||||||
"cljstyle" ["run" "-m" "cljstyle.main"]}
|
"cljstyle" ["run" "-m" "cljstyle.main"]}
|
||||||
|
|
@ -15,14 +15,14 @@
|
||||||
:plugins [[jainsahab/lein-githooks "1.0.0"]]
|
:plugins [[jainsahab/lein-githooks "1.0.0"]]
|
||||||
|
|
||||||
:profiles {:dev {:dependencies [[expound "0.9.0"]
|
:profiles {:dev {:dependencies [[expound "0.9.0"]
|
||||||
[lambdaisland/kaocha "1.71.1119"]
|
[lambdaisland/kaocha "1.85.1342"]
|
||||||
[lambdaisland/kaocha-cloverage "1.1.89"]
|
[lambdaisland/kaocha-cloverage "1.1.89"]
|
||||||
[lambdaisland/kaocha-junit-xml "1.17.101"]
|
[lambdaisland/kaocha-junit-xml "1.17.101"]
|
||||||
[mvxcvi/cljstyle "0.15.0" :exclusions [org.clojure/clojure]]
|
[mvxcvi/cljstyle "0.15.0" :exclusions [org.clojure/clojure]]
|
||||||
[org.clojure/test.check "1.1.1"]
|
[org.clojure/test.check "1.1.1"]
|
||||||
[orchestra "2021.01.01-1"]
|
[orchestra "2021.01.01-1"]
|
||||||
[org.clojure/tools.namespace "1.3.0"]
|
[org.clojure/tools.namespace "1.3.0"]
|
||||||
[org.testcontainers/postgresql "1.17.6"]
|
[org.testcontainers/postgresql "1.19.0"]
|
||||||
[com.fzakaria/slf4j-timbre "0.3.21"]
|
[com.fzakaria/slf4j-timbre "0.3.21"]
|
||||||
[nrepl "1.0.0"]]
|
[nrepl "1.0.0"]]
|
||||||
:source-paths ["dev-src"]}}
|
:source-paths ["dev-src"]}}
|
||||||
|
|
|
||||||
|
|
@ -334,7 +334,10 @@
|
||||||
(defn dump-logs
|
(defn dump-logs
|
||||||
"Dumps the logs found by invoking the function on the :string-log key"
|
"Dumps the logs found by invoking the function on the :string-log key"
|
||||||
[container-config]
|
[container-config]
|
||||||
((:log container-config)))
|
(let [log-fn (:log container-config)]
|
||||||
|
(if (some? log-fn)
|
||||||
|
(log-fn)
|
||||||
|
(throw (IllegalStateException. "You are trying to access the container logs, but have not configured a log configuration with :log-to")))))
|
||||||
|
|
||||||
(defn start!
|
(defn start!
|
||||||
"Starts the underlying testcontainer instance and adds new values to the
|
"Starts the underlying testcontainer instance and adds new values to the
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
(deftest create-test
|
(deftest create-test
|
||||||
(testing "Testing basic testcontainer generic image initialisation"
|
(testing "Testing basic testcontainer generic image initialisation"
|
||||||
(let [container (sut/create {:image-name "postgres:12.2"
|
(let [container (sut/create {:image-name "postgres:15.3"
|
||||||
:exposed-ports [5432]
|
:exposed-ports [5432]
|
||||||
:env-vars {"POSTGRES_PASSWORD" "pw"}})
|
:env-vars {"POSTGRES_PASSWORD" "pw"}})
|
||||||
initialized-container (sut/start! container)
|
initialized-container (sut/start! container)
|
||||||
|
|
@ -21,21 +21,29 @@
|
||||||
(is (nil? (:mapped-ports stopped-container)))))
|
(is (nil? (:mapped-ports stopped-container)))))
|
||||||
|
|
||||||
(testing "Testing log access to the container with string logs"
|
(testing "Testing log access to the container with string logs"
|
||||||
(let [container (sut/init {:container (PostgreSQLContainer. "postgres:12.2")
|
(let [container (sut/create {:image-name "postgres:15.3"
|
||||||
:log-to {:log-strategy :string}})
|
:exposed-ports [5432]
|
||||||
|
:env-vars {"POSTGRES_PASSWORD" "pw"}
|
||||||
|
:log-to {:log-strategy :string}})
|
||||||
initialized-container (sut/start! container)]
|
initialized-container (sut/start! container)]
|
||||||
(Thread/sleep 500)
|
(Thread/sleep 500)
|
||||||
(is (includes? (sut/dump-logs initialized-container) "database system is ready to accept connections"))))
|
(is (includes? (sut/dump-logs initialized-container) "database system is ready to accept connections"))))
|
||||||
|
|
||||||
(testing "Testing log access to the container with function logs"
|
(testing "Testing log access to the container with function logs"
|
||||||
(let [logs (atom [])]
|
(let [logs (atom [])]
|
||||||
(sut/start! (sut/init {:container (PostgreSQLContainer. "postgres:12.2")
|
(sut/start! (sut/init {:container (PostgreSQLContainer. "postgres:15.3")
|
||||||
|
:exposed-ports [5432]
|
||||||
:log-to {:log-strategy :fn
|
:log-to {:log-strategy :fn
|
||||||
:function #(swap! logs conj %)}}))
|
:function #(swap! logs conj %)}}))
|
||||||
(is (filter #(includes? "database system is ready to accept connections" %) @logs))))
|
(is (filter #(includes? "database system is ready to accept connections" %) @logs))))
|
||||||
|
|
||||||
|
(testing "Testing log access to the container with unconfigured logger"
|
||||||
|
(let [container (sut/start! (sut/init {:container (PostgreSQLContainer. "postgres:15.3")
|
||||||
|
:exposed-ports [5432]}))]
|
||||||
|
(is (thrown? IllegalStateException (sut/dump-logs container)))))
|
||||||
|
|
||||||
(testing "Testing basic testcontainer generic image initialisation with wait for log message"
|
(testing "Testing basic testcontainer generic image initialisation with wait for log message"
|
||||||
(let [container (sut/create {:image-name "postgres:12.2"
|
(let [container (sut/create {:image-name "postgres:15.3"
|
||||||
:exposed-ports [5432]
|
:exposed-ports [5432]
|
||||||
:env-vars {"POSTGRES_PASSWORD" "pw"}
|
:env-vars {"POSTGRES_PASSWORD" "pw"}
|
||||||
:wait-for {:wait-strategy :log
|
:wait-for {:wait-strategy :log
|
||||||
|
|
@ -51,7 +59,7 @@
|
||||||
(is (nil? (:mapped-ports stopped-container)))))
|
(is (nil? (:mapped-ports stopped-container)))))
|
||||||
|
|
||||||
(testing "Testing basic testcontainer generic image initialisation with wait for host port"
|
(testing "Testing basic testcontainer generic image initialisation with wait for host port"
|
||||||
(let [container (sut/create {:image-name "postgres:12.2"
|
(let [container (sut/create {:image-name "postgres:15.3"
|
||||||
:exposed-ports [5432]
|
:exposed-ports [5432]
|
||||||
:env-vars {"POSTGRES_PASSWORD" "pw"}
|
:env-vars {"POSTGRES_PASSWORD" "pw"}
|
||||||
:wait-for {:wait-strategy :port}})
|
:wait-for {:wait-strategy :port}})
|
||||||
|
|
@ -101,7 +109,8 @@
|
||||||
|
|
||||||
|
|
||||||
(testing "Executing a command in the running Docker container with a custom container"
|
(testing "Executing a command in the running Docker container with a custom container"
|
||||||
(let [container (sut/init {:container (PostgreSQLContainer. "postgres:12.2")})
|
(let [container (sut/init {:container (PostgreSQLContainer. "postgres:15.3")
|
||||||
|
:exposed-ports [5432]})
|
||||||
initialized-container (sut/start! container)
|
initialized-container (sut/start! container)
|
||||||
result (sut/execute-command! initialized-container ["whoami"])
|
result (sut/execute-command! initialized-container ["whoami"])
|
||||||
_stopped-container (sut/stop! container)]
|
_stopped-container (sut/stop! container)]
|
||||||
|
|
@ -111,7 +120,7 @@
|
||||||
(deftest execute-command-in-container
|
(deftest execute-command-in-container
|
||||||
|
|
||||||
(testing "Executing a command in the running Docker container"
|
(testing "Executing a command in the running Docker container"
|
||||||
(let [container (sut/create {:image-name "postgres:12.2"
|
(let [container (sut/create {:image-name "postgres:15.3"
|
||||||
:exposed-ports [5432]
|
:exposed-ports [5432]
|
||||||
:env-vars {"POSTGRES_PASSWORD" "pw"}})
|
:env-vars {"POSTGRES_PASSWORD" "pw"}})
|
||||||
initialized-container (sut/start! container)
|
initialized-container (sut/start! container)
|
||||||
|
|
@ -123,7 +132,7 @@
|
||||||
(deftest init-volume-test
|
(deftest init-volume-test
|
||||||
|
|
||||||
(testing "Testing mapping of a classpath resource"
|
(testing "Testing mapping of a classpath resource"
|
||||||
(let [container (-> (sut/create {:image-name "postgres:12.2"
|
(let [container (-> (sut/create {:image-name "postgres:15.3"
|
||||||
:exposed-ports [5432]
|
:exposed-ports [5432]
|
||||||
:env-vars {"POSTGRES_PASSWORD" "pw"}})
|
:env-vars {"POSTGRES_PASSWORD" "pw"}})
|
||||||
(sut/map-classpath-resource! {:resource-path "test.sql"
|
(sut/map-classpath-resource! {:resource-path "test.sql"
|
||||||
|
|
@ -140,7 +149,7 @@
|
||||||
(is (nil? (:mapped-ports stopped-container)))))
|
(is (nil? (:mapped-ports stopped-container)))))
|
||||||
|
|
||||||
(testing "Testing mapping of a filesystem-binding"
|
(testing "Testing mapping of a filesystem-binding"
|
||||||
(let [container (-> (sut/create {:image-name "postgres:12.2"
|
(let [container (-> (sut/create {:image-name "postgres:15.3"
|
||||||
:exposed-ports [5432]
|
:exposed-ports [5432]
|
||||||
:env-vars {"POSTGRES_PASSWORD" "pw"}})
|
:env-vars {"POSTGRES_PASSWORD" "pw"}})
|
||||||
(sut/bind-filesystem! {:host-path "."
|
(sut/bind-filesystem! {:host-path "."
|
||||||
|
|
@ -157,7 +166,7 @@
|
||||||
(is (nil? (:mapped-ports stopped-container)))))
|
(is (nil? (:mapped-ports stopped-container)))))
|
||||||
|
|
||||||
(testing "Copying a file from the host into the container"
|
(testing "Copying a file from the host into the container"
|
||||||
(let [container (-> (sut/create {:image-name "postgres:12.2"
|
(let [container (-> (sut/create {:image-name "postgres:15.3"
|
||||||
:exposed-ports [5432]
|
:exposed-ports [5432]
|
||||||
:env-vars {"POSTGRES_PASSWORD" "pw"}})
|
:env-vars {"POSTGRES_PASSWORD" "pw"}})
|
||||||
(sut/copy-file-to-container! {:path "test.sql"
|
(sut/copy-file-to-container! {:path "test.sql"
|
||||||
|
|
@ -175,7 +184,7 @@
|
||||||
|
|
||||||
|
|
||||||
(testing "Copying a file from the classpath into the container"
|
(testing "Copying a file from the classpath into the container"
|
||||||
(let [container (-> (sut/create {:image-name "postgres:12.2"
|
(let [container (-> (sut/create {:image-name "postgres:15.3"
|
||||||
:exposed-ports [5432]
|
:exposed-ports [5432]
|
||||||
:env-vars {"POSTGRES_PASSWORD" "pw"}})
|
:env-vars {"POSTGRES_PASSWORD" "pw"}})
|
||||||
(sut/copy-file-to-container! {:path "test.sql"
|
(sut/copy-file-to-container! {:path "test.sql"
|
||||||
|
|
@ -192,7 +201,7 @@
|
||||||
(is (nil? (:mapped-ports stopped-container)))))
|
(is (nil? (:mapped-ports stopped-container)))))
|
||||||
|
|
||||||
(testing "Copying a file from the host into a running container"
|
(testing "Copying a file from the host into a running container"
|
||||||
(let [container (sut/create {:image-name "postgres:12.2"
|
(let [container (sut/create {:image-name "postgres:15.3"
|
||||||
:exposed-ports [5432]
|
:exposed-ports [5432]
|
||||||
:env-vars {"POSTGRES_PASSWORD" "pw"}})
|
:env-vars {"POSTGRES_PASSWORD" "pw"}})
|
||||||
initialized-container (sut/start! container)
|
initialized-container (sut/start! container)
|
||||||
|
|
@ -211,7 +220,7 @@
|
||||||
(is (nil? (:mapped-ports stopped-container)))))
|
(is (nil? (:mapped-ports stopped-container)))))
|
||||||
|
|
||||||
(testing "Copying a file from the classpath into a running container"
|
(testing "Copying a file from the classpath into a running container"
|
||||||
(let [container (sut/create {:image-name "postgres:12.2"
|
(let [container (sut/create {:image-name "postgres:15.3"
|
||||||
:exposed-ports [5432]
|
:exposed-ports [5432]
|
||||||
:env-vars {"POSTGRES_PASSWORD" "pw"}})
|
:env-vars {"POSTGRES_PASSWORD" "pw"}})
|
||||||
initialized-container (sut/start! container)
|
initialized-container (sut/start! container)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue