maytasm3 commented on a change in pull request #9492: add manual laning strategy, integration test URL: https://github.com/apache/druid/pull/9492#discussion_r391213638
########## File path: server/src/test/java/org/apache/druid/server/scheduling/ManualQueryLaningStrategyTest.java ########## @@ -0,0 +1,149 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.druid.server.scheduling; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import org.apache.druid.java.util.common.Intervals; +import org.apache.druid.java.util.common.granularity.Granularities; +import org.apache.druid.query.Druids; +import org.apache.druid.query.QueryContexts; +import org.apache.druid.query.QueryPlus; +import org.apache.druid.query.aggregation.CountAggregatorFactory; +import org.apache.druid.query.timeseries.TimeseriesQuery; +import org.apache.druid.server.QueryLaningStrategy; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +@SuppressWarnings("ResultOfObjectAllocationIgnored") +public class ManualQueryLaningStrategyTest +{ + private Druids.TimeseriesQueryBuilder queryBuilder; + private QueryLaningStrategy exactStrategy; + private QueryLaningStrategy percentStrategy; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Before + public void setup() + { + this.queryBuilder = Druids.newTimeseriesQueryBuilder() + .dataSource("test") + .intervals(ImmutableList.of(Intervals.ETERNITY)) + .granularity(Granularities.DAY) + .aggregators(new CountAggregatorFactory("count")); + this.exactStrategy = + new ManualQueryLaningStrategy(ImmutableMap.of("one", 1, "ten", 10), null); + this.percentStrategy = + new ManualQueryLaningStrategy(ImmutableMap.of("one", 1, "ten", 10), true); + } + + @Test + public void testLanesMustBeSet() + { + expectedException.expect(NullPointerException.class); + expectedException.expectMessage("lanes must be set"); + new ManualQueryLaningStrategy(null, null); + } + + @Test + public void testMustDefineAtLeast1Lane() + { + expectedException.expect(IllegalArgumentException.class); + expectedException.expectMessage("lanes must define at least one lane"); + new ManualQueryLaningStrategy(ImmutableMap.of(), null); + } + + @Test + public void testExactLaneLimitsMustBeAboveZero() + { + expectedException.expect(IllegalArgumentException.class); + expectedException.expectMessage("All lane limits must be greater than 0"); + new ManualQueryLaningStrategy(ImmutableMap.of("zero", 0, "one", 1), null); + } + + @Test + public void testPercentLaneLimitsMustBeAboveZero() Review comment: testPercentLaneLimitsMustBeBelowOneHundred? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
