This is an automated email from the ASF dual-hosted git repository.

mtaha pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/age.git


The following commit(s) were added to refs/heads/master by this push:
     new 887564d9 Fix JDBC driver CI test failures (#2333)
887564d9 is described below

commit 887564d9ce0f153ad7dc9f30223aa303c3fb60d0
Author: John Gemignani <[email protected]>
AuthorDate: Fri Feb 13 01:54:06 2026 -0800

    Fix JDBC driver CI test failures (#2333)
    
    Fix JDBC driver CI test failures: encoding, Testcontainers, and
    Docker compatibility.
    
    Note: This PR was created with the help of AI tools and a human.
    
    - Set JavaCompile encoding to UTF-8 to fix unicode test failures in
      CI environments that default to US-ASCII.
    
    - Add Testcontainers wait strategy (Wait.forLogMessage) to wait for
      PostgreSQL to be fully ready before connecting.
    
    - Use agensGraphContainer.getHost() instead of hardcoded localhost
      for Docker-in-Docker compatibility.
    
    - Add sslmode=disable to JDBC URL since PostgreSQL driver 42.6.0+
      attempts SSL by default.
    
    - Remove silent exception swallowing around connection setup to fail
      fast with meaningful errors instead of NullPointerException.
    
    - Upgrade Testcontainers from 1.18.0 to 1.21.4 to fix Docker 29.x
      detection failure on ubuntu-24.04 runners (docker-java 3.3.x in
      1.18.0 cannot negotiate with Docker Engine 29.1.5 API).
    
    modified:   drivers/jdbc/lib/build.gradle.kts
    modified:   
drivers/jdbc/lib/src/test/java/org/apache/age/jdbc/BaseDockerizedTest.java
---
 drivers/jdbc/lib/build.gradle.kts                     |  6 +++++-
 .../java/org/apache/age/jdbc/BaseDockerizedTest.java  | 19 ++++++++++---------
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/jdbc/lib/build.gradle.kts 
b/drivers/jdbc/lib/build.gradle.kts
index 0b63bc5a..4965c2a5 100644
--- a/drivers/jdbc/lib/build.gradle.kts
+++ b/drivers/jdbc/lib/build.gradle.kts
@@ -38,13 +38,17 @@ dependencies {
     testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
     testRuntimeOnly("org.junit.platform:junit-platform-launcher")
 
-    testImplementation("org.testcontainers:testcontainers:1.18.0")
+    testImplementation("org.testcontainers:testcontainers:1.21.4")
     testImplementation("org.postgresql:postgresql:42.6.0")
 
     testImplementation("org.slf4j:slf4j-api:2.0.7")
     testImplementation("org.slf4j:slf4j-simple:2.0.7")
 }
 
+tasks.withType<JavaCompile> {
+    options.encoding = "UTF-8"
+}
+
 tasks.generateGrammarSource {
     maxHeapSize = "64m"
     source = project.objects
diff --git 
a/drivers/jdbc/lib/src/test/java/org/apache/age/jdbc/BaseDockerizedTest.java 
b/drivers/jdbc/lib/src/test/java/org/apache/age/jdbc/BaseDockerizedTest.java
index 393175c3..f46c5b5d 100644
--- a/drivers/jdbc/lib/src/test/java/org/apache/age/jdbc/BaseDockerizedTest.java
+++ b/drivers/jdbc/lib/src/test/java/org/apache/age/jdbc/BaseDockerizedTest.java
@@ -21,6 +21,7 @@ package org.apache.age.jdbc;
 
 import java.sql.DriverManager;
 import java.sql.Statement;
+import java.time.Duration;
 import org.apache.age.jdbc.base.Agtype;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
@@ -28,6 +29,7 @@ import org.junit.jupiter.api.TestInstance;
 import org.junit.jupiter.api.TestInstance.Lifecycle;
 import org.postgresql.jdbc.PgConnection;
 import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.Wait;
 import org.testcontainers.utility.DockerImageName;
 
 @TestInstance(Lifecycle.PER_CLASS)
@@ -54,20 +56,19 @@ public class BaseDockerizedTest {
         agensGraphContainer = new GenericContainer<>(DockerImageName
             .parse("apache/age:dev_snapshot_master"))
             .withEnv("POSTGRES_PASSWORD", CORRECT_DB_PASSWORDS)
-            .withExposedPorts(5432);
+            .withExposedPorts(5432)
+            .waitingFor(Wait.forLogMessage(".*database system is ready to 
accept connections.*\\n", 2)
+                .withStartupTimeout(Duration.ofSeconds(60)));
         agensGraphContainer.start();
 
+        String host = agensGraphContainer.getHost();
         int mappedPort = agensGraphContainer.getMappedPort(5432);
         String jdbcUrl = String
-            .format("jdbc:postgresql://%s:%d/%s", "localhost", mappedPort, 
"postgres");
+            .format("jdbc:postgresql://%s:%d/%s?sslmode=disable", host, 
mappedPort, "postgres");
 
-        try {
-            this.connection = DriverManager.getConnection(jdbcUrl, "postgres", 
CORRECT_DB_PASSWORDS)
-                         .unwrap(PgConnection.class);
-            this.connection.addDataType("agtype", Agtype.class);
-        } catch (Exception e) {
-            System.out.println(e);
-        }
+        this.connection = DriverManager.getConnection(jdbcUrl, "postgres", 
CORRECT_DB_PASSWORDS)
+                     .unwrap(PgConnection.class);
+        this.connection.addDataType("agtype", Agtype.class);
         try (Statement statement = connection.createStatement()) {
             statement.execute("CREATE EXTENSION IF NOT EXISTS age;");
             statement.execute("LOAD 'age'");

Reply via email to