Repository: phoenix Updated Branches: refs/heads/master 6e9ce8742 -> 27ef19f8c
PHOENIX-4141 Fix flapping TableSnapshotReadsMapReduceIT Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/27ef19f8 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/27ef19f8 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/27ef19f8 Branch: refs/heads/master Commit: 27ef19f8ce5b956deb795a45ba04ca865fef7ad9 Parents: 6e9ce87 Author: Samarth Jain <sama...@apache.org> Authored: Tue Sep 5 13:58:06 2017 -0700 Committer: Samarth Jain <sama...@apache.org> Committed: Tue Sep 5 13:58:06 2017 -0700 ---------------------------------------------------------------------- .../end2end/TableSnapshotReadsMapReduceIT.java | 58 ++++++++++++-------- 1 file changed, 35 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/27ef19f8/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableSnapshotReadsMapReduceIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableSnapshotReadsMapReduceIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableSnapshotReadsMapReduceIT.java index 4cc2a20..cae91a3 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableSnapshotReadsMapReduceIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableSnapshotReadsMapReduceIT.java @@ -18,11 +18,26 @@ package org.apache.phoenix.end2end; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; + import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.HBaseAdmin; - import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos; import org.apache.hadoop.io.NullWritable; @@ -32,20 +47,14 @@ import org.apache.hadoop.mapreduce.lib.output.NullOutputFormat; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.mapreduce.index.PhoenixIndexDBWritable; import org.apache.phoenix.mapreduce.util.PhoenixMapReduceUtil; -import org.junit.*; +import org.apache.phoenix.util.ReadOnlyProps; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; -import java.io.IOException; -import java.sql.*; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.UUID; +import com.google.common.collect.Maps; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class TableSnapshotReadsMapReduceIT extends ParallelStatsDisabledIT { +public class TableSnapshotReadsMapReduceIT extends BaseUniqueNamesOwnClusterIT { private final static String SNAPSHOT_NAME = "FOO"; private static final String FIELD1 = "FIELD1"; private static final String FIELD2 = "FIELD2"; @@ -58,6 +67,11 @@ public class TableSnapshotReadsMapReduceIT extends ParallelStatsDisabledIT { private long timestamp; private String tableName; + @BeforeClass + public static void doSetup() throws Exception { + Map<String,String> props = Maps.newHashMapWithExpectedSize(1); + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } @Test public void testMapReduceSnapshots() throws Exception { @@ -155,7 +169,7 @@ public class TableSnapshotReadsMapReduceIT extends ParallelStatsDisabledIT { assertFalse("Should only have stored" + result.size() + "rows in the table for the timestamp!", rs.next()); } finally { - deleteSnapshotAndTable(tableName); + deleteSnapshot(tableName); } } @@ -195,15 +209,13 @@ public class TableSnapshotReadsMapReduceIT extends ParallelStatsDisabledIT { conn.commit(); } - public void deleteSnapshotAndTable(String tableName) throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin(); - admin.deleteSnapshot(SNAPSHOT_NAME); - - conn.createStatement().execute("DROP TABLE " + tableName); - conn.close(); - - } + public void deleteSnapshot(String tableName) throws Exception { + try (Connection conn = DriverManager.getConnection(getUrl()); + HBaseAdmin admin = + conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin();) { + admin.deleteSnapshot(SNAPSHOT_NAME); + } + } public static class TableSnapshotMapper extends Mapper<NullWritable, PhoenixIndexDBWritable, ImmutableBytesWritable, NullWritable> {