aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar Benjamin Peterson <bp@benjamin.pe>2018-05-03 04:30:19 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-05-03 04:32:12 -0700
commit7e1c7bcd4215a20479963ec34c8d7b685f393cc6 (patch)
tree7dd4d13f52c52cc3a41b03ebc2035840eb32969d /src/test/java/com/google/devtools/build
parent8ac2fb1ff86a8a08d1a53888ae5adf901becd2b9 (diff)
Report what RemoteSpawnCache is doing.
Post ProgressStatus.CHECKING_CACHE if RemoteSpawnCache is checking the cache. The UI sees CHECKING_CACHE exactly the same as EXECUTING because no UIs currently have any special behavior for actions in cache-lookup state. This is still a UX improvement with --experimental_spawn_cache because EXECUTING is generally more correct than the old action state, which varies from harmless but unhelpful (no known state) to just wrong (C++ compile actions claimed they were doing include scanning during cache lookups). Closes #5130. Change-Id: I77421c3667c180875216f937fe0713f0e9415a7a PiperOrigin-RevId: 195233123
Diffstat (limited to 'src/test/java/com/google/devtools/build')
-rw-r--r--src/test/java/com/google/devtools/build/lib/BUILD1
-rw-r--r--src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnCacheTest.java15
2 files changed, 15 insertions, 1 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/BUILD b/src/test/java/com/google/devtools/build/lib/BUILD
index c626bf2436..fb3d52c6ff 100644
--- a/src/test/java/com/google/devtools/build/lib/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/BUILD
@@ -1237,6 +1237,7 @@ java_test(
"//src/main/java/com/google/devtools/build/lib:events",
"//src/main/java/com/google/devtools/build/lib:exitcode-external",
"//src/main/java/com/google/devtools/build/lib:io",
+ "//src/main/java/com/google/devtools/build/lib:util",
"//src/main/java/com/google/devtools/build/lib/actions",
"//src/main/java/com/google/devtools/build/lib/authandtls",
"//src/main/java/com/google/devtools/build/lib/clock",
diff --git a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnCacheTest.java b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnCacheTest.java
index 997d3dc67d..8baaa26564 100644
--- a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnCacheTest.java
+++ b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnCacheTest.java
@@ -48,6 +48,7 @@ import com.google.devtools.build.lib.remote.TreeNodeRepository.TreeNode;
import com.google.devtools.build.lib.remote.util.DigestUtil;
import com.google.devtools.build.lib.remote.util.DigestUtil.ActionKey;
import com.google.devtools.build.lib.remote.util.TracingMetadataUtils;
+import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.lib.util.io.FileOutErr;
import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.FileSystem.HashFunction;
@@ -61,7 +62,9 @@ import com.google.devtools.remoteexecution.v1test.Command;
import com.google.devtools.remoteexecution.v1test.RequestMetadata;
import java.io.IOException;
import java.time.Duration;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import java.util.SortedMap;
import org.junit.Before;
import org.junit.Test;
@@ -92,6 +95,7 @@ public class RemoteSpawnCacheTest {
@Mock private AbstractRemoteActionCache remoteCache;
private RemoteSpawnCache cache;
private FileOutErr outErr;
+ private final List<Pair<ProgressStatus, String>> progressUpdates = new ArrayList();
private StoredEventHandler eventHandler = new StoredEventHandler();
@@ -146,7 +150,7 @@ public class RemoteSpawnCacheTest {
@Override
public void report(ProgressStatus state, String name) {
- // TODO(ulfjack): Test that the right calls are made.
+ progressUpdates.add(Pair.of(state, name));
}
};
@@ -242,6 +246,8 @@ public class RemoteSpawnCacheTest {
// We expect the CachedLocalSpawnRunner to _not_ write to outErr at all.
assertThat(outErr.hasRecordedOutput()).isFalse();
assertThat(outErr.hasRecordedStderr()).isFalse();
+ assertThat(progressUpdates)
+ .containsExactly(Pair.of(ProgressStatus.CHECKING_CACHE, "remote-cache"));
}
@Test
@@ -270,6 +276,8 @@ public class RemoteSpawnCacheTest {
entry.store(result, outputFiles);
verify(remoteCache)
.upload(any(ActionKey.class), any(Path.class), eq(outputFiles), eq(outErr), eq(true));
+ assertThat(progressUpdates)
+ .containsExactly(Pair.of(ProgressStatus.CHECKING_CACHE, "remote-cache"));
}
@Test
@@ -299,6 +307,7 @@ public class RemoteSpawnCacheTest {
entry.store(result, outputFiles);
verify(remoteCache)
.upload(any(ActionKey.class), any(Path.class), eq(outputFiles), eq(outErr), eq(false));
+ assertThat(progressUpdates).containsExactly();
}
@Test
@@ -318,6 +327,8 @@ public class RemoteSpawnCacheTest {
entry.store(result, outputFiles);
verify(remoteCache)
.upload(any(ActionKey.class), any(Path.class), eq(outputFiles), eq(outErr), eq(false));
+ assertThat(progressUpdates)
+ .containsExactly(Pair.of(ProgressStatus.CHECKING_CACHE, "remote-cache"));
}
@Test
@@ -345,5 +356,7 @@ public class RemoteSpawnCacheTest {
assertThat(evt.getKind()).isEqualTo(EventKind.WARNING);
assertThat(evt.getMessage()).contains("fail");
assertThat(evt.getMessage()).contains("upload");
+ assertThat(progressUpdates)
+ .containsExactly(Pair.of(ProgressStatus.CHECKING_CACHE, "remote-cache"));
}
}