From d84f7998ef8f15e27376a0c8f25b320145c4ba9e Mon Sep 17 00:00:00 2001 From: Fredrik Medley Date: Thu, 25 Nov 2021 06:47:11 -0800 Subject: [PATCH] Fix remote spawn tests for remote_merkle_tree_cache=true When setting `--experimental_remote_merkle_tree_cache=true` as default and running the test suite, some errors became visible. This change fixes those errors. Closes #14300. PiperOrigin-RevId: 412274673 --- .../devtools/build/lib/remote/RemoteSpawnCacheTest.java | 2 +- .../devtools/build/lib/remote/RemoteSpawnRunnerTest.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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 4171d01fe5b763..61ce8de1bd9734 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 @@ -143,7 +143,7 @@ public MetadataProvider getMetadataProvider() { @Override public ArtifactExpander getArtifactExpander() { - throw new UnsupportedOperationException(); + return SIMPLE_ARTIFACT_EXPANDER; } @Override diff --git a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java index 68fce99846b68b..81bbc05a481c43 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java @@ -74,6 +74,7 @@ import com.google.devtools.build.lib.exec.RemoteLocalFallbackRegistry; import com.google.devtools.build.lib.exec.SpawnCheckingCacheEvent; import com.google.devtools.build.lib.exec.SpawnExecutingEvent; +import com.google.devtools.build.lib.exec.SpawnInputExpander; import com.google.devtools.build.lib.exec.SpawnRunner; import com.google.devtools.build.lib.exec.SpawnRunner.SpawnExecutionContext; import com.google.devtools.build.lib.exec.SpawnSchedulingEvent; @@ -1267,6 +1268,7 @@ public void shouldReportCheckingCacheBeforeScheduling() throws Exception { Spawn spawn = newSimpleSpawn(); SpawnExecutionContext policy = mock(SpawnExecutionContext.class); + when(policy.getSpawnInputExpander()).thenReturn(mock(SpawnInputExpander.class)); when(policy.getTimeout()).thenReturn(Duration.ZERO); when(executor.executeRemotely( @@ -1310,6 +1312,7 @@ public void shouldReportExecutingStatusWithoutMetadata() throws Exception { Spawn spawn = newSimpleSpawn(); SpawnExecutionContext policy = mock(SpawnExecutionContext.class); + when(policy.getSpawnInputExpander()).thenReturn(mock(SpawnInputExpander.class)); when(policy.getTimeout()).thenReturn(Duration.ZERO); when(executor.executeRemotely( @@ -1353,6 +1356,7 @@ public void shouldReportExecutingStatusAfterGotExecutingStageFromMetadata() thro Spawn spawn = newSimpleSpawn(); SpawnExecutionContext policy = mock(SpawnExecutionContext.class); + when(policy.getSpawnInputExpander()).thenReturn(mock(SpawnInputExpander.class)); when(policy.getTimeout()).thenReturn(Duration.ZERO); when(executor.executeRemotely( @@ -1413,6 +1417,7 @@ public void shouldIgnoreInvalidMetadata() throws Exception { Spawn spawn = newSimpleSpawn(); SpawnExecutionContext policy = mock(SpawnExecutionContext.class); + when(policy.getSpawnInputExpander()).thenReturn(mock(SpawnInputExpander.class)); when(policy.getTimeout()).thenReturn(Duration.ZERO); when(executor.executeRemotely( @@ -1461,6 +1466,7 @@ public void shouldReportExecutingStatusIfNoExecutingStatusFromMetadata() throws Spawn spawn = newSimpleSpawn(); SpawnExecutionContext policy = mock(SpawnExecutionContext.class); + when(policy.getSpawnInputExpander()).thenReturn(mock(SpawnInputExpander.class)); when(policy.getTimeout()).thenReturn(Duration.ZERO); when(executor.executeRemotely( @@ -1510,6 +1516,7 @@ public void shouldReportExecutingStatusEvenNoOperationFromServer() throws Except Spawn spawn = newSimpleSpawn(); SpawnExecutionContext policy = mock(SpawnExecutionContext.class); + when(policy.getSpawnInputExpander()).thenReturn(mock(SpawnInputExpander.class)); when(policy.getTimeout()).thenReturn(Duration.ZERO); when(executor.executeRemotely(