Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions google-cloud-jar-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
<configuration>
<forkCount>1C</forkCount>
<reuseForks>true</reuseForks>
<forkedProcessTimeoutInSeconds>1200</forkedProcessTimeoutInSeconds>
</configuration>
</plugin>
<plugin>
Expand Down
17 changes: 17 additions & 0 deletions java-storage/google-cloud-storage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,23 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<forkCount>1C</forkCount>
<reuseForks>true</reuseForks>
<forkedProcessTimeoutInSeconds>600</forkedProcessTimeoutInSeconds>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ final class MetadataService {
.createRequestFactory(
request -> {
request.setCurlLoggingEnabled(false);
request.setConnectTimeout(1000);
request.setReadTimeout(2000);
Comment on lines +45 to +46
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The 1-second connection timeout and 2-second read timeout for the metadata service may be too short for some CI environments, potentially causing flaky test failures. Increasing these to more conservative values (e.g., 5 seconds) is an acceptable temporary fix to unblock CI. If you plan to make these configurable at the instance level in the future, avoid declaring them as 'static final'.

References
  1. A temporary fix is acceptable to unblock CI, deferring a better solution to a separate effort.
  2. Avoid declaring constants as 'static final' if there is a plan to expose or configure them at the instance level in the future.

request.getHeaders().set("Metadata-Flavor", "Google");
}));
private static final String baseUri = "http://metadata.google.internal";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ private TestBench(
.createRequestFactory(
request -> {
request.setCurlLoggingEnabled(false);
request.setConnectTimeout(5000);
request.setReadTimeout(10000);
Comment on lines +131 to +132
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The timeouts for the TestBench (5s/10s) are hardcoded and inconsistent with the MetadataService timeouts. Centralizing these values into constants or a configuration class would improve maintainability. However, avoid declaring them as 'static final' if there is a plan to allow instance-level configuration in the future.

References
  1. Avoid declaring constants as 'static final' if there is a plan to expose or configure them at the instance level in the future.

request.getHeaders().setAccept("application/json");
request
.getHeaders()
Expand Down Expand Up @@ -487,6 +489,14 @@ static final class Builder {

private static final String DEFAULT_CONTAINER_NAME = "default";

private static int findFreePort() {
try (java.net.ServerSocket socket = new java.net.ServerSocket(0)) {
return socket.getLocalPort();
} catch (IOException e) {
throw new RuntimeException("No free port available", e);
}
}

private boolean ignorePullError;
private String baseUri;
private String gRPCBaseUri;
Expand All @@ -497,8 +507,8 @@ static final class Builder {
private Builder() {
this(
false,
DEFAULT_BASE_URI,
DEFAULT_GRPC_BASE_URI,
"http://localhost:" + findFreePort(),
"http://localhost:" + findFreePort(),
DEFAULT_IMAGE_NAME,
DEFAULT_IMAGE_TAG,
DEFAULT_CONTAINER_NAME);
Expand Down Expand Up @@ -550,13 +560,15 @@ public Builder setContainerName(String containerName) {
}

public TestBench build() {
String suffix = Optional.ofNullable(System.getProperty("surefire.forkNumber"))
.orElseGet(() -> java.util.UUID.randomUUID().toString().substring(0, 8));
return new TestBench(
ignorePullError,
baseUri,
gRPCBaseUri,
requireNonNull(dockerImageName, "dockerImageName must be non null"),
requireNonNull(dockerImageTag, "dockerImageTag must be non null"),
String.format(Locale.US, "storage-testbench_%s", containerName));
String.format(Locale.US, "storage-testbench_%s_%s", containerName, suffix));
}
}

Expand Down
Loading