Skip to content

Commit

Permalink
Fix core_test for IPv6-first environments
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin committed Mar 29, 2024
1 parent cc99451 commit f4e09f9
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions test/langohr/test/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
(deftest test-connection-with-default-parameters
(with-open [conn (lc/connect)]
(is (instance? com.rabbitmq.client.Connection conn))
(is (lc/automatically-recover? conn))
(is (lc/automatic-recovery-enabled? conn))
(is (lc/automatic-recovery-enabled? conn))
(is (lc/open? conn))))

Expand All @@ -32,7 +32,7 @@
:vhost "langohr_testbed" :username "langohr" :password "langohr.password"
:requested-heartbeat 3 :connection-timeout 5})]
(is (lc/open? conn))
(is (lc/automatically-recover? conn))
(is (lc/automatic-recovery-enabled? conn))
(is (= "127.0.0.1" (-> conn .getAddress .getHostAddress)))
(is (= 5672 (.getPort conn)))
(is (= 3 (.getHeartbeat conn)))))
Expand All @@ -53,7 +53,9 @@
(deftest test-connection-with-custom-executor
(with-open [conn (lc/connect {:executor (Executors/newFixedThreadPool 16)})]
(is (lc/open? conn))
(is (= "127.0.0.1" (-> conn .getAddress .getHostAddress)))
(let [addr (-> conn .getAddress .getHostAddress)]
(is (or (= "0:0:0:0:0:0:0:1" addr)
(= "127.0.0.1" addr))))
(is (= 5672 (.getPort conn)))))

(deftest test-connection-with-custom-thread-factory
Expand All @@ -73,13 +75,15 @@
(deftest test-connection-with-uri
(with-open [conn (lc/connect {:uri "amqp://127.0.0.1:5672"})]
(is (lc/open? conn))
(is (= "127.0.0.1" (-> conn .getAddress .getHostAddress)))
(let [addr (-> conn .getAddress .getHostAddress)]
(is (or (= "0:0:0:0:0:0:0:1" addr)
(= "127.0.0.1" addr))))
(is (= 5672 (.getPort conn)))
(is (-> conn .getServerProperties (get "capabilities") (get "publisher_confirms")))))

(deftest test-connection-with-connection-recovery-enabled
(with-open [conn (lc/connect {:automatically-recover true})]
(is (lc/automatically-recover? conn))
(is (lc/automatic-recovery-enabled? conn))
(is (lc/open? conn))))

(deftest test-broker-capabilities
Expand Down Expand Up @@ -150,7 +154,7 @@
(let [conn (lc/connect {:automatically-recover true})
ch (lc/create-channel conn)
latch (java.util.concurrent.CountDownLatch. 1)]
(is (lc/automatically-recover? conn))
(is (lc/automatic-recovery-enabled? conn))
(lc/on-recovery conn (fn [new-conn] (is false "should not start recovery after explicit shutdown")))
(lc/add-shutdown-listener conn
(fn [sse]
Expand Down

0 comments on commit f4e09f9

Please sign in to comment.