abhishekrb19 commented on code in PR #18025:
URL: https://github.com/apache/druid/pull/18025#discussion_r2125715232
##########
server/src/test/java/org/apache/druid/server/QueryResourceTest.java:
##########
@@ -528,6 +532,110 @@ public void testSuccessResponseWithTrailerHeader() throws
IOException
Assert.assertEquals(fields.get(QueryResource.RESPONSE_COMPLETE_TRAILER_HEADER),
"true");
}
+ @Test
+ public void
testResponseContextContainsMissingSegments_whenLastSegmentIsMissing() throws
IOException
+ {
+ final SegmentDescriptor missingSegDesc = new SegmentDescriptor(
+ Intervals.of("2025-01-01/P1D"), "0", 1
+ );
+
+ queryResource = new QueryResource(
+ new QueryLifecycleFactory(
+ CONGLOMERATE,
+ new QuerySegmentWalker()
+ {
+ @Override
+ public <T> QueryRunner<T> getQueryRunnerForIntervals(Query<T>
query, Iterable<Interval> intervals)
+ {
+ return (queryPlus, responseContext) -> new BaseSequence<>(
+ new BaseSequence.IteratorMaker<T, Iterator<T>>() {
+ @Override
+ public Iterator<T> make()
+ {
+ List<T> data = Collections.singletonList((T)
ImmutableMap.of("dummy", 1));
+ Iterator<T> realIterator = data.iterator();
+
+ return new Iterator<T>() {
+ private boolean done = false;
+
+ @Override
+ public boolean hasNext()
+ {
+ if (realIterator.hasNext()) {
+ return true;
+ } else if (!done) {
+ // Simulate a segment failure in the end after
initialize() has run
+
responseContext.addMissingSegments(ImmutableList.of(missingSegDesc));
+ done = true;
+ }
+ return false;
+ }
+
+ @Override
+ public T next()
+ {
+ return realIterator.next();
+ }
+ };
+ }
+
+ @Override
+ public void cleanup(Iterator<T> iterFromMake)
+ {
+ }
+ }
+ );
+ }
+
+ @Override
+ public <T> QueryRunner<T> getQueryRunnerForSegments(Query<T>
query, Iterable<SegmentDescriptor> specs)
+ {
+ throw new UnsupportedOperationException();
+ }
+ },
+ new DefaultGenericQueryMetricsFactory(),
+ new NoopServiceEmitter(),
+ testRequestLogger,
+ new AuthConfig(),
+ NoopPolicyEnforcer.instance(),
+ AuthTestUtils.TEST_AUTHORIZER_MAPPER,
+ Suppliers.ofInstance(new DefaultQueryConfig(ImmutableMap.of()))
+ ),
+ jsonMapper,
+ smileMapper,
+ queryScheduler,
+ new AuthConfig(),
+ null,
+ ResponseContextConfig.newConfig(true),
+ DRUID_NODE
+ );
+
+ expectPermissiveHappyPathAuth();
+
+ org.eclipse.jetty.server.Response response =
this.jettyResponseforRequest(testServletRequest);
+
+ // Execute the query
+ Assert.assertNull(queryResource.doPost(
+ new
ByteArrayInputStream(SIMPLE_TIMESERIES_QUERY.getBytes(StandardCharsets.UTF_8)),
+ null,
+ testServletRequest
+ ));
+
+
+ Assert.assertTrue(response.containsHeader(HttpHeader.TRAILER.toString()));
+ Assert.assertEquals(QueryResultPusher.RESULT_TRAILER_HEADERS,
response.getHeader(HttpHeader.TRAILER.toString()));
+
+ final HttpFields observedFields = response.getTrailers().get();
+
+
Assert.assertTrue(response.containsHeader(QueryResource.HEADER_RESPONSE_CONTEXT));
+ final DataServerResponse expectedResponse = new
DataServerResponse(ImmutableList.of(missingSegDesc));
Review Comment:
Good to know, I've removed `DataServerResponse` related changes and I've
added the map serialization to assert results for this test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]