mirror of https://github.com/apache/druid.git
Uniformly set Calcite systemProperties for All Unit tests (#5451)
Fixes test failures reported in - https://github.com/druid-io/druid/issues/4909 Issue is that If some test skips setting up Calcite system properties with proper encoding and loads calcite classes that use that property, All subsequent tests in the same JVM fails. To reproduce the issue - ExpressionsTest and CalciteQueryTest from IDE in this order. A better fix would be to not use System Properties in calcite, This will work for now. All new Calcite Unit tests that are added need to inherit CalciteTestBase.
This commit is contained in:
parent
fb493ae13a
commit
e0d456b1ba
|
@ -51,13 +51,13 @@ import io.druid.server.security.AuthConfig;
|
|||
import io.druid.server.security.AuthTestUtils;
|
||||
import io.druid.server.security.NoopEscalator;
|
||||
import io.druid.sql.calcite.filtration.Filtration;
|
||||
import io.druid.sql.calcite.planner.Calcites;
|
||||
import io.druid.sql.calcite.planner.DruidOperatorTable;
|
||||
import io.druid.sql.calcite.planner.DruidPlanner;
|
||||
import io.druid.sql.calcite.planner.PlannerConfig;
|
||||
import io.druid.sql.calcite.planner.PlannerFactory;
|
||||
import io.druid.sql.calcite.planner.PlannerResult;
|
||||
import io.druid.sql.calcite.schema.DruidSchema;
|
||||
import io.druid.sql.calcite.util.CalciteTestBase;
|
||||
import io.druid.sql.calcite.util.CalciteTests;
|
||||
import io.druid.sql.calcite.util.QueryLogHook;
|
||||
import io.druid.sql.calcite.util.SpecificSegmentsQuerySegmentWalker;
|
||||
|
@ -72,7 +72,7 @@ import org.junit.rules.TemporaryFolder;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class QuantileSqlAggregatorTest
|
||||
public class QuantileSqlAggregatorTest extends CalciteTestBase
|
||||
{
|
||||
private static final String DATA_SOURCE = "foo";
|
||||
|
||||
|
@ -88,8 +88,6 @@ public class QuantileSqlAggregatorTest
|
|||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
Calcites.setSystemProperties();
|
||||
|
||||
// Note: this is needed in order to properly register the serde for Histogram.
|
||||
new ApproximateHistogramDruidModule().configure(null);
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ import io.druid.sql.calcite.planner.DruidOperatorTable;
|
|||
import io.druid.sql.calcite.planner.PlannerConfig;
|
||||
import io.druid.sql.calcite.planner.PlannerFactory;
|
||||
import io.druid.sql.calcite.schema.DruidSchema;
|
||||
import io.druid.sql.calcite.util.CalciteTestBase;
|
||||
import io.druid.sql.calcite.util.CalciteTests;
|
||||
import io.druid.sql.calcite.util.QueryLogHook;
|
||||
import io.druid.sql.calcite.util.SpecificSegmentsQuerySegmentWalker;
|
||||
|
@ -89,7 +90,7 @@ import java.util.Random;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class DruidAvaticaHandlerTest
|
||||
public class DruidAvaticaHandlerTest extends CalciteTestBase
|
||||
{
|
||||
private static final AvaticaServerConfig AVATICA_CONFIG = new AvaticaServerConfig()
|
||||
{
|
||||
|
@ -128,7 +129,6 @@ public class DruidAvaticaHandlerTest
|
|||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
Calcites.setSystemProperties();
|
||||
walker = CalciteTests.createMockWalker(temporaryFolder.newFolder());
|
||||
final PlannerConfig plannerConfig = new PlannerConfig();
|
||||
final DruidSchema druidSchema = CalciteTests.createMockSchema(walker, plannerConfig);
|
||||
|
|
|
@ -24,14 +24,14 @@ import com.google.common.collect.Lists;
|
|||
import io.druid.java.util.common.DateTimes;
|
||||
import io.druid.math.expr.ExprMacroTable;
|
||||
import io.druid.server.security.AllowAllAuthenticator;
|
||||
import io.druid.server.security.NoopEscalator;
|
||||
import io.druid.server.security.AuthConfig;
|
||||
import io.druid.server.security.AuthTestUtils;
|
||||
import io.druid.sql.calcite.planner.Calcites;
|
||||
import io.druid.server.security.NoopEscalator;
|
||||
import io.druid.sql.calcite.planner.DruidOperatorTable;
|
||||
import io.druid.sql.calcite.planner.PlannerConfig;
|
||||
import io.druid.sql.calcite.planner.PlannerFactory;
|
||||
import io.druid.sql.calcite.schema.DruidSchema;
|
||||
import io.druid.sql.calcite.util.CalciteTestBase;
|
||||
import io.druid.sql.calcite.util.CalciteTests;
|
||||
import io.druid.sql.calcite.util.QueryLogHook;
|
||||
import io.druid.sql.calcite.util.SpecificSegmentsQuerySegmentWalker;
|
||||
|
@ -46,7 +46,7 @@ import org.junit.rules.TemporaryFolder;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class DruidStatementTest
|
||||
public class DruidStatementTest extends CalciteTestBase
|
||||
{
|
||||
@Rule
|
||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
|
@ -60,7 +60,6 @@ public class DruidStatementTest
|
|||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
Calcites.setSystemProperties();
|
||||
walker = CalciteTests.createMockWalker(temporaryFolder.newFolder());
|
||||
final PlannerConfig plannerConfig = new PlannerConfig();
|
||||
final DruidSchema druidSchema = CalciteTests.createMockSchema(
|
||||
|
@ -162,7 +161,7 @@ public class DruidStatementTest
|
|||
final String sql = "SELECT __time, cnt, dim1, dim2, m1 FROM druid.foo";
|
||||
final DruidStatement statement = new DruidStatement("", 0, null, () -> {
|
||||
}).prepare(plannerFactory, sql, -1, AllowAllAuthenticator.ALLOW_ALL_RESULT);
|
||||
|
||||
|
||||
// First frame, ask for 2 rows.
|
||||
Meta.Frame frame = statement.execute().nextFrame(DruidStatement.START_OFFSET, 2);
|
||||
Assert.assertEquals(
|
||||
|
|
|
@ -96,6 +96,7 @@ import io.druid.sql.calcite.planner.PlannerContext;
|
|||
import io.druid.sql.calcite.planner.PlannerFactory;
|
||||
import io.druid.sql.calcite.planner.PlannerResult;
|
||||
import io.druid.sql.calcite.schema.DruidSchema;
|
||||
import io.druid.sql.calcite.util.CalciteTestBase;
|
||||
import io.druid.sql.calcite.util.CalciteTests;
|
||||
import io.druid.sql.calcite.util.QueryLogHook;
|
||||
import io.druid.sql.calcite.util.SpecificSegmentsQuerySegmentWalker;
|
||||
|
@ -122,7 +123,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CalciteQueryTest
|
||||
public class CalciteQueryTest extends CalciteTestBase
|
||||
{
|
||||
private static final Logger log = new Logger(CalciteQueryTest.class);
|
||||
|
||||
|
@ -232,7 +233,6 @@ public class CalciteQueryTest
|
|||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
Calcites.setSystemProperties();
|
||||
walker = CalciteTests.createMockWalker(temporaryFolder.newFolder());
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ import io.druid.sql.calcite.planner.Calcites;
|
|||
import io.druid.sql.calcite.planner.PlannerConfig;
|
||||
import io.druid.sql.calcite.planner.PlannerContext;
|
||||
import io.druid.sql.calcite.table.RowSignature;
|
||||
import io.druid.sql.calcite.util.CalciteTestBase;
|
||||
import io.druid.sql.calcite.util.CalciteTests;
|
||||
import org.apache.calcite.avatica.util.TimeUnit;
|
||||
import org.apache.calcite.avatica.util.TimeUnitRange;
|
||||
|
@ -63,7 +64,7 @@ import org.junit.Test;
|
|||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
public class ExpressionsTest
|
||||
public class ExpressionsTest extends CalciteTestBase
|
||||
{
|
||||
private static final DateTimeZone LOS_ANGELES = DateTimes.inferTzfromString("America/Los_Angeles");
|
||||
|
||||
|
|
|
@ -24,10 +24,11 @@ import io.druid.java.util.common.Intervals;
|
|||
import io.druid.query.filter.IntervalDimFilter;
|
||||
import io.druid.query.filter.NotDimFilter;
|
||||
import io.druid.segment.column.Column;
|
||||
import io.druid.sql.calcite.util.CalciteTestBase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class FiltrationTest
|
||||
public class FiltrationTest extends CalciteTestBase
|
||||
{
|
||||
@Test
|
||||
public void testNotIntervals()
|
||||
|
|
|
@ -22,11 +22,12 @@ package io.druid.sql.calcite.http;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.druid.segment.TestHelper;
|
||||
import io.druid.sql.calcite.util.CalciteTestBase;
|
||||
import io.druid.sql.http.SqlQuery;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SqlQueryTest
|
||||
public class SqlQueryTest extends CalciteTestBase
|
||||
{
|
||||
@Test
|
||||
public void testSerde() throws Exception
|
||||
|
|
|
@ -30,15 +30,15 @@ import io.druid.math.expr.ExprMacroTable;
|
|||
import io.druid.query.QueryInterruptedException;
|
||||
import io.druid.query.ResourceLimitExceededException;
|
||||
import io.druid.server.security.AllowAllAuthenticator;
|
||||
import io.druid.server.security.NoopEscalator;
|
||||
import io.druid.server.security.AuthConfig;
|
||||
import io.druid.server.security.AuthTestUtils;
|
||||
import io.druid.sql.calcite.planner.Calcites;
|
||||
import io.druid.server.security.NoopEscalator;
|
||||
import io.druid.sql.calcite.planner.DruidOperatorTable;
|
||||
import io.druid.sql.calcite.planner.PlannerConfig;
|
||||
import io.druid.sql.calcite.planner.PlannerContext;
|
||||
import io.druid.sql.calcite.planner.PlannerFactory;
|
||||
import io.druid.sql.calcite.schema.DruidSchema;
|
||||
import io.druid.sql.calcite.util.CalciteTestBase;
|
||||
import io.druid.sql.calcite.util.CalciteTests;
|
||||
import io.druid.sql.calcite.util.QueryLogHook;
|
||||
import io.druid.sql.calcite.util.SpecificSegmentsQuerySegmentWalker;
|
||||
|
@ -60,7 +60,7 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SqlResourceTest
|
||||
public class SqlResourceTest extends CalciteTestBase
|
||||
{
|
||||
private static final ObjectMapper JSON_MAPPER = new DefaultObjectMapper();
|
||||
|
||||
|
@ -76,10 +76,10 @@ public class SqlResourceTest
|
|||
|
||||
private HttpServletRequest req;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
Calcites.setSystemProperties();
|
||||
walker = CalciteTests.createMockWalker(temporaryFolder.newFolder());
|
||||
|
||||
final PlannerConfig plannerConfig = new PlannerConfig();
|
||||
|
@ -143,7 +143,9 @@ public class SqlResourceTest
|
|||
{
|
||||
final List<List<Object>> rows = doPost(
|
||||
new SqlQuery("SELECT COUNT(*), 'foo' FROM druid.foo", SqlQuery.ResultFormat.ARRAY, null),
|
||||
new TypeReference<List<List<Object>>>() {}
|
||||
new TypeReference<List<List<Object>>>()
|
||||
{
|
||||
}
|
||||
).rhs;
|
||||
|
||||
Assert.assertEquals(
|
||||
|
@ -317,6 +319,8 @@ public class SqlResourceTest
|
|||
|
||||
private Pair<QueryInterruptedException, List<Map<String, Object>>> doPost(final SqlQuery query) throws Exception
|
||||
{
|
||||
return doPost(query, new TypeReference<List<Map<String, Object>>>() {});
|
||||
return doPost(query, new TypeReference<List<Map<String, Object>>>()
|
||||
{
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,11 @@
|
|||
package io.druid.sql.calcite.planner;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import io.druid.sql.calcite.util.CalciteTestBase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class CalcitesTest
|
||||
public class CalcitesTest extends CalciteTestBase
|
||||
{
|
||||
@Test
|
||||
public void testEscapeStringLiteral()
|
||||
|
|
|
@ -24,7 +24,6 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import io.druid.data.input.InputRow;
|
||||
import io.druid.java.util.common.Intervals;
|
||||
import io.druid.segment.writeout.OffHeapMemorySegmentWriteOutMediumFactory;
|
||||
import io.druid.query.aggregation.CountAggregatorFactory;
|
||||
import io.druid.query.aggregation.DoubleSumAggregatorFactory;
|
||||
import io.druid.query.aggregation.LongSumAggregatorFactory;
|
||||
|
@ -32,10 +31,11 @@ import io.druid.query.aggregation.hyperloglog.HyperUniquesAggregatorFactory;
|
|||
import io.druid.segment.IndexBuilder;
|
||||
import io.druid.segment.QueryableIndex;
|
||||
import io.druid.segment.incremental.IncrementalIndexSchema;
|
||||
import io.druid.segment.writeout.OffHeapMemorySegmentWriteOutMediumFactory;
|
||||
import io.druid.server.security.NoopEscalator;
|
||||
import io.druid.sql.calcite.planner.Calcites;
|
||||
import io.druid.sql.calcite.planner.PlannerConfig;
|
||||
import io.druid.sql.calcite.table.DruidTable;
|
||||
import io.druid.sql.calcite.util.CalciteTestBase;
|
||||
import io.druid.sql.calcite.util.CalciteTests;
|
||||
import io.druid.sql.calcite.util.SpecificSegmentsQuerySegmentWalker;
|
||||
import io.druid.sql.calcite.util.TestServerInventoryView;
|
||||
|
@ -58,7 +58,7 @@ import java.io.File;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DruidSchemaTest
|
||||
public class DruidSchemaTest extends CalciteTestBase
|
||||
{
|
||||
private static final PlannerConfig PLANNER_CONFIG_DEFAULT = new PlannerConfig();
|
||||
|
||||
|
@ -83,8 +83,6 @@ public class DruidSchemaTest
|
|||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
Calcites.setSystemProperties();
|
||||
|
||||
final File tmpDir = temporaryFolder.newFolder();
|
||||
final QueryableIndex index1 = IndexBuilder.create()
|
||||
.tmpDir(new File(tmpDir, "1"))
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Licensed to Metamarkets Group Inc. (Metamarkets) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Metamarkets 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 io.druid.sql.calcite.util;
|
||||
|
||||
import io.druid.sql.calcite.planner.Calcites;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
public abstract class CalciteTestBase
|
||||
{
|
||||
@BeforeClass
|
||||
public static void setupCalciteProperties()
|
||||
{
|
||||
Calcites.setSystemProperties();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue