2323import java .sql .ResultSetMetaData ;
2424import java .sql .SQLException ;
2525import java .sql .Statement ;
26- import java .time .Duration ;
2726import java .util .ArrayList ;
2827import java .util .Arrays ;
2928import java .util .Collections ;
3837import org .slf4j .LoggerFactory ;
3938import org .testcontainers .clickhouse .ClickHouseContainer ;
4039import org .testcontainers .containers .GenericContainer ;
41- import org .testcontainers .containers .wait .strategy .LogMessageWaitStrategy ;
4240import org .testcontainers .utility .DockerImageName ;
4341
4442/**
@@ -61,6 +59,8 @@ public class ClickHouseResourceManager extends TestContainerResourceManager<Gene
6159 private static final String DEFAULT_CLICKHOUSE_CONTAINER_TAG = "23.8" ;
6260
6361 private final String jdbcConnectionString ;
62+ private final String username ;
63+ private final String password ;
6464
6565 final List <String > managedTableNames = new ArrayList <>();
6666
@@ -69,16 +69,9 @@ public class ClickHouseResourceManager extends TestContainerResourceManager<Gene
6969 }
7070
7171 private static ClickHouseContainer buildContainer (Builder builder ) {
72- ClickHouseContainer container =
73- new ClickHouseContainer (
74- DockerImageName .parse (builder .containerImageName )
75- .withTag (builder .containerImageTag ))
76- .withStartupAttempts (10 );
77-
78- Duration startupTimeout = Duration .ofMinutes (2 );
79- container .setWaitStrategy (new LogMessageWaitStrategy ().withStartupTimeout (startupTimeout ));
80-
81- return container ;
72+ return new ClickHouseContainer (
73+ DockerImageName .parse (builder .containerImageName ).withTag (builder .containerImageTag ))
74+ .withStartupAttempts (10 );
8275 }
8376
8477 // @VisibleForTesting
@@ -88,12 +81,18 @@ private static ClickHouseContainer buildContainer(Builder builder) {
8881 throws SQLException {
8982 super (container , builder );
9083
84+ this .username = container .getUsername ();
85+ this .password = container .getPassword ();
9186 this .jdbcConnectionString =
9287 "jdbc:clickhouse://"
9388 + this .getHost ()
9489 + ":"
9590 + this .getPort (CLICKHOUSE_INTERNAL_PORT )
96- + "/default" ;
91+ + "/default"
92+ + "?user="
93+ + this .username
94+ + "&password="
95+ + this .password ;
9796
9897 this .connection =
9998 clickHosueConnection != null ? clickHosueConnection : container .createConnection ("" );
@@ -126,6 +125,16 @@ public synchronized String getJdbcConnectionString() {
126125 return jdbcConnectionString ;
127126 }
128127
128+ /** Returns the username for the ClickHouse service. */
129+ public synchronized String getUsername () {
130+ return username ;
131+ }
132+
133+ /** Returns the password for the ClickHouse service. */
134+ public synchronized String getPassword () {
135+ return password ;
136+ }
137+
129138 synchronized boolean tableExists (String tableName ) throws SQLException {
130139
131140 ClickHouseUtils .checkValidTableName (tableName );
0 commit comments