Skip to content

Conversation

@mhl-b
Copy link
Contributor

@mhl-b mhl-b commented Aug 29, 2025

Adding assertion on exception message for missing content in incremental bulk test.

#133685 (comment)

@mhl-b mhl-b requested a review from DaveCTurner August 29, 2025 19:32
@mhl-b mhl-b added >non-issue :Distributed Coordination/Network Http and internode communication implementations Team:Distributed Coordination Meta label for Distributed Coordination team v9.2.0 labels Aug 29, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination)

Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

assertThrows returns the exception it caught, so you can just do this:

        assertEquals(
            "request body is required",
            assertThrows(
                ElasticsearchParseException.class,
                () -> new RestBulkAction(
                    Settings.EMPTY,
                    ClusterSettings.createBuiltInClusterSettings(),
                    new IncrementalBulkService(mock(Client.class), mock(IndexingPressure.class), MeterRegistry.NOOP)
                ).handleRequest(
                    new FakeRestRequest.Builder(xContentRegistry()).withPath("my_index/_bulk")
                        .withContentLength(0)
                        .withBody(new FakeHttpBodyStream())
                        .build(),
                    mock(RestChannel.class),
                    mock(NodeClient.class)
                )
            ).getMessage()
        );

Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

LGTM (slight preference for keeping assertThrows, see previous comment, but it doesn't matter much either way)

@mhl-b
Copy link
Contributor Author

mhl-b commented Sep 2, 2025

assertThrows returns the exception it caught, so you can just do this:

Ah, I love to read code starting from both ends towards centre, especially when flip monitor 90 degrees and slowly cross eyes. ꩜

@DaveCTurner
Copy link
Contributor

Hehe just be glad the callbacks don't go backwards...

@mhl-b mhl-b merged commit 2364939 into elastic:main Sep 4, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed Coordination/Network Http and internode communication implementations >non-issue Team:Distributed Coordination Meta label for Distributed Coordination team v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants