Skip to content

Conversation

@abhishekrb19
Copy link
Contributor

@abhishekrb19 abhishekrb19 commented Dec 19, 2025

Test-only change:

  • Increases test coverage for the DirectDruidClient class from 57%, 35%, 16% to 76%, 73%, 52% for method / line / branch coverage respectively. We can add more tests as we evolve the code and/or do bug fixes.
  • Replaces mocks with more concrete classes and test helpers, allowing the internals of the class, including HttpResponseHandler to be exercised.
  • Also added a test for feat: log total bytes gathered when max scatter-gather bytes limit is reached #18841 for which coverage had to be skipped

This PR has:

  • been self-reviewed.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.

Replaces mocks with more concrete test helpers that will invoke and exercise the internals
of DirectDruidClient response handler, etc. Also, add a new unit test for
ResourceExceededException that wasn't previously exercised.
Copy link
Contributor

@jtuglu1 jtuglu1 left a comment

Choose a reason for hiding this comment

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

LGTM – once the minor comments are handled.

return initHttpClientWithFuture(new TestHttpClient(objectMapper, future), false);
}

private HttpClient initHttpClientWithFuture(TestHttpClient httpClient, boolean throwQueryError)
Copy link
Contributor

@jtuglu1 jtuglu1 Dec 31, 2025

Choose a reason for hiding this comment

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

can we name this something different? It has the same name as the above method but different signature. Maybe something like initHttpClientFromExistingClient.

}

@Test
public void testQueryTimeoutBeforeFuture() throws IOException, InterruptedException
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing the mocks I believe removes InterruptedException – let's clean that up too while we're here.

Come to think of it, I'm not quite sure why a linter wouldn't catch this. We should add this as a rule.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed InterruptedException from this test method.

Come to think of it, I'm not quite sure why a linter wouldn't catch this. We should add this as a rule.

hmm, I vaguely recall that we did have IntelliJ checks to catch this kind of issue, but they were removed at some point. I'm not sure if pmc/checkstyle can be configured to catch this.

.andReturn(SettableFuture.create())
.atLeastOnce();
// A simple HttpClient that records requests and returns queued futures per call.
class SequencedHttpClient implements HttpClient
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move this to member class? This might be helpful for other tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I’ve moved it to a separate test class under the same root as TestHttpClient.

@abhishekrb19 abhishekrb19 merged commit 5fb5926 into master Jan 3, 2026
172 of 182 checks passed
@abhishekrb19 abhishekrb19 deleted the druid_client_test_coverage branch January 3, 2026 17:22
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.

2 participants