Skip to content

test(storage): fast open failure and retry behaviour - #14865

Draft
Dhriti07 wants to merge 1 commit into
fast-open/03-validate-fast-open-configfrom
fast-open/04-failure-retry-tests
Draft

Dhriti07 wants to merge 1 commit into
fast-open/03-validate-fast-open-configfrom
fast-open/04-failure-retry-tests

Conversation

@Dhriti07

Copy link
Copy Markdown
Contributor

Fourth step of fast open BiDi reads (go/fast-open-bidi-read, b/552263062).

Pins three things fast open gets from the existing read stream:

  • when the server rejects the fast open range (OUT_OF_RANGE), the open fails with that error and is not retried;
  • when the connection drops before any reply, the retried open sends the fast open range again;
  • when the connection drops part way through the fast open range, the re-open asks only for the remaining bytes and readAs returns the full range.

Fourth step of fast open BiDi reads (go/fast-open-bidi-read, b/552263062).

Pins how fast open behaves when things go wrong, using the existing read
stream:
- when the server fails the stream with OUT_OF_RANGE, the open fails with that
  error and is not retried;
- when the server rejects only the fast open range (OUT_OF_RANGE naming its
  read id), the session re-opens without it and readAs fails with the error.
  This differs from the "fail open" choice in the design doc; it is kept as is
  until the error shape zonal buckets return is confirmed;
- when the connection drops before any reply, the retried open sends the fast
  open range again;
- when the connection drops part way through the fast open range, the re-open
  asks only for the remaining bytes and readAs returns the full range.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds several unit tests to ITFastOpenFakeTest.java to verify the behavior of ObjectReadSession under various server failure and connection drop scenarios. The feedback suggests improving the exception assertions in these tests by using instanceof with anyMatch instead of exact class equality checks with Throwable::getClass, which is more robust against subclasses and avoids stream collection overhead.

Comment on lines +272 to +276
assertThat(
Throwables.getCausalChain(e).stream()
.<Class<?>>map(Throwable::getClass)
.collect(toList()))
.contains(OutOfRangeException.class);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using Throwable::getClass with .contains(OutOfRangeException.class) performs an exact class equality check. If a subclass of OutOfRangeException is thrown, this assertion will fail. Using instanceof (via anyMatch) is more robust as it correctly handles subclasses, is more idiomatic, and avoids the overhead of collecting the stream to a list. Additionally, this allows removing the unused import static java.util.stream.Collectors.toList;.

      assertThat(Throwables.getCausalChain(e).stream().anyMatch(t -> t instanceof OutOfRangeException))
          .isTrue();

Comment on lines +325 to +329
assertThat(
Throwables.getCausalChain(e).stream()
.<Class<?>>map(Throwable::getClass)
.collect(toList()))
.contains(OutOfRangeException.class);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using Throwable::getClass with .contains(OutOfRangeException.class) performs an exact class equality check. If a subclass of OutOfRangeException is thrown, this assertion will fail. Using instanceof (via anyMatch) is more robust as it correctly handles subclasses, is more idiomatic, and avoids the overhead of collecting the stream to a list. Additionally, this allows removing the unused import static java.util.stream.Collectors.toList;.

        assertThat(Throwables.getCausalChain(e).stream().anyMatch(t -> t instanceof OutOfRangeException))
            .isTrue();

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant