gjacoby126 commented on a change in pull request #520: PHOENIX-5333: A tool to
upgrade existing tables/indexes to use self-c…
URL: https://github.com/apache/phoenix/pull/520#discussion_r295514966
##########
File path:
phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexUpgradeToolIT.java
##########
@@ -0,0 +1,506 @@
+package org.apache.phoenix.end2end;
+
+import com.google.common.collect.Maps;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.TableNotFoundException;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.hbase.index.Indexer;
+import org.apache.phoenix.index.GlobalIndexChecker;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.mapreduce.index.IndexUpgradeTool;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.query.ConnectionQueryServices;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.query.QueryServicesOptions;
+import org.apache.phoenix.util.PropertiesUtil;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
+import org.junit.runners.Parameterized;
+
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Properties;
+import java.util.UUID;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class IndexUpgradeToolIT extends BaseTest {
+
+ private final boolean mutable;
+ private final boolean upgrade;
+ private StringBuilder optionsBuilder;
+ private String tableDDLOptions;
+
+ private static Map<String, String> serverProps =
Maps.newHashMapWithExpectedSize(1), clientProps =
Maps.newHashMapWithExpectedSize(1);
+
+ private String [] indexesList = {"TEST.INDEX1", "TEST.INDEX2",
"TEST1.INDEX3","TEST1.INDEX2","TEST1.INDEX1","TEST.INDEX3"};
+ private String [] tableList = {"TEST.MOCK1","TEST1.MOCK2","TEST.MOCK3"};
+
+ private String inputList =
"TEST.MOCK1:INDEX1,INDEX2;TEST1.MOCK2:INDEX3,INDEX2,INDEX1;TEST.MOCK3:INDEX3";
+
+
+ @Before
+ public void setup () throws Exception {
+ optionsBuilder = new StringBuilder();
+
+ if (upgrade) {
+ if
((Boolean.TRUE.toString()).equals(clientProps.get(QueryServices.INDEX_REGION_OBSERVER_ENABLED_ATTRIB)))
{
+ tearDownMiniClusterAsync(1);
+ }
+
clientProps.put(QueryServices.INDEX_REGION_OBSERVER_ENABLED_ATTRIB,
Boolean.FALSE.toString());
+ } else {
+ if
((Boolean.FALSE.toString()).equals(clientProps.get(QueryServices.INDEX_REGION_OBSERVER_ENABLED_ATTRIB)))
{
+ tearDownMiniClusterAsync(1);
+ }
+
clientProps.put(QueryServices.INDEX_REGION_OBSERVER_ENABLED_ATTRIB,
Boolean.TRUE.toString());
+ }
+ if (!mutable) {
+ optionsBuilder.append(" IMMUTABLE_ROWS=true");
+ }
+ setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()),
+ new ReadOnlyProps(clientProps.entrySet().iterator()));
+ tableDDLOptions = optionsBuilder.toString();
+ try (Connection conn = DriverManager.getConnection(getUrl(), new
Properties())) {
+ conn.setAutoCommit(true);
+ prepareSetup(conn);
+ }
+
+ }
+
+
+ private void prepareSetup(Connection conn) throws SQLException {
+ //inputList is "TEST.MOCK1: INDEX1, INDEX2; TEST1.MOCK2: INDEX3,
INDEX2, INDEX1; TEST.MOCK3: INDEX3";
+ conn.createStatement().execute("CREATE TABLE TEST.MOCK1 (id bigint NOT
NULL PRIMARY KEY, a.name varchar, sal bigint, address
varchar)"+tableDDLOptions);
Review comment:
Usual convention is to create unique table names for each test so that they
don't clash. This helps us be able to run tests in parallel.
----------------------------------------------------------------
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