Skip to content

Commit 0ae8c0d

Browse files
authored
Merge branch 'main' into enable-graalvm-tests
2 parents 384d00a + 243bee0 commit 0ae8c0d

43 files changed

Lines changed: 1896 additions & 250 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ target/
1111
**/.project
1212
**/.settings/
1313
**/.classpath
14+
.vscode/
1415

1516
# direnv
1617
.envrc
@@ -72,3 +73,4 @@ artman-genfiles
7273
*.zip
7374
*.tar.gz
7475
*.rar
76+
.tools

.kokoro/check_coverage.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,23 @@
1616
# `-e` enables the script to automatically fail when a command fails
1717
set -e
1818

19-
export CUR_COVER=$(cat core/target/site/jacoco/index.html | grep -o 'Total[^%]*' | sed 's/<.*>//; s/Total//')
20-
echo "Current Coverage is $CUR_COVER%"
19+
# Calculate total coverage, skipping the generated protobuf file.
20+
# The CSV file generated by Jacoco has the test coverage for each. We use AWK to process this CSV file.
21+
# here's what the AWK program means:
22+
#
23+
# NR > 1 && Skip the first line, it only has field names
24+
# $3 != "com.google.cloud.sql.core.mdx" Skip any line for class in the protobuf generated package 'mdx'
25+
# { covered += $6; total += $6+$5; } For each line add a running sum of covered lines and total lines
26+
# END { printf "%2.f", covered/total * 100}' At the end, print out the coverage percentage, no decimals
27+
#
28+
29+
CUR_COVER=$( awk -F, \
30+
'NR > 1 && $3 != "com.google.cloud.sql.core.mdx" { covered += $6; total += $6+$5; } END { printf "%2.f", covered/total * 100}' \
31+
< "core/target/site/jacoco/jacoco.csv")
32+
2133
if [ "$CUR_COVER" -lt 75 ]; then
34+
echo "FAIL: Current Coverage is $CUR_COVER%, less than the required 75%"
2235
exit 1;
36+
else
37+
echo "PASS: Current Coverage is $CUR_COVER%"
2338
fi

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
## [1.25.3](https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory/compare/v1.25.2...v1.25.3) (2025-08-12)
4+
5+
6+
### Bug Fixes
7+
8+
* Use the -jre variant of Google Guava library for GraalVM compatability. ([#2187](https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory/issues/2187)) ([7fb819f](https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory/commit/7fb819fb0d0856c337a8b7ec10ebce899ad496b3)), closes [#2178](https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory/issues/2178)
9+
10+
11+
### Dependencies
12+
13+
* Update dependencies to latest. ([#2185](https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory/issues/2185)) ([163cdae](https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory/commit/163cdaeda6f36cc2c0290aa86eed8a1224e3635c))
14+
315
## [1.25.2](https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory/compare/v1.25.1...v1.25.2) (2025-07-14)
416

517

build.sh

Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,19 @@ function clean() {
3030
}
3131

3232
## build - Builds the project without running tests.
33-
function test() {
33+
function build() {
3434
mvn install -DskipTests=true
3535
}
3636

3737
## test - Runs local unit tests.
3838
function test() {
39-
mvn install
39+
if [[ "$(uname -s)" == "Darwin" ]]; then
40+
echo "macOS detected. Setting up IP aliases for tests."
41+
echo "You may be prompted for your password to run sudo."
42+
sudo ifconfig lo0 alias 127.0.0.2 up
43+
sudo ifconfig lo0 alias 127.0.0.3 up
44+
fi
45+
mvn -P coverage test
4046
}
4147

4248
## e2e - Runs end-to-end integration tests.
@@ -69,49 +75,63 @@ function lint() {
6975
}
7076

7177

78+
## deps - updates dependencies to the latest version
79+
function deps() {
80+
mvn versions:use-latest-versions
81+
find . -name 'pom.xml.versionsBackup' -print0 | xargs -0 rm -f
82+
}
83+
84+
7285
# write_e2e_env - Loads secrets from the gcloud project and writes
7386
# them to target/e2e.env to run e2e tests.
7487
#
7588
function write_e2e_env(){
76-
secret_vars=(MYSQL_CONNECTION_NAME
77-
MYSQL_USER
78-
MYSQL_PASS
79-
MYSQL_DB
80-
MYSQL_IAM_CONNECTION_NAME
81-
MYSQL_USER_IAM_JAVA
82-
POSTGRES_CONNECTION_NAME
83-
POSTGRES_IAM_CONNECTION_NAME
84-
POSTGRES_USER
85-
POSTGRES_USER_IAM_JAVA
86-
POSTGRES_PASS
87-
POSTGRES_DB
88-
POSTGRES_CAS_CONNECTION_NAME
89-
POSTGRES_CAS_PASS
90-
POSTGRES_CUSTOMER_CAS_CONNECTION_NAME
91-
POSTGRES_CUSTOMER_CAS_PASS
92-
POSTGRES_CUSTOMER_CAS_PASS_VALID_DOMAIN_NAME
93-
POSTGRES_CUSTOMER_CAS_PASS_INVALID_DOMAIN_NAME
94-
SQLSERVER_CONNECTION_NAME
95-
SQLSERVER_USER
96-
SQLSERVER_PASS
97-
SQLSERVER_DB
98-
IMPERSONATED_USER
99-
QUOTA_PROJECT
100-
)
89+
# Set the default to .envrc file if no argument is passed
90+
outfile="${1:-.envrc}"
91+
secret_vars=(
92+
MYSQL_CONNECTION_NAME=MYSQL_CONNECTION_NAME
93+
MYSQL_USER=MYSQL_USER
94+
MYSQL_USER_IAM=MYSQL_USER_IAM_GO
95+
MYSQL_PASS=MYSQL_PASS
96+
MYSQL_DB=MYSQL_DB
97+
MYSQL_MCP_CONNECTION_NAME=MYSQL_MCP_CONNECTION_NAME
98+
MYSQL_MCP_PASS=MYSQL_MCP_PASS
99+
POSTGRES_CONNECTION_NAME=POSTGRES_CONNECTION_NAME
100+
POSTGRES_USER=POSTGRES_USER
101+
POSTGRES_USER_IAM=POSTGRES_USER_IAM_GO
102+
POSTGRES_PASS=POSTGRES_PASS
103+
POSTGRES_DB=POSTGRES_DB
104+
POSTGRES_CAS_CONNECTION_NAME=POSTGRES_CAS_CONNECTION_NAME
105+
POSTGRES_CAS_PASS=POSTGRES_CAS_PASS
106+
POSTGRES_CUSTOMER_CAS_CONNECTION_NAME=POSTGRES_CUSTOMER_CAS_CONNECTION_NAME
107+
POSTGRES_CUSTOMER_CAS_PASS=POSTGRES_CUSTOMER_CAS_PASS
108+
POSTGRES_CUSTOMER_CAS_DOMAIN_NAME=POSTGRES_CUSTOMER_CAS_DOMAIN_NAME
109+
POSTGRES_CUSTOMER_CAS_INVALID_DOMAIN_NAME=POSTGRES_CUSTOMER_CAS_INVALID_DOMAIN_NAME
110+
POSTGRES_MCP_CONNECTION_NAME=POSTGRES_MCP_CONNECTION_NAME
111+
POSTGRES_MCP_PASS=POSTGRES_MCP_PASS
112+
SQLSERVER_CONNECTION_NAME=SQLSERVER_CONNECTION_NAME
113+
SQLSERVER_USER=SQLSERVER_USER
114+
SQLSERVER_PASS=SQLSERVER_PASS
115+
SQLSERVER_DB=SQLSERVER_DB
116+
QUOTA_PROJECT=QUOTA_PROJECT
117+
)
101118

102119
if [[ -z "${TEST_PROJECT:-}" ]] ; then
103120
echo "Set TEST_PROJECT environment variable to the project containing"
104121
echo "the e2e test suite secrets."
105122
exit 1
106123
fi
107124

108-
echo "Getting test secrets from $TEST_PROJECT into $1"
125+
echo "Getting test secrets from $TEST_PROJECT into $outfile"
109126
{
110-
for name in "${secret_vars[@]}" ; do
111-
val=$(gcloud secrets versions access latest --project "$TEST_PROJECT" --secret="$name")
112-
echo "export $name=\'$val\'"
127+
for env_name in "${secret_vars[@]}" ; do
128+
env_var_name="${env_name%%=*}"
129+
secret_name="${env_name##*=}"
130+
set -x
131+
val=$(gcloud secrets versions access latest --project "$TEST_PROJECT" --secret="$secret_name")
132+
echo "export $env_var_name='$val'"
113133
done
114-
} > "$1"
134+
} > "$outfile"
115135

116136
}
117137

core/pom.xml

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
<parent>
2424
<groupId>com.google.cloud.sql</groupId>
2525
<artifactId>jdbc-socket-factory-parent</artifactId>
26-
<version>1.25.3-SNAPSHOT</version><!-- {x-version-update:jdbc-socket-factory-parent:current} -->
26+
<version>1.25.4-SNAPSHOT</version><!-- {x-version-update:jdbc-socket-factory-parent:current} -->
2727
</parent>
2828
<artifactId>jdbc-socket-factory-core</artifactId>
29-
<version>1.25.3-SNAPSHOT</version><!-- {x-version-update:jdbc-socket-factory-core:current} -->
29+
<version>1.25.4-SNAPSHOT</version><!-- {x-version-update:jdbc-socket-factory-core:current} -->
3030
<packaging>jar</packaging>
3131

3232
<name>Cloud SQL Core Socket Factory (Core Library, don't depend on this directly)</name>
@@ -127,6 +127,11 @@
127127
<artifactId>google-oauth-client</artifactId>
128128
</dependency>
129129

130+
<dependency>
131+
<groupId>dnsjava</groupId>
132+
<artifactId>dnsjava</artifactId>
133+
</dependency>
134+
130135
<!-- com.google.cloud.sql.nativeimage.CloudSqlFeature needs the GraalVM
131136
dependencies for compilation. The provided-scope dependencies do not add
132137
additional dependencies to library users. -->
@@ -205,11 +210,53 @@
205210
<artifactId>logback-classic</artifactId>
206211
<scope>test</scope>
207212
</dependency>
213+
<dependency>
214+
<groupId>com.google.protobuf</groupId>
215+
<artifactId>protobuf-java</artifactId>
216+
</dependency>
208217

209218
</dependencies>
210219

211220
<build>
212221
<plugins>
222+
<plugin>
223+
<groupId>org.codehaus.mojo</groupId>
224+
<artifactId>build-helper-maven-plugin</artifactId>
225+
<version>3.3.0</version>
226+
<executions>
227+
<execution>
228+
<id>test</id>
229+
<phase>generate-sources</phase>
230+
<goals>
231+
<goal>add-source</goal>
232+
</goals>
233+
<configuration>
234+
<sources>
235+
<source>${project.basedir}/target/generated-sources</source>
236+
</sources>
237+
</configuration>
238+
</execution>
239+
</executions>
240+
</plugin>
241+
<plugin>
242+
<groupId>com.github.os72</groupId>
243+
<artifactId>protoc-jar-maven-plugin</artifactId>
244+
<version>3.11.4</version>
245+
<executions>
246+
<execution>
247+
<phase>generate-sources</phase>
248+
<goals>
249+
<goal>run</goal>
250+
</goals>
251+
<configuration>
252+
<optimizeCodegen>false</optimizeCodegen>
253+
<protocVersion>3.23.0</protocVersion>
254+
<includeStdTypes>true</includeStdTypes>
255+
<outputOptions></outputOptions>
256+
</configuration>
257+
</execution>
258+
</executions>
259+
</plugin>
213260
<plugin>
214261
<groupId>org.apache.maven.plugins</groupId>
215262
<artifactId>maven-jar-plugin</artifactId>

core/src/main/java/com/google/cloud/sql/core/ConnectionConfig.java

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public class ConnectionConfig {
5454
public static final List<IpType> DEFAULT_IP_TYPE_LIST =
5555
Arrays.asList(IpType.PUBLIC, IpType.PRIVATE);
5656
public static final String CLOUD_SQL_GOOGLE_CREDENTIALS_PATH = "cloudSqlGoogleCredentialsPath";
57+
public static final String MDX_CLIENT_PROTOCOL_TYPE = "mdxClientProtocolType";
5758

5859
private final ConnectorConfig connectorConfig;
5960
private final String cloudSqlInstance;
@@ -64,6 +65,7 @@ public class ConnectionConfig {
6465
private final AuthType authType;
6566
private final String unixSocketPathSuffix;
6667
private final String domainName;
68+
private final String mdxClientProtocolType;
6769

6870
/** Create a new ConnectionConfig from the well known JDBC Connection properties. */
6971
public static ConnectionConfig fromConnectionProperties(Properties props) {
@@ -116,6 +118,9 @@ public static ConnectionConfig fromConnectionProperties(Properties props, String
116118
? RefreshStrategy.LAZY
117119
: RefreshStrategy.BACKGROUND;
118120

121+
final String mdxClientProtocolType =
122+
props.getProperty(ConnectionConfig.MDX_CLIENT_PROTOCOL_TYPE);
123+
119124
return new ConnectionConfig(
120125
csqlInstanceName,
121126
namedConnection,
@@ -133,7 +138,8 @@ public static ConnectionConfig fromConnectionProperties(Properties props, String
133138
.withAdminQuotaProject(adminQuotaProject)
134139
.withUniverseDomain(universeDomain)
135140
.withRefreshStrategy(refreshStrategy)
136-
.build());
141+
.build(),
142+
mdxClientProtocolType);
137143
}
138144

139145
/**
@@ -197,7 +203,8 @@ private ConnectionConfig(
197203
AuthType authType,
198204
String unixSocketPathSuffix,
199205
String domainName,
200-
ConnectorConfig connectorConfig) {
206+
ConnectorConfig connectorConfig,
207+
String mdxClientProtocolType) {
201208
this.cloudSqlInstance = cloudSqlInstance;
202209
this.namedConnector = namedConnector;
203210
this.unixSocketPath = unixSocketPath;
@@ -206,6 +213,7 @@ private ConnectionConfig(
206213
this.connectorConfig = connectorConfig;
207214
this.authType = authType;
208215
this.domainName = domainName;
216+
this.mdxClientProtocolType = mdxClientProtocolType;
209217
}
210218

211219
/** Creates a new instance of the ConnectionConfig with an updated connectorConfig. */
@@ -218,7 +226,8 @@ public ConnectionConfig withConnectorConfig(ConnectorConfig config) {
218226
authType,
219227
unixSocketPathSuffix,
220228
domainName,
221-
config);
229+
config,
230+
mdxClientProtocolType);
222231
}
223232

224233
/** Creates a new instance of the ConnectionConfig with an updated cloudSqlInstance. */
@@ -231,7 +240,8 @@ public ConnectionConfig withCloudSqlInstance(String newCloudSqlInstance) {
231240
authType,
232241
unixSocketPathSuffix,
233242
domainName,
234-
connectorConfig);
243+
connectorConfig,
244+
mdxClientProtocolType);
235245
}
236246

237247
/** Creates a new instance of the ConnectionConfig with an updated cloudSqlInstance. */
@@ -244,7 +254,22 @@ public ConnectionConfig withDomainName(String domainName) {
244254
authType,
245255
unixSocketPathSuffix,
246256
domainName,
247-
connectorConfig);
257+
connectorConfig,
258+
mdxClientProtocolType);
259+
}
260+
261+
/** Creates a new instance of the ConnectionConfig with an updated clientProtocolType. */
262+
public ConnectionConfig withMdxClientProtocolType(String mdxClientProtocolType) {
263+
return new ConnectionConfig(
264+
cloudSqlInstance,
265+
namedConnector,
266+
unixSocketPath,
267+
ipTypes,
268+
authType,
269+
unixSocketPathSuffix,
270+
domainName,
271+
connectorConfig,
272+
mdxClientProtocolType);
248273
}
249274

250275
public String getNamedConnector() {
@@ -279,6 +304,10 @@ public String getDomainName() {
279304
return domainName;
280305
}
281306

307+
public String getMdxClientProtocolType() {
308+
return mdxClientProtocolType;
309+
}
310+
282311
/** The builder for the ConnectionConfig. */
283312
public static class Builder {
284313

@@ -290,6 +319,7 @@ public static class Builder {
290319
private ConnectorConfig connectorConfig = new ConnectorConfig.Builder().build();
291320
private AuthType authType = DEFAULT_AUTH_TYPE;
292321
private String domainName;
322+
private String mdxClientProtocolType;
293323

294324
/** Chained setter for CloudSqlInstance field. */
295325
public Builder withCloudSqlInstance(String cloudSqlInstance) {
@@ -345,6 +375,12 @@ public Builder withUnixSocketPathSuffix(String unixSocketPathSuffix) {
345375
return this;
346376
}
347377

378+
/** Chained setter for MdxClientProtocolType field. */
379+
public Builder withMdxClientProtocolType(String mdxClientProtocolType) {
380+
this.mdxClientProtocolType = mdxClientProtocolType;
381+
return this;
382+
}
383+
348384
/** Builds a new instance of {@code ConnectionConfig}. */
349385
public ConnectionConfig build() {
350386
return new ConnectionConfig(
@@ -355,7 +391,8 @@ public ConnectionConfig build() {
355391
authType,
356392
unixSocketPathSuffix,
357393
domainName,
358-
connectorConfig);
394+
connectorConfig,
395+
mdxClientProtocolType);
359396
}
360397
}
361398
}

0 commit comments

Comments
 (0)