Repository: phoenix Updated Branches: refs/heads/encodecolumns 0c22c2f00 -> a0d529894 (forced update)
PHOENIX-3061 IndexTool marks index as ACTIVE and exit 0 even if bulkload has error Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/b26936e1 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/b26936e1 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/b26936e1 Branch: refs/heads/encodecolumns Commit: b26936e1a437e63be0bedaab79e74b353cc0c4c9 Parents: 0848e3d Author: James Taylor <[email protected]> Authored: Wed Jul 13 09:40:42 2016 +0200 Committer: James Taylor <[email protected]> Committed: Wed Jul 13 09:45:44 2016 +0200 ---------------------------------------------------------------------- .../end2end/index/AsyncImmutableIndexIT.java | 55 +++++++++----------- 1 file changed, 25 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/b26936e1/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/AsyncImmutableIndexIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/AsyncImmutableIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/AsyncImmutableIndexIT.java index 8c90b6e..46bbfca 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/AsyncImmutableIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/AsyncImmutableIndexIT.java @@ -23,35 +23,21 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.sql.Connection; +import java.sql.DatabaseMetaData; import java.sql.DriverManager; import java.sql.ResultSet; -import java.util.Map; import java.util.Properties; -import org.apache.hadoop.conf.Configuration; -import org.apache.phoenix.end2end.BaseOwnClusterHBaseManagedTimeIT; -import org.apache.phoenix.end2end.IndexToolIT; -import org.apache.phoenix.mapreduce.index.IndexTool; -import org.apache.phoenix.query.QueryServices; -import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.end2end.BaseHBaseManagedTimeIT; +import org.apache.phoenix.schema.PIndexState; +import org.apache.phoenix.schema.PTableType; import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; -import org.apache.phoenix.util.ReadOnlyProps; -import org.junit.BeforeClass; +import org.apache.phoenix.util.StringUtil; import org.junit.Test; -import com.google.common.collect.Maps; - -public class AsyncImmutableIndexIT extends BaseOwnClusterHBaseManagedTimeIT { - - @BeforeClass - public static void doSetup() throws Exception { - Map<String, String> serverProps = Maps.newHashMapWithExpectedSize(1); - serverProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, - QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); - setUpRealDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), - ReadOnlyProps.EMPTY_PROPS); - } +public class AsyncImmutableIndexIT extends BaseHBaseManagedTimeIT { + private static final long MAX_WAIT_FOR_INDEX_BUILD_TIME_MS = 45000; @Test public void testDeleteFromImmutable() throws Exception { @@ -77,13 +63,22 @@ public class AsyncImmutableIndexIT extends BaseOwnClusterHBaseManagedTimeIT { conn.createStatement().execute("delete from TEST_TABLE where pk1 = 'a'"); conn.commit(); - // run the index MR job - final IndexTool indexingTool = new IndexTool(); - indexingTool.setConf(new Configuration(getUtility().getConfiguration())); - final String[] cmdArgs = - IndexToolIT.getArgValues(null, "TEST_TABLE", "TEST_INDEX", true); - int status = indexingTool.run(cmdArgs); - assertEquals(0, status); + DatabaseMetaData dbmd = conn.getMetaData(); + String escapedTableName = StringUtil.escapeLike("TEST_INDEX"); + String[] tableType = new String[] {PTableType.INDEX.toString()}; + long startTime = System.currentTimeMillis(); + boolean isIndexActive = false; + do { + ResultSet rs = dbmd.getTables("", "", escapedTableName, tableType); + assertTrue(rs.next()); + if (PIndexState.valueOf(rs.getString("INDEX_STATE")) == PIndexState.ACTIVE) { + isIndexActive = true; + break; + } + Thread.sleep(3000); + } while (System.currentTimeMillis() - startTime < MAX_WAIT_FOR_INDEX_BUILD_TIME_MS); + + assertTrue(isIndexActive); // upsert two more rows conn.createStatement().execute( @@ -97,8 +92,8 @@ public class AsyncImmutableIndexIT extends BaseOwnClusterHBaseManagedTimeIT { String query = "SELECT pk3 from TEST_TABLE ORDER BY pk3"; ResultSet rs = conn.createStatement().executeQuery("EXPLAIN " + query); String expectedPlan = - "CLIENT 1-CHUNK PARALLEL 1-WAY FULL SCAN OVER TEST_INDEX\n" - + " SERVER FILTER BY FIRST KEY ONLY"; + "CLIENT PARALLEL 1-WAY FULL SCAN OVER TEST_INDEX\n" + + " SERVER FILTER BY FIRST KEY ONLY"; assertEquals("Wrong plan ", expectedPlan, QueryUtil.getExplainPlan(rs)); rs = conn.createStatement().executeQuery(query); assertTrue(rs.next());
