Change tests that set server-side config to NeedsOwnMiniClusterTest Destroy driver in MutableIndexReplicationIT to prevent other tests from failing
Conflicts: phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/2faeda4a Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/2faeda4a Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/2faeda4a Branch: refs/heads/master Commit: 2faeda4a747056946dba05a903646cf9e7e0a927 Parents: 661d730 Author: James Taylor <jtay...@salesforce.com> Authored: Tue Oct 7 00:45:31 2014 -0700 Committer: James Taylor <jtay...@salesforce.com> Committed: Tue Oct 7 02:32:32 2014 -0700 ---------------------------------------------------------------------- .../end2end/BaseClientManagedTimeIT.java | 29 +--------- .../phoenix/end2end/BaseHBaseManagedTimeIT.java | 25 +++------ .../BaseOwnClusterClientManagedTimeIT.java | 30 ++++++++++ .../BaseOwnClusterHBaseManagedTimeIT.java | 30 ++++++++++ .../phoenix/end2end/BaseOwnClusterIT.java | 32 +++++++++++ .../end2end/BaseTenantSpecificTablesIT.java | 12 +--- .../apache/phoenix/end2end/CreateTableIT.java | 2 +- .../org/apache/phoenix/end2end/KeyOnlyIT.java | 6 +- .../phoenix/end2end/MultiCfQueryExecIT.java | 8 +-- .../phoenix/end2end/ParallelIteratorsIT.java | 25 ++------- .../phoenix/end2end/StatsCollectorIT.java | 12 +--- .../end2end/TenantSpecificTablesDDLIT.java | 2 +- .../end2end/TenantSpecificTablesDMLIT.java | 2 +- .../index/MutableIndexReplicationIT.java | 56 +++++++++++++------ .../phoenix/end2end/index/SaltedIndexIT.java | 2 - .../org/apache/phoenix/util/ReadOnlyProps.java | 4 ++ .../java/org/apache/phoenix/query/BaseTest.java | 58 ++++++++++++++++++-- .../java/org/apache/phoenix/util/TestUtil.java | 5 ++ 18 files changed, 223 insertions(+), 117 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/2faeda4a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseClientManagedTimeIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseClientManagedTimeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseClientManagedTimeIT.java index 2f60ea1..14dffcb 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseClientManagedTimeIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseClientManagedTimeIT.java @@ -17,10 +17,6 @@ */ package org.apache.phoenix.end2end; -import static org.junit.Assert.assertTrue; - -import java.sql.Date; - import javax.annotation.concurrent.NotThreadSafe; import org.apache.hadoop.conf.Configuration; @@ -64,28 +60,7 @@ public abstract class BaseClientManagedTimeIT extends BaseTest { } @AfterClass - public static void dropTables() throws Exception { - try { - disableAndDropNonSystemTables(driver); - } finally { - try { - assertTrue(destroyDriver(driver)); - } finally { - driver = null; - } - } - } - - protected static void initATableValues(String tenantId, byte[][] splits, Date date, Long ts) throws Exception { - BaseTest.initATableValues(tenantId, splits, date, ts, getUrl()); - } - - protected static void initEntityHistoryTableValues(String tenantId, byte[][] splits, Date date, Long ts) throws Exception { - BaseTest.initEntityHistoryTableValues(tenantId, splits, date, ts, getUrl()); - } - - protected static void initSaltedEntityHistoryTableValues(String tenantId, byte[][] splits, Date date, Long ts) throws Exception { - BaseTest.initSaltedEntityHistoryTableValues(tenantId, splits, date, ts, getUrl()); + public static void doTeardown() throws Exception { + dropNonSystemTables(); } - } http://git-wip-us.apache.org/repos/asf/phoenix/blob/2faeda4a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseHBaseManagedTimeIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseHBaseManagedTimeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseHBaseManagedTimeIT.java index 1d0f004..679f29d 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseHBaseManagedTimeIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseHBaseManagedTimeIT.java @@ -17,8 +17,6 @@ */ package org.apache.phoenix.end2end; -import static org.junit.Assert.assertTrue; - import javax.annotation.concurrent.NotThreadSafe; import org.apache.hadoop.conf.Configuration; @@ -51,27 +49,18 @@ public abstract class BaseHBaseManagedTimeIT extends BaseTest { return new Configuration(config); } - @After - public void cleanUpAfterTest() throws Exception { - deletePriorTables(HConstants.LATEST_TIMESTAMP, getUrl()); - } - @BeforeClass public static void doSetup() throws Exception { setUpTestDriver(ReadOnlyProps.EMPTY_PROPS); } @AfterClass - public static void dropTables() throws Exception { - try { - disableAndDropNonSystemTables(driver); - } finally { - try { - assertTrue(destroyDriver(driver)); - } finally { - driver = null; - } - } + public static void doTeardown() throws Exception { + dropNonSystemTables(); + } + + @After + public void cleanUpAfterTest() throws Exception { + deletePriorTables(HConstants.LATEST_TIMESTAMP, getUrl()); } - } http://git-wip-us.apache.org/repos/asf/phoenix/blob/2faeda4a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterClientManagedTimeIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterClientManagedTimeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterClientManagedTimeIT.java new file mode 100644 index 0000000..d986e40 --- /dev/null +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterClientManagedTimeIT.java @@ -0,0 +1,30 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * 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 maynot 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 applicablelaw 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.phoenix.end2end; + +import org.junit.After; + +public class BaseOwnClusterClientManagedTimeIT extends BaseOwnClusterIT { + @After + public void cleanUpAfterTest() throws Exception { + long ts = nextTimestamp(); + deletePriorTables(ts - 1, getUrl()); + } +} http://git-wip-us.apache.org/repos/asf/phoenix/blob/2faeda4a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterHBaseManagedTimeIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterHBaseManagedTimeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterHBaseManagedTimeIT.java new file mode 100644 index 0000000..3472230 --- /dev/null +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterHBaseManagedTimeIT.java @@ -0,0 +1,30 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * 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 maynot 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 applicablelaw 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.phoenix.end2end; + +import org.apache.hadoop.hbase.HConstants; +import org.junit.After; + +public class BaseOwnClusterHBaseManagedTimeIT extends BaseOwnClusterIT { + @After + public void cleanUpAfterTest() throws Exception { + deletePriorTables(HConstants.LATEST_TIMESTAMP, getUrl()); + } +} http://git-wip-us.apache.org/repos/asf/phoenix/blob/2faeda4a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterIT.java new file mode 100644 index 0000000..330022b --- /dev/null +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterIT.java @@ -0,0 +1,32 @@ +/* + * Copyright 2010 The Apache Software Foundation + * + * 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 maynot 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 applicablelaw 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.phoenix.end2end; + +import org.apache.phoenix.query.BaseTest; +import org.junit.AfterClass; +import org.junit.experimental.categories.Category; + +@Category(NeedsOwnMiniClusterTest.class) +public class BaseOwnClusterIT extends BaseTest { + @AfterClass + public static void doTeardown() throws Exception { + tearDownMiniCluster(); + } +} http://git-wip-us.apache.org/repos/asf/phoenix/blob/2faeda4a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java index fe08ac5..362fa08 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java @@ -30,15 +30,8 @@ import org.junit.experimental.categories.Category; import com.google.common.collect.Maps; -/** - * Describe your class here. - * - * - * @since 2.2 - */ - -@Category(ClientManagedTimeTest.class) -public abstract class BaseTenantSpecificTablesIT extends BaseClientManagedTimeIT { +@Category(NeedsOwnMiniClusterTest.class) +public abstract class BaseTenantSpecificTablesIT extends BaseOwnClusterClientManagedTimeIT { protected static final String TENANT_ID = "ZZTop"; protected static final String TENANT_TYPE_ID = "abc"; protected static String PHOENIX_JDBC_TENANT_SPECIFIC_URL; @@ -80,7 +73,6 @@ public abstract class BaseTenantSpecificTablesIT extends BaseClientManagedTimeIT } @BeforeClass - @Shadower(classBeingShadowed = BaseClientManagedTimeIT.class) public static void doSetup() throws Exception { Map<String,String> props = Maps.newHashMapWithExpectedSize(3); // Must update config before starting server http://git-wip-us.apache.org/repos/asf/phoenix/blob/2faeda4a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateTableIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateTableIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateTableIT.java index 1f9afc4..0b5c105 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateTableIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateTableIT.java @@ -94,8 +94,8 @@ public class CreateTableIT extends BaseClientManagedTimeIT { " id INTEGER not null primary key desc\n" + " ) "; conn.createStatement().execute(ddl); - conn = DriverManager.getConnection(getUrl(), props); props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); + conn = DriverManager.getConnection(getUrl(), props); try { conn.createStatement().execute(ddl); fail(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/2faeda4a/phoenix-core/src/it/java/org/apache/phoenix/end2end/KeyOnlyIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/KeyOnlyIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/KeyOnlyIT.java index 9b26c2e..b7e3314 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/KeyOnlyIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/KeyOnlyIT.java @@ -44,17 +44,17 @@ import org.junit.experimental.categories.Category; import com.google.common.collect.Maps; -@Category(ClientManagedTimeTest.class) -public class KeyOnlyIT extends BaseClientManagedTimeIT { +@Category(NeedsOwnMiniClusterTest.class) +public class KeyOnlyIT extends BaseOwnClusterClientManagedTimeIT { @BeforeClass - @Shadower(classBeingShadowed = BaseClientManagedTimeIT.class) public static void doSetup() throws Exception { Map<String,String> props = Maps.newHashMapWithExpectedSize(3); // Must update config before starting server props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(20)); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); } + @Test public void testKeyOnly() throws Exception { long ts = nextTimestamp(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/2faeda4a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MultiCfQueryExecIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MultiCfQueryExecIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MultiCfQueryExecIT.java index f4665b2..a28d346 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MultiCfQueryExecIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MultiCfQueryExecIT.java @@ -44,18 +44,18 @@ import org.junit.experimental.categories.Category; import com.google.common.collect.Maps; -@Category(ClientManagedTimeTest.class) -public class MultiCfQueryExecIT extends BaseClientManagedTimeIT { +@Category(NeedsOwnMiniClusterTest.class) +public class MultiCfQueryExecIT extends BaseOwnClusterClientManagedTimeIT { private static final String MULTI_CF = "MULTI_CF"; @BeforeClass - @Shadower(classBeingShadowed = BaseClientManagedTimeIT.class) public static void doSetup() throws Exception { Map<String,String> props = Maps.newHashMapWithExpectedSize(3); // Must update config before starting server - props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(20l)); + props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(20)); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); } + protected static void initTableValues(long ts) throws Exception { ensureTableCreated(getUrl(),MULTI_CF,null, ts-2); http://git-wip-us.apache.org/repos/asf/phoenix/blob/2faeda4a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelIteratorsIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelIteratorsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelIteratorsIT.java index 5a1be0b..dd5b661 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelIteratorsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelIteratorsIT.java @@ -19,6 +19,7 @@ package org.apache.phoenix.end2end; import static org.apache.phoenix.util.TestUtil.STABLE_NAME; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; +import static org.apache.phoenix.util.TestUtil.analyzeTable; import static org.apache.phoenix.util.TestUtil.getAllSplits; import static org.apache.phoenix.util.TestUtil.getSplits; import static org.junit.Assert.assertEquals; @@ -29,7 +30,6 @@ import java.sql.PreparedStatement; import java.util.List; import java.util.Map; -import org.apache.phoenix.jdbc.PhoenixPreparedStatement; import org.apache.phoenix.query.KeyRange; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.PDataType; @@ -40,8 +40,8 @@ import org.junit.experimental.categories.Category; import com.google.common.collect.Maps; -@Category(HBaseManagedTimeTest.class) -public class ParallelIteratorsIT extends BaseHBaseManagedTimeIT { +@Category(NeedsOwnMiniClusterTest.class) +public class ParallelIteratorsIT extends BaseOwnClusterHBaseManagedTimeIT { protected static final byte[] KMIN = new byte[] {'!'}; protected static final byte[] KMIN2 = new byte[] {'.'}; @@ -59,7 +59,6 @@ public class ParallelIteratorsIT extends BaseHBaseManagedTimeIT { protected static final byte[] KP = new byte[] { 'p' }; @BeforeClass - @Shadower(classBeingShadowed = BaseClientManagedTimeIT.class) public static void doSetup() throws Exception { Map<String,String> props = Maps.newHashMapWithExpectedSize(3); // Must update config before starting server @@ -76,12 +75,8 @@ public class ParallelIteratorsIT extends BaseHBaseManagedTimeIT { PreparedStatement stmt = conn.prepareStatement("ANALYZE STABLE"); stmt.execute(); - // number of regions > target query concurrency - PhoenixPreparedStatement pstmt; List<KeyRange> keyRanges; - pstmt = conn.prepareStatement("SELECT COUNT(*) FROM STABLE").unwrap(PhoenixPreparedStatement.class); - pstmt.execute(); keyRanges = getAllSplits(conn); assertEquals("Unexpected number of splits: " + keyRanges, 7, keyRanges.size()); assertEquals(newKeyRange(KeyRange.UNBOUND, KMIN), keyRanges.get(0)); @@ -114,26 +109,18 @@ public class ParallelIteratorsIT extends BaseHBaseManagedTimeIT { byte[][] splits = new byte[][] { K3, K9, KR }; ensureTableCreated(getUrl(), STABLE_NAME, splits); - PreparedStatement stmt = conn.prepareStatement("ANALYZE STABLE"); - stmt.execute(); List<KeyRange> keyRanges = getAllSplits(conn); assertEquals(4, keyRanges.size()); upsert(conn, new byte[][] { KMIN, K4, K11 }); - stmt = conn.prepareStatement("ANALYZE STABLE"); - stmt.execute(); - conn.prepareStatement("SELECT COUNT(*) FROM STABLE").executeQuery(); + analyzeTable(conn); keyRanges = getAllSplits(conn); assertEquals(7, keyRanges.size()); upsert(conn, new byte[][] { KMIN2, K5, K12 }); - stmt = conn.prepareStatement("ANALYZE STABLE"); - stmt.execute(); - conn.prepareStatement("SELECT COUNT(*) FROM STABLE").executeQuery(); + analyzeTable(conn); keyRanges = getAllSplits(conn); assertEquals(10, keyRanges.size()); upsert(conn, new byte[][] { K1, K6, KP }); - stmt = conn.prepareStatement("ANALYZE STABLE"); - stmt.execute(); - conn.prepareStatement("SELECT COUNT(*) FROM STABLE").executeQuery(); + analyzeTable(conn); keyRanges = getAllSplits(conn); assertEquals(13, keyRanges.size()); conn.close(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/2faeda4a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsCollectorIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsCollectorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsCollectorIT.java index 3c0d683..03ff316 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsCollectorIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsCollectorIT.java @@ -22,20 +22,14 @@ import org.junit.experimental.categories.Category; import com.google.common.collect.Maps; -@Category(HBaseManagedTimeTest.class) -public class StatsCollectorIT extends BaseHBaseManagedTimeIT { - //private static String url; - private static int frequency = 5000; +@Category(NeedsOwnMiniClusterTest.class) +public class StatsCollectorIT extends BaseOwnClusterHBaseManagedTimeIT { @BeforeClass - @Shadower(classBeingShadowed = BaseHBaseManagedTimeIT.class) public static void doSetup() throws Exception { Map<String,String> props = Maps.newHashMapWithExpectedSize(3); // Must update config before starting server - props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(20l)); - props.put(QueryServices.STATS_UPDATE_FREQ_MS_ATTRIB, Integer.toString(frequency)); - props.put(QueryServices.QUEUE_SIZE_ATTRIB, Integer.toString(20)); - props.put(QueryServices.THREAD_POOL_SIZE_ATTRIB, Integer.toString(20)); + props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(20)); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/2faeda4a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDDLIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDDLIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDDLIT.java index 0e2b75c..a9fa412 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDDLIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDDLIT.java @@ -56,7 +56,7 @@ import org.apache.phoenix.util.StringUtil; import org.junit.Test; import org.junit.experimental.categories.Category; -@Category(ClientManagedTimeTest.class) +@Category(NeedsOwnMiniClusterTest.class) public class TenantSpecificTablesDDLIT extends BaseTenantSpecificTablesIT { @Test http://git-wip-us.apache.org/repos/asf/phoenix/blob/2faeda4a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java index 21f80f9..f0ed1d0 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java @@ -39,7 +39,7 @@ import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; -@Category(ClientManagedTimeTest.class) +@Category(NeedsOwnMiniClusterTest.class) public class TenantSpecificTablesDMLIT extends BaseTenantSpecificTablesIT { @Test http://git-wip-us.apache.org/repos/asf/phoenix/blob/2faeda4a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexReplicationIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexReplicationIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexReplicationIT.java index 9981ed8..ca59df8 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexReplicationIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexReplicationIT.java @@ -17,12 +17,36 @@ */ package org.apache.phoenix.end2end.index; -import com.google.common.collect.Maps; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Properties; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.*; -import org.apache.hadoop.hbase.client.*; +import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.HBaseTestingUtility; +import org.apache.hadoop.hbase.HColumnDescriptor; +import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.client.HBaseAdmin; +import org.apache.hadoop.hbase.client.HTable; +import org.apache.hadoop.hbase.client.Result; +import org.apache.hadoop.hbase.client.ResultScanner; +import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.client.replication.ReplicationAdmin; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; @@ -32,22 +56,15 @@ import org.apache.phoenix.jdbc.PhoenixEmbeddedDriver; import org.apache.phoenix.jdbc.PhoenixTestDriver; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.QueryServices; -import org.apache.phoenix.util.*; +import org.apache.phoenix.util.PropertiesUtil; +import org.apache.phoenix.util.ReadOnlyProps; +import org.apache.phoenix.util.SchemaUtil; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; -import java.io.IOException; -import java.sql.*; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; -import static org.junit.Assert.*; -import static org.junit.Assert.assertEquals; +import com.google.common.collect.Maps; /** * Test that we correctly replicate indexes over replication @@ -94,8 +111,15 @@ public class MutableIndexReplicationIT extends BaseTest { @AfterClass public static void tearDownAfterClass() throws Exception { - utility2.shutdownMiniCluster(); - utility1.shutdownMiniCluster(); + try { + destroyDriver(); + } finally { + try { + utility2.shutdownMiniCluster(); + } finally { + utility1.shutdownMiniCluster(); + } + } } private static void setupConfigsAndStartCluster() throws Exception { http://git-wip-us.apache.org/repos/asf/phoenix/blob/2faeda4a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/SaltedIndexIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/SaltedIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/SaltedIndexIT.java index f72cc3c..0279283 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/SaltedIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/SaltedIndexIT.java @@ -57,8 +57,6 @@ public class SaltedIndexIT extends BaseIndexIT { props.put(QueryServices.INDEX_MUTATE_BATCH_SIZE_THRESHOLD_ATTRIB, Integer.toString(2)); // Drop the HBase table metadata for this test props.put(QueryServices.DROP_METADATA_ATTRIB, Boolean.toString(true)); - // Don't put guideposts in - props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(10000000)); // Must update config before starting server setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/2faeda4a/phoenix-core/src/main/java/org/apache/phoenix/util/ReadOnlyProps.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/ReadOnlyProps.java b/phoenix-core/src/main/java/org/apache/phoenix/util/ReadOnlyProps.java index fe039d3..68b0879 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/util/ReadOnlyProps.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/ReadOnlyProps.java @@ -265,4 +265,8 @@ public class ReadOnlyProps implements Iterable<Entry<String, String>> { public Iterator<Entry<String, String>> iterator() { return props.entrySet().iterator(); } + + public boolean isEmpty() { + return props.isEmpty(); + } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/2faeda4a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java index 653c90d..7bdab7b 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java @@ -154,7 +154,7 @@ import com.google.common.collect.Sets; public abstract class BaseTest { private static final Map<String,String> tableDDLMap; private static Logger logger = Logger.getLogger("BaseTest.class"); - private static HBaseTestingUtility utility = null; + static { ImmutableMap.Builder<String,String> builder = ImmutableMap.builder(); builder.put(ENTITY_HISTORY_TABLE_NAME,"create table " + ENTITY_HISTORY_TABLE_NAME + @@ -454,6 +454,7 @@ public abstract class BaseTest { private static String url; protected static PhoenixTestDriver driver; private static boolean clusterInitialized = false; + private static HBaseTestingUtility utility; protected static final Configuration config = HBaseConfiguration.create(); protected static String getUrl() { @@ -485,6 +486,39 @@ public abstract class BaseTest { } } + protected static void destroyDriver() throws Exception { + if (driver != null) { + try { + assertTrue(destroyDriver(driver)); + } finally { + driver = null; + } + } + } + + protected static void dropNonSystemTables() throws Exception { + try { + disableAndDropNonSystemTables(); + } finally { + destroyDriver(); + } + } + + protected static void tearDownMiniCluster() throws Exception { + try { + destroyDriver(); + } finally { + try { + if (utility != null) { + utility.shutdownMiniCluster(); + } + } finally { + utility = null; + clusterInitialized = false; + } + } + } + protected static void setUpTestDriver(ReadOnlyProps props) throws Exception { String url = checkClusterInitialized(props); if (driver == null) { @@ -1051,16 +1085,28 @@ public abstract class BaseTest { conn.close(); } } - + + protected static void initATableValues(String tenantId, byte[][] splits, Date date, Long ts) throws Exception { + initATableValues(tenantId, splits, date, ts, getUrl()); + } + + protected static void initEntityHistoryTableValues(String tenantId, byte[][] splits, Date date, Long ts) throws Exception { + initEntityHistoryTableValues(tenantId, splits, date, ts, getUrl()); + } + + protected static void initSaltedEntityHistoryTableValues(String tenantId, byte[][] splits, Date date, Long ts) throws Exception { + initSaltedEntityHistoryTableValues(tenantId, splits, date, ts, getUrl()); + } + protected static void initEntityHistoryTableValues(String tenantId, byte[][] splits, String url) throws Exception { - initEntityHistoryTableValues(tenantId, splits, null); + initEntityHistoryTableValues(tenantId, splits, null, null, url); } protected static void initEntityHistoryTableValues(String tenantId, byte[][] splits, Date date, String url) throws Exception { - initEntityHistoryTableValues(tenantId, splits, date, null); + initEntityHistoryTableValues(tenantId, splits, date, null, url); } - protected static void initEntityHistoryTableValues(String tenantId, byte[][] splits, Date date, Long ts, String url) throws Exception { + private static void initEntityHistoryTableValues(String tenantId, byte[][] splits, Date date, Long ts, String url) throws Exception { if (ts == null) { ensureTableCreated(url, ENTITY_HISTORY_TABLE_NAME, splits); } else { @@ -1271,7 +1317,7 @@ public abstract class BaseTest { /** * Disable and drop all the tables except SYSTEM.CATALOG and SYSTEM.SEQUENCE */ - protected static void disableAndDropNonSystemTables(PhoenixTestDriver driver) throws Exception { + private static void disableAndDropNonSystemTables() throws Exception { HBaseAdmin admin = driver.getConnectionQueryServices(null, null).getAdmin(); try { HTableDescriptor[] tables = admin.listTables(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/2faeda4a/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java b/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java index 4c33660..65bc7b2 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java @@ -497,6 +497,11 @@ public class TestUtil { conn.createStatement().execute(query); } + public static void analyzeTable(Connection conn) throws IOException, SQLException { + String query = "ANALYZE " + STABLE_NAME; + conn.createStatement().execute(query); + } + public static void analyzeTable(String url, long ts, String tableName) throws IOException, SQLException { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));