Skip to content
Merged
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
11 changes: 11 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,17 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<systemPropertyVariables>
<logback.statusListenerClass>ch.qos.logback.core.status.NopStatusListener</logback.statusListenerClass>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,20 @@
import java.net.InetSocketAddress;
import java.time.Duration;
import java.util.Locale;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

final class FakeServer implements AutoCloseable {

private final Server server;
private final GrpcStorageOptions grpcStorageOptions;
private final ScheduledThreadPoolExecutor executor;

FakeServer(Server server, GrpcStorageOptions grpcStorageOptions) {
FakeServer(
Server server, GrpcStorageOptions grpcStorageOptions, ScheduledThreadPoolExecutor executor) {
this.server = server;
this.grpcStorageOptions = grpcStorageOptions;
this.executor = executor;
}

GrpcStorageOptions getGrpcStorageOptions() {
Expand All @@ -51,11 +55,16 @@ StorageSettings storageSettings() throws IOException {
@Override
public void close() throws InterruptedException {
server.shutdownNow().awaitTermination(10, TimeUnit.SECONDS);
executor.shutdownNow();
//noinspection ResultOfMethodCallIgnored
executor.awaitTermination(5, TimeUnit.SECONDS);
}

static FakeServer of(StorageGrpc.StorageImplBase service) throws IOException {
InetSocketAddress address = new InetSocketAddress("localhost", 0);
Server server = NettyServerBuilder.forAddress(address).addService(service).build();
InetSocketAddress address = new InetSocketAddress("127.0.0.1", 0);
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(4);
Server server =
NettyServerBuilder.forAddress(address).addService(service).executor(executor).build();
server.start();
String endpoint = String.format(Locale.US, "%s:%d", address.getHostString(), server.getPort());
GrpcStorageOptions grpcStorageOptions =
Expand All @@ -80,6 +89,6 @@ static FakeServer of(StorageGrpc.StorageImplBase service) throws IOException {
.setMaxRpcTimeoutDuration(Duration.ofSeconds(25))
.build())
.build();
return new FakeServer(server, grpcStorageOptions);
return new FakeServer(server, grpcStorageOptions, executor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,8 @@ public String toString() {
}

static final class Builder {
private static final String DEFAULT_BASE_URI = "http://localhost:9000";
private static final String DEFAULT_GRPC_BASE_URI = "http://localhost:9005";
private static final String DEFAULT_BASE_URI = "http://127.0.0.1:9000";
private static final String DEFAULT_GRPC_BASE_URI = "http://127.0.0.1:9005";
private static final String DEFAULT_IMAGE_NAME;
private static final String DEFAULT_IMAGE_TAG;

Expand Down
Loading