From 7adc83d90d7377fb680d921a696c964a530e3135 Mon Sep 17 00:00:00 2001 From: Dmitry Sherstobitov Date: Thu, 19 Dec 2024 13:31:42 -0800 Subject: [PATCH] Fixed port issue 2 --- yugabyte/src/yugabyte/auto.clj | 2 +- yugabyte/src/yugabyte/ysql/client.clj | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/yugabyte/src/yugabyte/auto.clj b/yugabyte/src/yugabyte/auto.clj index adee8b8ff..35036fbff 100644 --- a/yugabyte/src/yugabyte/auto.clj +++ b/yugabyte/src/yugabyte/auto.clj @@ -253,7 +253,7 @@ (ycql.client/await-setup node) :ysql - (ysql.client/check-setup-successful node)) + (ysql.client/check-setup-successful node test)) :started) diff --git a/yugabyte/src/yugabyte/ysql/client.clj b/yugabyte/src/yugabyte/ysql/client.clj index 022bf3563..387ecb77a 100644 --- a/yugabyte/src/yugabyte/ysql/client.clj +++ b/yugabyte/src/yugabyte/ysql/client.clj @@ -19,7 +19,11 @@ (def conn-isolation-level "Default isolation level for connections" Connection/TRANSACTION_SERIALIZABLE) -(def ysql-port 5431) +(defn ysql-port + [test] + (if (:connection-manager test) + 5431 + 5433)) (def max-retry-attempts "Maximum number of attempts to be performed by with-retry" 30) (def max-delay-between-retries-ms "Maximum delay between retries for with-retry" 200) @@ -28,12 +32,12 @@ (defn db-spec "Assemble a JDBC connection specification for a given Jepsen node." - [dbname user password node] + [dbname user password node port] {:dbtype "yugabytedb" :dbname dbname :classname "com.yugabyte.Driver" :host (name node) - :port ysql-port + :port port :user user :password password :loginTimeout (/ default-timeout 1000) @@ -111,13 +115,13 @@ (defn open-conn "Opens a connection to the given node." - [dbname user password node] + [dbname user password node port] (util/timeout default-timeout (throw+ {:type :connection-timed-out :node node}) (info "Connection" dbname) (util/retry 0.1 - (let [spec (db-spec dbname user password node) + (let [spec (db-spec dbname user password node port) conn (j/get-connection spec) spec' (j/add-connection spec conn)] (.setTransactionIsolation conn conn-isolation-level) @@ -137,20 +141,20 @@ "Connects to the YSQL interface and immediately disconnects. YB just... doesn't accept connections sometimes, so we use this to give up on the setup process if the cluster looks broken. Hack hack hack." - [node] + [node test] (try+ - (let [conn (open-conn "postgres" "postgres" "" node)] + (let [conn (open-conn "postgres" "postgres" "" node (ysql-port test))] (close-conn conn)) (catch [:type :connection-timed-out] e (throw+ {:type :jepsen.db/setup-failed})))) (defn conn-wrapper "Constructs a network client for a node, and opens it" - [node] + [node test] (rc/open! (rc/wrapper {:name node - :open (partial open-conn "jepsen" "jepsen" "jepsen" node) + :open (partial open-conn "jepsen" "jepsen" "jepsen" node (ysql-port test)) :close close-conn ; Do not log intermediate reconnection errors (if the reconnect fails, we'll still get it) :log? false}))) @@ -432,7 +436,7 @@ client/Client (open! [~'this ~'test ~'node] - (assoc ~'this :conn-wrapper (conn-wrapper ~'node))) + (assoc ~'this :conn-wrapper (conn-wrapper ~'node ~'test))) (setup! [~'this ~'test] (once-per-cluster