66import org .apache .cloudberry .pxf .automation .structures .tables .utils .TableFactory ;
77import org .apache .cloudberry .pxf .automation .testcontainers .ClickHouseContainer ;
88import org .testng .Assert ;
9+ import org .testng .ITest ;
10+ import org .testng .annotations .BeforeMethod ;
911import org .testng .annotations .DataProvider ;
1012import org .testng .annotations .Factory ;
1113import org .testng .annotations .Test ;
1214
15+ import java .lang .reflect .Method ;
1316import java .math .BigDecimal ;
1417import java .nio .charset .StandardCharsets ;
1518import java .sql .Connection ;
2326import java .util .UUID ;
2427
2528@ WorksWithFDW
26- public class JdbcClickhouseTest extends AbstractTestcontainersTest {
29+ public class JdbcClickhouseTest extends AbstractTestcontainersTest implements ITest {
2730
2831 private static final String CLICKHOUSE_DRIVER = "com.clickhouse.jdbc.ClickHouseDriver" ;
2932
@@ -83,6 +86,7 @@ public static Object[] createInstances(String imageTag) {
8386 public static Object [][] clickhouseVersions () {
8487 return new Object [][] {
8588 { "24" },
89+ { "26.1.4.35" },
8690 { "26.2" },
8791 };
8892 }
@@ -109,52 +113,52 @@ public void afterClass() throws Exception {
109113
110114 @ Test (groups = {"testcontainers" , "jdbc-tc" })
111115 public void readSupportedTypes () throws Exception {
112- runReadSupportedTypes (clickhouseContainer .getJdbcUrl (), false );
116+ runReadSupportedTypes (clickhouseContainer .getInternalJdbcUrl (), clickhouseContainer . getJdbcUrl (), false );
113117 }
114118
115119 @ Test (groups = {"testcontainers" , "jdbc-tc" })
116120 public void readSupportedTypesWithProtocolCompression () throws Exception {
117- runReadSupportedTypes (clickhouseContainer .getJdbcUrl (), true );
121+ runReadSupportedTypes (clickhouseContainer .getInternalJdbcUrl (), clickhouseContainer . getJdbcUrl (), true );
118122 }
119123
120124 @ Test (groups = {"testcontainers" , "jdbc-tc" })
121125 public void readSupportedTypesWithHttpConnectionProvider () throws Exception {
122- runReadSupportedTypes (clickhouseContainer .getJdbcUrl (), false , true );
126+ runReadSupportedTypes (clickhouseContainer .getInternalJdbcUrl (), clickhouseContainer . getJdbcUrl (), false , true );
123127 }
124128
125129 @ Test (groups = {"testcontainers" , "jdbc-tc" })
126130 public void writeSupportedTypes () throws Exception {
127- runWriteSupportedTypes (clickhouseContainer .getJdbcUrl (), false );
131+ runWriteSupportedTypes (clickhouseContainer .getInternalJdbcUrl (), clickhouseContainer . getJdbcUrl (), false );
128132 }
129133
130134 @ Test (groups = {"testcontainers" , "jdbc-tc" })
131135 public void writeSupportedTypesWithProtocolCompression () throws Exception {
132- runWriteSupportedTypes (clickhouseContainer .getJdbcUrl (), true );
136+ runWriteSupportedTypes (clickhouseContainer .getInternalJdbcUrl (), clickhouseContainer . getJdbcUrl (), true );
133137 }
134138
135139 @ Test (groups = {"testcontainers" , "jdbc-tc" })
136140 public void writeSupportedTypesWithHttpConnectionProvider () throws Exception {
137- runWriteSupportedTypes (clickhouseContainer .getJdbcUrl (), false , true );
141+ runWriteSupportedTypes (clickhouseContainer .getInternalJdbcUrl (), clickhouseContainer . getJdbcUrl (), false , true );
138142 }
139143
140144 @ Test (groups = {"testcontainers" , "jdbc-tc" })
141145 public void writeSupportedTypesWithHttpConnectionProviderAndCompression () throws Exception {
142- runWriteSupportedTypes (clickhouseContainer .getJdbcUrl (), true , true );
146+ runWriteSupportedTypes (clickhouseContainer .getInternalJdbcUrl (), clickhouseContainer . getJdbcUrl (), true , true );
143147 }
144148
145- private void runReadSupportedTypes (String jdbcUrl , boolean enableProtocolCompression ) throws Exception {
146- runReadSupportedTypes (jdbcUrl , enableProtocolCompression , false );
149+ private void runReadSupportedTypes (String internalJdbcUrl , String externalJdbcUrl , boolean enableProtocolCompression ) throws Exception {
150+ runReadSupportedTypes (internalJdbcUrl , externalJdbcUrl , enableProtocolCompression , false );
147151 }
148152
149- private void runReadSupportedTypes (String jdbcUrl , boolean enableProtocolCompression , boolean enableHttpConnectionProvider ) throws Exception {
150- createAndSeedClickhouseReadTable (jdbcUrl );
153+ private void runReadSupportedTypes (String internalJdbcUrl , String externalJdbcUrl , boolean enableProtocolCompression , boolean enableHttpConnectionProvider ) throws Exception {
154+ createAndSeedClickhouseReadTable (externalJdbcUrl );
151155
152156 ExternalTable pxfRead = TableFactory .getPxfJdbcReadableTable (
153157 "pxf_ch_clickhouse_read_types" ,
154158 CLICKHOUSE_PXF_FIELDS ,
155159 CLICKHOUSE_TABLE_READ ,
156160 CLICKHOUSE_DRIVER ,
157- jdbcUrl ,
161+ internalJdbcUrl ,
158162 ClickHouseContainer .CLICKHOUSE_USER ,
159163 "PASS=" + ClickHouseContainer .CLICKHOUSE_PASSWORD );
160164 pxfRead .setHost (pxfHost );
@@ -175,19 +179,19 @@ private void runReadSupportedTypes(String jdbcUrl, boolean enableProtocolCompres
175179 }
176180 }
177181
178- private void runWriteSupportedTypes (String jdbcUrl , boolean enableProtocolCompression ) throws Exception {
179- runWriteSupportedTypes (jdbcUrl , enableProtocolCompression , false );
182+ private void runWriteSupportedTypes (String internalJdbcUrl , String externalJdbcUrl , boolean enableProtocolCompression ) throws Exception {
183+ runWriteSupportedTypes (internalJdbcUrl , externalJdbcUrl , enableProtocolCompression , false );
180184 }
181185
182- private void runWriteSupportedTypes (String jdbcUrl , boolean enableProtocolCompression , boolean enableHttpConnectionProvider ) throws Exception {
183- createClickhouseWriteTable (jdbcUrl );
186+ private void runWriteSupportedTypes (String internalJdbcUrl , String externalJdbcUrl , boolean enableProtocolCompression , boolean enableHttpConnectionProvider ) throws Exception {
187+ createClickhouseWriteTable (externalJdbcUrl );
184188
185189 ExternalTable pxfWrite = TableFactory .getPxfJdbcWritableTable (
186190 "pxf_ch_clickhouse_write_types" ,
187191 CLICKHOUSE_PXF_FIELDS ,
188192 CLICKHOUSE_TABLE_WRITE ,
189193 CLICKHOUSE_DRIVER ,
190- jdbcUrl ,
194+ internalJdbcUrl ,
191195 ClickHouseContainer .CLICKHOUSE_USER ,
192196 "PASS=" + ClickHouseContainer .CLICKHOUSE_PASSWORD );
193197 pxfWrite .setHost (pxfHost );
@@ -206,7 +210,7 @@ private void runWriteSupportedTypes(String jdbcUrl, boolean enableProtocolCompre
206210 CLICKHOUSE_PXF_FIELDS ,
207211 CLICKHOUSE_TABLE_WRITE ,
208212 CLICKHOUSE_DRIVER ,
209- jdbcUrl ,
213+ internalJdbcUrl ,
210214 ClickHouseContainer .CLICKHOUSE_USER ,
211215 "PASS=" + ClickHouseContainer .CLICKHOUSE_PASSWORD );
212216 pxfVerify .setHost (pxfHost );
@@ -235,8 +239,8 @@ private void createAndSeedClickhouseReadTable(String jdbcUrl) throws SQLExceptio
235239 }
236240 }
237241
238- private void createClickhouseWriteTable (String jdbcUrl ) throws SQLException {
239- try (Connection chConn = openClickhouseConnection (jdbcUrl )) {
242+ private void createClickhouseWriteTable (String externalJdbcUrl ) throws SQLException {
243+ try (Connection chConn = openClickhouseConnection (externalJdbcUrl )) {
240244 createClickhouseServerTable (chConn , CLICKHOUSE_TABLE_WRITE );
241245 }
242246 }
@@ -268,7 +272,7 @@ private void insertClickhouseReadFixture(Connection chConn) throws SQLException
268272 String insertSql = "INSERT INTO " + CLICKHOUSE_TABLE_READ + " ("
269273 + "i_int, s_small, b_big, f_float32, d_float64, b_bool, dec, t_text, bin, d_date, d_ts, d_tstz, d_uuid"
270274 + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ;
271- Timestamp rowTs = Timestamp . valueOf ( V_D_TS );
275+
272276 try (PreparedStatement ps = chConn .prepareStatement (insertSql )) {
273277 ps .setInt (1 , V_I_INT );
274278 ps .setShort (2 , V_S_SMALL );
@@ -280,8 +284,8 @@ private void insertClickhouseReadFixture(Connection chConn) throws SQLException
280284 ps .setString (8 , V_T_TEXT );
281285 ps .setBytes (9 , V_BIN_BYTES );
282286 ps .setDate (10 , Date .valueOf (V_D_DATE ));
283- ps .setTimestamp (11 , rowTs );
284- ps .setTimestamp (12 , rowTs );
287+ ps .setTimestamp (11 , Timestamp . valueOf ( V_D_TS ) );
288+ ps .setTimestamp (12 , Timestamp . valueOf ( V_D_TS ) );
285289 ps .setObject (13 , UUID .fromString (V_D_UUID ));
286290 ps .executeUpdate ();
287291 }
@@ -293,4 +297,17 @@ private Connection openClickhouseConnection(String jdbcUrl) throws SQLException
293297 props .setProperty ("password" , ClickHouseContainer .CLICKHOUSE_PASSWORD );
294298 return DriverManager .getConnection (jdbcUrl , props );
295299 }
300+
301+
302+ private ThreadLocal <String > testName = new ThreadLocal <>();
303+
304+ @ BeforeMethod
305+ protected void beforeMethod (Method method ) throws Exception {
306+ testName .set (method .getName () + "[" + dockerImageTag + "]" );
307+ }
308+
309+ @ Override
310+ public String getTestName () {
311+ return testName .get ();
312+ }
296313}
0 commit comments