Skip to content

Commit

Permalink
Fix test build
Browse files Browse the repository at this point in the history
  • Loading branch information
aherrmann committed Feb 9, 2022
1 parent aa96766 commit 62921a2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import static org.junit.Assert.assertThrows;

import com.google.devtools.build.lib.authandtls.AuthAndTLSOptions;
import com.google.common.util.concurrent.ListeningScheduledExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.devtools.build.lib.clock.JavaClock;
import com.google.devtools.build.lib.remote.common.RemoteCacheClient;
import com.google.devtools.build.lib.remote.disk.DiskAndRemoteCacheClient;
Expand All @@ -32,6 +34,8 @@
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
import com.google.devtools.common.options.Options;
import java.io.IOException;
import java.util.concurrent.Executors;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -47,6 +51,13 @@ public class RemoteCacheClientFactoryTest {
private final AuthAndTLSOptions authAndTlsOptions = Options.getDefaults(AuthAndTLSOptions.class);
private Path workingDirectory;
private InMemoryFileSystem fs;
private ListeningScheduledExecutorService retryScheduler =
MoreExecutors.listeningDecorator(Executors.newScheduledThreadPool(1));
private RemoteRetrier retrier = new RemoteRetrier(
() -> RemoteRetrier.RETRIES_DISABLED,
(e) -> false,
retryScheduler,
Retrier.ALLOW_ALL_CALLS);

@Before
public final void setUp() {
Expand All @@ -63,7 +74,7 @@ public void createCombinedCacheWithExistingWorkingDirectory() throws IOException

RemoteCacheClient blobStore =
RemoteCacheClientFactory.create(
remoteOptions, /* creds= */ null, authAndTlsOptions, workingDirectory, digestUtil);
remoteOptions, /* creds= */ null, authAndTlsOptions, workingDirectory, digestUtil, retrier);

assertThat(blobStore).isInstanceOf(DiskAndRemoteCacheClient.class);
}
Expand All @@ -76,7 +87,7 @@ public void createCombinedCacheWithNotExistingWorkingDirectory() throws IOExcept

RemoteCacheClient blobStore =
RemoteCacheClientFactory.create(
remoteOptions, /* creds= */ null, authAndTlsOptions, workingDirectory, digestUtil);
remoteOptions, /* creds= */ null, authAndTlsOptions, workingDirectory, digestUtil, retrier);

assertThat(blobStore).isInstanceOf(DiskAndRemoteCacheClient.class);
assertThat(workingDirectory.exists()).isTrue();
Expand All @@ -96,7 +107,8 @@ public void createCombinedCacheWithMissingWorkingDirectoryShouldThrowException()
/* creds= */ null,
authAndTlsOptions,
/* workingDirectory= */ null,
digestUtil));
digestUtil,
retrier));
}

@Test
Expand All @@ -106,7 +118,7 @@ public void createHttpCacheWithProxy() throws IOException {

RemoteCacheClient blobStore =
RemoteCacheClientFactory.create(
remoteOptions, /* creds= */ null, authAndTlsOptions, workingDirectory, digestUtil);
remoteOptions, /* creds= */ null, authAndTlsOptions, workingDirectory, digestUtil, retrier);

assertThat(blobStore).isInstanceOf(HttpCacheClient.class);
}
Expand All @@ -125,7 +137,8 @@ public void createHttpCacheFailsWithUnsupportedProxyProtocol() {
/* creds= */ null,
authAndTlsOptions,
workingDirectory,
digestUtil)))
digestUtil,
retrier)))
.hasMessageThat()
.contains("Remote cache proxy unsupported: bad-proxy");
}
Expand All @@ -136,7 +149,7 @@ public void createHttpCacheWithoutProxy() throws IOException {

RemoteCacheClient blobStore =
RemoteCacheClientFactory.create(
remoteOptions, /* creds= */ null, authAndTlsOptions, workingDirectory, digestUtil);
remoteOptions, /* creds= */ null, authAndTlsOptions, workingDirectory, digestUtil, retrier);

assertThat(blobStore).isInstanceOf(HttpCacheClient.class);
}
Expand All @@ -147,7 +160,7 @@ public void createDiskCache() throws IOException {

RemoteCacheClient blobStore =
RemoteCacheClientFactory.create(
remoteOptions, /* creds= */ null, authAndTlsOptions, workingDirectory, digestUtil);
remoteOptions, /* creds= */ null, authAndTlsOptions, workingDirectory, digestUtil, retrier);

assertThat(blobStore).isInstanceOf(DiskCacheClient.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ java_test(
test_class = "com.google.devtools.build.lib.AllTests",
deps = [
"//src/main/java/com/google/devtools/build/lib/authandtls",
"//src/main/java/com/google/devtools/build/lib/remote:Retrier",
"//src/main/java/com/google/devtools/build/lib/remote/common",
"//src/main/java/com/google/devtools/build/lib/remote/http",
"//src/main/java/com/google/devtools/build/lib/remote/util",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.authandtls.AuthAndTLSOptions;
import com.google.common.util.concurrent.ListeningScheduledExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.devtools.build.lib.remote.RemoteRetrier;
import com.google.devtools.build.lib.remote.Retrier;
import com.google.devtools.build.lib.remote.common.RemoteActionExecutionContext;
import com.google.devtools.build.lib.remote.util.DigestUtil;
import com.google.devtools.build.lib.remote.util.TracingMetadataUtils;
Expand Down Expand Up @@ -90,6 +94,7 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.function.IntFunction;
import javax.annotation.Nullable;
import org.junit.Before;
Expand Down Expand Up @@ -265,6 +270,13 @@ private HttpCacheClient createHttpBlobStore(
AuthAndTLSOptions authAndTlsOptions)
throws Exception {
SocketAddress socketAddress = serverChannel.localAddress();
ListeningScheduledExecutorService retryScheduler =
MoreExecutors.listeningDecorator(Executors.newScheduledThreadPool(1));
RemoteRetrier retrier = new RemoteRetrier(
() -> RemoteRetrier.RETRIES_DISABLED,
(e) -> false,
retryScheduler,
Retrier.ALLOW_ALL_CALLS);
if (socketAddress instanceof DomainSocketAddress) {
DomainSocketAddress domainSocketAddress = (DomainSocketAddress) socketAddress;
URI uri = new URI("http://localhost");
Expand All @@ -276,6 +288,7 @@ private HttpCacheClient createHttpBlobStore(
remoteVerifyDownloads,
ImmutableList.of(),
DIGEST_UTIL,
retrier,
creds,
authAndTlsOptions);
} else if (socketAddress instanceof InetSocketAddress) {
Expand All @@ -288,6 +301,7 @@ private HttpCacheClient createHttpBlobStore(
remoteVerifyDownloads,
ImmutableList.of(),
DIGEST_UTIL,
retrier,
creds,
authAndTlsOptions);
} else {
Expand Down

0 comments on commit 62921a2

Please sign in to comment.