Skip to content

Commit

Permalink
Make --workspace_status_command work with "Builds without the Bytes".
Browse files Browse the repository at this point in the history
Fixes #8385

Due to a typo in delete() stable-status.txt would not get deleted
between builds. More details in #8385.

Thanks @emfree for the debugging work and pointing out the root cause!

Closes #9280.

PiperOrigin-RevId: 266118848
  • Loading branch information
buchgr authored and copybara-github committed Aug 29, 2019
1 parent a30df55 commit 5c02b92
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public String getFileSystemType(Path path) {
@Override
public boolean delete(Path path) throws IOException {
RemoteFileArtifactValue m = getRemoteInputMetadata(path);
if (m != null) {
if (m == null) {
return super.delete(path);
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,35 @@ public void testCreateSymbolicLink() throws InterruptedException, IOException {
verifyNoMoreInteractions(inputFetcher);
}

@Test
public void testDeleteRemoteFile() throws Exception {
// arrange
ActionInputMap inputs = new ActionInputMap(1);
Artifact remoteArtifact = createRemoteArtifact("remote-file", "remote contents", inputs);
FileSystem actionFs = newRemoteActionFileSystem(inputs);

// act
boolean success = actionFs.delete(actionFs.getPath(remoteArtifact.getPath().getPathString()));

// assert
assertThat(success).isTrue();
}

@Test
public void testDeleteLocalFile() throws Exception {
// arrange
ActionInputMap inputs = new ActionInputMap(0);
FileSystem actionFs = newRemoteActionFileSystem(inputs);
Path filePath = actionFs.getPath(execRoot.getPathString()).getChild("local-file");
FileSystemUtils.writeContent(filePath, StandardCharsets.UTF_8, "local contents");

// act
boolean success = actionFs.delete(actionFs.getPath(filePath.getPathString()));

// assert
assertThat(success).isTrue();
}

private FileSystem newRemoteActionFileSystem(ActionInputMap inputs) {
return new RemoteActionFileSystem(
fs,
Expand Down
37 changes: 37 additions & 0 deletions src/test/shell/bazel/remote/remote_execution_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,43 @@ EOF
expect_not_log "remote cache hit"
}

function test_downloads_minimal_stable_status() {
# Regression test for #8385

mkdir -p a
cat > a/BUILD <<'EOF'
genrule(
name = "foo",
srcs = [],
outs = ["foo.txt"],
cmd = "echo \"foo\" > \"$@\"",
)
EOF

cat > status.sh << 'EOF'
#!/bin/sh
echo "STABLE_FOO 1"
EOF
chmod +x status.sh

bazel build \
--remote_executor=grpc://localhost:${worker_port} \
--experimental_remote_download_minimal \
--workspace_status_command=status.sh \
//a:foo || "Failed to build //a:foo"

cat > status.sh << 'EOF'
#!/bin/sh
echo "STABLE_FOO 2"
EOF

bazel build \
--remote_executor=grpc://localhost:${worker_port} \
--experimental_remote_download_minimal \
--workspace_status_command=status.sh \
//a:foo || "Failed to build //a:foo"
}

# TODO(alpha): Add a test that fails remote execution when remote worker
# supports sandbox.

Expand Down

0 comments on commit 5c02b92

Please sign in to comment.