aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
authorGravatar buchgr <buchgr@google.com>2017-07-14 12:58:50 +0200
committerGravatar László Csomor <laszlocsomor@google.com>2017-07-14 16:34:27 +0200
commit9f7edd7a7d66c34b937cbda01119dcb2dec6fdf5 (patch)
tree28c87302396c99af2f4c2bdd04da8a1d2be0c5cc /src/main
parent57ff834702f75760e2d611590e44c13f7b3c580d (diff)
remote: Don't cache test if marked "external". Fixes #3362
RELNOTES: None. PiperOrigin-RevId: 161937673
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/ExecutionRequirements.java6
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/Spawns.java7
-rw-r--r--src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java13
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutor.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java5
5 files changed, 25 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ExecutionRequirements.java b/src/main/java/com/google/devtools/build/lib/actions/ExecutionRequirements.java
index 46ff4b0a82..a07af7b558 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/ExecutionRequirements.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/ExecutionRequirements.java
@@ -143,4 +143,10 @@ public class ExecutionRequirements {
public static final ImmutableMap<String, String> WORKER_MODE_ENABLED =
ImmutableMap.of(SUPPORTS_WORKERS, "1");
+
+ /**
+ * Whether we should disable remote caching of an action. This can be set to force a rerun of an
+ * action even if there is a cache entry for it.
+ */
+ public static final String NO_CACHE = "no-cache";
}
diff --git a/src/main/java/com/google/devtools/build/lib/actions/Spawns.java b/src/main/java/com/google/devtools/build/lib/actions/Spawns.java
index 35cfd5568e..d4827be875 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/Spawns.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/Spawns.java
@@ -25,6 +25,13 @@ public final class Spawns {
private Spawns() {}
/**
+ * Returns {@code true} if the result of {@code spawn} may be cached.
+ */
+ public static boolean mayBeCached(Spawn spawn) {
+ return !spawn.getExecutionInfo().containsKey(ExecutionRequirements.NO_CACHE);
+ }
+
+ /**
* Parse the timeout key in the spawn execution info, if it exists. Otherwise, return -1.
*/
public static int getTimeoutSeconds(Spawn spawn) throws ExecException {
diff --git a/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java b/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java
index 31913957bc..8ef6049ae8 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java
@@ -20,6 +20,7 @@ import com.google.devtools.build.lib.actions.ActionExecutionContext;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.EnvironmentalExecException;
import com.google.devtools.build.lib.actions.ExecException;
+import com.google.devtools.build.lib.actions.ExecutionRequirements;
import com.google.devtools.build.lib.actions.ExecutionStrategy;
import com.google.devtools.build.lib.actions.ResourceSet;
import com.google.devtools.build.lib.actions.SimpleSpawn;
@@ -47,7 +48,6 @@ import com.google.devtools.build.lib.view.test.TestStatus.TestResultData;
import com.google.devtools.build.lib.view.test.TestStatus.TestResultData.Builder;
import java.io.Closeable;
import java.io.IOException;
-import java.util.HashMap;
import java.util.Map;
/** Runs TestRunnerAction actions. */
@@ -107,10 +107,13 @@ public class StandaloneTestStrategy extends TestStrategy {
ResolvedPaths resolvedPaths = action.resolve(execRoot);
- Map<String, String> info = new HashMap<>();
+ ImmutableMap.Builder<String, String> executionInfo = ImmutableMap.builder();
+ if (!action.shouldCacheResult()) {
+ executionInfo.put(ExecutionRequirements.NO_CACHE, "");
+ }
// This key is only understood by StandaloneSpawnStrategy.
- info.put("timeout", "" + getTimeout(action));
- info.putAll(action.getTestProperties().getExecutionInfo());
+ executionInfo.put("timeout", "" + getTimeout(action));
+ executionInfo.putAll(action.getTestProperties().getExecutionInfo());
ResourceSet localResourceUsage =
action
@@ -123,7 +126,7 @@ public class StandaloneTestStrategy extends TestStrategy {
action,
getArgs(COLLECT_COVERAGE, action),
ImmutableMap.copyOf(env),
- ImmutableMap.copyOf(info),
+ executionInfo.build(),
new RunfilesSupplierImpl(
runfilesDir.relativeTo(execRoot), action.getExecutionSettings().getRunfiles()),
/*inputs=*/ ImmutableList.copyOf(action.getInputs()),
diff --git a/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutor.java b/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutor.java
index 68046fe2ca..06aabda492 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutor.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutor.java
@@ -40,7 +40,7 @@ import javax.annotation.Nullable;
/** A remote work executor that uses gRPC for communicating the work, inputs and outputs. */
@ThreadSafe
-final class GrpcRemoteExecutor {
+class GrpcRemoteExecutor {
private final Channel channel;
private final CallCredentials callCredentials;
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java
index 7a50e1cd3f..58c6c668a6 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java
@@ -96,7 +96,7 @@ final class RemoteSpawnRunner implements SpawnRunner {
// Look up action cache, and reuse the action output if it is found.
ActionKey actionKey = Digests.computeActionKey(action);
try {
- boolean acceptCachedResult = options.remoteAcceptCached;
+ boolean acceptCachedResult = options.remoteAcceptCached && Spawns.mayBeCached(spawn);
ActionResult result =
acceptCachedResult
? remoteCache.getCachedActionResult(actionKey)
@@ -198,7 +198,8 @@ final class RemoteSpawnRunner implements SpawnRunner {
ActionKey actionKey)
throws ExecException, IOException, InterruptedException {
SpawnResult result = fallbackRunner.exec(spawn, policy);
- if (options.remoteUploadLocalResults && remoteCache != null && actionKey != null) {
+ if (options.remoteUploadLocalResults && Spawns.mayBeCached(spawn) && remoteCache != null
+ && actionKey != null) {
ArrayList<Path> outputFiles = new ArrayList<>();
for (ActionInput output : spawn.getOutputFiles()) {
Path outputFile = execRoot.getRelative(output.getExecPathString());