You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "xtern (via GitHub)" <gi...@apache.org> on 2025/11/18 16:22:56 UTC

[PR] IGNITE-25587 Jdbc. Basic connection failover tests [ignite-3]

xtern opened a new pull request, #7007:
URL: https://github.com/apache/ignite-3/pull/7007

   https://issues.apache.org/jira/browse/IGNITE-25587


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25587 Jdbc. Basic connection failover tests [ignite-3]

Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #7007:
URL: https://github.com/apache/ignite-3/pull/7007#discussion_r2544756287


##########
modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionFailoverTest.java:
##########
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.jdbc;
+
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrows;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.time.Duration;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.ignite.internal.ClusterPerTestIntegrationTest;
+import org.apache.ignite.internal.jdbc.JdbcConnection;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Basic test scenarios with JDBC connection failover.
+ */
+public class ItJdbcConnectionFailoverTest extends ClusterPerTestIntegrationTest {
+    private static final int BASE_CLIENT_PORT = 10800;
+
+    @Override
+    protected int initialNodes() {
+        return 0;
+    }
+
+    /**
+     * Ensures that the client establishes connections to multiple nodes.
+     */
+    @Test
+    void testMultipleConnectionEstablishment() throws SQLException {
+        int nodesCount = 2;
+
+        cluster.startAndInit(nodesCount, new int[]{0});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            await().timeout(Duration.ofSeconds(5))
+                    .until(() -> channelsCount(connection), is(nodesCount));

Review Comment:
   I think it some kind of implementation approach and not a requirement ? Or i miss smth ? Why do we really need to check channels count ?



##########
modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionFailoverTest.java:
##########
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.jdbc;
+
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrows;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.time.Duration;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.ignite.internal.ClusterPerTestIntegrationTest;
+import org.apache.ignite.internal.jdbc.JdbcConnection;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Basic test scenarios with JDBC connection failover.
+ */
+public class ItJdbcConnectionFailoverTest extends ClusterPerTestIntegrationTest {
+    private static final int BASE_CLIENT_PORT = 10800;
+
+    @Override
+    protected int initialNodes() {
+        return 0;
+    }
+
+    /**
+     * Ensures that the client establishes connections to multiple nodes.
+     */
+    @Test
+    void testMultipleConnectionEstablishment() throws SQLException {
+        int nodesCount = 2;
+
+        cluster.startAndInit(nodesCount, new int[]{0});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            await().timeout(Duration.ofSeconds(5))
+                    .until(() -> channelsCount(connection), is(nodesCount));
+        }
+    }
+
+    /**
+     * Ensures that the query is forwarded to the alive node.
+     *
+     * <p>Test sequentially restarts each cluster node keeping CMG majority alive.
+     */
+    @Test
+    void testConnectionFailover() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{0, 1, 2});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            try (Statement statement = connection.createStatement()) {
+                statement.executeUpdate("CREATE ZONE zone1 (REPLICAS 3, PARTITIONS 1) STORAGE PROFILES ['default']");

Review Comment:
   let`s store default **partitions**  here ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25587 Jdbc. Basic connection failover tests [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern closed pull request #7007: IGNITE-25587 Jdbc. Basic connection failover tests
URL: https://github.com/apache/ignite-3/pull/7007


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25587 Jdbc. Basic connection failover tests [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #7007:
URL: https://github.com/apache/ignite-3/pull/7007#discussion_r2544884634


##########
modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionFailoverTest.java:
##########
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.jdbc;
+
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrows;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.time.Duration;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.ignite.internal.ClusterPerTestIntegrationTest;
+import org.apache.ignite.internal.jdbc.JdbcConnection;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Basic test scenarios with JDBC connection failover.
+ */
+public class ItJdbcConnectionFailoverTest extends ClusterPerTestIntegrationTest {
+    private static final int BASE_CLIENT_PORT = 10800;
+
+    @Override
+    protected int initialNodes() {
+        return 0;
+    }
+
+    /**
+     * Ensures that the client establishes connections to multiple nodes.
+     */
+    @Test
+    void testMultipleConnectionEstablishment() throws SQLException {
+        int nodesCount = 2;
+
+        cluster.startAndInit(nodesCount, new int[]{0});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            await().timeout(Duration.ofSeconds(5))
+                    .until(() -> channelsCount(connection), is(nodesCount));

Review Comment:
   I had the same thoughts – the test has been removed.
   
   P.S. I originally added it based on what I saw in AI2.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25587 Jdbc. Basic connection failover tests [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #7007:
URL: https://github.com/apache/ignite-3/pull/7007#discussion_r2544888711


##########
modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionFailoverTest.java:
##########
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.jdbc;
+
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrows;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.time.Duration;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.ignite.internal.ClusterPerTestIntegrationTest;
+import org.apache.ignite.internal.jdbc.JdbcConnection;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Basic test scenarios with JDBC connection failover.
+ */
+public class ItJdbcConnectionFailoverTest extends ClusterPerTestIntegrationTest {
+    private static final int BASE_CLIENT_PORT = 10800;
+
+    @Override
+    protected int initialNodes() {
+        return 0;
+    }
+
+    /**
+     * Ensures that the client establishes connections to multiple nodes.
+     */
+    @Test
+    void testMultipleConnectionEstablishment() throws SQLException {
+        int nodesCount = 2;
+
+        cluster.startAndInit(nodesCount, new int[]{0});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            await().timeout(Duration.ofSeconds(5))
+                    .until(() -> channelsCount(connection), is(nodesCount));
+        }
+    }
+
+    /**
+     * Ensures that the query is forwarded to the alive node.
+     *
+     * <p>Test sequentially restarts each cluster node keeping CMG majority alive.
+     */
+    @Test
+    void testConnectionFailover() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{0, 1, 2});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            try (Statement statement = connection.createStatement()) {
+                statement.executeUpdate("CREATE ZONE zone1 (REPLICAS 3, PARTITIONS 1) STORAGE PROFILES ['default']");

Review Comment:
   Fixed thanks



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25587 Jdbc. Basic connection failover tests [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #7007:
URL: https://github.com/apache/ignite-3/pull/7007#discussion_r2541435596


##########
modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionFailoverTest.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.jdbc;
+
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrows;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.time.Duration;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.ignite.internal.ClusterPerTestIntegrationTest;
+import org.apache.ignite.internal.jdbc2.JdbcConnection2;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Basic test scenarios with JDBC connection failover.
+ */
+public class ItJdbcConnectionFailoverTest extends ClusterPerTestIntegrationTest {
+    private static final int BASE_CLIENT_PORT = 10800;
+
+    @Override
+    protected int initialNodes() {
+        return 0;
+    }
+
+    @Test
+    void testMultipleConnectionEstablishment() throws SQLException {
+        int nodesCount = 2;
+
+        cluster.startAndInit(nodesCount, new int[]{0});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            await().timeout(Duration.ofSeconds(5))
+                    .until(() -> channelsCount(connection), is(nodesCount));
+        }
+    }
+
+    /**
+     * Ensures that the query is forwarded to the alive node.
+     *
+     * <p>Test sequentially restarts each cluster node keeping CMG majority alive.
+     */
+    @Test
+    void testConnectionFailover() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{0, 1, 2});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            try (Statement stmt = connection.createStatement()) {
+                stmt.executeUpdate("CREATE ZONE zone1 (REPLICAS 3, PARTITIONS 1) STORAGE PROFILES ['default']");
+                stmt.executeUpdate("CREATE TABLE t(id INT PRIMARY KEY, val INT) ZONE zone1");
+                assertThat(stmt.executeUpdate("INSERT INTO t VALUES (1, 1)"), is(1));
+
+                cluster.stopNode(0);
+                assertThat(stmt.executeUpdate("INSERT INTO t VALUES (2, 2)"), is(1));
+
+                cluster.startNode(0);
+                cluster.stopNode(1);
+                assertThat(stmt.executeUpdate("INSERT INTO t VALUES (3, 3)"), is(1));
+
+                cluster.startNode(1);
+                cluster.stopNode(2);
+                assertThat(stmt.executeUpdate("INSERT INTO t VALUES (4, 4)"), is(1));
+
+                ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM t WHERE id > 0");
+                assertThat(rs.next(), is(true));
+                assertThat(rs.getInt(1), is(4));
+            }
+        }
+    }
+
+    /**
+     * Checks transparent connection establishment after losing all connections.
+     */
+    @Test
+    void testTotalConnectionFailover() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{2});
+        String dummyQuery = "SELECT 1";
+
+        try (Connection connection = getConnection(nodesCount - 1)) {
+            try (Statement stmt = connection.createStatement()) {
+                assertThat(stmt.execute(dummyQuery), is(true));
+
+                // Stop all cluster nodes known to the client.
+                cluster.stopNode(0);
+                cluster.stopNode(1);
+
+                //noinspection ThrowableNotThrown
+                assertThrows(
+                        SQLException.class,
+                        () -> stmt.execute("SELECT 1"),
+                        "Connection refused"
+                );
+
+                cluster.startNode(1);
+
+                assertThat(stmt.execute("SELECT 1"), is(true));
+            }
+        }
+    }
+
+    @Test
+    @Disabled("https://issues.apache.org/jira/browse/IGNITE-27091")
+    void testTransactionCannotBeUsedAfterNodeRestart() throws SQLException {

Review Comment:
   Currently, this test only fails on the last line—an attempt to rollback a transaction while closing the statement throws "channel is closed." The fix seems trivial, but during a private discussion, it was decided to address this in a separate ticket.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25587 Jdbc. Basic connection failover tests [ignite-3]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #7007:
URL: https://github.com/apache/ignite-3/pull/7007#discussion_r2544717556


##########
modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionFailoverTest.java:
##########
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.jdbc;
+
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrows;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.time.Duration;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.ignite.internal.ClusterPerTestIntegrationTest;
+import org.apache.ignite.internal.jdbc.JdbcConnection;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Basic test scenarios with JDBC connection failover.
+ */
+public class ItJdbcConnectionFailoverTest extends ClusterPerTestIntegrationTest {
+    private static final int BASE_CLIENT_PORT = 10800;
+
+    @Override
+    protected int initialNodes() {
+        return 0;
+    }
+
+    /**
+     * Ensures that the client establishes connections to multiple nodes.
+     */
+    @Test
+    void testMultipleConnectionEstablishment() throws SQLException {
+        int nodesCount = 2;
+
+        cluster.startAndInit(nodesCount, new int[]{0});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            await().timeout(Duration.ofSeconds(5))
+                    .until(() -> channelsCount(connection), is(nodesCount));
+        }
+    }
+
+    /**
+     * Ensures that the query is forwarded to the alive node.
+     *
+     * <p>Test sequentially restarts each cluster node keeping CMG majority alive.
+     */
+    @Test
+    void testConnectionFailover() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{0, 1, 2});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            try (Statement statement = connection.createStatement()) {
+                statement.executeUpdate("CREATE ZONE zone1 (REPLICAS 3, PARTITIONS 1) STORAGE PROFILES ['default']");
+                statement.executeUpdate("CREATE TABLE t(id INT PRIMARY KEY, val INT) ZONE zone1");
+
+                try (PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO t VALUES (?, ?)")) {
+                    performUpdates(preparedStatement, 0, 100);
+
+                    cluster.stopNode(0);
+                    performUpdates(preparedStatement, 100, 200);
+
+                    cluster.startNode(0);
+                    cluster.stopNode(1);
+                    performUpdates(preparedStatement, 200, 300);
+
+                    cluster.startNode(1);
+                    cluster.stopNode(2);
+                    performUpdates(preparedStatement, 300, 400);
+                }
+
+                try (ResultSet rs = statement.executeQuery("SELECT COUNT(*) FROM t WHERE id >= 0")) {
+                    assertThat(rs.next(), is(true));
+                    assertThat(rs.getInt(1), is(400));
+                }
+            }
+        }
+    }
+
+    /**
+     * Checks transparent connection establishment after losing all connections.
+     */
+    @Test
+    void testTotalConnectionFailover() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{2});
+        String dummyQuery = "SELECT 1";
+
+        try (Connection connection = getConnection(nodesCount - 1)) {
+            try (Statement stmt = connection.createStatement()) {
+                assertThat(stmt.execute(dummyQuery), is(true));
+
+                // Stop all cluster nodes known to the client.
+                cluster.stopNode(0);
+                cluster.stopNode(1);
+
+                //noinspection ThrowableNotThrown
+                assertThrows(
+                        SQLException.class,
+                        () -> stmt.execute("SELECT 1"),
+                        "Connection refused"
+                );
+
+                cluster.startNode(1);
+
+                assertThat(stmt.execute("SELECT 1"), is(true));
+            }
+        }
+    }
+
+    /**
+     * Ensures that the client receives the meaningful exception when the node holding the client transaction goes down.

Review Comment:
   Grammar issue: should be "a meaningful exception" instead of "the meaningful exception".
   ```suggestion
        * Ensures that the client receives a meaningful exception when the node holding the client transaction goes down.
   ```



##########
modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionFailoverTest.java:
##########
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.jdbc;
+
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrows;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.time.Duration;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.ignite.internal.ClusterPerTestIntegrationTest;
+import org.apache.ignite.internal.jdbc.JdbcConnection;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Basic test scenarios with JDBC connection failover.
+ */
+public class ItJdbcConnectionFailoverTest extends ClusterPerTestIntegrationTest {
+    private static final int BASE_CLIENT_PORT = 10800;
+
+    @Override
+    protected int initialNodes() {
+        return 0;
+    }
+
+    /**
+     * Ensures that the client establishes connections to multiple nodes.
+     */
+    @Test
+    void testMultipleConnectionEstablishment() throws SQLException {
+        int nodesCount = 2;
+
+        cluster.startAndInit(nodesCount, new int[]{0});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            await().timeout(Duration.ofSeconds(5))
+                    .until(() -> channelsCount(connection), is(nodesCount));
+        }
+    }
+
+    /**
+     * Ensures that the query is forwarded to the alive node.
+     *
+     * <p>Test sequentially restarts each cluster node keeping CMG majority alive.
+     */
+    @Test
+    void testConnectionFailover() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{0, 1, 2});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            try (Statement statement = connection.createStatement()) {
+                statement.executeUpdate("CREATE ZONE zone1 (REPLICAS 3, PARTITIONS 1) STORAGE PROFILES ['default']");
+                statement.executeUpdate("CREATE TABLE t(id INT PRIMARY KEY, val INT) ZONE zone1");
+
+                try (PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO t VALUES (?, ?)")) {
+                    performUpdates(preparedStatement, 0, 100);
+
+                    cluster.stopNode(0);
+                    performUpdates(preparedStatement, 100, 200);
+
+                    cluster.startNode(0);
+                    cluster.stopNode(1);
+                    performUpdates(preparedStatement, 200, 300);
+
+                    cluster.startNode(1);
+                    cluster.stopNode(2);
+                    performUpdates(preparedStatement, 300, 400);
+                }
+
+                try (ResultSet rs = statement.executeQuery("SELECT COUNT(*) FROM t WHERE id >= 0")) {
+                    assertThat(rs.next(), is(true));
+                    assertThat(rs.getInt(1), is(400));
+                }
+            }
+        }
+    }
+
+    /**
+     * Checks transparent connection establishment after losing all connections.
+     */
+    @Test
+    void testTotalConnectionFailover() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{2});
+        String dummyQuery = "SELECT 1";
+
+        try (Connection connection = getConnection(nodesCount - 1)) {
+            try (Statement stmt = connection.createStatement()) {
+                assertThat(stmt.execute(dummyQuery), is(true));
+
+                // Stop all cluster nodes known to the client.
+                cluster.stopNode(0);
+                cluster.stopNode(1);
+
+                //noinspection ThrowableNotThrown
+                assertThrows(
+                        SQLException.class,
+                        () -> stmt.execute("SELECT 1"),
+                        "Connection refused"
+                );
+
+                cluster.startNode(1);
+
+                assertThat(stmt.execute("SELECT 1"), is(true));
+            }
+        }
+    }
+
+    /**
+     * Ensures that the client receives the meaningful exception when the node holding the client transaction goes down.
+     */
+    @Test
+    @Disabled("https://issues.apache.org/jira/browse/IGNITE-27091")
+    void testTransactionCannotBeUsedAfterNodeRestart() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{2});
+
+        try (Connection connection = getConnection(nodesCount - 1)) {
+            connection.setAutoCommit(false);
+
+            try (Statement stmt = connection.createStatement()) {
+                assertThat(stmt.execute("SELECT 1"), is(true));

Review Comment:
   [nitpick] Consider using a named constant or variable for this query string rather than hardcoding "SELECT 1" for consistency and maintainability. Multiple tests in this file use this same query, so defining it once would make future changes easier.



##########
modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionFailoverTest.java:
##########
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.jdbc;
+
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrows;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.time.Duration;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.ignite.internal.ClusterPerTestIntegrationTest;
+import org.apache.ignite.internal.jdbc.JdbcConnection;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Basic test scenarios with JDBC connection failover.
+ */
+public class ItJdbcConnectionFailoverTest extends ClusterPerTestIntegrationTest {
+    private static final int BASE_CLIENT_PORT = 10800;
+
+    @Override
+    protected int initialNodes() {
+        return 0;
+    }
+
+    /**
+     * Ensures that the client establishes connections to multiple nodes.
+     */
+    @Test
+    void testMultipleConnectionEstablishment() throws SQLException {
+        int nodesCount = 2;
+
+        cluster.startAndInit(nodesCount, new int[]{0});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            await().timeout(Duration.ofSeconds(5))
+                    .until(() -> channelsCount(connection), is(nodesCount));
+        }
+    }
+
+    /**
+     * Ensures that the query is forwarded to the alive node.
+     *
+     * <p>Test sequentially restarts each cluster node keeping CMG majority alive.
+     */
+    @Test
+    void testConnectionFailover() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{0, 1, 2});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            try (Statement statement = connection.createStatement()) {
+                statement.executeUpdate("CREATE ZONE zone1 (REPLICAS 3, PARTITIONS 1) STORAGE PROFILES ['default']");
+                statement.executeUpdate("CREATE TABLE t(id INT PRIMARY KEY, val INT) ZONE zone1");
+
+                try (PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO t VALUES (?, ?)")) {
+                    performUpdates(preparedStatement, 0, 100);
+
+                    cluster.stopNode(0);
+                    performUpdates(preparedStatement, 100, 200);
+
+                    cluster.startNode(0);
+                    cluster.stopNode(1);
+                    performUpdates(preparedStatement, 200, 300);
+
+                    cluster.startNode(1);
+                    cluster.stopNode(2);
+                    performUpdates(preparedStatement, 300, 400);
+                }
+
+                try (ResultSet rs = statement.executeQuery("SELECT COUNT(*) FROM t WHERE id >= 0")) {
+                    assertThat(rs.next(), is(true));
+                    assertThat(rs.getInt(1), is(400));
+                }
+            }
+        }
+    }
+
+    /**
+     * Checks transparent connection establishment after losing all connections.
+     */
+    @Test
+    void testTotalConnectionFailover() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{2});
+        String dummyQuery = "SELECT 1";
+
+        try (Connection connection = getConnection(nodesCount - 1)) {
+            try (Statement stmt = connection.createStatement()) {
+                assertThat(stmt.execute(dummyQuery), is(true));
+
+                // Stop all cluster nodes known to the client.
+                cluster.stopNode(0);
+                cluster.stopNode(1);
+
+                //noinspection ThrowableNotThrown
+                assertThrows(
+                        SQLException.class,
+                        () -> stmt.execute("SELECT 1"),
+                        "Connection refused"
+                );

Review Comment:
   [nitpick] Consider using `JdbcTestUtils.assertThrowsSqlException` instead of `IgniteTestUtils.assertThrows` for consistency with other JDBC tests. This helper is specifically designed for SQL exception assertions and is used consistently throughout the JDBC test suite.
   
   Example:
   ```java
   JdbcTestUtils.assertThrowsSqlException(
       "Connection refused",
       () -> stmt.execute("SELECT 1")
   );
   ```



##########
modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionFailoverTest.java:
##########
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.jdbc;
+
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrows;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.time.Duration;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.ignite.internal.ClusterPerTestIntegrationTest;
+import org.apache.ignite.internal.jdbc.JdbcConnection;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Basic test scenarios with JDBC connection failover.
+ */
+public class ItJdbcConnectionFailoverTest extends ClusterPerTestIntegrationTest {
+    private static final int BASE_CLIENT_PORT = 10800;
+
+    @Override
+    protected int initialNodes() {
+        return 0;
+    }
+
+    /**
+     * Ensures that the client establishes connections to multiple nodes.
+     */
+    @Test
+    void testMultipleConnectionEstablishment() throws SQLException {
+        int nodesCount = 2;
+
+        cluster.startAndInit(nodesCount, new int[]{0});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            await().timeout(Duration.ofSeconds(5))
+                    .until(() -> channelsCount(connection), is(nodesCount));
+        }
+    }
+
+    /**
+     * Ensures that the query is forwarded to the alive node.
+     *
+     * <p>Test sequentially restarts each cluster node keeping CMG majority alive.
+     */
+    @Test
+    void testConnectionFailover() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{0, 1, 2});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            try (Statement statement = connection.createStatement()) {
+                statement.executeUpdate("CREATE ZONE zone1 (REPLICAS 3, PARTITIONS 1) STORAGE PROFILES ['default']");
+                statement.executeUpdate("CREATE TABLE t(id INT PRIMARY KEY, val INT) ZONE zone1");
+
+                try (PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO t VALUES (?, ?)")) {
+                    performUpdates(preparedStatement, 0, 100);
+
+                    cluster.stopNode(0);
+                    performUpdates(preparedStatement, 100, 200);
+
+                    cluster.startNode(0);
+                    cluster.stopNode(1);
+                    performUpdates(preparedStatement, 200, 300);
+
+                    cluster.startNode(1);
+                    cluster.stopNode(2);
+                    performUpdates(preparedStatement, 300, 400);
+                }
+
+                try (ResultSet rs = statement.executeQuery("SELECT COUNT(*) FROM t WHERE id >= 0")) {
+                    assertThat(rs.next(), is(true));
+                    assertThat(rs.getInt(1), is(400));
+                }
+            }
+        }
+    }
+
+    /**
+     * Checks transparent connection establishment after losing all connections.
+     */
+    @Test
+    void testTotalConnectionFailover() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{2});
+        String dummyQuery = "SELECT 1";
+
+        try (Connection connection = getConnection(nodesCount - 1)) {
+            try (Statement stmt = connection.createStatement()) {
+                assertThat(stmt.execute(dummyQuery), is(true));
+
+                // Stop all cluster nodes known to the client.
+                cluster.stopNode(0);
+                cluster.stopNode(1);
+
+                //noinspection ThrowableNotThrown
+                assertThrows(
+                        SQLException.class,
+                        () -> stmt.execute("SELECT 1"),
+                        "Connection refused"
+                );
+
+                cluster.startNode(1);
+
+                assertThat(stmt.execute("SELECT 1"), is(true));

Review Comment:
   The hardcoded query string "SELECT 1" duplicates the `dummyQuery` variable defined at line 110. Consider using the `dummyQuery` variable for consistency and maintainability.
   
   ```java
   assertThat(stmt.execute(dummyQuery), is(true));
   ```
   ```suggestion
                   assertThat(stmt.execute(dummyQuery), is(true));
   ```



##########
modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionFailoverTest.java:
##########
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.jdbc;
+
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrows;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.time.Duration;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.ignite.internal.ClusterPerTestIntegrationTest;
+import org.apache.ignite.internal.jdbc.JdbcConnection;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Basic test scenarios with JDBC connection failover.
+ */
+public class ItJdbcConnectionFailoverTest extends ClusterPerTestIntegrationTest {
+    private static final int BASE_CLIENT_PORT = 10800;
+
+    @Override
+    protected int initialNodes() {
+        return 0;
+    }
+
+    /**
+     * Ensures that the client establishes connections to multiple nodes.
+     */
+    @Test
+    void testMultipleConnectionEstablishment() throws SQLException {
+        int nodesCount = 2;
+
+        cluster.startAndInit(nodesCount, new int[]{0});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            await().timeout(Duration.ofSeconds(5))
+                    .until(() -> channelsCount(connection), is(nodesCount));
+        }
+    }
+
+    /**
+     * Ensures that the query is forwarded to the alive node.
+     *
+     * <p>Test sequentially restarts each cluster node keeping CMG majority alive.
+     */
+    @Test
+    void testConnectionFailover() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{0, 1, 2});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            try (Statement statement = connection.createStatement()) {
+                statement.executeUpdate("CREATE ZONE zone1 (REPLICAS 3, PARTITIONS 1) STORAGE PROFILES ['default']");
+                statement.executeUpdate("CREATE TABLE t(id INT PRIMARY KEY, val INT) ZONE zone1");
+
+                try (PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO t VALUES (?, ?)")) {
+                    performUpdates(preparedStatement, 0, 100);
+
+                    cluster.stopNode(0);
+                    performUpdates(preparedStatement, 100, 200);
+
+                    cluster.startNode(0);
+                    cluster.stopNode(1);
+                    performUpdates(preparedStatement, 200, 300);
+
+                    cluster.startNode(1);
+                    cluster.stopNode(2);
+                    performUpdates(preparedStatement, 300, 400);
+                }
+
+                try (ResultSet rs = statement.executeQuery("SELECT COUNT(*) FROM t WHERE id >= 0")) {
+                    assertThat(rs.next(), is(true));
+                    assertThat(rs.getInt(1), is(400));
+                }
+            }
+        }
+    }
+
+    /**
+     * Checks transparent connection establishment after losing all connections.
+     */
+    @Test
+    void testTotalConnectionFailover() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{2});
+        String dummyQuery = "SELECT 1";
+
+        try (Connection connection = getConnection(nodesCount - 1)) {
+            try (Statement stmt = connection.createStatement()) {
+                assertThat(stmt.execute(dummyQuery), is(true));
+
+                // Stop all cluster nodes known to the client.
+                cluster.stopNode(0);
+                cluster.stopNode(1);
+
+                //noinspection ThrowableNotThrown
+                assertThrows(
+                        SQLException.class,
+                        () -> stmt.execute("SELECT 1"),
+                        "Connection refused"
+                );
+
+                cluster.startNode(1);
+
+                assertThat(stmt.execute("SELECT 1"), is(true));
+            }
+        }
+    }
+
+    /**
+     * Ensures that the client receives the meaningful exception when the node holding the client transaction goes down.
+     */
+    @Test
+    @Disabled("https://issues.apache.org/jira/browse/IGNITE-27091")
+    void testTransactionCannotBeUsedAfterNodeRestart() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{2});
+
+        try (Connection connection = getConnection(nodesCount - 1)) {
+            connection.setAutoCommit(false);
+
+            try (Statement stmt = connection.createStatement()) {
+                assertThat(stmt.execute("SELECT 1"), is(true));
+
+                // Stop all cluster nodes known to the client.
+                cluster.stopNode(0);
+                cluster.stopNode(1);
+
+                String query = "SELECT 1";
+
+                //noinspection ThrowableNotThrown
+                assertThrows(
+                        SQLException.class,
+                        () -> stmt.execute(query),
+                        "Connection refused"
+                );

Review Comment:
   [nitpick] Consider using `JdbcTestUtils.assertThrowsSqlException` instead of `IgniteTestUtils.assertThrows` for consistency with other JDBC tests. This helper is specifically designed for SQL exception assertions and is used consistently throughout the JDBC test suite.
   
   Example:
   ```java
   JdbcTestUtils.assertThrowsSqlException(
       "Connection refused",
       () -> stmt.execute(query)
   );
   ```



##########
modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionFailoverTest.java:
##########
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.jdbc;
+
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrows;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.time.Duration;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.ignite.internal.ClusterPerTestIntegrationTest;
+import org.apache.ignite.internal.jdbc.JdbcConnection;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Basic test scenarios with JDBC connection failover.
+ */
+public class ItJdbcConnectionFailoverTest extends ClusterPerTestIntegrationTest {
+    private static final int BASE_CLIENT_PORT = 10800;
+
+    @Override
+    protected int initialNodes() {
+        return 0;
+    }
+
+    /**
+     * Ensures that the client establishes connections to multiple nodes.
+     */
+    @Test
+    void testMultipleConnectionEstablishment() throws SQLException {
+        int nodesCount = 2;
+
+        cluster.startAndInit(nodesCount, new int[]{0});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            await().timeout(Duration.ofSeconds(5))
+                    .until(() -> channelsCount(connection), is(nodesCount));
+        }
+    }
+
+    /**
+     * Ensures that the query is forwarded to the alive node.
+     *
+     * <p>Test sequentially restarts each cluster node keeping CMG majority alive.
+     */
+    @Test
+    void testConnectionFailover() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{0, 1, 2});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            try (Statement statement = connection.createStatement()) {
+                statement.executeUpdate("CREATE ZONE zone1 (REPLICAS 3, PARTITIONS 1) STORAGE PROFILES ['default']");
+                statement.executeUpdate("CREATE TABLE t(id INT PRIMARY KEY, val INT) ZONE zone1");
+
+                try (PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO t VALUES (?, ?)")) {
+                    performUpdates(preparedStatement, 0, 100);
+
+                    cluster.stopNode(0);
+                    performUpdates(preparedStatement, 100, 200);
+
+                    cluster.startNode(0);
+                    cluster.stopNode(1);
+                    performUpdates(preparedStatement, 200, 300);
+
+                    cluster.startNode(1);
+                    cluster.stopNode(2);
+                    performUpdates(preparedStatement, 300, 400);
+                }
+
+                try (ResultSet rs = statement.executeQuery("SELECT COUNT(*) FROM t WHERE id >= 0")) {
+                    assertThat(rs.next(), is(true));
+                    assertThat(rs.getInt(1), is(400));
+                }
+            }
+        }
+    }
+
+    /**
+     * Checks transparent connection establishment after losing all connections.
+     */
+    @Test
+    void testTotalConnectionFailover() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{2});
+        String dummyQuery = "SELECT 1";
+
+        try (Connection connection = getConnection(nodesCount - 1)) {
+            try (Statement stmt = connection.createStatement()) {
+                assertThat(stmt.execute(dummyQuery), is(true));
+
+                // Stop all cluster nodes known to the client.
+                cluster.stopNode(0);
+                cluster.stopNode(1);
+
+                //noinspection ThrowableNotThrown
+                assertThrows(
+                        SQLException.class,
+                        () -> stmt.execute("SELECT 1"),
+                        "Connection refused"
+                );
+
+                cluster.startNode(1);
+
+                assertThat(stmt.execute("SELECT 1"), is(true));
+            }
+        }
+    }
+
+    /**
+     * Ensures that the client receives the meaningful exception when the node holding the client transaction goes down.
+     */
+    @Test
+    @Disabled("https://issues.apache.org/jira/browse/IGNITE-27091")
+    void testTransactionCannotBeUsedAfterNodeRestart() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{2});
+
+        try (Connection connection = getConnection(nodesCount - 1)) {
+            connection.setAutoCommit(false);
+
+            try (Statement stmt = connection.createStatement()) {
+                assertThat(stmt.execute("SELECT 1"), is(true));
+
+                // Stop all cluster nodes known to the client.
+                cluster.stopNode(0);
+                cluster.stopNode(1);
+
+                String query = "SELECT 1";
+
+                //noinspection ThrowableNotThrown
+                assertThrows(
+                        SQLException.class,
+                        () -> stmt.execute(query),
+                        "Connection refused"
+                );
+
+                cluster.startNode(0);
+                cluster.startNode(1);
+
+                //noinspection ThrowableNotThrown
+                assertThrows(
+                        SQLException.class,
+                        () -> stmt.execute(query),
+                        "Transaction context has been lost due to connection errors"
+                );

Review Comment:
   [nitpick] Consider using `JdbcTestUtils.assertThrowsSqlException` instead of `IgniteTestUtils.assertThrows` for consistency with other JDBC tests. This helper is specifically designed for SQL exception assertions and is used consistently throughout the JDBC test suite.
   
   Example:
   ```java
   JdbcTestUtils.assertThrowsSqlException(
       "Transaction context has been lost due to connection errors",
       () -> stmt.execute(query)
   );
   ```



##########
modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionFailoverTest.java:
##########
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.jdbc;
+
+import static org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrows;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.time.Duration;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.ignite.internal.ClusterPerTestIntegrationTest;
+import org.apache.ignite.internal.jdbc.JdbcConnection;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Basic test scenarios with JDBC connection failover.
+ */
+public class ItJdbcConnectionFailoverTest extends ClusterPerTestIntegrationTest {
+    private static final int BASE_CLIENT_PORT = 10800;
+
+    @Override
+    protected int initialNodes() {
+        return 0;
+    }
+
+    /**
+     * Ensures that the client establishes connections to multiple nodes.
+     */
+    @Test
+    void testMultipleConnectionEstablishment() throws SQLException {
+        int nodesCount = 2;
+
+        cluster.startAndInit(nodesCount, new int[]{0});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            await().timeout(Duration.ofSeconds(5))
+                    .until(() -> channelsCount(connection), is(nodesCount));
+        }
+    }
+
+    /**
+     * Ensures that the query is forwarded to the alive node.
+     *
+     * <p>Test sequentially restarts each cluster node keeping CMG majority alive.
+     */
+    @Test
+    void testConnectionFailover() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{0, 1, 2});
+
+        try (Connection connection = getConnection(nodesCount)) {
+            try (Statement statement = connection.createStatement()) {
+                statement.executeUpdate("CREATE ZONE zone1 (REPLICAS 3, PARTITIONS 1) STORAGE PROFILES ['default']");
+                statement.executeUpdate("CREATE TABLE t(id INT PRIMARY KEY, val INT) ZONE zone1");
+
+                try (PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO t VALUES (?, ?)")) {
+                    performUpdates(preparedStatement, 0, 100);
+
+                    cluster.stopNode(0);
+                    performUpdates(preparedStatement, 100, 200);
+
+                    cluster.startNode(0);
+                    cluster.stopNode(1);
+                    performUpdates(preparedStatement, 200, 300);
+
+                    cluster.startNode(1);
+                    cluster.stopNode(2);
+                    performUpdates(preparedStatement, 300, 400);
+                }
+
+                try (ResultSet rs = statement.executeQuery("SELECT COUNT(*) FROM t WHERE id >= 0")) {
+                    assertThat(rs.next(), is(true));
+                    assertThat(rs.getInt(1), is(400));
+                }
+            }
+        }
+    }
+
+    /**
+     * Checks transparent connection establishment after losing all connections.
+     */
+    @Test
+    void testTotalConnectionFailover() throws SQLException {
+        int nodesCount = 3;
+        cluster.startAndInit(nodesCount, new int[]{2});
+        String dummyQuery = "SELECT 1";
+
+        try (Connection connection = getConnection(nodesCount - 1)) {
+            try (Statement stmt = connection.createStatement()) {
+                assertThat(stmt.execute(dummyQuery), is(true));
+
+                // Stop all cluster nodes known to the client.
+                cluster.stopNode(0);
+                cluster.stopNode(1);
+
+                //noinspection ThrowableNotThrown
+                assertThrows(
+                        SQLException.class,
+                        () -> stmt.execute("SELECT 1"),
+                        "Connection refused"
+                );
+
+                cluster.startNode(1);
+
+                assertThat(stmt.execute("SELECT 1"), is(true));

Review Comment:
   The hardcoded query string "SELECT 1" duplicates the `dummyQuery` variable defined at line 110. Consider using the `dummyQuery` variable for consistency and maintainability.
   
   ```java
   () -> stmt.execute(dummyQuery)
   ```
   ```suggestion
                           () -> stmt.execute(dummyQuery),
                           "Connection refused"
                   );
   
                   cluster.startNode(1);
   
                   assertThat(stmt.execute(dummyQuery), is(true));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-25587 Jdbc. Basic connection failover tests [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on PR #7007:
URL: https://github.com/apache/ignite-3/pull/7007#issuecomment-3556648909

   > As i can see - all listed tests are exploited node left as some king of connection lost. But in practice it`s not a case, probably we can extend tests with smth like: no request from server node (NAT problems emulation). I really don`t know is it possible to implement it, if no - it need to be tested somewhere else, qa probably ?
   
   As far as I know we don't have such tools in the integration framework.
   We have a unit test `RetryPolcyTest`, but it seems to be outside the scope of JDBC tests.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org