Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make readWithPit integration tests less sensitive to ES response size #180261

Merged
merged 8 commits into from
Apr 24, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ export const readWithPit =
});
})
.catch((e) => {
console.log(e);
console.log(e.message);
console.log(JSON.stringify(e.meta));
console.log(JSON.stringify(e.body));
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing this should be reverted?

if (
e instanceof EsErrors.RequestAbortedError &&
/The content length \(\d+\) is bigger than the maximum/.test(e.message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1311,8 +1311,14 @@ describe('migration actions', () => {
maxResponseSizeBytes: 500, // set a small size to force the error
});
const rightResponse = (await readWithPitTask()) as Either.Right<ReadWithPit>;

await expect(Either.isRight(rightResponse)).toBe(true);
if (Either.isRight(rightResponse)) {
await expect(Either.isRight(rightResponse)).toBe(true);
} else {
console.log(
'got a left: ',
(rightResponse as Either.Left<EsResponseTooLargeError>).left.type
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also fail the test. Perhaps this logic could be:

      const rightResponse = await readWithPitTask()
      if (Either.isLeft(rightResponse)) {
        fail(`Expected a successful response but got ${rightResponse.left}`);
      }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah this was meant as a throw-away debugging PR but CI won't run when there's console.log's and I think it'd be better for the future to have your suggestion, should be enough to find the cause.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, it looks like my suggestion was wrong, the fail function does not actually exist in runtime (despite TS thinking it does). Looks it was removed in jest 27. Should probably just use throw new Error(...)!


readWithPitTask = readWithPit({
client,
Expand Down