use of org.apache.druid.query.spec.MultipleIntervalSegmentSpec in project druid by druid-io.
the class SetAndVerifyContextQueryRunnerTest method testTimeoutIsUsedIfTimeoutIsNonZero.
@Test
public void testTimeoutIsUsedIfTimeoutIsNonZero() throws InterruptedException {
Query<ScanResultValue> query = new Druids.ScanQueryBuilder().dataSource("foo").intervals(new MultipleIntervalSegmentSpec(ImmutableList.of(Intervals.ETERNITY))).context(ImmutableMap.of(QueryContexts.TIMEOUT_KEY, 1)).build();
ServerConfig defaultConfig = new ServerConfig();
QueryRunner<ScanResultValue> mockRunner = EasyMock.createMock(QueryRunner.class);
SetAndVerifyContextQueryRunner<ScanResultValue> queryRunner = new SetAndVerifyContextQueryRunner<>(defaultConfig, mockRunner);
Query<ScanResultValue> transformed = queryRunner.withTimeoutAndMaxScatterGatherBytes(query, defaultConfig);
Thread.sleep(100);
// timeout is set to 1, so withTimeoutAndMaxScatterGatherBytes should set QUERY_FAIL_TIME to be the current
// time + 1 at the time the method was called
// this means that after sleeping for 1 millis, the fail time should be less than the current time when checking
Assert.assertTrue(System.currentTimeMillis() > (Long) transformed.getContextValue(DirectDruidClient.QUERY_FAIL_TIME));
}
use of org.apache.druid.query.spec.MultipleIntervalSegmentSpec in project druid by druid-io.
the class QueryHostFinderTest method testFindServer.
@Test
public void testFindServer() {
QueryHostFinder queryRunner = new QueryHostFinder(brokerSelector, new RendezvousHashAvaticaConnectionBalancer());
Server server = queryRunner.findServer(new TimeBoundaryQuery(new TableDataSource("test"), new MultipleIntervalSegmentSpec(Collections.singletonList(Intervals.of("2011-08-31/2011-09-01"))), null, null, null));
Assert.assertEquals("foo", server.getHost());
}
use of org.apache.druid.query.spec.MultipleIntervalSegmentSpec in project druid by druid-io.
the class TieredBrokerHostSelectorTest method testSelectBasedOnQueryContext.
@Test
public void testSelectBasedOnQueryContext() {
final Druids.TimeseriesQueryBuilder queryBuilder = Druids.newTimeseriesQueryBuilder().dataSource("test").aggregators(Collections.singletonList(new CountAggregatorFactory("count"))).intervals(new MultipleIntervalSegmentSpec(Collections.singletonList(Intervals.of("2009/2010"))));
Assert.assertEquals(brokerSelector.getDefaultServiceName(), brokerSelector.select(queryBuilder.build()).lhs);
Assert.assertEquals("hotBroker", brokerSelector.select(queryBuilder.context(ImmutableMap.of(QueryContexts.BROKER_SERVICE_NAME, "hotBroker")).build()).lhs);
Assert.assertEquals("coldBroker", brokerSelector.select(queryBuilder.context(ImmutableMap.of(QueryContexts.BROKER_SERVICE_NAME, "coldBroker")).build()).lhs);
}
use of org.apache.druid.query.spec.MultipleIntervalSegmentSpec in project druid by druid-io.
the class QueryContextsTest method testDefaultEnableQueryDebugging.
@Test
public void testDefaultEnableQueryDebugging() {
Query<?> query = new TestQuery(new TableDataSource("test"), new MultipleIntervalSegmentSpec(ImmutableList.of(Intervals.of("0/100"))), false, ImmutableMap.of());
Assert.assertFalse(QueryContexts.isDebug(query));
Assert.assertFalse(QueryContexts.isDebug(query.getContext()));
}
use of org.apache.druid.query.spec.MultipleIntervalSegmentSpec in project druid by druid-io.
the class QueryContextsTest method testQueryTimeout.
@Test
public void testQueryTimeout() {
Query<?> query = new TestQuery(new TableDataSource("test"), new MultipleIntervalSegmentSpec(ImmutableList.of(Intervals.of("0/100"))), false, ImmutableMap.of(QueryContexts.TIMEOUT_KEY, 1000));
Assert.assertEquals(1000, QueryContexts.getTimeout(query));
query = QueryContexts.withDefaultTimeout(query, 1_000_000);
Assert.assertEquals(1000, QueryContexts.getTimeout(query));
}
Aggregations