Skip to content

Commit

Permalink
[7.1.1] Also inject a failure for createWritableDirectory when testin…
Browse files Browse the repository at this point in the history
…g that ActionOutputDirectoryHelper propagates exceptions. (#21683)

Failure to do causes a flaky test failure when simulating an IOException
while the `knownDirectories` cache is disabled. The reason is that
`ActionOutputDirectoryHelper#forceCreateDirectoryAndParents` calls
either `createDirectory` or `createWritableDirectory`, depending on
whether the parent directory is in the cache or not. However,
"disabling" the cache sets its size to zero, which doesn't prevent
insertion; rather, it causes inserted entries to be almost immediately
deleted by a background thread. Thus, if only one of `createDirectory`
and `createWritableDirectory` throws, the test outcome depends on how
fast the background thread runs.

(We could make the zero-sized cache an actual no-op, but it's unlikely
that anyone would want to set it to zero outside of test code, so it's
not worth the trouble.)

Fixes #21471.

Commit
f924338

PiperOrigin-RevId: 615513608
Change-Id: Id2247596c6af0e5d5142072de8309227a1d1cbd1

Co-authored-by: Googler <tjgq@google.com>
  • Loading branch information
bazel-io and tjgq authored Mar 13, 2024
1 parent e67c6cc commit 7c7c5c3
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,14 @@ public boolean createDirectory(PathFragment path) throws IOException {
return super.createDirectory(path);
}

@Override
public boolean createWritableDirectory(PathFragment path) throws IOException {
if (path.equals(failingPath)) {
throw injectedException;
}
return super.createWritableDirectory(path);
}

@Override
public void createDirectoryAndParents(PathFragment path) throws IOException {
if (path.equals(failingPath)) {
Expand Down

0 comments on commit 7c7c5c3

Please sign in to comment.